Add suggestions for unresolved imports.
This commit adds suggestions for unresolved imports in the cases where there could be a missing `crate::`, `super::`, `self::` or a missing external crate name before an import.
This commit is contained in:
parent
4cf11765dc
commit
29e2376ac7
9 changed files with 244 additions and 19 deletions
|
|
@ -19,15 +19,15 @@ mod a {
|
|||
mod b {
|
||||
use alloc::HashMap;
|
||||
//~^ ERROR unresolved import `alloc` [E0432]
|
||||
//~| Did you mean `a::alloc`?
|
||||
//~| Did you mean `super::alloc`?
|
||||
mod c {
|
||||
use alloc::HashMap;
|
||||
//~^ ERROR unresolved import `alloc` [E0432]
|
||||
//~| Did you mean `a::alloc`?
|
||||
//~| Did you mean `std::alloc`?
|
||||
mod d {
|
||||
use alloc::HashMap;
|
||||
//~^ ERROR unresolved import `alloc` [E0432]
|
||||
//~| Did you mean `a::alloc`?
|
||||
//~| Did you mean `std::alloc`?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ error[E0432]: unresolved import `alloc`
|
|||
--> $DIR/resolve_self_super_hint.rs:20:13
|
||||
|
|
||||
LL | use alloc::HashMap;
|
||||
| ^^^^^ Did you mean `a::alloc`?
|
||||
| ^^^^^ Did you mean `super::alloc`?
|
||||
|
||||
error[E0432]: unresolved import `alloc`
|
||||
--> $DIR/resolve_self_super_hint.rs:24:17
|
||||
|
|
||||
LL | use alloc::HashMap;
|
||||
| ^^^^^ Did you mean `a::alloc`?
|
||||
| ^^^^^ Did you mean `std::alloc`?
|
||||
|
||||
error[E0432]: unresolved import `alloc`
|
||||
--> $DIR/resolve_self_super_hint.rs:28:21
|
||||
|
|
||||
LL | use alloc::HashMap;
|
||||
| ^^^^^ Did you mean `a::alloc`?
|
||||
| ^^^^^ Did you mean `std::alloc`?
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
15
src/test/ui/rust-2018/auxiliary/baz.rs
Normal file
15
src/test/ui/rust-2018/auxiliary/baz.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// This file is used as part of the local-path-suggestions.rs test.
|
||||
|
||||
pub mod foobar {
|
||||
pub struct Baz;
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ error[E0432]: unresolved import `alloc`
|
|||
--> $DIR/issue-54006.rs:16:5
|
||||
|
|
||||
LL | use alloc::vec;
|
||||
| ^^^^^ Could not find `alloc` in `{{root}}`
|
||||
| ^^^^^ Did you mean `std::alloc`?
|
||||
|
||||
error: cannot determine resolution for the macro `vec`
|
||||
--> $DIR/issue-54006.rs:20:18
|
||||
|
|
|
|||
31
src/test/ui/rust-2018/local-path-suggestions.rs
Normal file
31
src/test/ui/rust-2018/local-path-suggestions.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:baz.rs
|
||||
// compile-flags:--extern baz
|
||||
// edition:2018
|
||||
|
||||
mod foo {
|
||||
type Bar = u32;
|
||||
}
|
||||
|
||||
mod baz {
|
||||
use foo::Bar;
|
||||
|
||||
fn baz() {
|
||||
let x: Bar = 22;
|
||||
}
|
||||
}
|
||||
|
||||
use foo::Bar;
|
||||
|
||||
use foobar::Baz;
|
||||
|
||||
fn main() { }
|
||||
21
src/test/ui/rust-2018/local-path-suggestions.stderr
Normal file
21
src/test/ui/rust-2018/local-path-suggestions.stderr
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
error[E0432]: unresolved import `foo`
|
||||
--> $DIR/local-path-suggestions.rs:20:9
|
||||
|
|
||||
LL | use foo::Bar;
|
||||
| ^^^ Did you mean `crate::foo`?
|
||||
|
||||
error[E0432]: unresolved import `foo`
|
||||
--> $DIR/local-path-suggestions.rs:27:5
|
||||
|
|
||||
LL | use foo::Bar;
|
||||
| ^^^ Did you mean `self::foo`?
|
||||
|
||||
error[E0432]: unresolved import `foobar`
|
||||
--> $DIR/local-path-suggestions.rs:29:5
|
||||
|
|
||||
LL | use foobar::Baz;
|
||||
| ^^^^^^ Did you mean `baz::foobar`?
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0432`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue