summaryrefslogtreecommitdiffstats
path: root/tests/ui/imports/issue-45829
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/imports/issue-45829')
-rw-r--r--tests/ui/imports/issue-45829/auxiliary/issue-45829-a.rs1
-rw-r--r--tests/ui/imports/issue-45829/auxiliary/issue-45829-b.rs1
-rw-r--r--tests/ui/imports/issue-45829/import-self.rs19
-rw-r--r--tests/ui/imports/issue-45829/import-self.stderr70
-rw-r--r--tests/ui/imports/issue-45829/import-twice.rs9
-rw-r--r--tests/ui/imports/issue-45829/import-twice.stderr13
-rw-r--r--tests/ui/imports/issue-45829/issue-45829.rs9
-rw-r--r--tests/ui/imports/issue-45829/issue-45829.stderr17
-rw-r--r--tests/ui/imports/issue-45829/rename-extern-vs-use.rs11
-rw-r--r--tests/ui/imports/issue-45829/rename-extern-vs-use.stderr17
-rw-r--r--tests/ui/imports/issue-45829/rename-extern-with-tab.rs8
-rw-r--r--tests/ui/imports/issue-45829/rename-extern-with-tab.stderr17
-rw-r--r--tests/ui/imports/issue-45829/rename-extern.rs8
-rw-r--r--tests/ui/imports/issue-45829/rename-extern.stderr17
-rw-r--r--tests/ui/imports/issue-45829/rename-use-vs-extern.rs7
-rw-r--r--tests/ui/imports/issue-45829/rename-use-vs-extern.stderr17
-rw-r--r--tests/ui/imports/issue-45829/rename-use-with-tabs.rs12
-rw-r--r--tests/ui/imports/issue-45829/rename-use-with-tabs.stderr17
-rw-r--r--tests/ui/imports/issue-45829/rename-with-path.rs4
-rw-r--r--tests/ui/imports/issue-45829/rename-with-path.stderr17
-rw-r--r--tests/ui/imports/issue-45829/rename.rs7
-rw-r--r--tests/ui/imports/issue-45829/rename.stderr17
22 files changed, 315 insertions, 0 deletions
diff --git a/tests/ui/imports/issue-45829/auxiliary/issue-45829-a.rs b/tests/ui/imports/issue-45829/auxiliary/issue-45829-a.rs
new file mode 100644
index 000000000..e9f7fefb6
--- /dev/null
+++ b/tests/ui/imports/issue-45829/auxiliary/issue-45829-a.rs
@@ -0,0 +1 @@
+pub const FOO: usize = *&0;
diff --git a/tests/ui/imports/issue-45829/auxiliary/issue-45829-b.rs b/tests/ui/imports/issue-45829/auxiliary/issue-45829-b.rs
new file mode 100644
index 000000000..e9f7fefb6
--- /dev/null
+++ b/tests/ui/imports/issue-45829/auxiliary/issue-45829-b.rs
@@ -0,0 +1 @@
+pub const FOO: usize = *&0;
diff --git a/tests/ui/imports/issue-45829/import-self.rs b/tests/ui/imports/issue-45829/import-self.rs
new file mode 100644
index 000000000..2dc4331ce
--- /dev/null
+++ b/tests/ui/imports/issue-45829/import-self.rs
@@ -0,0 +1,19 @@
+mod foo {
+ pub struct A;
+ pub struct B;
+}
+
+use foo::{self};
+//~^ ERROR is defined multiple times
+
+use foo as self;
+//~^ ERROR expected identifier
+
+use foo::self; //~ ERROR is defined multiple times
+//~^ ERROR `self` imports are only allowed within a { } list
+
+use foo::A;
+use foo::{self as A};
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/import-self.stderr b/tests/ui/imports/issue-45829/import-self.stderr
new file mode 100644
index 000000000..0c9424f30
--- /dev/null
+++ b/tests/ui/imports/issue-45829/import-self.stderr
@@ -0,0 +1,70 @@
+error: expected identifier, found keyword `self`
+ --> $DIR/import-self.rs:9:12
+ |
+LL | use foo as self;
+ | ^^^^ expected identifier, found keyword
+
+error[E0429]: `self` imports are only allowed within a { } list
+ --> $DIR/import-self.rs:12:8
+ |
+LL | use foo::self;
+ | ^^^^^^
+ |
+help: consider importing the module directly
+ |
+LL - use foo::self;
+LL + use foo;
+ |
+help: alternatively, use the multi-path `use` syntax to import `self`
+ |
+LL | use foo::{self};
+ | + +
+
+error[E0255]: the name `foo` is defined multiple times
+ --> $DIR/import-self.rs:6:11
+ |
+LL | mod foo {
+ | ------- previous definition of the module `foo` here
+...
+LL | use foo::{self};
+ | ^^^^ `foo` reimported here
+ |
+ = note: `foo` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use foo::{self as other_foo};
+ | ~~~~~~~~~~~~~~~~~
+
+error[E0255]: the name `foo` is defined multiple times
+ --> $DIR/import-self.rs:12:5
+ |
+LL | mod foo {
+ | ------- previous definition of the module `foo` here
+...
+LL | use foo::self;
+ | ^^^^^^^^^ `foo` reimported here
+ |
+ = note: `foo` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use foo as other_foo;
+ | ~~~~~~~~~~~~~~~~
+
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/import-self.rs:16:11
+ |
+LL | use foo::A;
+ | ------ previous import of the type `A` here
+LL | use foo::{self as A};
+ | ^^^^^^^^^ `A` reimported here
+ |
+ = note: `A` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use foo::{self as OtherA};
+ | ~~~~~~~~~~~~~~
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0252, E0255, E0429.
+For more information about an error, try `rustc --explain E0252`.
diff --git a/tests/ui/imports/issue-45829/import-twice.rs b/tests/ui/imports/issue-45829/import-twice.rs
new file mode 100644
index 000000000..e5a8bb7ad
--- /dev/null
+++ b/tests/ui/imports/issue-45829/import-twice.rs
@@ -0,0 +1,9 @@
+mod foo {
+ pub struct A;
+ pub struct B;
+}
+
+use foo::{A, A};
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/import-twice.stderr b/tests/ui/imports/issue-45829/import-twice.stderr
new file mode 100644
index 000000000..656b011bc
--- /dev/null
+++ b/tests/ui/imports/issue-45829/import-twice.stderr
@@ -0,0 +1,13 @@
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/import-twice.rs:6:14
+ |
+LL | use foo::{A, A};
+ | - ^ `A` reimported here
+ | |
+ | previous import of the type `A` here
+ |
+ = note: `A` 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 E0252`.
diff --git a/tests/ui/imports/issue-45829/issue-45829.rs b/tests/ui/imports/issue-45829/issue-45829.rs
new file mode 100644
index 000000000..1e76e4b14
--- /dev/null
+++ b/tests/ui/imports/issue-45829/issue-45829.rs
@@ -0,0 +1,9 @@
+mod foo {
+ pub struct A;
+ pub struct B;
+}
+
+use foo::{A, B as A};
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/issue-45829.stderr b/tests/ui/imports/issue-45829/issue-45829.stderr
new file mode 100644
index 000000000..e9a9d47ce
--- /dev/null
+++ b/tests/ui/imports/issue-45829/issue-45829.stderr
@@ -0,0 +1,17 @@
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/issue-45829.rs:6:14
+ |
+LL | use foo::{A, B as A};
+ | - ^^^^^^ `A` reimported here
+ | |
+ | previous import of the type `A` here
+ |
+ = note: `A` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use foo::{A, B as OtherA};
+ | ~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/tests/ui/imports/issue-45829/rename-extern-vs-use.rs b/tests/ui/imports/issue-45829/rename-extern-vs-use.rs
new file mode 100644
index 000000000..aef7aa35c
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-extern-vs-use.rs
@@ -0,0 +1,11 @@
+// aux-build:issue-45829-b.rs
+
+mod foo {
+ pub mod bar {}
+}
+
+use foo::bar;
+extern crate issue_45829_b as bar;
+//~^ ERROR the name `bar` is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/rename-extern-vs-use.stderr b/tests/ui/imports/issue-45829/rename-extern-vs-use.stderr
new file mode 100644
index 000000000..98fd8a623
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-extern-vs-use.stderr
@@ -0,0 +1,17 @@
+error[E0254]: the name `bar` is defined multiple times
+ --> $DIR/rename-extern-vs-use.rs:8:1
+ |
+LL | use foo::bar;
+ | -------- previous import of the module `bar` here
+LL | extern crate issue_45829_b as bar;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` reimported here
+ |
+ = note: `bar` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | extern crate issue_45829_b as other_bar;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0254`.
diff --git a/tests/ui/imports/issue-45829/rename-extern-with-tab.rs b/tests/ui/imports/issue-45829/rename-extern-with-tab.rs
new file mode 100644
index 000000000..0da8b826c
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-extern-with-tab.rs
@@ -0,0 +1,8 @@
+// aux-build:issue-45829-a.rs
+// aux-build:issue-45829-b.rs
+
+extern crate issue_45829_a;
+extern crate issue_45829_b as issue_45829_a;
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/rename-extern-with-tab.stderr b/tests/ui/imports/issue-45829/rename-extern-with-tab.stderr
new file mode 100644
index 000000000..2c4e8ce99
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-extern-with-tab.stderr
@@ -0,0 +1,17 @@
+error[E0259]: the name `issue_45829_a` is defined multiple times
+ --> $DIR/rename-extern-with-tab.rs:5:1
+ |
+LL | extern crate issue_45829_a;
+ | --------------------------- previous import of the extern crate `issue_45829_a` here
+LL | extern crate issue_45829_b as issue_45829_a;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `issue_45829_a` reimported here
+ |
+ = note: `issue_45829_a` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | extern crate issue_45829_b as other_issue_45829_a;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0259`.
diff --git a/tests/ui/imports/issue-45829/rename-extern.rs b/tests/ui/imports/issue-45829/rename-extern.rs
new file mode 100644
index 000000000..7dbda6932
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-extern.rs
@@ -0,0 +1,8 @@
+// aux-build:issue-45829-a.rs
+// aux-build:issue-45829-b.rs
+
+extern crate issue_45829_a;
+extern crate issue_45829_b as issue_45829_a;
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/rename-extern.stderr b/tests/ui/imports/issue-45829/rename-extern.stderr
new file mode 100644
index 000000000..209ae2201
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-extern.stderr
@@ -0,0 +1,17 @@
+error[E0259]: the name `issue_45829_a` is defined multiple times
+ --> $DIR/rename-extern.rs:5:1
+ |
+LL | extern crate issue_45829_a;
+ | --------------------------- previous import of the extern crate `issue_45829_a` here
+LL | extern crate issue_45829_b as issue_45829_a;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `issue_45829_a` reimported here
+ |
+ = note: `issue_45829_a` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | extern crate issue_45829_b as other_issue_45829_a;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0259`.
diff --git a/tests/ui/imports/issue-45829/rename-use-vs-extern.rs b/tests/ui/imports/issue-45829/rename-use-vs-extern.rs
new file mode 100644
index 000000000..0cf3a77fd
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-use-vs-extern.rs
@@ -0,0 +1,7 @@
+// aux-build:issue-45829-b.rs
+
+extern crate issue_45829_b;
+use std as issue_45829_b;
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr b/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr
new file mode 100644
index 000000000..dfb5810c4
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr
@@ -0,0 +1,17 @@
+error[E0254]: the name `issue_45829_b` is defined multiple times
+ --> $DIR/rename-use-vs-extern.rs:4:5
+ |
+LL | extern crate issue_45829_b;
+ | --------------------------- previous import of the extern crate `issue_45829_b` here
+LL | use std as issue_45829_b;
+ | ^^^^^^^^^^^^^^^^^^^^ `issue_45829_b` reimported here
+ |
+ = note: `issue_45829_b` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use std as other_issue_45829_b;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0254`.
diff --git a/tests/ui/imports/issue-45829/rename-use-with-tabs.rs b/tests/ui/imports/issue-45829/rename-use-with-tabs.rs
new file mode 100644
index 000000000..86c5fa00f
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-use-with-tabs.rs
@@ -0,0 +1,12 @@
+mod foo {
+ pub struct A;
+
+ pub mod bar {
+ pub struct B;
+ }
+}
+
+use foo::{A, bar::B as A};
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/rename-use-with-tabs.stderr b/tests/ui/imports/issue-45829/rename-use-with-tabs.stderr
new file mode 100644
index 000000000..5a63af588
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-use-with-tabs.stderr
@@ -0,0 +1,17 @@
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/rename-use-with-tabs.rs:9:14
+ |
+LL | use foo::{A, bar::B as A};
+ | - ^^^^^^^^^^^^^^^^^ `A` reimported here
+ | |
+ | previous import of the type `A` here
+ |
+ = note: `A` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use foo::{A, bar::B as OtherA};
+ | ~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/tests/ui/imports/issue-45829/rename-with-path.rs b/tests/ui/imports/issue-45829/rename-with-path.rs
new file mode 100644
index 000000000..e278a8789
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-with-path.rs
@@ -0,0 +1,4 @@
+use std::{collections::HashMap as A, sync::Arc as A};
+//~^ ERROR is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/imports/issue-45829/rename-with-path.stderr b/tests/ui/imports/issue-45829/rename-with-path.stderr
new file mode 100644
index 000000000..2d26b0838
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename-with-path.stderr
@@ -0,0 +1,17 @@
+error[E0252]: the name `A` is defined multiple times
+ --> $DIR/rename-with-path.rs:1:38
+ |
+LL | use std::{collections::HashMap as A, sync::Arc as A};
+ | ------------------------- ^^^^^^^^^^^^^^ `A` reimported here
+ | |
+ | previous import of the type `A` here
+ |
+ = note: `A` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use std::{collections::HashMap as A, sync::Arc as OtherA};
+ | ~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/tests/ui/imports/issue-45829/rename.rs b/tests/ui/imports/issue-45829/rename.rs
new file mode 100644
index 000000000..1c45956c6
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename.rs
@@ -0,0 +1,7 @@
+use core;
+use std as core;
+//~^ ERROR is defined multiple times
+
+fn main() {
+ 1 + 1;
+}
diff --git a/tests/ui/imports/issue-45829/rename.stderr b/tests/ui/imports/issue-45829/rename.stderr
new file mode 100644
index 000000000..ed185ae2a
--- /dev/null
+++ b/tests/ui/imports/issue-45829/rename.stderr
@@ -0,0 +1,17 @@
+error[E0252]: the name `core` is defined multiple times
+ --> $DIR/rename.rs:2:5
+ |
+LL | use core;
+ | ---- previous import of the module `core` here
+LL | use std as core;
+ | ^^^^^^^^^^^ `core` reimported here
+ |
+ = note: `core` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use std as other_core;
+ | ~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.