forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#113331 - chenyukang:yukang-fix-112590-false…
…-positive, r=estebank Add filter with following segment while lookup typo for path From the discussion: rust-lang#112917 (comment) Seems we can not get the assoc items for `Struct`, `Enum` in the resolving phase. A obvious filter is avoid suggesting the same name with the following segment path. Use `following_seg` can extend the function `smart_resolve_partial_mod_path_errors` for more scenarios, such as `std::sync_error::atomic::AtomicBool` in test case. r? `@estebank`
- Loading branch information
Showing
14 changed files
with
301 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// edition:2018 | ||
#![feature(decl_macro)] | ||
|
||
macro a() { | ||
extern crate core as my_core; | ||
mod v { | ||
// Early resolution. | ||
use my_core; //~ ERROR unresolved import `my_core` | ||
} | ||
mod u { | ||
// Late resolution. | ||
fn f() { my_core::mem::drop(0); } | ||
//~^ ERROR failed to resolve: use of undeclared crate or module `my_core` | ||
} | ||
} | ||
|
||
a!(); | ||
|
||
mod v { | ||
// Early resolution. | ||
use my_core; //~ ERROR unresolved import `my_core` | ||
} | ||
mod u { | ||
// Late resolution. | ||
fn f() { my_core::mem::drop(0); } | ||
//~^ ERROR failed to resolve: use of undeclared crate or module `my_core` | ||
} | ||
|
||
fn main() {} |
53 changes: 53 additions & 0 deletions
53
tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
error[E0432]: unresolved import `my_core` | ||
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:21:9 | ||
| | ||
LL | use my_core; | ||
| ^^^^^^^ no external crate `my_core` | ||
|
||
error[E0432]: unresolved import `my_core` | ||
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:8:13 | ||
| | ||
LL | use my_core; | ||
| ^^^^^^^ no external crate `my_core` | ||
... | ||
LL | a!(); | ||
| ---- in this macro invocation | ||
| | ||
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `my_core` | ||
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:12:18 | ||
| | ||
LL | fn f() { my_core::mem::drop(0); } | ||
| ^^^^^^^ use of undeclared crate or module `my_core` | ||
... | ||
LL | a!(); | ||
| ---- in this macro invocation | ||
| | ||
= help: consider importing one of these items: | ||
std::mem | ||
core::mem | ||
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `my_core` | ||
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:25:14 | ||
| | ||
LL | fn f() { my_core::mem::drop(0); } | ||
| ^^^^^^^ use of undeclared crate or module `my_core` | ||
| | ||
help: consider importing one of these items | ||
| | ||
LL + use core::mem; | ||
| | ||
LL + use std::mem; | ||
| | ||
help: if you import `mem`, refer to it directly | ||
| | ||
LL - fn f() { my_core::mem::drop(0); } | ||
LL + fn f() { mem::drop(0); } | ||
| | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0432, E0433. | ||
For more information about an error, try `rustc --explain E0432`. |
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,3 +1,4 @@ | ||
// edition:2015 | ||
#![feature(decl_macro)] | ||
|
||
macro a() { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// run-rustfix | ||
use std::vec; | ||
|
||
use std::sync::atomic::AtomicBool; | ||
|
||
mod foo { | ||
pub mod bar { | ||
pub mod baz { | ||
pub use std::vec::Vec as MyVec; | ||
} | ||
} | ||
} | ||
|
||
mod u { | ||
use foo::bar::baz::MyVec; | ||
|
||
fn _a() { | ||
let _: Vec<i32> = MyVec::new(); //~ ERROR failed to resolve | ||
} | ||
} | ||
|
||
mod v { | ||
use foo::bar::baz::MyVec; | ||
|
||
fn _b() { | ||
let _: Vec<i32> = MyVec::new(); //~ ERROR failed to resolve | ||
} | ||
} | ||
|
||
fn main() { | ||
let _t: Vec<i32> = Vec::new(); //~ ERROR failed to resolve | ||
type _B = vec::Vec::<u8>; //~ ERROR failed to resolve | ||
let _t = AtomicBool::new(true); //~ ERROR failed to resolve | ||
} |
Oops, something went wrong.