summaryrefslogtreecommitdiffstats
path: root/src/test/ui/unresolved
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/unresolved')
-rw-r--r--src/test/ui/unresolved/unresolved-asterisk-imports.rs4
-rw-r--r--src/test/ui/unresolved/unresolved-asterisk-imports.stderr11
-rw-r--r--src/test/ui/unresolved/unresolved-extern-mod-suggestion.rs5
-rw-r--r--src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr13
-rw-r--r--src/test/ui/unresolved/unresolved-import-recovery.rs17
-rw-r--r--src/test/ui/unresolved/unresolved-import-recovery.stderr9
-rw-r--r--src/test/ui/unresolved/unresolved-import.rs56
-rw-r--r--src/test/ui/unresolved/unresolved-import.stderr50
8 files changed, 165 insertions, 0 deletions
diff --git a/src/test/ui/unresolved/unresolved-asterisk-imports.rs b/src/test/ui/unresolved/unresolved-asterisk-imports.rs
new file mode 100644
index 000000000..2d853a66c
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-asterisk-imports.rs
@@ -0,0 +1,4 @@
+use not_existing_crate::*; //~ ERROR unresolved import `not_existing_crate
+use std as foo;
+
+fn main() {}
diff --git a/src/test/ui/unresolved/unresolved-asterisk-imports.stderr b/src/test/ui/unresolved/unresolved-asterisk-imports.stderr
new file mode 100644
index 000000000..8df8eab34
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-asterisk-imports.stderr
@@ -0,0 +1,11 @@
+error[E0432]: unresolved import `not_existing_crate`
+ --> $DIR/unresolved-asterisk-imports.rs:1:5
+ |
+LL | use not_existing_crate::*;
+ | ^^^^^^^^^^^^^^^^^^ maybe a missing crate `not_existing_crate`?
+ |
+ = help: consider adding `extern crate not_existing_crate` to use the `not_existing_crate` crate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.rs b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.rs
new file mode 100644
index 000000000..a1bf0f210
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.rs
@@ -0,0 +1,5 @@
+extern crate core;
+use core;
+//~^ ERROR the name `core` is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr
new file mode 100644
index 000000000..28333228a
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr
@@ -0,0 +1,13 @@
+error[E0254]: the name `core` is defined multiple times
+ --> $DIR/unresolved-extern-mod-suggestion.rs:2:5
+ |
+LL | extern crate core;
+ | ------------------ previous import of the extern crate `core` here
+LL | use core;
+ | ^^^^ `core` reimported here
+ |
+ = note: `core` must be defined only once in the type namespace of this module
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0254`.
diff --git a/src/test/ui/unresolved/unresolved-import-recovery.rs b/src/test/ui/unresolved/unresolved-import-recovery.rs
new file mode 100644
index 000000000..0b0653378
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-import-recovery.rs
@@ -0,0 +1,17 @@
+// Check that unresolved imports do not create additional errors and ICEs
+
+mod m {
+ pub use unresolved; //~ ERROR unresolved import `unresolved`
+
+ fn f() {
+ let unresolved = 0; // OK
+ }
+}
+
+fn main() {
+ match 0u8 {
+ m::unresolved => {} // OK
+ m::unresolved(..) => {} // OK
+ m::unresolved{..} => {} // OK
+ }
+}
diff --git a/src/test/ui/unresolved/unresolved-import-recovery.stderr b/src/test/ui/unresolved/unresolved-import-recovery.stderr
new file mode 100644
index 000000000..5e371b70b
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-import-recovery.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `unresolved`
+ --> $DIR/unresolved-import-recovery.rs:4:13
+ |
+LL | pub use unresolved;
+ | ^^^^^^^^^^ no `unresolved` in the root
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/unresolved/unresolved-import.rs b/src/test/ui/unresolved/unresolved-import.rs
new file mode 100644
index 000000000..4125c593c
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-import.rs
@@ -0,0 +1,56 @@
+use foo::bar; //~ ERROR unresolved import `foo` [E0432]
+ //~^ maybe a missing crate `foo`?
+ //~| HELP consider adding `extern crate foo` to use the `foo` crate
+
+use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432]
+ //~| no `Baz` in `bar`
+ //~| HELP a similar name exists in the module
+ //~| SUGGESTION Bar
+
+use food::baz; //~ ERROR unresolved import `food::baz`
+ //~| no `baz` in `food`
+ //~| HELP a similar name exists in the module
+ //~| SUGGESTION bag
+
+use food::{beens as Foo}; //~ ERROR unresolved import `food::beens` [E0432]
+ //~| no `beens` in `food`
+ //~| HELP a similar name exists in the module
+ //~| SUGGESTION beans
+
+mod bar {
+ pub struct Bar;
+}
+
+mod food {
+ pub use self::zug::baz::{self as bag, Foobar as beans};
+
+ mod zug {
+ pub mod baz {
+ pub struct Foobar;
+ }
+ }
+}
+
+mod m {
+ enum MyEnum {
+ MyVariant
+ }
+
+ use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432]
+ //~| HELP a similar path exists
+ //~| SUGGESTION self::MyEnum
+}
+
+mod items {
+ enum Enum {
+ Variant
+ }
+
+ use Enum::*; //~ ERROR unresolved import `Enum` [E0432]
+ //~| HELP a similar path exists
+ //~| SUGGESTION self::Enum
+
+ fn item() {}
+}
+
+fn main() {}
diff --git a/src/test/ui/unresolved/unresolved-import.stderr b/src/test/ui/unresolved/unresolved-import.stderr
new file mode 100644
index 000000000..0dd928c8b
--- /dev/null
+++ b/src/test/ui/unresolved/unresolved-import.stderr
@@ -0,0 +1,50 @@
+error[E0432]: unresolved import `foo`
+ --> $DIR/unresolved-import.rs:1:5
+ |
+LL | use foo::bar;
+ | ^^^ maybe a missing crate `foo`?
+ |
+ = help: consider adding `extern crate foo` to use the `foo` crate
+
+error[E0432]: unresolved import `bar::Baz`
+ --> $DIR/unresolved-import.rs:5:5
+ |
+LL | use bar::Baz as x;
+ | ^^^^^---^^^^^
+ | | |
+ | | help: a similar name exists in the module: `Bar`
+ | no `Baz` in `bar`
+
+error[E0432]: unresolved import `food::baz`
+ --> $DIR/unresolved-import.rs:10:5
+ |
+LL | use food::baz;
+ | ^^^^^^---
+ | | |
+ | | help: a similar name exists in the module: `bag`
+ | no `baz` in `food`
+
+error[E0432]: unresolved import `food::beens`
+ --> $DIR/unresolved-import.rs:15:12
+ |
+LL | use food::{beens as Foo};
+ | -----^^^^^^^
+ | |
+ | no `beens` in `food`
+ | help: a similar name exists in the module: `beans`
+
+error[E0432]: unresolved import `MyEnum`
+ --> $DIR/unresolved-import.rs:39:9
+ |
+LL | use MyEnum::*;
+ | ^^^^^^ help: a similar path exists: `self::MyEnum`
+
+error[E0432]: unresolved import `Enum`
+ --> $DIR/unresolved-import.rs:49:9
+ |
+LL | use Enum::*;
+ | ^^^^ help: a similar path exists: `self::Enum`
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0432`.