-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #58349 - petrochenkov:uni201x, r=pnkfelix
resolve: Simplify import resolution for mixed 2015/2018 edition mode Non-controversial part of #57745. Before: | Local edition (per-span) | Global edition (--edition) | Imports (`use foo;`) | Absolute paths (`::foo`) | | ------------- |----------------|-----------------------------------------|------------------------------------------------| | 2018 | Any | Uniform | Extern prelude | | 2015 | 2015 | Crate-relative | Crate-relative | | 2015 | 2018 | Crate-relative with fallback to Uniform (future-proofed to error if the result is not Crate-relative or from Extern prelude) | Crate-relative with fallback to Extern prelude | After: | Local edition (per-span) | Global edition (--edition) | Imports (`use foo;`) | Absolute paths (`::foo`) | | ------------- |----------------|-----------------------------------------|------------------------------------------------| | 2018 | Any | Uniform | Extern prelude | | 2015 | 2015 | Crate-relative | Crate-relative | | 2015 | 2018 | Crate-relative with fallback to Extern prelude | Crate-relative with fallback to Extern prelude | I.e. only the behavior of the mixed local-2015-global-2018 mode is changed. This mixed mode has two goals: - Address regressions from #56053 (comment). Both "before" and "after" variants address those regressions. - Be retrofit-able to "full 2015" edition (#57745). Any more complex fallback scheme (with more candidates) than "Crate-relative with fallback to Extern prelude" will give more regressions than #57745 (comment) and is therefore less retrofit-able while also being, well, more complex. So, we can settle on "Crate-relative with fallback to Extern prelude". (I'll hopefully proceed with #57745 after mid-February.) r? @Centril
- Loading branch information
Showing
7 changed files
with
11 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/test/ui/editions/edition-imports-virtual-2015-ambiguity.stderr
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
// edition:2018 | ||
// aux-build:edition-imports-2015.rs | ||
// error-pattern: imports can only refer to extern crate names passed with `--extern` | ||
|
||
#[macro_use] | ||
extern crate edition_imports_2015; | ||
|
||
mod check { | ||
gen_gated!(); | ||
gen_gated!(); //~ ERROR unresolved import `E` | ||
} | ||
|
||
fn main() {} |
17 changes: 4 additions & 13 deletions
17
src/test/ui/editions/edition-imports-virtual-2015-gated.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,11 @@ | ||
error: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition | ||
--> <::edition_imports_2015::gen_gated macros>:1:50 | ||
| | ||
LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } } | ||
| ^ | ||
| | ||
::: $DIR/edition-imports-virtual-2015-gated.rs:9:5 | ||
error[E0432]: unresolved import `E` | ||
--> $DIR/edition-imports-virtual-2015-gated.rs:8:5 | ||
| | ||
LL | gen_gated!(); | ||
| ------------- not an extern crate passed with `--extern` | ||
| | ||
note: this import refers to the enum defined here | ||
--> $DIR/edition-imports-virtual-2015-gated.rs:9:5 | ||
| ^^^^^^^^^^^^^ could not find `E` in `{{root}}` | ||
| | ||
LL | gen_gated!(); | ||
| ^^^^^^^^^^^^^ | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0432`. |