summaryrefslogtreecommitdiffstats
path: root/tests/ui/unresolved
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/unresolved
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/unresolved')
-rw-r--r--tests/ui/unresolved/unresolved-asterisk-imports.rs4
-rw-r--r--tests/ui/unresolved/unresolved-asterisk-imports.stderr11
-rw-r--r--tests/ui/unresolved/unresolved-candidates.rs13
-rw-r--r--tests/ui/unresolved/unresolved-candidates.stderr26
-rw-r--r--tests/ui/unresolved/unresolved-extern-mod-suggestion.rs5
-rw-r--r--tests/ui/unresolved/unresolved-extern-mod-suggestion.stderr13
-rw-r--r--tests/ui/unresolved/unresolved-import-recovery.rs17
-rw-r--r--tests/ui/unresolved/unresolved-import-recovery.stderr9
-rw-r--r--tests/ui/unresolved/unresolved-import.rs56
-rw-r--r--tests/ui/unresolved/unresolved-import.stderr50
10 files changed, 204 insertions, 0 deletions
diff --git a/tests/ui/unresolved/unresolved-asterisk-imports.rs b/tests/ui/unresolved/unresolved-asterisk-imports.rs
new file mode 100644
index 000000000..2d853a66c
--- /dev/null
+++ b/tests/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/tests/ui/unresolved/unresolved-asterisk-imports.stderr b/tests/ui/unresolved/unresolved-asterisk-imports.stderr
new file mode 100644
index 000000000..8df8eab34
--- /dev/null
+++ b/tests/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/tests/ui/unresolved/unresolved-candidates.rs b/tests/ui/unresolved/unresolved-candidates.rs
new file mode 100644
index 000000000..38b227f60
--- /dev/null
+++ b/tests/ui/unresolved/unresolved-candidates.rs
@@ -0,0 +1,13 @@
+mod a {
+ pub trait Trait {}
+}
+
+mod b {
+ use Trait; //~ ERROR unresolved import `Trait`
+}
+
+mod c {
+ impl Trait for () {} //~ ERROR cannot find trait `Trait` in this scope
+}
+
+fn main() {}
diff --git a/tests/ui/unresolved/unresolved-candidates.stderr b/tests/ui/unresolved/unresolved-candidates.stderr
new file mode 100644
index 000000000..ea737c567
--- /dev/null
+++ b/tests/ui/unresolved/unresolved-candidates.stderr
@@ -0,0 +1,26 @@
+error[E0432]: unresolved import `Trait`
+ --> $DIR/unresolved-candidates.rs:6:9
+ |
+LL | use Trait;
+ | ^^^^^ no `Trait` in the root
+ |
+help: consider importing this trait instead
+ |
+LL | use a::Trait;
+ | ~~~~~~~~
+
+error[E0405]: cannot find trait `Trait` in this scope
+ --> $DIR/unresolved-candidates.rs:10:10
+ |
+LL | impl Trait for () {}
+ | ^^^^^ not found in this scope
+ |
+help: consider importing this trait
+ |
+LL | use a::Trait;
+ |
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0405, E0432.
+For more information about an error, try `rustc --explain E0405`.
diff --git a/tests/ui/unresolved/unresolved-extern-mod-suggestion.rs b/tests/ui/unresolved/unresolved-extern-mod-suggestion.rs
new file mode 100644
index 000000000..a1bf0f210
--- /dev/null
+++ b/tests/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/tests/ui/unresolved/unresolved-extern-mod-suggestion.stderr b/tests/ui/unresolved/unresolved-extern-mod-suggestion.stderr
new file mode 100644
index 000000000..28333228a
--- /dev/null
+++ b/tests/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/tests/ui/unresolved/unresolved-import-recovery.rs b/tests/ui/unresolved/unresolved-import-recovery.rs
new file mode 100644
index 000000000..0b0653378
--- /dev/null
+++ b/tests/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/tests/ui/unresolved/unresolved-import-recovery.stderr b/tests/ui/unresolved/unresolved-import-recovery.stderr
new file mode 100644
index 000000000..5e371b70b
--- /dev/null
+++ b/tests/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/tests/ui/unresolved/unresolved-import.rs b/tests/ui/unresolved/unresolved-import.rs
new file mode 100644
index 000000000..4125c593c
--- /dev/null
+++ b/tests/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/tests/ui/unresolved/unresolved-import.stderr b/tests/ui/unresolved/unresolved-import.stderr
new file mode 100644
index 000000000..0dd928c8b
--- /dev/null
+++ b/tests/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`.