about summary refs log tree commit diff
path: root/src/test/ui/resolve
diff options
context:
space:
mode:
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-09-11 01:15:40 +0200
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-09-26 18:43:58 +0200
commit65eb381dec051e31d1fb17a5a7629bdee1eb9922 (patch)
tree34e873ef33bc6718a27952e244d7f17b5198bf98 /src/test/ui/resolve
parentac8dd1b2f24dc62c962172b27433106b4e84dc62 (diff)
downloadrust-65eb381dec051e31d1fb17a5a7629bdee1eb9922.tar.gz
rust-65eb381dec051e31d1fb17a5a7629bdee1eb9922.zip
Do not suggest importing inaccessible items
Diffstat (limited to 'src/test/ui/resolve')
-rw-r--r--src/test/ui/resolve/issue-42944.stderr6
-rw-r--r--src/test/ui/resolve/issue-88472.rs35
-rw-r--r--src/test/ui/resolve/issue-88472.stderr34
-rw-r--r--src/test/ui/resolve/privacy-enum-ctor.stderr48
-rw-r--r--src/test/ui/resolve/privacy-struct-ctor.stderr6
5 files changed, 85 insertions, 44 deletions
diff --git a/src/test/ui/resolve/issue-42944.stderr b/src/test/ui/resolve/issue-42944.stderr
index 008492529d1..1ca7a6d34f7 100644
--- a/src/test/ui/resolve/issue-42944.stderr
+++ b/src/test/ui/resolve/issue-42944.stderr
@@ -16,10 +16,8 @@ error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this s
 LL |         Bx(());
    |         ^^ not found in this scope
    |
-help: consider importing this tuple struct
-   |
-LL |     use foo::Bx;
-   |
+   = note: this tuple struct exists but is inaccessible:
+           foo::Bx
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/resolve/issue-88472.rs b/src/test/ui/resolve/issue-88472.rs
new file mode 100644
index 00000000000..53cfec57466
--- /dev/null
+++ b/src/test/ui/resolve/issue-88472.rs
@@ -0,0 +1,35 @@
+// Regression test for #88472, where a suggestion was issued to
+// import an inaccessible struct.
+
+#![warn(unused_imports)]
+//~^ NOTE: the lint level is defined here
+
+mod a {
+    struct Foo;
+}
+
+mod b {
+    use crate::a::*;
+    //~^ WARNING: unused import
+    type Bar = Foo;
+    //~^ ERROR: cannot find type `Foo` in this scope [E0412]
+    //~| NOTE: not found in this scope
+    //~| NOTE: this struct exists but is inaccessible
+}
+
+mod c {
+    enum Eee {}
+
+    mod d {
+        enum Eee {}
+    }
+}
+
+mod e {
+    type Baz = Eee;
+    //~^ ERROR: cannot find type `Eee` in this scope [E0412]
+    //~| NOTE: not found in this scope
+    //~| NOTE: these items exist but are inaccessible
+}
+
+fn main() {}
diff --git a/src/test/ui/resolve/issue-88472.stderr b/src/test/ui/resolve/issue-88472.stderr
new file mode 100644
index 00000000000..6846210b302
--- /dev/null
+++ b/src/test/ui/resolve/issue-88472.stderr
@@ -0,0 +1,34 @@
+error[E0412]: cannot find type `Foo` in this scope
+  --> $DIR/issue-88472.rs:14:16
+   |
+LL |     type Bar = Foo;
+   |                ^^^ not found in this scope
+   |
+   = note: this struct exists but is inaccessible:
+           a::Foo
+
+error[E0412]: cannot find type `Eee` in this scope
+  --> $DIR/issue-88472.rs:29:16
+   |
+LL |     type Baz = Eee;
+   |                ^^^ not found in this scope
+   |
+   = note: these items exist but are inaccessible:
+           c::Eee
+           c::d::Eee
+
+warning: unused import: `crate::a::*`
+  --> $DIR/issue-88472.rs:12:9
+   |
+LL |     use crate::a::*;
+   |         ^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-88472.rs:4:9
+   |
+LL | #![warn(unused_imports)]
+   |         ^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr
index 192349e0faf..e79f953970a 100644
--- a/src/test/ui/resolve/privacy-enum-ctor.stderr
+++ b/src/test/ui/resolve/privacy-enum-ctor.stderr
@@ -169,16 +169,10 @@ LL |     pub enum E {
    |     ---------- similarly named enum `E` defined here
 ...
 LL |     let _: Z = m::n::Z;
-   |            ^
-   |
-help: an enum with a similar name exists
-   |
-LL |     let _: E = m::n::Z;
-   |            ~
-help: consider importing this enum
-   |
-LL | use m::Z;
+   |            ^ help: an enum with a similar name exists: `E`
    |
+   = note: this enum exists but is inaccessible:
+           m::Z
 
 error[E0423]: expected value, found enum `m::n::Z`
   --> $DIR/privacy-enum-ctor.rs:57:16
@@ -215,16 +209,10 @@ LL |     pub enum E {
    |     ---------- similarly named enum `E` defined here
 ...
 LL |     let _: Z = m::n::Z::Fn;
-   |            ^
-   |
-help: an enum with a similar name exists
-   |
-LL |     let _: E = m::n::Z::Fn;
-   |            ~
-help: consider importing this enum
-   |
-LL | use m::Z;
+   |            ^ help: an enum with a similar name exists: `E`
    |
+   = note: this enum exists but is inaccessible:
+           m::Z
 
 error[E0412]: cannot find type `Z` in this scope
   --> $DIR/privacy-enum-ctor.rs:64:12
@@ -233,16 +221,10 @@ LL |     pub enum E {
    |     ---------- similarly named enum `E` defined here
 ...
 LL |     let _: Z = m::n::Z::Struct;
-   |            ^
-   |
-help: an enum with a similar name exists
-   |
-LL |     let _: E = m::n::Z::Struct;
-   |            ~
-help: consider importing this enum
-   |
-LL | use m::Z;
+   |            ^ help: an enum with a similar name exists: `E`
    |
+   = note: this enum exists but is inaccessible:
+           m::Z
 
 error[E0423]: expected value, found struct variant `m::n::Z::Struct`
   --> $DIR/privacy-enum-ctor.rs:64:16
@@ -262,16 +244,10 @@ LL |     pub enum E {
    |     ---------- similarly named enum `E` defined here
 ...
 LL |     let _: Z = m::n::Z::Unit {};
-   |            ^
-   |
-help: an enum with a similar name exists
-   |
-LL |     let _: E = m::n::Z::Unit {};
-   |            ~
-help: consider importing this enum
-   |
-LL | use m::Z;
+   |            ^ help: an enum with a similar name exists: `E`
    |
+   = note: this enum exists but is inaccessible:
+           m::Z
 
 error[E0603]: enum `Z` is private
   --> $DIR/privacy-enum-ctor.rs:57:22
diff --git a/src/test/ui/resolve/privacy-struct-ctor.stderr b/src/test/ui/resolve/privacy-struct-ctor.stderr
index e5d6f7e9e24..bf1d6753cc1 100644
--- a/src/test/ui/resolve/privacy-struct-ctor.stderr
+++ b/src/test/ui/resolve/privacy-struct-ctor.stderr
@@ -33,10 +33,8 @@ error[E0423]: expected value, found struct `xcrate::S`
 LL |     xcrate::S;
    |     ^^^^^^^^^ constructor is not visible here due to private fields
    |
-help: consider importing this tuple struct instead
-   |
-LL | use m::S;
-   |
+   = note: this tuple struct exists but is inaccessible:
+           m::S
 
 error[E0603]: tuple struct constructor `Z` is private
   --> $DIR/privacy-struct-ctor.rs:18:12