-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#![no_implicit_prelude]
should only apply to the current module, not to all children
#14969
Comments
I originally implemented it with these semantics because it seemed reasonable/common* for someone to not want the prelude in their entire crate (e.g. if they're using a custom prelude), and having to type However, I have no evidence for this claim. * Common among uses of |
@huonw Well, as a contra point, I just had to manually import prelude items in like 5 submodules because of that , so I personally think it should be changed :) I'd understand it the attribute where a crate-root only attribute but the current semantic is neither here nor there imo. |
About avoiding writing that attribute all the time: Now that macros can expand to multible items, something like |
Triage: this still works this way today. |
I agree that disabling for the whole crate seems like it would be the common case (as a contra contra point it's how I want to use it 😛). If it does get changed then it would be nice to be able to apply it as a crate attribute as well that disables the prelude throughout the crate (although, I guess that would mean not being able to apply it to just the root module, maybe it would need to be a different name for the crate only attribute?). |
From RFC 501:
Once #20561 is implemented, this will no longer be an issue, since the |
Update builtin attribute list
Currently, the
#![no_implicit_prelude]
attribute can be used to disable thelibstd
prelude imports for a module. However, it seems to disable them for all submodules as well, which makes no sense seeing how the prelude is just a bunch ofuse
statements, and those don't propagate into child modules.Example:
... which results in an error for the
bar
module as well:As a fix,
#![no_implicit_prelude]
should be changed to only apply to the module it is applied on.The text was updated successfully, but these errors were encountered: