diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-04-28 21:27:01 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-04-28 22:36:57 +0300 |
| commit | fbbec7670137860cfbdcf3522f61c8b87f4319cb (patch) | |
| tree | c67f9d2ea1a7a63c35c0a60797a7706d41f8e323 /src | |
| parent | bdfdbcd44d457b2ac6d0cea4fb71739d3166cb98 (diff) | |
| download | rust-fbbec7670137860cfbdcf3522f61c8b87f4319cb.tar.gz rust-fbbec7670137860cfbdcf3522f61c8b87f4319cb.zip | |
resolve: Consider erroneous imports used to avoid duplicate diagnostics
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_resolve/resolve_imports.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/imports/unresolved-imports-used.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/imports/unresolved-imports-used.stderr | 22 |
3 files changed, 36 insertions, 0 deletions
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 58e0df1cd7c..4dddf811c05 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -627,6 +627,8 @@ impl<'a> Resolver<'a> { let dummy_binding = self.import(dummy_binding, directive); self.per_ns(|this, ns| { let _ = this.try_define(directive.parent_scope.module, target, ns, dummy_binding); + // Consider erroneous imports used to avoid duplicate diagnostics. + this.record_use(target, ns, dummy_binding, false); }); } } diff --git a/src/test/ui/imports/unresolved-imports-used.rs b/src/test/ui/imports/unresolved-imports-used.rs new file mode 100644 index 00000000000..d1461e7b041 --- /dev/null +++ b/src/test/ui/imports/unresolved-imports-used.rs @@ -0,0 +1,12 @@ +// There should be *no* unused import errors. +#![deny(unused_imports)] + +mod qux { + fn quz() {} +} + +use qux::quz; //~ ERROR function `quz` is private +use qux::bar; //~ ERROR unresolved import `qux::bar` +use foo::bar; //~ ERROR unresolved import `foo` + +fn main() {} diff --git a/src/test/ui/imports/unresolved-imports-used.stderr b/src/test/ui/imports/unresolved-imports-used.stderr new file mode 100644 index 00000000000..f20db881c86 --- /dev/null +++ b/src/test/ui/imports/unresolved-imports-used.stderr @@ -0,0 +1,22 @@ +error[E0432]: unresolved import `qux::bar` + --> $DIR/unresolved-imports-used.rs:9:5 + | +LL | use qux::bar; + | ^^^^^^^^ no `bar` in `qux` + +error[E0432]: unresolved import `foo` + --> $DIR/unresolved-imports-used.rs:10:5 + | +LL | use foo::bar; + | ^^^ maybe a missing `extern crate foo;`? + +error[E0603]: function `quz` is private + --> $DIR/unresolved-imports-used.rs:8:10 + | +LL | use qux::quz; + | ^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0432, E0603. +For more information about an error, try `rustc --explain E0432`. |
