]> git.lizzy.rs Git - rust.git/commitdiff
clarify what the item is in "not a module" error
authorAndy Russell <arussell123@gmail.com>
Mon, 1 Apr 2019 20:22:12 +0000 (16:22 -0400)
committerAndy Russell <arussell123@gmail.com>
Wed, 10 Apr 2019 16:55:21 +0000 (12:55 -0400)
15 files changed:
src/librustc_resolve/lib.rs
src/test/ui/issues/issue-30560.rs
src/test/ui/issues/issue-30560.stderr
src/test/ui/macros/macro-path-prelude-fail-1.rs
src/test/ui/macros/macro-path-prelude-fail-1.stderr
src/test/ui/resolve/resolve-variant-assoc-item.rs
src/test/ui/resolve/resolve-variant-assoc-item.stderr
src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr
src/test/ui/ufcs/ufcs-partially-resolved.rs
src/test/ui/ufcs/ufcs-partially-resolved.stderr
src/test/ui/use/use-associated-const.rs [new file with mode: 0644]
src/test/ui/use/use-associated-const.stderr [new file with mode: 0644]
src/test/ui/use/use-from-trait-xc.stderr
src/test/ui/use/use-from-trait.rs
src/test/ui/use/use-from-trait.stderr

index 5216156c0cab81d14b0ff2cbdfb40c28edc8cae9..ffc783ae9f235dd56eee44cadce2cbb94b4e5362 100644 (file)
@@ -3731,9 +3731,16 @@ fn resolve_path(
                             def, path.len() - i - 1
                         ));
                     } else {
+                        let label = format!(
+                            "`{}` is {} {}, not a module",
+                            ident,
+                            def.article(),
+                            def.kind_name(),
+                        );
+
                         return PathResult::Failed {
                             span: ident.span,
-                            label: format!("not a module `{}`", ident),
+                            label,
                             suggestion: None,
                             is_error_from_last_segment: is_last,
                         };
index c848a1c51ca37ed35bb30fe294b1597b0f022a10..d8d4ca608f1c07f1d8b869f78f629168c7367bda 100644 (file)
@@ -1,10 +1,7 @@
 type Alias = ();
-use Alias::*;
-//~^ ERROR unresolved import `Alias` [E0432]
-//~| not a module `Alias`
-use std::io::Result::*;
-//~^ ERROR unresolved import `std::io::Result` [E0432]
-//~| not a module `Result`
+use Alias::*; //~ ERROR unresolved import `Alias` [E0432]
+
+use std::io::Result::*; //~ ERROR unresolved import `std::io::Result` [E0432]
 
 trait T {}
 use T::*; //~ ERROR items in traits are not importable
index 5225f190f9ed4a137fb3c9ee03ea0f6d394accbb..b74134aaccc0d8fa13873d5c40cb2e30ff76e4bd 100644 (file)
@@ -1,5 +1,5 @@
 error: items in traits are not importable.
-  --> $DIR/issue-30560.rs:10:5
+  --> $DIR/issue-30560.rs:7:5
    |
 LL | use T::*;
    |     ^^^^
@@ -8,13 +8,13 @@ error[E0432]: unresolved import `Alias`
   --> $DIR/issue-30560.rs:2:5
    |
 LL | use Alias::*;
-   |     ^^^^^ not a module `Alias`
+   |     ^^^^^ `Alias` is a type alias, not a module
 
 error[E0432]: unresolved import `std::io::Result`
-  --> $DIR/issue-30560.rs:5:14
+  --> $DIR/issue-30560.rs:4:14
    |
 LL | use std::io::Result::*;
-   |              ^^^^^^ not a module `Result`
+   |              ^^^^^^ `Result` is a type alias, not a module
 
 error: aborting due to 3 previous errors
 
index 354c2bf8571d924fd7b6e406550a41d6d51cd5a7..cd695ca916ea9aac354b35a6533fab14d6afe31c 100644 (file)
@@ -2,8 +2,8 @@
 
 mod m {
     fn check() {
-        Vec::clone!(); //~ ERROR failed to resolve: not a module `Vec`
-        u8::clone!(); //~ ERROR failed to resolve: not a module `u8`
+        Vec::clone!(); //~ ERROR failed to resolve: `Vec` is a struct, not a module
+        u8::clone!(); //~ ERROR failed to resolve: `u8` is a builtin type, not a module
     }
 }
 
index 551d2fe8ce041cb7127d8563ac87ba6caa883c95..b68e89f07f67600c91c5fadd0f74ff15379277ef 100644 (file)
@@ -1,14 +1,14 @@
-error[E0433]: failed to resolve: not a module `Vec`
+error[E0433]: failed to resolve: `Vec` is a struct, not a module
   --> $DIR/macro-path-prelude-fail-1.rs:5:9
    |
 LL |         Vec::clone!();
-   |         ^^^ not a module `Vec`
+   |         ^^^ `Vec` is a struct, not a module
 
-error[E0433]: failed to resolve: not a module `u8`
+error[E0433]: failed to resolve: `u8` is a builtin type, not a module
   --> $DIR/macro-path-prelude-fail-1.rs:6:9
    |
 LL |         u8::clone!();
-   |         ^^ not a module `u8`
+   |         ^^ `u8` is a builtin type, not a module
 
 error: aborting due to 2 previous errors
 
index f0f55c0c66718d488c7c6f70b4496dec4fe4e015..db4fedfb0bdf866b643c8c3897878ebfb8eae7a1 100644 (file)
@@ -2,6 +2,6 @@ enum E { V }
 use E::V;
 
 fn main() {
-    E::V::associated_item; //~ ERROR failed to resolve: not a module `V`
-    V::associated_item; //~ ERROR failed to resolve: not a module `V`
+    E::V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module
+    V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module
 }
index 173976d707c70cc0569d65ef624892fbdef00ff7..4be1019968bcc7c7b20192bfe24a6e3ec231bc34 100644 (file)
@@ -1,14 +1,14 @@
-error[E0433]: failed to resolve: not a module `V`
+error[E0433]: failed to resolve: `V` is a variant, not a module
   --> $DIR/resolve-variant-assoc-item.rs:5:8
    |
 LL |     E::V::associated_item;
-   |        ^ not a module `V`
+   |        ^ `V` is a variant, not a module
 
-error[E0433]: failed to resolve: not a module `V`
+error[E0433]: failed to resolve: `V` is a variant, not a module
   --> $DIR/resolve-variant-assoc-item.rs:6:5
    |
 LL |     V::associated_item;
-   |     ^ not a module `V`
+   |     ^ `V` is a variant, not a module
 
 error: aborting due to 2 previous errors
 
index a61af699cdc3382a98d2de40052649aec240e390..42daf7c6fb12ffae7a22c38b77fc6c6abb5afbeb 100644 (file)
@@ -8,7 +8,7 @@ error[E0432]: unresolved import `rustfmt`
   --> $DIR/prelude-fail.rs:7:5
    |
 LL | use rustfmt::skip as imported_rustfmt_skip;
-   |     ^^^^^^^ not a module `rustfmt`
+   |     ^^^^^^^ `rustfmt` is a tool module, not a module
 
 error: aborting due to 2 previous errors
 
index 4efded8b37661ceb68beba63d6fc630bc28b8129..82a593ff16cfa165f87018dcf7dc2174b72a8eb4 100644 (file)
@@ -45,9 +45,9 @@ fn main() {
     <u8 as E::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N`
     <u8 as A::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N`
     let _: <u8 as Tr::Y>::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y`
-    let _: <u8 as E::Y>::NN; //~ ERROR failed to resolve: not a module `Y`
+    let _: <u8 as E::Y>::NN; //~ ERROR failed to resolve: `Y` is a variant, not a module
     <u8 as Tr::Y>::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y`
-    <u8 as E::Y>::NN; //~ ERROR failed to resolve: not a module `Y`
+    <u8 as E::Y>::NN; //~ ERROR failed to resolve: `Y` is a variant, not a module
 
     let _: <u8 as Dr>::Z; //~ ERROR expected associated type, found method `Dr::Z`
     <u8 as Dr>::X; //~ ERROR expected method or associated constant, found associated type `Dr::X`
index 900c729721104b7ec98c7b34d97c820089d731bd..c399a32bc56b86d5235076b14ce0bbe4119c4666 100644 (file)
@@ -1,14 +1,14 @@
-error[E0433]: failed to resolve: not a module `Y`
+error[E0433]: failed to resolve: `Y` is a variant, not a module
   --> $DIR/ufcs-partially-resolved.rs:48:22
    |
 LL |     let _: <u8 as E::Y>::NN;
-   |                      ^ not a module `Y`
+   |                      ^ `Y` is a variant, not a module
 
-error[E0433]: failed to resolve: not a module `Y`
+error[E0433]: failed to resolve: `Y` is a variant, not a module
   --> $DIR/ufcs-partially-resolved.rs:50:15
    |
 LL |     <u8 as E::Y>::NN;
-   |               ^ not a module `Y`
+   |               ^ `Y` is a variant, not a module
 
 error[E0576]: cannot find associated type `N` in trait `Tr`
   --> $DIR/ufcs-partially-resolved.rs:19:24
diff --git a/src/test/ui/use/use-associated-const.rs b/src/test/ui/use/use-associated-const.rs
new file mode 100644 (file)
index 0000000..714fbda
--- /dev/null
@@ -0,0 +1,13 @@
+#![allow(unused_imports)]
+
+pub mod foo {
+    pub struct Foo;
+
+    impl Foo {
+        pub const BAR: i32 = 0;
+    }
+}
+
+use foo::Foo::BAR; //~ ERROR unresolved import `foo::Foo`
+
+fn main() {}
diff --git a/src/test/ui/use/use-associated-const.stderr b/src/test/ui/use/use-associated-const.stderr
new file mode 100644 (file)
index 0000000..4bc0d7e
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `foo::Foo`
+  --> $DIR/use-associated-const.rs:11:10
+   |
+LL | use foo::Foo::BAR;
+   |          ^^^ `Foo` is a struct, not a module
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
index 97dc603f9eb2d2361094028da27156ce3201eee8..faa4829bfdd6238ac6e28b63d5bc404b5502e706 100644 (file)
@@ -20,19 +20,19 @@ error[E0432]: unresolved import `use_from_trait_xc::Foo`
   --> $DIR/use-from-trait-xc.rs:14:24
    |
 LL | use use_from_trait_xc::Foo::new;
-   |                        ^^^ not a module `Foo`
+   |                        ^^^ `Foo` is a struct, not a module
 
 error[E0432]: unresolved import `use_from_trait_xc::Foo`
   --> $DIR/use-from-trait-xc.rs:17:24
    |
 LL | use use_from_trait_xc::Foo::C;
-   |                        ^^^ not a module `Foo`
+   |                        ^^^ `Foo` is a struct, not a module
 
 error[E0432]: unresolved import `use_from_trait_xc::Bar`
   --> $DIR/use-from-trait-xc.rs:20:24
    |
 LL | use use_from_trait_xc::Bar::new as bnew;
-   |                        ^^^ not a module `Bar`
+   |                        ^^^ `Bar` is a struct, not a module
 
 error[E0432]: unresolved import `use_from_trait_xc::Baz::new`
   --> $DIR/use-from-trait-xc.rs:23:5
index fe578723bd3fcc694e20754d4ec434408c31bbd2..eab4bb6e3b5bee6b57066c213a1589cc593ca6aa 100644 (file)
@@ -1,17 +1,10 @@
-use Trait::foo;
-//~^ ERROR `foo` is not directly importable
-use Trait::Assoc;
-//~^ ERROR `Assoc` is not directly importable
-use Trait::C;
-//~^ ERROR `C` is not directly importable
+use Trait::foo; //~ ERROR `foo` is not directly importable
+use Trait::Assoc; //~ ERROR `Assoc` is not directly importable
+use Trait::C; //~ ERROR `C` is not directly importable
 
-use Foo::new;
-//~^ ERROR unresolved import `Foo` [E0432]
-//~| not a module `Foo`
+use Foo::new; //~ ERROR unresolved import `Foo` [E0432]
 
-use Foo::C2;
-//~^ ERROR unresolved import `Foo` [E0432]
-//~| not a module `Foo`
+use Foo::C2; //~ ERROR unresolved import `Foo` [E0432]
 
 pub trait Trait {
     fn foo();
index 9e138422a2fb07ac6a6b81dfc5eddeadbe285959..af4b3b0c455e152977e8e9979d3e328628c8db66 100644 (file)
@@ -5,28 +5,28 @@ LL | use Trait::foo;
    |     ^^^^^^^^^^ cannot be imported directly
 
 error[E0253]: `Assoc` is not directly importable
-  --> $DIR/use-from-trait.rs:3:5
+  --> $DIR/use-from-trait.rs:2:5
    |
 LL | use Trait::Assoc;
    |     ^^^^^^^^^^^^ cannot be imported directly
 
 error[E0253]: `C` is not directly importable
-  --> $DIR/use-from-trait.rs:5:5
+  --> $DIR/use-from-trait.rs:3:5
    |
 LL | use Trait::C;
    |     ^^^^^^^^ cannot be imported directly
 
 error[E0432]: unresolved import `Foo`
-  --> $DIR/use-from-trait.rs:8:5
+  --> $DIR/use-from-trait.rs:5:5
    |
 LL | use Foo::new;
-   |     ^^^ not a module `Foo`
+   |     ^^^ `Foo` is a struct, not a module
 
 error[E0432]: unresolved import `Foo`
-  --> $DIR/use-from-trait.rs:12:5
+  --> $DIR/use-from-trait.rs:7:5
    |
 LL | use Foo::C2;
-   |     ^^^ not a module `Foo`
+   |     ^^^ `Foo` is a struct, not a module
 
 error: aborting due to 5 previous errors