librustc: Forbid external crates, imports, and/or items from being #16482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
declared with the same name in the same scope.
This breaks several common patterns. First are unused imports:
Change this code to the following:
Second, this patch breaks globs that import names that are shadowed by
subsequent imports. For example:
Change this code to remove the glob:
Or qualify all uses of
bar
:Finally, this patch breaks code that, at top level, explicitly imports
std
and doesn't disable the prelude.Because the prelude imports
std
implicitly, there is no need toexplicitly import it; just remove such directives.
The old behavior can be opted into via the
import_shadowing
featuregate. Use of this feature gate is discouraged.
This implements RFC #116.
Closes #16464.
[breaking-change]
r? @brson