summaryrefslogtreecommitdiffstats
path: root/src/test/ui/imports
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/imports
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/imports')
-rw-r--r--src/test/ui/imports/absolute-paths-in-nested-use-groups.rs11
-rw-r--r--src/test/ui/imports/absolute-paths-in-nested-use-groups.stderr21
-rw-r--r--src/test/ui/imports/auxiliary/gensymed.rs3
-rw-r--r--src/test/ui/imports/auxiliary/glob-conflict.rs13
-rw-r--r--src/test/ui/imports/auxiliary/import_crate_var.rs7
-rw-r--r--src/test/ui/imports/auxiliary/issue-36881-aux.rs1
-rw-r--r--src/test/ui/imports/auxiliary/issue-52891.rs33
-rw-r--r--src/test/ui/imports/auxiliary/issue-55811.rs5
-rw-r--r--src/test/ui/imports/auxiliary/issue-56125.rs11
-rw-r--r--src/test/ui/imports/auxiliary/issue-59764.rs18
-rw-r--r--src/test/ui/imports/auxiliary/overlapping_pub_trait_source.rs13
-rw-r--r--src/test/ui/imports/auxiliary/two_macros.rs5
-rw-r--r--src/test/ui/imports/auxiliary/unnamed_pub_trait_source.rs13
-rw-r--r--src/test/ui/imports/double-import.rs15
-rw-r--r--src/test/ui/imports/double-import.stderr17
-rw-r--r--src/test/ui/imports/duplicate.rs51
-rw-r--r--src/test/ui/imports/duplicate.stderr74
-rw-r--r--src/test/ui/imports/export-glob-imports-target.rs22
-rw-r--r--src/test/ui/imports/export-multi.rs12
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs6
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr19
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs16
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs12
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs16
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs13
-rw-r--r--src/test/ui/imports/extern-crate-used.rs32
-rw-r--r--src/test/ui/imports/extern-crate-used.stderr14
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs16
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-cfg.rs16
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-fail.rs22
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-fail.stderr20
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-pass.rs12
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs26
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr36
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs12
-rw-r--r--src/test/ui/imports/gensymed.rs9
-rw-r--r--src/test/ui/imports/glob-conflict-cross-crate.rs8
-rw-r--r--src/test/ui/imports/glob-conflict-cross-crate.stderr15
-rw-r--r--src/test/ui/imports/glob-cycles.rs18
-rw-r--r--src/test/ui/imports/glob-resolve1.rs39
-rw-r--r--src/test/ui/imports/glob-resolve1.stderr114
-rw-r--r--src/test/ui/imports/glob-shadowing.rs34
-rw-r--r--src/test/ui/imports/glob-shadowing.stderr54
-rw-r--r--src/test/ui/imports/glob-use-std.rs11
-rw-r--r--src/test/ui/imports/import-crate-var.rs8
-rw-r--r--src/test/ui/imports/import-crate-var.stderr10
-rw-r--r--src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs20
-rw-r--r--src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs7
-rw-r--r--src/test/ui/imports/import-crate-with-invalid-spans/main.rs13
-rw-r--r--src/test/ui/imports/import-from-missing.rs12
-rw-r--r--src/test/ui/imports/import-from-missing.stderr9
-rw-r--r--src/test/ui/imports/import-from.rs11
-rw-r--r--src/test/ui/imports/import-glob-0-rpass.rs29
-rw-r--r--src/test/ui/imports/import-glob-0.rs16
-rw-r--r--src/test/ui/imports/import-glob-0.stderr9
-rw-r--r--src/test/ui/imports/import-glob-1.rs27
-rw-r--r--src/test/ui/imports/import-glob-circular.rs19
-rw-r--r--src/test/ui/imports/import-glob-circular.stderr9
-rw-r--r--src/test/ui/imports/import-glob-crate.rs19
-rw-r--r--src/test/ui/imports/import-in-block.rs13
-rw-r--r--src/test/ui/imports/import-loop-2.rs13
-rw-r--r--src/test/ui/imports/import-loop-2.stderr9
-rw-r--r--src/test/ui/imports/import-loop.rs9
-rw-r--r--src/test/ui/imports/import-loop.stderr9
-rw-r--r--src/test/ui/imports/import-prefix-macro-1.rs16
-rw-r--r--src/test/ui/imports/import-prefix-macro-1.stderr13
-rw-r--r--src/test/ui/imports/import-prefix-macro-2.rs16
-rw-r--r--src/test/ui/imports/import-prefix-macro-2.stderr13
-rw-r--r--src/test/ui/imports/import-prefix-macro.rs27
-rw-r--r--src/test/ui/imports/import-rename.rs13
-rw-r--r--src/test/ui/imports/import-rpass.rs12
-rw-r--r--src/test/ui/imports/import-trailing-comma.rs13
-rw-r--r--src/test/ui/imports/import-trait-method.rs7
-rw-r--r--src/test/ui/imports/import-trait-method.stderr9
-rw-r--r--src/test/ui/imports/import.rs17
-rw-r--r--src/test/ui/imports/import.stderr31
-rw-r--r--src/test/ui/imports/import2-rpass.rs9
-rw-r--r--src/test/ui/imports/import2.rs10
-rw-r--r--src/test/ui/imports/import2.stderr9
-rw-r--r--src/test/ui/imports/import3-rpass.rs13
-rw-r--r--src/test/ui/imports/import3.rs4
-rw-r--r--src/test/ui/imports/import3.stderr11
-rw-r--r--src/test/ui/imports/import4-rpass.rs9
-rw-r--r--src/test/ui/imports/import4.rs7
-rw-r--r--src/test/ui/imports/import4.stderr9
-rw-r--r--src/test/ui/imports/import5.rs10
-rw-r--r--src/test/ui/imports/import6.rs15
-rw-r--r--src/test/ui/imports/import7.rs18
-rw-r--r--src/test/ui/imports/import8.rs10
-rw-r--r--src/test/ui/imports/imports.rs66
-rw-r--r--src/test/ui/imports/inaccessible_type_aliases.rs14
-rw-r--r--src/test/ui/imports/inaccessible_type_aliases.stderr30
-rw-r--r--src/test/ui/imports/issue-13404.rs10
-rw-r--r--src/test/ui/imports/issue-13404.stderr9
-rw-r--r--src/test/ui/imports/issue-1697.rs6
-rw-r--r--src/test/ui/imports/issue-1697.stderr11
-rw-r--r--src/test/ui/imports/issue-18083.rs25
-rw-r--r--src/test/ui/imports/issue-19498.rs13
-rw-r--r--src/test/ui/imports/issue-19498.stderr47
-rw-r--r--src/test/ui/imports/issue-24081.rs18
-rw-r--r--src/test/ui/imports/issue-24081.stderr78
-rw-r--r--src/test/ui/imports/issue-24883.rs17
-rw-r--r--src/test/ui/imports/issue-25396.rs29
-rw-r--r--src/test/ui/imports/issue-25396.stderr59
-rw-r--r--src/test/ui/imports/issue-26873-multifile/A/B.rs4
-rw-r--r--src/test/ui/imports/issue-26873-multifile/A/C.rs6
-rw-r--r--src/test/ui/imports/issue-26873-multifile/A/mod.rs5
-rw-r--r--src/test/ui/imports/issue-26873-multifile/compiletest-ignore-dir0
-rw-r--r--src/test/ui/imports/issue-26873-multifile/issue-26873-multifile.rs11
-rw-r--r--src/test/ui/imports/issue-26873-multifile/issue-26873-onefile.rs25
-rw-r--r--src/test/ui/imports/issue-26873-multifile/mod.rs4
-rw-r--r--src/test/ui/imports/issue-26886.rs8
-rw-r--r--src/test/ui/imports/issue-26886.stderr24
-rw-r--r--src/test/ui/imports/issue-28134.rs5
-rw-r--r--src/test/ui/imports/issue-28134.stderr21
-rw-r--r--src/test/ui/imports/issue-28388-1.rs5
-rw-r--r--src/test/ui/imports/issue-28388-1.stderr9
-rw-r--r--src/test/ui/imports/issue-28388-2.rs10
-rw-r--r--src/test/ui/imports/issue-28388-2.stderr15
-rw-r--r--src/test/ui/imports/issue-2937.rs6
-rw-r--r--src/test/ui/imports/issue-2937.stderr9
-rw-r--r--src/test/ui/imports/issue-30560.rs9
-rw-r--r--src/test/ui/imports/issue-30560.stderr21
-rw-r--r--src/test/ui/imports/issue-31212.rs10
-rw-r--r--src/test/ui/imports/issue-31212.stderr16
-rw-r--r--src/test/ui/imports/issue-32119.rs17
-rw-r--r--src/test/ui/imports/issue-32222.rs22
-rw-r--r--src/test/ui/imports/issue-32354-suggest-import-rename.fixed16
-rw-r--r--src/test/ui/imports/issue-32354-suggest-import-rename.rs16
-rw-r--r--src/test/ui/imports/issue-32354-suggest-import-rename.stderr17
-rw-r--r--src/test/ui/imports/issue-32833.rs7
-rw-r--r--src/test/ui/imports/issue-32833.stderr9
-rw-r--r--src/test/ui/imports/issue-33464.rs10
-rw-r--r--src/test/ui/imports/issue-33464.stderr27
-rw-r--r--src/test/ui/imports/issue-36881.rs6
-rw-r--r--src/test/ui/imports/issue-36881.stderr11
-rw-r--r--src/test/ui/imports/issue-37887.rs4
-rw-r--r--src/test/ui/imports/issue-37887.stderr21
-rw-r--r--src/test/ui/imports/issue-38293.rs16
-rw-r--r--src/test/ui/imports/issue-38293.stderr21
-rw-r--r--src/test/ui/imports/issue-4366-2.rs26
-rw-r--r--src/test/ui/imports/issue-4366-2.stderr27
-rw-r--r--src/test/ui/imports/issue-4366.rs26
-rw-r--r--src/test/ui/imports/issue-4366.stderr14
-rw-r--r--src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed5
-rw-r--r--src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs5
-rw-r--r--src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr15
-rw-r--r--src/test/ui/imports/issue-45829/auxiliary/issue-45829-a.rs1
-rw-r--r--src/test/ui/imports/issue-45829/auxiliary/issue-45829-b.rs1
-rw-r--r--src/test/ui/imports/issue-45829/import-self.rs19
-rw-r--r--src/test/ui/imports/issue-45829/import-self.stderr70
-rw-r--r--src/test/ui/imports/issue-45829/import-twice.rs9
-rw-r--r--src/test/ui/imports/issue-45829/import-twice.stderr13
-rw-r--r--src/test/ui/imports/issue-45829/issue-45829.rs9
-rw-r--r--src/test/ui/imports/issue-45829/issue-45829.stderr17
-rw-r--r--src/test/ui/imports/issue-45829/rename-extern-vs-use.rs11
-rw-r--r--src/test/ui/imports/issue-45829/rename-extern-vs-use.stderr17
-rw-r--r--src/test/ui/imports/issue-45829/rename-extern-with-tab.rs8
-rw-r--r--src/test/ui/imports/issue-45829/rename-extern-with-tab.stderr17
-rw-r--r--src/test/ui/imports/issue-45829/rename-extern.rs8
-rw-r--r--src/test/ui/imports/issue-45829/rename-extern.stderr17
-rw-r--r--src/test/ui/imports/issue-45829/rename-use-vs-extern.rs7
-rw-r--r--src/test/ui/imports/issue-45829/rename-use-vs-extern.stderr17
-rw-r--r--src/test/ui/imports/issue-45829/rename-use-with-tabs.rs12
-rw-r--r--src/test/ui/imports/issue-45829/rename-use-with-tabs.stderr17
-rw-r--r--src/test/ui/imports/issue-45829/rename-with-path.rs4
-rw-r--r--src/test/ui/imports/issue-45829/rename-with-path.stderr17
-rw-r--r--src/test/ui/imports/issue-45829/rename.rs7
-rw-r--r--src/test/ui/imports/issue-45829/rename.stderr17
-rw-r--r--src/test/ui/imports/issue-47623.rs3
-rw-r--r--src/test/ui/imports/issue-47623.stderr9
-rw-r--r--src/test/ui/imports/issue-4865-1.rs33
-rw-r--r--src/test/ui/imports/issue-4865-2.rs24
-rw-r--r--src/test/ui/imports/issue-4865-3.rs17
-rw-r--r--src/test/ui/imports/issue-52891.fixed37
-rw-r--r--src/test/ui/imports/issue-52891.rs38
-rw-r--r--src/test/ui/imports/issue-52891.stderr131
-rw-r--r--src/test/ui/imports/issue-53140.rs11
-rw-r--r--src/test/ui/imports/issue-53269.rs11
-rw-r--r--src/test/ui/imports/issue-53269.stderr31
-rw-r--r--src/test/ui/imports/issue-53512.rs8
-rw-r--r--src/test/ui/imports/issue-53512.stderr9
-rw-r--r--src/test/ui/imports/issue-53565.rs7
-rw-r--r--src/test/ui/imports/issue-53565.stderr20
-rw-r--r--src/test/ui/imports/issue-55457.rs10
-rw-r--r--src/test/ui/imports/issue-55457.stderr52
-rw-r--r--src/test/ui/imports/issue-55811.rs6
-rw-r--r--src/test/ui/imports/issue-55884-1.rs21
-rw-r--r--src/test/ui/imports/issue-55884-1.stderr23
-rw-r--r--src/test/ui/imports/issue-55884-2.rs14
-rw-r--r--src/test/ui/imports/issue-55884-2.stderr30
-rw-r--r--src/test/ui/imports/issue-56125.rs21
-rw-r--r--src/test/ui/imports/issue-56125.stderr58
-rw-r--r--src/test/ui/imports/issue-56263.rs8
-rw-r--r--src/test/ui/imports/issue-57015.rs13
-rw-r--r--src/test/ui/imports/issue-57015.stderr9
-rw-r--r--src/test/ui/imports/issue-57539.rs8
-rw-r--r--src/test/ui/imports/issue-57539.stderr19
-rw-r--r--src/test/ui/imports/issue-59764.rs136
-rw-r--r--src/test/ui/imports/issue-59764.stderr246
-rw-r--r--src/test/ui/imports/issue-62767.rs30
-rw-r--r--src/test/ui/imports/issue-68103.rs6
-rw-r--r--src/test/ui/imports/issue-8208.rs17
-rw-r--r--src/test/ui/imports/issue-8208.stderr21
-rw-r--r--src/test/ui/imports/issue-8640.rs10
-rw-r--r--src/test/ui/imports/issue-8640.stderr17
-rw-r--r--src/test/ui/imports/local-modularized-tricky-fail-1.rs47
-rw-r--r--src/test/ui/imports/local-modularized-tricky-fail-1.stderr95
-rw-r--r--src/test/ui/imports/local-modularized-tricky-fail-2.rs22
-rw-r--r--src/test/ui/imports/local-modularized-tricky-fail-2.stderr43
-rw-r--r--src/test/ui/imports/local-modularized-tricky-pass-1.rs19
-rw-r--r--src/test/ui/imports/local-modularized-tricky-pass-2.rs50
-rw-r--r--src/test/ui/imports/local-modularized.rs35
-rw-r--r--src/test/ui/imports/macro-paths.rs28
-rw-r--r--src/test/ui/imports/macro-paths.stderr43
-rw-r--r--src/test/ui/imports/macros.rs42
-rw-r--r--src/test/ui/imports/macros.stderr60
-rw-r--r--src/test/ui/imports/no-std-inject.rs6
-rw-r--r--src/test/ui/imports/no-std-inject.stderr15
-rw-r--r--src/test/ui/imports/overlapping_pub_trait.rs15
-rw-r--r--src/test/ui/imports/overlapping_pub_trait.stderr20
-rw-r--r--src/test/ui/imports/reexport-star.rs16
-rw-r--r--src/test/ui/imports/reexports.rs37
-rw-r--r--src/test/ui/imports/reexports.stderr62
-rw-r--r--src/test/ui/imports/resolve_self_super_hint.rs27
-rw-r--r--src/test/ui/imports/resolve_self_super_hint.stderr33
-rw-r--r--src/test/ui/imports/rfc-1560-warning-cycle.rs13
-rw-r--r--src/test/ui/imports/rfc-1560-warning-cycle.stderr23
-rw-r--r--src/test/ui/imports/shadow_builtin_macros.rs52
-rw-r--r--src/test/ui/imports/shadow_builtin_macros.stderr72
-rw-r--r--src/test/ui/imports/tool-mod-child.rs7
-rw-r--r--src/test/ui/imports/tool-mod-child.stderr36
-rw-r--r--src/test/ui/imports/unnamed_pub_trait.rs16
-rw-r--r--src/test/ui/imports/unnamed_pub_trait.stderr20
-rw-r--r--src/test/ui/imports/unresolved-imports-used.rs18
-rw-r--r--src/test/ui/imports/unresolved-imports-used.stderr72
-rw-r--r--src/test/ui/imports/unused-import-issue-87973.fixed8
-rw-r--r--src/test/ui/imports/unused-import-issue-87973.rs11
-rw-r--r--src/test/ui/imports/unused-import-issue-87973.stderr14
-rw-r--r--src/test/ui/imports/unused-imports-in-test-mode.rs102
-rw-r--r--src/test/ui/imports/unused-imports-in-test-mode.stderr68
-rw-r--r--src/test/ui/imports/unused-imports-in-test-module.rs89
-rw-r--r--src/test/ui/imports/unused-imports-in-test-module.stderr92
-rw-r--r--src/test/ui/imports/unused-macro-use.rs11
-rw-r--r--src/test/ui/imports/unused-macro-use.stderr21
-rw-r--r--src/test/ui/imports/unused.rs27
-rw-r--r--src/test/ui/imports/unused.stderr15
-rw-r--r--src/test/ui/imports/use-mod.rs33
248 files changed, 5534 insertions, 0 deletions
diff --git a/src/test/ui/imports/absolute-paths-in-nested-use-groups.rs b/src/test/ui/imports/absolute-paths-in-nested-use-groups.rs
new file mode 100644
index 000000000..96b513167
--- /dev/null
+++ b/src/test/ui/imports/absolute-paths-in-nested-use-groups.rs
@@ -0,0 +1,11 @@
+#![allow(unused_imports)]
+
+mod foo {}
+
+use foo::{
+ ::bar, //~ ERROR crate root in paths can only be used in start position
+ super::bar, //~ ERROR `super` in paths can only be used in start position
+ self::bar, //~ ERROR `self` in paths can only be used in start position
+};
+
+fn main() {}
diff --git a/src/test/ui/imports/absolute-paths-in-nested-use-groups.stderr b/src/test/ui/imports/absolute-paths-in-nested-use-groups.stderr
new file mode 100644
index 000000000..e41590ac4
--- /dev/null
+++ b/src/test/ui/imports/absolute-paths-in-nested-use-groups.stderr
@@ -0,0 +1,21 @@
+error[E0433]: failed to resolve: crate root in paths can only be used in start position
+ --> $DIR/absolute-paths-in-nested-use-groups.rs:6:5
+ |
+LL | ::bar,
+ | ^ crate root in paths can only be used in start position
+
+error[E0433]: failed to resolve: `super` in paths can only be used in start position
+ --> $DIR/absolute-paths-in-nested-use-groups.rs:7:5
+ |
+LL | super::bar,
+ | ^^^^^ `super` in paths can only be used in start position
+
+error[E0433]: failed to resolve: `self` in paths can only be used in start position
+ --> $DIR/absolute-paths-in-nested-use-groups.rs:8:5
+ |
+LL | self::bar,
+ | ^^^^ `self` in paths can only be used in start position
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/src/test/ui/imports/auxiliary/gensymed.rs b/src/test/ui/imports/auxiliary/gensymed.rs
new file mode 100644
index 000000000..bbb19f5ec
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/gensymed.rs
@@ -0,0 +1,3 @@
+// edition:2018
+
+mod std {}
diff --git a/src/test/ui/imports/auxiliary/glob-conflict.rs b/src/test/ui/imports/auxiliary/glob-conflict.rs
new file mode 100644
index 000000000..c83db64c6
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/glob-conflict.rs
@@ -0,0 +1,13 @@
+mod m1 {
+ pub fn f() {}
+}
+mod m2 {
+ pub fn f(_: u8) {}
+}
+
+pub use m1::*;
+pub use m2::*;
+
+pub mod glob {
+ pub use *;
+}
diff --git a/src/test/ui/imports/auxiliary/import_crate_var.rs b/src/test/ui/imports/auxiliary/import_crate_var.rs
new file mode 100644
index 000000000..a273b103a
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/import_crate_var.rs
@@ -0,0 +1,7 @@
+pub fn f() {}
+
+#[macro_export]
+macro_rules! m { () => {
+ use $crate;
+ import_crate_var::f();
+} }
diff --git a/src/test/ui/imports/auxiliary/issue-36881-aux.rs b/src/test/ui/imports/auxiliary/issue-36881-aux.rs
new file mode 100644
index 000000000..e373b6438
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/issue-36881-aux.rs
@@ -0,0 +1 @@
+pub trait Foo {}
diff --git a/src/test/ui/imports/auxiliary/issue-52891.rs b/src/test/ui/imports/auxiliary/issue-52891.rs
new file mode 100644
index 000000000..075981183
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/issue-52891.rs
@@ -0,0 +1,33 @@
+pub mod a {
+ pub mod inner {
+ }
+}
+
+pub mod b {
+ pub mod inner {
+ }
+}
+
+pub mod c {}
+
+pub mod d {}
+
+pub mod e {}
+
+pub mod f {}
+
+pub mod g {}
+
+pub mod h {}
+
+pub mod i {}
+
+pub mod j {}
+
+pub mod k {}
+
+pub mod l {}
+
+pub mod m {}
+
+pub mod n {}
diff --git a/src/test/ui/imports/auxiliary/issue-55811.rs b/src/test/ui/imports/auxiliary/issue-55811.rs
new file mode 100644
index 000000000..877e4cdb0
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/issue-55811.rs
@@ -0,0 +1,5 @@
+mod m {}
+
+// These two imports should not conflict when this crate is loaded from some other crate.
+use m::{};
+use m::{};
diff --git a/src/test/ui/imports/auxiliary/issue-56125.rs b/src/test/ui/imports/auxiliary/issue-56125.rs
new file mode 100644
index 000000000..8e0797582
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/issue-56125.rs
@@ -0,0 +1,11 @@
+pub mod issue_56125 {}
+
+pub mod last_segment {
+ pub mod issue_56125 {}
+}
+
+pub mod non_last_segment {
+ pub mod non_last_segment {
+ pub mod issue_56125 {}
+ }
+}
diff --git a/src/test/ui/imports/auxiliary/issue-59764.rs b/src/test/ui/imports/auxiliary/issue-59764.rs
new file mode 100644
index 000000000..a92eed968
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/issue-59764.rs
@@ -0,0 +1,18 @@
+pub mod foo {
+ #[macro_export]
+ macro_rules! makro {
+ ($foo:ident) => {
+ fn $foo() { }
+ }
+ }
+
+ pub fn baz() {}
+
+ pub fn foobar() {}
+
+ pub mod barbaz {
+ pub fn barfoo() {}
+ }
+}
+
+pub fn foobaz() {}
diff --git a/src/test/ui/imports/auxiliary/overlapping_pub_trait_source.rs b/src/test/ui/imports/auxiliary/overlapping_pub_trait_source.rs
new file mode 100644
index 000000000..2a25d60ac
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/overlapping_pub_trait_source.rs
@@ -0,0 +1,13 @@
+/* This crate declares an item as both `prelude::*` and `m::Tr`.
+ * The compiler should always suggest `m::Tr`. */
+
+pub struct S;
+
+pub mod prelude {
+ pub use crate::m::Tr as _;
+}
+
+pub mod m {
+ pub trait Tr { fn method(&self); }
+ impl Tr for crate::S { fn method(&self) {} }
+}
diff --git a/src/test/ui/imports/auxiliary/two_macros.rs b/src/test/ui/imports/auxiliary/two_macros.rs
new file mode 100644
index 000000000..92c211467
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/two_macros.rs
@@ -0,0 +1,5 @@
+#[macro_export]
+macro_rules! m { ($($t:tt)*) => { $($t)* } }
+
+#[macro_export]
+macro_rules! n { ($($t:tt)*) => { $($t)* } }
diff --git a/src/test/ui/imports/auxiliary/unnamed_pub_trait_source.rs b/src/test/ui/imports/auxiliary/unnamed_pub_trait_source.rs
new file mode 100644
index 000000000..d73c9a795
--- /dev/null
+++ b/src/test/ui/imports/auxiliary/unnamed_pub_trait_source.rs
@@ -0,0 +1,13 @@
+/* This crate declares an item that is unnamed.
+ * Its only public path is through `prelude::*`. */
+
+pub struct S;
+
+mod m {
+ pub trait Tr { fn method(&self); }
+ impl Tr for crate::S { fn method(&self) {} }
+}
+
+pub mod prelude {
+ pub use crate::m::Tr as _;
+}
diff --git a/src/test/ui/imports/double-import.rs b/src/test/ui/imports/double-import.rs
new file mode 100644
index 000000000..e7325368b
--- /dev/null
+++ b/src/test/ui/imports/double-import.rs
@@ -0,0 +1,15 @@
+// This tests that conflicting imports shows both `use` lines
+// when reporting the error.
+
+mod sub1 {
+ pub fn foo() {} // implementation 1
+}
+
+mod sub2 {
+ pub fn foo() {} // implementation 2
+}
+
+use sub1::foo;
+use sub2::foo; //~ ERROR the name `foo` is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/imports/double-import.stderr b/src/test/ui/imports/double-import.stderr
new file mode 100644
index 000000000..82f5eb83e
--- /dev/null
+++ b/src/test/ui/imports/double-import.stderr
@@ -0,0 +1,17 @@
+error[E0252]: the name `foo` is defined multiple times
+ --> $DIR/double-import.rs:13:5
+ |
+LL | use sub1::foo;
+ | --------- previous import of the value `foo` here
+LL | use sub2::foo;
+ | ^^^^^^^^^ `foo` reimported here
+ |
+ = note: `foo` must be defined only once in the value namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use sub2::foo as other_foo;
+ | ~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/src/test/ui/imports/duplicate.rs b/src/test/ui/imports/duplicate.rs
new file mode 100644
index 000000000..db6538969
--- /dev/null
+++ b/src/test/ui/imports/duplicate.rs
@@ -0,0 +1,51 @@
+mod a {
+ pub fn foo() {}
+}
+
+mod b {
+ pub fn foo() {}
+}
+
+mod c {
+ pub use a::foo;
+}
+
+mod d {
+ use a::foo;
+ use a::foo; //~ ERROR the name `foo` is defined multiple times
+}
+
+mod e {
+ pub use a::*;
+ pub use c::*; // ok
+}
+
+mod f {
+ pub use a::*;
+ pub use b::*;
+}
+
+mod g {
+ pub use a::*;
+ pub use f::*;
+}
+
+fn main() {
+ e::foo();
+ f::foo(); //~ ERROR `foo` is ambiguous
+ g::foo();
+}
+
+mod ambiguous_module_errors {
+ pub mod m1 { pub use super::m1 as foo; pub fn bar() {} }
+ pub mod m2 { pub use super::m2 as foo; }
+
+ use self::m1::*;
+ use self::m2::*;
+
+ use self::foo::bar; //~ ERROR `foo` is ambiguous
+
+ fn f() {
+ foo::bar(); //~ ERROR `foo` is ambiguous
+ }
+}
diff --git a/src/test/ui/imports/duplicate.stderr b/src/test/ui/imports/duplicate.stderr
new file mode 100644
index 000000000..997a2741b
--- /dev/null
+++ b/src/test/ui/imports/duplicate.stderr
@@ -0,0 +1,74 @@
+error[E0252]: the name `foo` is defined multiple times
+ --> $DIR/duplicate.rs:15:9
+ |
+LL | use a::foo;
+ | ------ previous import of the value `foo` here
+LL | use a::foo;
+ | ^^^^^^ `foo` reimported here
+ |
+ = note: `foo` must be defined only once in the value namespace of this module
+
+error[E0659]: `foo` is ambiguous
+ --> $DIR/duplicate.rs:46:15
+ |
+LL | use self::foo::bar;
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple glob imports of a name in the same module
+note: `foo` could refer to the module imported here
+ --> $DIR/duplicate.rs:43:9
+ |
+LL | use self::m1::*;
+ | ^^^^^^^^^^^
+ = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the module imported here
+ --> $DIR/duplicate.rs:44:9
+ |
+LL | use self::m2::*;
+ | ^^^^^^^^^^^
+ = help: consider adding an explicit import of `foo` to disambiguate
+
+error[E0659]: `foo` is ambiguous
+ --> $DIR/duplicate.rs:35:8
+ |
+LL | f::foo();
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple glob imports of a name in the same module
+note: `foo` could refer to the function imported here
+ --> $DIR/duplicate.rs:24:13
+ |
+LL | pub use a::*;
+ | ^^^^
+ = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the function imported here
+ --> $DIR/duplicate.rs:25:13
+ |
+LL | pub use b::*;
+ | ^^^^
+ = help: consider adding an explicit import of `foo` to disambiguate
+
+error[E0659]: `foo` is ambiguous
+ --> $DIR/duplicate.rs:49:9
+ |
+LL | foo::bar();
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple glob imports of a name in the same module
+note: `foo` could refer to the module imported here
+ --> $DIR/duplicate.rs:43:9
+ |
+LL | use self::m1::*;
+ | ^^^^^^^^^^^
+ = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the module imported here
+ --> $DIR/duplicate.rs:44:9
+ |
+LL | use self::m2::*;
+ | ^^^^^^^^^^^
+ = help: consider adding an explicit import of `foo` to disambiguate
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0252, E0659.
+For more information about an error, try `rustc --explain E0252`.
diff --git a/src/test/ui/imports/export-glob-imports-target.rs b/src/test/ui/imports/export-glob-imports-target.rs
new file mode 100644
index 000000000..4df807ea4
--- /dev/null
+++ b/src/test/ui/imports/export-glob-imports-target.rs
@@ -0,0 +1,22 @@
+// run-pass
+
+#![allow(non_upper_case_globals)]
+#![allow(dead_code)]
+// Test that a glob-export functions as an import
+// when referenced within its own local scope.
+
+// Modified to not use export since it's going away. --pcw
+
+// pretty-expanded FIXME #23616
+
+mod foo {
+ use foo::bar::*;
+ pub mod bar {
+ pub static a : isize = 10;
+ }
+ pub fn zum() {
+ let _b = a;
+ }
+}
+
+pub fn main() { }
diff --git a/src/test/ui/imports/export-multi.rs b/src/test/ui/imports/export-multi.rs
new file mode 100644
index 000000000..02bdbe8af
--- /dev/null
+++ b/src/test/ui/imports/export-multi.rs
@@ -0,0 +1,12 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+use m::f;
+use m::g;
+
+mod m {
+ pub fn f() { }
+ pub fn g() { }
+}
+
+pub fn main() { f(); g(); m::f(); m::g(); }
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs
new file mode 100644
index 000000000..1c0d3b4b9
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs
@@ -0,0 +1,6 @@
+extern crate self; //~ ERROR `extern crate self;` requires renaming
+
+#[macro_use] //~ ERROR `#[macro_use]` is not supported on `extern crate self`
+extern crate self as foo;
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr
new file mode 100644
index 000000000..127765727
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr
@@ -0,0 +1,19 @@
+error: `extern crate self;` requires renaming
+ --> $DIR/extern-crate-self-fail.rs:1:1
+ |
+LL | extern crate self;
+ | ^^^^^^^^^^^^^^^^^^
+ |
+help: rename the `self` crate to be able to import it
+ |
+LL | extern crate self as name;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: `#[macro_use]` is not supported on `extern crate self`
+ --> $DIR/extern-crate-self-fail.rs:3:1
+ |
+LL | #[macro_use]
+ | ^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs
new file mode 100644
index 000000000..796835228
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+// Test that a macro can correctly expand the alias
+// in an `extern crate self as ALIAS` item.
+
+fn the_answer() -> usize { 42 }
+
+macro_rules! alias_self {
+ ($alias:ident) => { extern crate self as $alias; }
+}
+
+alias_self!(the_alias);
+
+fn main() {
+ assert_eq!(the_alias::the_answer(), 42);
+}
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs
new file mode 100644
index 000000000..244293be7
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs
@@ -0,0 +1,12 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+// Test that `extern crate self;` is accepted
+// syntactically as an item for use in a macro.
+
+macro_rules! accept_item { ($x:item) => {} }
+
+accept_item! {
+ extern crate self;
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs
new file mode 100644
index 000000000..009a92e87
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+// Test that a macro can correctly expand `self` in
+// an `extern crate self as ALIAS` item.
+
+fn the_answer() -> usize { 42 }
+
+macro_rules! extern_something {
+ ($alias:ident) => { extern crate $alias as the_alias; }
+}
+
+extern_something!(self);
+
+fn main() {
+ assert_eq!(the_alias::the_answer(), 42);
+}
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs
new file mode 100644
index 000000000..9cebb622e
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs
@@ -0,0 +1,13 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+extern crate self as foo;
+
+struct S;
+
+mod m {
+ fn check() {
+ foo::S; // OK
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-crate-used.rs b/src/test/ui/imports/extern-crate-used.rs
new file mode 100644
index 000000000..8198c1816
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-used.rs
@@ -0,0 +1,32 @@
+// Extern crate items are marked as used if they are used
+// through extern prelude entries introduced by them.
+
+// edition:2018
+
+#![deny(unused_extern_crates)]
+
+// Shouldn't suggest changing to `use`, as new name
+// would no longer be added to the prelude which could cause
+// compilation errors for imports that use the new name in
+// other modules. See #57672.
+extern crate core as iso1;
+extern crate core as iso2;
+extern crate core as iso3;
+extern crate core as iso4;
+
+// Doesn't introduce its extern prelude entry, so it's still considered unused.
+extern crate core; //~ ERROR unused extern crate
+
+mod m {
+ use iso1::any as are_you_okay1;
+ use ::iso2::any as are_you_okay2;
+ type AreYouOkay1 = dyn iso3::any::Any;
+ type AreYouOkay2 = dyn (::iso4::any::Any);
+
+ use core::any as are_you_okay3;
+ use ::core::any as are_you_okay4;
+ type AreYouOkay3 = dyn core::any::Any;
+ type AreYouOkay4 = dyn (::core::any::Any);
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-crate-used.stderr b/src/test/ui/imports/extern-crate-used.stderr
new file mode 100644
index 000000000..1b9a2e472
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-used.stderr
@@ -0,0 +1,14 @@
+error: unused extern crate
+ --> $DIR/extern-crate-used.rs:18:1
+ |
+LL | extern crate core;
+ | ^^^^^^^^^^^^^^^^^^ help: remove it
+ |
+note: the lint level is defined here
+ --> $DIR/extern-crate-used.rs:6:9
+ |
+LL | #![deny(unused_extern_crates)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs b/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs
new file mode 100644
index 000000000..30d87f90b
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs
@@ -0,0 +1,16 @@
+// build-pass (FIXME(62277): could be check-pass?)
+// edition:2018
+
+macro_rules! define_iso { () => {
+ extern crate std as iso;
+}}
+
+::iso::thread_local! {
+ static S: u8 = 0;
+}
+
+define_iso!();
+
+fn main() {
+ let s = S;
+}
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-cfg.rs b/src/test/ui/imports/extern-prelude-extern-crate-cfg.rs
new file mode 100644
index 000000000..cfae08fcc
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-cfg.rs
@@ -0,0 +1,16 @@
+// build-pass (FIXME(62277): could be check-pass?)
+// compile-flags:--cfg my_feature
+
+#![no_std]
+
+#[cfg(my_feature)]
+extern crate std;
+
+mod m {
+ #[cfg(my_feature)]
+ fn conditional() {
+ std::vec::Vec::<u8>::new(); // OK
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-fail.rs b/src/test/ui/imports/extern-prelude-extern-crate-fail.rs
new file mode 100644
index 000000000..feb1ab09d
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-fail.rs
@@ -0,0 +1,22 @@
+// aux-build:two_macros.rs
+// compile-flags:--extern non_existent
+
+mod n {
+ extern crate two_macros;
+}
+
+mod m {
+ fn check() {
+ two_macros::m!(); //~ ERROR failed to resolve: use of undeclared crate or module `two_macros`
+ }
+}
+
+macro_rules! define_std_as_non_existent {
+ () => {
+ extern crate std as non_existent;
+ //~^ ERROR `extern crate` items cannot shadow names passed with `--extern`
+ }
+}
+define_std_as_non_existent!();
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr b/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr
new file mode 100644
index 000000000..f7e37449e
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr
@@ -0,0 +1,20 @@
+error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
+ --> $DIR/extern-prelude-extern-crate-fail.rs:16:9
+ |
+LL | extern crate std as non_existent;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | define_std_as_non_existent!();
+ | ----------------------------- in this macro invocation
+ |
+ = note: this error originates in the macro `define_std_as_non_existent` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0433]: failed to resolve: use of undeclared crate or module `two_macros`
+ --> $DIR/extern-prelude-extern-crate-fail.rs:10:9
+ |
+LL | two_macros::m!();
+ | ^^^^^^^^^^ use of undeclared crate or module `two_macros`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-pass.rs b/src/test/ui/imports/extern-prelude-extern-crate-pass.rs
new file mode 100644
index 000000000..c87d58f63
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-pass.rs
@@ -0,0 +1,12 @@
+// build-pass (FIXME(62277): could be check-pass?)
+// aux-build:two_macros.rs
+
+extern crate two_macros;
+
+mod m {
+ fn check() {
+ two_macros::m!(); // OK
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs
new file mode 100644
index 000000000..6ff3ab736
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs
@@ -0,0 +1,26 @@
+// aux-build:two_macros.rs
+
+macro_rules! define_vec {
+ () => {
+ extern crate std as Vec;
+ }
+}
+
+define_vec!();
+
+mod m {
+ fn check() {
+ Vec::panic!(); //~ ERROR `Vec` is ambiguous
+ }
+}
+
+macro_rules! define_other_core {
+ () => {
+ extern crate std as core;
+ //~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
+ }
+}
+
+define_other_core!();
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr
new file mode 100644
index 000000000..c31c88403
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr
@@ -0,0 +1,36 @@
+error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
+ --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:19:9
+ |
+LL | extern crate std as core;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | define_other_core!();
+ | -------------------- in this macro invocation
+ |
+ = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0659]: `Vec` is ambiguous
+ --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9
+ |
+LL | Vec::panic!();
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
+note: `Vec` could refer to the crate imported here
+ --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:5:9
+ |
+LL | extern crate std as Vec;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | define_vec!();
+ | ------------- in this macro invocation
+note: `Vec` could also refer to the struct defined here
+ --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
+ |
+LL | pub use super::v1::*;
+ | ^^^^^^^^^^^^
+ = note: this error originates in the macro `define_vec` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs b/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs
new file mode 100644
index 000000000..9e69a27d7
--- /dev/null
+++ b/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs
@@ -0,0 +1,12 @@
+// build-pass (FIXME(62277): could be check-pass?)
+// aux-build:two_macros.rs
+
+extern crate two_macros as core;
+
+mod m {
+ fn check() {
+ core::m!(); // OK
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/gensymed.rs b/src/test/ui/imports/gensymed.rs
new file mode 100644
index 000000000..7b53f0c53
--- /dev/null
+++ b/src/test/ui/imports/gensymed.rs
@@ -0,0 +1,9 @@
+// check-pass
+// edition:2018
+// aux-build:gensymed.rs
+
+extern crate gensymed;
+
+use gensymed::*;
+
+fn main() {}
diff --git a/src/test/ui/imports/glob-conflict-cross-crate.rs b/src/test/ui/imports/glob-conflict-cross-crate.rs
new file mode 100644
index 000000000..d84c243f2
--- /dev/null
+++ b/src/test/ui/imports/glob-conflict-cross-crate.rs
@@ -0,0 +1,8 @@
+// aux-build:glob-conflict.rs
+
+extern crate glob_conflict;
+
+fn main() {
+ glob_conflict::f(); //~ ERROR cannot find function `f` in crate `glob_conflict`
+ glob_conflict::glob::f(); //~ ERROR cannot find function `f` in module `glob_conflict::glob`
+}
diff --git a/src/test/ui/imports/glob-conflict-cross-crate.stderr b/src/test/ui/imports/glob-conflict-cross-crate.stderr
new file mode 100644
index 000000000..0e3b4222f
--- /dev/null
+++ b/src/test/ui/imports/glob-conflict-cross-crate.stderr
@@ -0,0 +1,15 @@
+error[E0425]: cannot find function `f` in crate `glob_conflict`
+ --> $DIR/glob-conflict-cross-crate.rs:6:20
+ |
+LL | glob_conflict::f();
+ | ^ not found in `glob_conflict`
+
+error[E0425]: cannot find function `f` in module `glob_conflict::glob`
+ --> $DIR/glob-conflict-cross-crate.rs:7:26
+ |
+LL | glob_conflict::glob::f();
+ | ^ not found in `glob_conflict::glob`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/imports/glob-cycles.rs b/src/test/ui/imports/glob-cycles.rs
new file mode 100644
index 000000000..f354cc885
--- /dev/null
+++ b/src/test/ui/imports/glob-cycles.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+mod foo {
+ pub use bar::*;
+ pub use main as f;
+}
+
+mod bar {
+ pub use foo::*;
+}
+
+pub use foo::*;
+pub use baz::*;
+mod baz {
+ pub use super::*;
+}
+
+pub fn main() {}
diff --git a/src/test/ui/imports/glob-resolve1.rs b/src/test/ui/imports/glob-resolve1.rs
new file mode 100644
index 000000000..904b77117
--- /dev/null
+++ b/src/test/ui/imports/glob-resolve1.rs
@@ -0,0 +1,39 @@
+// Make sure that globs only bring in public things.
+
+use bar::*;
+
+mod bar {
+ use self::fpriv as import;
+ fn fpriv() {}
+ extern "C" {
+ fn epriv();
+ }
+ enum A {
+ A1,
+ }
+ pub enum B {
+ B1,
+ }
+
+ struct C;
+
+ type D = isize;
+}
+
+fn foo<T>() {}
+
+fn main() {
+ fpriv(); //~ ERROR cannot find function `fpriv` in this scope
+ epriv(); //~ ERROR cannot find function `epriv` in this scope
+ B; //~ ERROR expected value, found enum `B`
+ C; //~ ERROR cannot find value `C` in this scope
+ import(); //~ ERROR: cannot find function `import` in this scope
+
+ foo::<A>(); //~ ERROR: cannot find type `A` in this scope
+ foo::<C>(); //~ ERROR: cannot find type `C` in this scope
+ foo::<D>(); //~ ERROR: cannot find type `D` in this scope
+}
+
+mod other {
+ pub fn import() {}
+}
diff --git a/src/test/ui/imports/glob-resolve1.stderr b/src/test/ui/imports/glob-resolve1.stderr
new file mode 100644
index 000000000..3b66a5e31
--- /dev/null
+++ b/src/test/ui/imports/glob-resolve1.stderr
@@ -0,0 +1,114 @@
+error[E0425]: cannot find function `fpriv` in this scope
+ --> $DIR/glob-resolve1.rs:26:5
+ |
+LL | fpriv();
+ | ^^^^^ not found in this scope
+ |
+note: function `bar::fpriv` exists but is inaccessible
+ --> $DIR/glob-resolve1.rs:7:5
+ |
+LL | fn fpriv() {}
+ | ^^^^^^^^^^ not accessible
+
+error[E0425]: cannot find function `epriv` in this scope
+ --> $DIR/glob-resolve1.rs:27:5
+ |
+LL | epriv();
+ | ^^^^^ not found in this scope
+ |
+note: function `bar::epriv` exists but is inaccessible
+ --> $DIR/glob-resolve1.rs:9:9
+ |
+LL | fn epriv();
+ | ^^^^^^^^^^^ not accessible
+
+error[E0423]: expected value, found enum `B`
+ --> $DIR/glob-resolve1.rs:28:5
+ |
+LL | B;
+ | ^
+ |
+note: the enum is defined here
+ --> $DIR/glob-resolve1.rs:14:5
+ |
+LL | / pub enum B {
+LL | | B1,
+LL | | }
+ | |_____^
+help: you might have meant to use the following enum variant
+ |
+LL | B::B1;
+ | ~~~~~
+
+error[E0425]: cannot find value `C` in this scope
+ --> $DIR/glob-resolve1.rs:29:5
+ |
+LL | C;
+ | ^ not found in this scope
+ |
+note: unit struct `bar::C` exists but is inaccessible
+ --> $DIR/glob-resolve1.rs:18:5
+ |
+LL | struct C;
+ | ^^^^^^^^^ not accessible
+
+error[E0425]: cannot find function `import` in this scope
+ --> $DIR/glob-resolve1.rs:30:5
+ |
+LL | import();
+ | ^^^^^^ not found in this scope
+ |
+help: consider importing this function
+ |
+LL | use other::import;
+ |
+
+error[E0412]: cannot find type `A` in this scope
+ --> $DIR/glob-resolve1.rs:32:11
+ |
+LL | pub enum B {
+ | ---------- similarly named enum `B` defined here
+...
+LL | foo::<A>();
+ | ^ help: an enum with a similar name exists: `B`
+ |
+note: enum `bar::A` exists but is inaccessible
+ --> $DIR/glob-resolve1.rs:11:5
+ |
+LL | enum A {
+ | ^^^^^^ not accessible
+
+error[E0412]: cannot find type `C` in this scope
+ --> $DIR/glob-resolve1.rs:33:11
+ |
+LL | pub enum B {
+ | ---------- similarly named enum `B` defined here
+...
+LL | foo::<C>();
+ | ^ help: an enum with a similar name exists: `B`
+ |
+note: struct `bar::C` exists but is inaccessible
+ --> $DIR/glob-resolve1.rs:18:5
+ |
+LL | struct C;
+ | ^^^^^^^^^ not accessible
+
+error[E0412]: cannot find type `D` in this scope
+ --> $DIR/glob-resolve1.rs:34:11
+ |
+LL | pub enum B {
+ | ---------- similarly named enum `B` defined here
+...
+LL | foo::<D>();
+ | ^ help: an enum with a similar name exists: `B`
+ |
+note: type alias `bar::D` exists but is inaccessible
+ --> $DIR/glob-resolve1.rs:20:5
+ |
+LL | type D = isize;
+ | ^^^^^^^^^^^^^^^ not accessible
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0412, E0423, E0425.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/src/test/ui/imports/glob-shadowing.rs b/src/test/ui/imports/glob-shadowing.rs
new file mode 100644
index 000000000..3a33b592b
--- /dev/null
+++ b/src/test/ui/imports/glob-shadowing.rs
@@ -0,0 +1,34 @@
+#![feature(decl_macro)]
+
+mod m {
+ pub macro env($e: expr) { $e }
+ pub macro fenv() { 0 }
+}
+
+mod glob_in_normal_module {
+ use m::*;
+ fn check() {
+ let x = env!("PATH"); //~ ERROR `env` is ambiguous
+ }
+}
+
+mod glob_in_block_module {
+ fn block() {
+ use m::*;
+ fn check() {
+ let x = env!("PATH"); //~ ERROR `env` is ambiguous
+ }
+ }
+}
+
+mod glob_shadows_item {
+ pub macro fenv($e: expr) { $e }
+ fn block() {
+ use m::*;
+ fn check() {
+ let x = fenv!(); //~ ERROR `fenv` is ambiguous
+ }
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/glob-shadowing.stderr b/src/test/ui/imports/glob-shadowing.stderr
new file mode 100644
index 000000000..aff2eff68
--- /dev/null
+++ b/src/test/ui/imports/glob-shadowing.stderr
@@ -0,0 +1,54 @@
+error[E0659]: `env` is ambiguous
+ --> $DIR/glob-shadowing.rs:11:17
+ |
+LL | let x = env!("PATH");
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
+ = note: `env` could refer to a macro from prelude
+note: `env` could also refer to the macro imported here
+ --> $DIR/glob-shadowing.rs:9:9
+ |
+LL | use m::*;
+ | ^^^^
+ = help: consider adding an explicit import of `env` to disambiguate
+ = help: or use `self::env` to refer to this macro unambiguously
+
+error[E0659]: `env` is ambiguous
+ --> $DIR/glob-shadowing.rs:19:21
+ |
+LL | let x = env!("PATH");
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
+ = note: `env` could refer to a macro from prelude
+note: `env` could also refer to the macro imported here
+ --> $DIR/glob-shadowing.rs:17:13
+ |
+LL | use m::*;
+ | ^^^^
+ = help: consider adding an explicit import of `env` to disambiguate
+
+error[E0659]: `fenv` is ambiguous
+ --> $DIR/glob-shadowing.rs:29:21
+ |
+LL | let x = fenv!();
+ | ^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
+note: `fenv` could refer to the macro imported here
+ --> $DIR/glob-shadowing.rs:27:13
+ |
+LL | use m::*;
+ | ^^^^
+ = help: consider adding an explicit import of `fenv` to disambiguate
+note: `fenv` could also refer to the macro defined here
+ --> $DIR/glob-shadowing.rs:25:5
+ |
+LL | pub macro fenv($e: expr) { $e }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: use `self::fenv` to refer to this macro unambiguously
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/glob-use-std.rs b/src/test/ui/imports/glob-use-std.rs
new file mode 100644
index 000000000..ef06cc570
--- /dev/null
+++ b/src/test/ui/imports/glob-use-std.rs
@@ -0,0 +1,11 @@
+// Issue #7580
+
+// run-fail
+// error-pattern:panic works
+// ignore-emscripten no processes
+
+use std::*;
+
+fn main() {
+ panic!("panic works")
+}
diff --git a/src/test/ui/imports/import-crate-var.rs b/src/test/ui/imports/import-crate-var.rs
new file mode 100644
index 000000000..aac5a15d3
--- /dev/null
+++ b/src/test/ui/imports/import-crate-var.rs
@@ -0,0 +1,8 @@
+// aux-build:import_crate_var.rs
+
+#[macro_use] extern crate import_crate_var;
+
+fn main() {
+ m!();
+ //~^ ERROR `$crate` may not be imported
+}
diff --git a/src/test/ui/imports/import-crate-var.stderr b/src/test/ui/imports/import-crate-var.stderr
new file mode 100644
index 000000000..f1f1dfbdb
--- /dev/null
+++ b/src/test/ui/imports/import-crate-var.stderr
@@ -0,0 +1,10 @@
+error: `$crate` may not be imported
+ --> $DIR/import-crate-var.rs:6:5
+ |
+LL | m!();
+ | ^^^^
+ |
+ = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs b/src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs
new file mode 100644
index 000000000..b76c1680b
--- /dev/null
+++ b/src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs
@@ -0,0 +1,20 @@
+#![crate_type = "rlib"]
+// no-prefer-dynamic
+
+// compile-flags: -g
+
+#[macro_use]
+mod crate_with_invalid_spans_macros;
+
+pub fn exported_generic<T>(x: T, y: u32) -> (T, u32) {
+ // Using the add1 macro will produce an invalid span, because the `y` passed
+ // to the macro will have a span from this file, but the rest of the code
+ // generated from the macro will have spans from the macro-defining file.
+ // The AST node for the (1 + y) expression generated by the macro will then
+ // take it's `lo` span bound from the `1` literal in the macro-defining file
+ // and it's `hi` bound from `y` in this file, which should be lower than the
+ // `lo` and even lower than the lower bound of the SourceFile it is supposedly
+ // contained in because the SourceFile for this file was allocated earlier than
+ // the SourceFile of the macro-defining file.
+ return (x, add1!(y));
+}
diff --git a/src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs b/src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs
new file mode 100644
index 000000000..63611c242
--- /dev/null
+++ b/src/test/ui/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs
@@ -0,0 +1,7 @@
+macro_rules! add1 {
+ ($e:expr) => ({
+ let a = 1 + $e;
+ let b = $e + 1;
+ a + b - 1
+ })
+}
diff --git a/src/test/ui/imports/import-crate-with-invalid-spans/main.rs b/src/test/ui/imports/import-crate-with-invalid-spans/main.rs
new file mode 100644
index 000000000..64a4deca8
--- /dev/null
+++ b/src/test/ui/imports/import-crate-with-invalid-spans/main.rs
@@ -0,0 +1,13 @@
+// run-pass
+// aux-build:crate_with_invalid_spans.rs
+
+// pretty-expanded FIXME #23616
+
+extern crate crate_with_invalid_spans;
+
+fn main() {
+ // The AST of `exported_generic` stored in crate_with_invalid_spans's
+ // metadata should contain an invalid span where span.lo() > span.hi().
+ // Let's make sure the compiler doesn't crash when encountering this.
+ let _ = crate_with_invalid_spans::exported_generic(32u32, 7u32);
+}
diff --git a/src/test/ui/imports/import-from-missing.rs b/src/test/ui/imports/import-from-missing.rs
new file mode 100644
index 000000000..8eae70020
--- /dev/null
+++ b/src/test/ui/imports/import-from-missing.rs
@@ -0,0 +1,12 @@
+use spam::{ham, eggs}; //~ ERROR unresolved import `spam::eggs` [E0432]
+ //~^ no `eggs` in `spam`
+
+mod spam {
+ pub fn ham() { }
+}
+
+fn main() {
+ ham();
+ // Expect eggs to pass because the compiler inserts a fake name for it
+ eggs();
+}
diff --git a/src/test/ui/imports/import-from-missing.stderr b/src/test/ui/imports/import-from-missing.stderr
new file mode 100644
index 000000000..4254bfb5e
--- /dev/null
+++ b/src/test/ui/imports/import-from-missing.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `spam::eggs`
+ --> $DIR/import-from-missing.rs:1:17
+ |
+LL | use spam::{ham, eggs};
+ | ^^^^ no `eggs` in `spam`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/import-from.rs b/src/test/ui/imports/import-from.rs
new file mode 100644
index 000000000..2817977b3
--- /dev/null
+++ b/src/test/ui/imports/import-from.rs
@@ -0,0 +1,11 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+use spam::{ham, eggs};
+
+mod spam {
+ pub fn ham() { }
+ pub fn eggs() { }
+}
+
+pub fn main() { ham(); eggs(); }
diff --git a/src/test/ui/imports/import-glob-0-rpass.rs b/src/test/ui/imports/import-glob-0-rpass.rs
new file mode 100644
index 000000000..9c6a87279
--- /dev/null
+++ b/src/test/ui/imports/import-glob-0-rpass.rs
@@ -0,0 +1,29 @@
+// run-pass
+#![allow(dead_code)]
+use module_of_many_things::*;
+use dug::too::greedily::and::too::deep::*;
+
+mod module_of_many_things {
+ pub fn f1() { println!("f1"); }
+ pub fn f2() { println!("f2"); }
+ fn f3() { println!("f3"); }
+ pub fn f4() { println!("f4"); }
+}
+
+mod dug {
+ pub mod too {
+ pub mod greedily {
+ pub mod and {
+ pub mod too {
+ pub mod deep {
+ pub fn nameless_fear() { println!("Boo!"); }
+ pub fn also_redstone() { println!("Whatever."); }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+pub fn main() { f1(); f2(); f4(); nameless_fear(); also_redstone(); }
diff --git a/src/test/ui/imports/import-glob-0.rs b/src/test/ui/imports/import-glob-0.rs
new file mode 100644
index 000000000..37a0d1545
--- /dev/null
+++ b/src/test/ui/imports/import-glob-0.rs
@@ -0,0 +1,16 @@
+use module_of_many_things::*;
+
+mod module_of_many_things {
+ pub fn f1() { println!("f1"); }
+ pub fn f2() { println!("f2"); }
+ fn f3() { println!("f3"); }
+ pub fn f4() { println!("f4"); }
+}
+
+
+fn main() {
+ f1();
+ f2();
+ f999(); //~ ERROR cannot find function `f999` in this scope
+ f4();
+}
diff --git a/src/test/ui/imports/import-glob-0.stderr b/src/test/ui/imports/import-glob-0.stderr
new file mode 100644
index 000000000..820ff1bb5
--- /dev/null
+++ b/src/test/ui/imports/import-glob-0.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find function `f999` in this scope
+ --> $DIR/import-glob-0.rs:14:5
+ |
+LL | f999();
+ | ^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/imports/import-glob-1.rs b/src/test/ui/imports/import-glob-1.rs
new file mode 100644
index 000000000..fcc0b63f1
--- /dev/null
+++ b/src/test/ui/imports/import-glob-1.rs
@@ -0,0 +1,27 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_imports)]
+// This should resolve fine. Prior to fix, the last import
+// was being tried too early, and marked as unrsolved before
+// the glob import had a chance to be resolved.
+
+mod bar {
+ pub use self::middle::*;
+
+ mod middle {
+ pub use self::baz::Baz;
+
+ mod baz {
+ pub enum Baz {
+ Baz1,
+ Baz2
+ }
+ }
+ }
+}
+
+mod foo {
+ use bar::Baz::{Baz1, Baz2};
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/import-glob-circular.rs b/src/test/ui/imports/import-glob-circular.rs
new file mode 100644
index 000000000..e47fa870c
--- /dev/null
+++ b/src/test/ui/imports/import-glob-circular.rs
@@ -0,0 +1,19 @@
+mod circ1 {
+ pub use circ2::f2;
+ pub fn f1() { println!("f1"); }
+ pub fn common() -> usize { return 0; }
+}
+
+mod circ2 {
+ pub use circ1::f1;
+ pub fn f2() { println!("f2"); }
+ pub fn common() -> usize { return 1; }
+}
+
+mod test {
+ use circ1::*;
+
+ fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/import-glob-circular.stderr b/src/test/ui/imports/import-glob-circular.stderr
new file mode 100644
index 000000000..86bbea579
--- /dev/null
+++ b/src/test/ui/imports/import-glob-circular.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find function `f1066` in this scope
+ --> $DIR/import-glob-circular.rs:16:17
+ |
+LL | fn test() { f1066(); }
+ | ^^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/imports/import-glob-crate.rs b/src/test/ui/imports/import-glob-crate.rs
new file mode 100644
index 000000000..501392b78
--- /dev/null
+++ b/src/test/ui/imports/import-glob-crate.rs
@@ -0,0 +1,19 @@
+// run-pass
+use std::mem::*;
+
+pub fn main() {
+ assert_eq!(size_of::<u8>(), 1);
+ let (mut x, mut y) = (1, 2);
+ swap(&mut x, &mut y);
+ assert_eq!(x, 2);
+ assert_eq!(y, 1);
+}
+
+#[allow(unused)]
+fn f() {
+ mod foo { pub use *; }
+ mod bar { pub use ::*; }
+
+ foo::main();
+ bar::main();
+}
diff --git a/src/test/ui/imports/import-in-block.rs b/src/test/ui/imports/import-in-block.rs
new file mode 100644
index 000000000..19703904e
--- /dev/null
+++ b/src/test/ui/imports/import-in-block.rs
@@ -0,0 +1,13 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+pub fn main() {
+ use std::mem::replace;
+ let mut x = 5;
+ let _ = replace(&mut x, 6);
+ {
+ use std::mem::*;
+ let mut y = 6;
+ swap(&mut x, &mut y);
+ }
+}
diff --git a/src/test/ui/imports/import-loop-2.rs b/src/test/ui/imports/import-loop-2.rs
new file mode 100644
index 000000000..14a85dd08
--- /dev/null
+++ b/src/test/ui/imports/import-loop-2.rs
@@ -0,0 +1,13 @@
+// error-pattern:import
+
+mod a {
+ pub use b::x;
+}
+
+mod b {
+ pub use a::x;
+
+ fn main() { let y = x; }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/import-loop-2.stderr b/src/test/ui/imports/import-loop-2.stderr
new file mode 100644
index 000000000..1abfcde03
--- /dev/null
+++ b/src/test/ui/imports/import-loop-2.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `a::x`
+ --> $DIR/import-loop-2.rs:8:13
+ |
+LL | pub use a::x;
+ | ^^^^ no `x` in `a`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/import-loop.rs b/src/test/ui/imports/import-loop.rs
new file mode 100644
index 000000000..b48783401
--- /dev/null
+++ b/src/test/ui/imports/import-loop.rs
@@ -0,0 +1,9 @@
+// error-pattern:import
+
+use y::x;
+
+mod y {
+ pub use y::x;
+}
+
+fn main() { }
diff --git a/src/test/ui/imports/import-loop.stderr b/src/test/ui/imports/import-loop.stderr
new file mode 100644
index 000000000..b87bfb1be
--- /dev/null
+++ b/src/test/ui/imports/import-loop.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `y::x`
+ --> $DIR/import-loop.rs:6:13
+ |
+LL | pub use y::x;
+ | ^^^^ no `x` in `y`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/import-prefix-macro-1.rs b/src/test/ui/imports/import-prefix-macro-1.rs
new file mode 100644
index 000000000..91cfd3768
--- /dev/null
+++ b/src/test/ui/imports/import-prefix-macro-1.rs
@@ -0,0 +1,16 @@
+mod a {
+ pub mod b {
+ pub mod c {
+ pub struct S;
+ pub struct Z;
+ }
+ }
+}
+
+macro_rules! import {
+ ($p: path) => (use $p {S, Z}); //~ERROR expected one of `::`, `;`, or `as`, found `{`
+}
+
+import! { a::b::c }
+
+fn main() {}
diff --git a/src/test/ui/imports/import-prefix-macro-1.stderr b/src/test/ui/imports/import-prefix-macro-1.stderr
new file mode 100644
index 000000000..8868ee3ae
--- /dev/null
+++ b/src/test/ui/imports/import-prefix-macro-1.stderr
@@ -0,0 +1,13 @@
+error: expected one of `::`, `;`, or `as`, found `{`
+ --> $DIR/import-prefix-macro-1.rs:11:27
+ |
+LL | ($p: path) => (use $p {S, Z});
+ | ^^^^^^ expected one of `::`, `;`, or `as`
+...
+LL | import! { a::b::c }
+ | ------------------- in this macro invocation
+ |
+ = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/imports/import-prefix-macro-2.rs b/src/test/ui/imports/import-prefix-macro-2.rs
new file mode 100644
index 000000000..952d161e8
--- /dev/null
+++ b/src/test/ui/imports/import-prefix-macro-2.rs
@@ -0,0 +1,16 @@
+mod a {
+ pub mod b {
+ pub mod c {
+ pub struct S;
+ pub struct Z;
+ }
+ }
+}
+
+macro_rules! import {
+ ($p: path) => (use ::$p {S, Z}); //~ERROR expected identifier, found `a::b::c`
+}
+
+import! { a::b::c }
+
+fn main() {}
diff --git a/src/test/ui/imports/import-prefix-macro-2.stderr b/src/test/ui/imports/import-prefix-macro-2.stderr
new file mode 100644
index 000000000..23f8d5764
--- /dev/null
+++ b/src/test/ui/imports/import-prefix-macro-2.stderr
@@ -0,0 +1,13 @@
+error: expected identifier, found `a::b::c`
+ --> $DIR/import-prefix-macro-2.rs:11:26
+ |
+LL | ($p: path) => (use ::$p {S, Z});
+ | ^^ expected identifier
+...
+LL | import! { a::b::c }
+ | ------------------- in this macro invocation
+ |
+ = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/imports/import-prefix-macro.rs b/src/test/ui/imports/import-prefix-macro.rs
new file mode 100644
index 000000000..d770bb0da
--- /dev/null
+++ b/src/test/ui/imports/import-prefix-macro.rs
@@ -0,0 +1,27 @@
+// run-pass
+#![allow(unused_variables)]
+mod a {
+ pub mod b {
+ pub mod c {
+ pub struct S;
+ pub struct Z;
+ }
+ pub struct W;
+ }
+}
+
+macro_rules! import {
+ (1 $p: path) => (use $p;);
+ (2 $p: path) => (use $p::{Z};);
+ (3 $p: path) => (use $p::*;);
+}
+
+import! { 1 a::b::c::S }
+import! { 2 a::b::c }
+import! { 3 a::b }
+
+fn main() {
+ let s = S;
+ let z = Z;
+ let w = W;
+}
diff --git a/src/test/ui/imports/import-rename.rs b/src/test/ui/imports/import-rename.rs
new file mode 100644
index 000000000..9ad2b34b8
--- /dev/null
+++ b/src/test/ui/imports/import-rename.rs
@@ -0,0 +1,13 @@
+// run-pass
+#![allow(unused_variables)]
+use foo::{x, y as fooy};
+use Maybe::{Yes as MaybeYes};
+
+pub enum Maybe { Yes, No }
+mod foo {
+ use super::Maybe::{self as MaybeFoo};
+ pub fn x(a: MaybeFoo) {}
+ pub fn y(a: i32) { println!("{}", a); }
+}
+
+pub fn main() { x(MaybeYes); fooy(10); }
diff --git a/src/test/ui/imports/import-rpass.rs b/src/test/ui/imports/import-rpass.rs
new file mode 100644
index 000000000..de8bf6261
--- /dev/null
+++ b/src/test/ui/imports/import-rpass.rs
@@ -0,0 +1,12 @@
+// run-pass
+mod foo {
+ pub fn x(y: isize) { println!("{}", y); }
+}
+
+mod bar {
+ use foo::x;
+ use foo::x as z;
+ pub fn thing() { x(10); z(10); }
+}
+
+pub fn main() { bar::thing(); }
diff --git a/src/test/ui/imports/import-trailing-comma.rs b/src/test/ui/imports/import-trailing-comma.rs
new file mode 100644
index 000000000..f65c5c866
--- /dev/null
+++ b/src/test/ui/imports/import-trailing-comma.rs
@@ -0,0 +1,13 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+use foo::bar::{baz, quux,};
+
+mod foo {
+ pub mod bar {
+ pub fn baz() { }
+ pub fn quux() { }
+ }
+}
+
+pub fn main() { baz(); quux(); }
diff --git a/src/test/ui/imports/import-trait-method.rs b/src/test/ui/imports/import-trait-method.rs
new file mode 100644
index 000000000..97dd68f1e
--- /dev/null
+++ b/src/test/ui/imports/import-trait-method.rs
@@ -0,0 +1,7 @@
+trait Foo {
+ fn foo();
+}
+
+use Foo::foo; //~ ERROR not directly importable
+
+fn main() { foo(); }
diff --git a/src/test/ui/imports/import-trait-method.stderr b/src/test/ui/imports/import-trait-method.stderr
new file mode 100644
index 000000000..3c26907d3
--- /dev/null
+++ b/src/test/ui/imports/import-trait-method.stderr
@@ -0,0 +1,9 @@
+error[E0253]: `foo` is not directly importable
+ --> $DIR/import-trait-method.rs:5:5
+ |
+LL | use Foo::foo;
+ | ^^^^^^^^ cannot be imported directly
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0253`.
diff --git a/src/test/ui/imports/import.rs b/src/test/ui/imports/import.rs
new file mode 100644
index 000000000..3170dd2fa
--- /dev/null
+++ b/src/test/ui/imports/import.rs
@@ -0,0 +1,17 @@
+use zed::bar;
+use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432]
+ //~| no `baz` in `zed`
+ //~| HELP a similar name exists in the module
+ //~| SUGGESTION bar
+
+
+mod zed {
+ pub fn bar() { println!("bar"); }
+ use foo; //~ ERROR unresolved import `foo` [E0432]
+ //~^ no `foo` in the root
+}
+
+fn main() {
+ zed::foo(); //~ ERROR `foo` is private
+ bar();
+}
diff --git a/src/test/ui/imports/import.stderr b/src/test/ui/imports/import.stderr
new file mode 100644
index 000000000..797712e2d
--- /dev/null
+++ b/src/test/ui/imports/import.stderr
@@ -0,0 +1,31 @@
+error[E0432]: unresolved import `zed::baz`
+ --> $DIR/import.rs:2:5
+ |
+LL | use zed::baz;
+ | ^^^^^---
+ | | |
+ | | help: a similar name exists in the module: `bar`
+ | no `baz` in `zed`
+
+error[E0432]: unresolved import `foo`
+ --> $DIR/import.rs:10:9
+ |
+LL | use foo;
+ | ^^^ no `foo` in the root
+
+error[E0603]: unresolved item import `foo` is private
+ --> $DIR/import.rs:15:10
+ |
+LL | zed::foo();
+ | ^^^ private unresolved item import
+ |
+note: the unresolved item import `foo` is defined here
+ --> $DIR/import.rs:10:9
+ |
+LL | use foo;
+ | ^^^
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0432, E0603.
+For more information about an error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/import2-rpass.rs b/src/test/ui/imports/import2-rpass.rs
new file mode 100644
index 000000000..7b70f799e
--- /dev/null
+++ b/src/test/ui/imports/import2-rpass.rs
@@ -0,0 +1,9 @@
+// run-pass
+
+use zed::bar;
+
+mod zed {
+ pub fn bar() { println!("bar"); }
+}
+
+pub fn main() { bar(); }
diff --git a/src/test/ui/imports/import2.rs b/src/test/ui/imports/import2.rs
new file mode 100644
index 000000000..036d6bc07
--- /dev/null
+++ b/src/test/ui/imports/import2.rs
@@ -0,0 +1,10 @@
+use baz::zed::bar; //~ ERROR unresolved import `baz::zed` [E0432]
+ //~^ could not find `zed` in `baz`
+
+mod baz {}
+mod zed {
+ pub fn bar() { println!("bar3"); }
+}
+fn main() {
+ bar();
+}
diff --git a/src/test/ui/imports/import2.stderr b/src/test/ui/imports/import2.stderr
new file mode 100644
index 000000000..da888979c
--- /dev/null
+++ b/src/test/ui/imports/import2.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `baz::zed`
+ --> $DIR/import2.rs:1:10
+ |
+LL | use baz::zed::bar;
+ | ^^^ could not find `zed` in `baz`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/import3-rpass.rs b/src/test/ui/imports/import3-rpass.rs
new file mode 100644
index 000000000..17797aed3
--- /dev/null
+++ b/src/test/ui/imports/import3-rpass.rs
@@ -0,0 +1,13 @@
+// run-pass
+#![allow(unused_imports)]
+
+use baz::zed;
+use baz::zed::bar;
+
+mod baz {
+ pub mod zed {
+ pub fn bar() { println!("bar2"); }
+ }
+}
+
+pub fn main() { bar(); }
diff --git a/src/test/ui/imports/import3.rs b/src/test/ui/imports/import3.rs
new file mode 100644
index 000000000..2c6ac9a00
--- /dev/null
+++ b/src/test/ui/imports/import3.rs
@@ -0,0 +1,4 @@
+// error-pattern: unresolved
+use main::bar;
+
+fn main() { println!("foo"); }
diff --git a/src/test/ui/imports/import3.stderr b/src/test/ui/imports/import3.stderr
new file mode 100644
index 000000000..ca75c9c18
--- /dev/null
+++ b/src/test/ui/imports/import3.stderr
@@ -0,0 +1,11 @@
+error[E0432]: unresolved import `main`
+ --> $DIR/import3.rs:2:5
+ |
+LL | use main::bar;
+ | ^^^^ maybe a missing crate `main`?
+ |
+ = help: consider adding `extern crate main` to use the `main` crate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/import4-rpass.rs b/src/test/ui/imports/import4-rpass.rs
new file mode 100644
index 000000000..4fda53861
--- /dev/null
+++ b/src/test/ui/imports/import4-rpass.rs
@@ -0,0 +1,9 @@
+// run-pass
+
+use zed::bar;
+
+mod zed {
+ pub fn bar() { println!("bar"); }
+}
+
+pub fn main() { let _zed = 42; bar(); }
diff --git a/src/test/ui/imports/import4.rs b/src/test/ui/imports/import4.rs
new file mode 100644
index 000000000..ba3b7fbf5
--- /dev/null
+++ b/src/test/ui/imports/import4.rs
@@ -0,0 +1,7 @@
+// error-pattern: import
+
+
+mod a { pub use b::foo; }
+mod b { pub use a::foo; }
+
+fn main() { println!("loop"); }
diff --git a/src/test/ui/imports/import4.stderr b/src/test/ui/imports/import4.stderr
new file mode 100644
index 000000000..e0b478f1a
--- /dev/null
+++ b/src/test/ui/imports/import4.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `a::foo`
+ --> $DIR/import4.rs:5:17
+ |
+LL | mod b { pub use a::foo; }
+ | ^^^^^^ no `foo` in `a`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/import5.rs b/src/test/ui/imports/import5.rs
new file mode 100644
index 000000000..be2a55c2d
--- /dev/null
+++ b/src/test/ui/imports/import5.rs
@@ -0,0 +1,10 @@
+// run-pass
+use foo::bar;
+mod foo {
+ pub use foo::zed::bar;
+ pub mod zed {
+ pub fn bar() { println!("foo"); }
+ }
+}
+
+pub fn main() { bar(); }
diff --git a/src/test/ui/imports/import6.rs b/src/test/ui/imports/import6.rs
new file mode 100644
index 000000000..e11b28531
--- /dev/null
+++ b/src/test/ui/imports/import6.rs
@@ -0,0 +1,15 @@
+// run-pass
+#![allow(unused_imports)]
+
+use foo::zed;
+use bar::baz;
+
+mod foo {
+ pub mod zed {
+ pub fn baz() { println!("baz"); }
+ }
+}
+mod bar {
+ pub use foo::zed::baz;
+}
+pub fn main() { baz(); }
diff --git a/src/test/ui/imports/import7.rs b/src/test/ui/imports/import7.rs
new file mode 100644
index 000000000..aca7fbdc4
--- /dev/null
+++ b/src/test/ui/imports/import7.rs
@@ -0,0 +1,18 @@
+// run-pass
+#![allow(unused_imports)]
+
+use foo::zed;
+use bar::baz;
+
+mod foo {
+ pub mod zed {
+ pub fn baz() { println!("baz"); }
+ }
+}
+mod bar {
+ pub use foo::zed::baz;
+ pub mod foo {
+ pub mod zed {}
+ }
+}
+pub fn main() { baz(); }
diff --git a/src/test/ui/imports/import8.rs b/src/test/ui/imports/import8.rs
new file mode 100644
index 000000000..87f0986ba
--- /dev/null
+++ b/src/test/ui/imports/import8.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+use foo::x;
+use foo::x as z;
+
+mod foo {
+ pub fn x(y: isize) { println!("{}", y); }
+}
+
+pub fn main() { x(10); z(10); }
diff --git a/src/test/ui/imports/imports.rs b/src/test/ui/imports/imports.rs
new file mode 100644
index 000000000..acb2b32b5
--- /dev/null
+++ b/src/test/ui/imports/imports.rs
@@ -0,0 +1,66 @@
+// run-pass
+#![allow(unused)]
+
+// Like other items, private imports can be imported and used non-lexically in paths.
+mod a {
+ use a as foo;
+ use self::foo::foo as bar;
+
+ mod b {
+ use super::bar;
+ }
+}
+
+mod foo { pub fn f() {} }
+mod bar { pub fn f() {} }
+
+pub fn f() -> bool { true }
+
+// Items and explicit imports shadow globs.
+fn g() {
+ use foo::*;
+ use bar::*;
+ fn f() -> bool { true }
+ let _: bool = f();
+}
+
+fn h() {
+ use foo::*;
+ use bar::*;
+ use f;
+ let _: bool = f();
+}
+
+// Here, there appears to be shadowing but isn't because of namespaces.
+mod b {
+ use foo::*; // This imports `f` in the value namespace.
+ use super::b as f; // This imports `f` only in the type namespace,
+ fn test() { self::f(); } // so the glob isn't shadowed.
+}
+
+// Here, there is shadowing in one namespace, but not the other.
+mod c {
+ mod test {
+ pub fn f() {}
+ pub mod f {}
+ }
+ use self::test::*; // This glob-imports `f` in both namespaces.
+ mod f { pub fn f() {} } // This shadows the glob only in the value namespace.
+
+ fn test() {
+ self::f(); // Check that the glob-imported value isn't shadowed.
+ self::f::f(); // Check that the glob-imported module is shadowed.
+ }
+}
+
+// Unused names can be ambiguous.
+mod d {
+ pub use foo::*; // This imports `f` in the value namespace.
+ pub use bar::*; // This also imports `f` in the value namespace.
+}
+
+mod e {
+ pub use d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`.
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/inaccessible_type_aliases.rs b/src/test/ui/imports/inaccessible_type_aliases.rs
new file mode 100644
index 000000000..c3d4214e2
--- /dev/null
+++ b/src/test/ui/imports/inaccessible_type_aliases.rs
@@ -0,0 +1,14 @@
+mod a {
+ type Foo = u64;
+ type Bar = u64;
+}
+
+mod b {
+ type Foo = u64;
+}
+
+fn main() {
+ let x: Foo = 100; //~ ERROR: cannot find type `Foo` in this scope
+ let y: Bar = 100; //~ ERROR: cannot find type `Bar` in this scope
+ println!("x: {}, y: {}", x, y);
+}
diff --git a/src/test/ui/imports/inaccessible_type_aliases.stderr b/src/test/ui/imports/inaccessible_type_aliases.stderr
new file mode 100644
index 000000000..ef2242460
--- /dev/null
+++ b/src/test/ui/imports/inaccessible_type_aliases.stderr
@@ -0,0 +1,30 @@
+error[E0412]: cannot find type `Foo` in this scope
+ --> $DIR/inaccessible_type_aliases.rs:11:12
+ |
+LL | let x: Foo = 100;
+ | ^^^ not found in this scope
+ |
+note: these type aliases exist but are inaccessible
+ --> $DIR/inaccessible_type_aliases.rs:2:5
+ |
+LL | type Foo = u64;
+ | ^^^^^^^^^^^^^^^ `a::Foo`: not accessible
+...
+LL | type Foo = u64;
+ | ^^^^^^^^^^^^^^^ `b::Foo`: not accessible
+
+error[E0412]: cannot find type `Bar` in this scope
+ --> $DIR/inaccessible_type_aliases.rs:12:12
+ |
+LL | let y: Bar = 100;
+ | ^^^ not found in this scope
+ |
+note: type alias `a::Bar` exists but is inaccessible
+ --> $DIR/inaccessible_type_aliases.rs:3:5
+ |
+LL | type Bar = u64;
+ | ^^^^^^^^^^^^^^^ not accessible
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/src/test/ui/imports/issue-13404.rs b/src/test/ui/imports/issue-13404.rs
new file mode 100644
index 000000000..c5af827d5
--- /dev/null
+++ b/src/test/ui/imports/issue-13404.rs
@@ -0,0 +1,10 @@
+use a::f;
+use b::f; //~ ERROR: unresolved import `b::f` [E0432]
+ //~^ no `f` in `b`
+
+mod a { pub fn f() {} }
+mod b { }
+
+fn main() {
+ f();
+}
diff --git a/src/test/ui/imports/issue-13404.stderr b/src/test/ui/imports/issue-13404.stderr
new file mode 100644
index 000000000..1f50debb0
--- /dev/null
+++ b/src/test/ui/imports/issue-13404.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `b::f`
+ --> $DIR/issue-13404.rs:2:5
+ |
+LL | use b::f;
+ | ^^^^ no `f` in `b`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-1697.rs b/src/test/ui/imports/issue-1697.rs
new file mode 100644
index 000000000..5cd76d21f
--- /dev/null
+++ b/src/test/ui/imports/issue-1697.rs
@@ -0,0 +1,6 @@
+// Testing that we don't fail abnormally after hitting the errors
+
+use unresolved::*; //~ ERROR unresolved import `unresolved` [E0432]
+ //~^ maybe a missing crate `unresolved`?
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-1697.stderr b/src/test/ui/imports/issue-1697.stderr
new file mode 100644
index 000000000..019ef9ad5
--- /dev/null
+++ b/src/test/ui/imports/issue-1697.stderr
@@ -0,0 +1,11 @@
+error[E0432]: unresolved import `unresolved`
+ --> $DIR/issue-1697.rs:3:5
+ |
+LL | use unresolved::*;
+ | ^^^^^^^^^^ maybe a missing crate `unresolved`?
+ |
+ = help: consider adding `extern crate unresolved` to use the `unresolved` crate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-18083.rs b/src/test/ui/imports/issue-18083.rs
new file mode 100644
index 000000000..36420ec14
--- /dev/null
+++ b/src/test/ui/imports/issue-18083.rs
@@ -0,0 +1,25 @@
+// check-pass
+#![allow(dead_code)]
+#![allow(unused_imports)]
+// These crossed imports should resolve fine, and not block on
+// each other and be reported as unresolved.
+
+mod a {
+ use b::{B};
+ pub use self::inner::A;
+
+ mod inner {
+ pub struct A;
+ }
+}
+
+mod b {
+ use a::{A};
+ pub use self::inner::B;
+
+ mod inner {
+ pub struct B;
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-19498.rs b/src/test/ui/imports/issue-19498.rs
new file mode 100644
index 000000000..5fe6742f5
--- /dev/null
+++ b/src/test/ui/imports/issue-19498.rs
@@ -0,0 +1,13 @@
+use self::A;
+use self::B;
+mod A {} //~ ERROR the name `A` is defined multiple times
+//~| `A` redefined here
+pub mod B {} //~ ERROR the name `B` is defined multiple times
+//~| `B` redefined here
+mod C {
+ use C::D;
+ mod D {} //~ ERROR the name `D` is defined multiple times
+ //~| `D` redefined here
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-19498.stderr b/src/test/ui/imports/issue-19498.stderr
new file mode 100644
index 000000000..9d2602209
--- /dev/null
+++ b/src/test/ui/imports/issue-19498.stderr
@@ -0,0 +1,47 @@
+error[E0255]: the name `A` is defined multiple times
+ --> $DIR/issue-19498.rs:3:1
+ |
+LL | use self::A;
+ | ------- previous import of the module `A` here
+LL | use self::B;
+LL | mod A {}
+ | ^^^^^ `A` redefined 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 self::A as OtherA;
+ | ~~~~~~~~~~~~~~~~~
+
+error[E0255]: the name `B` is defined multiple times
+ --> $DIR/issue-19498.rs:5:1
+ |
+LL | use self::B;
+ | ------- previous import of the module `B` here
+...
+LL | pub mod B {}
+ | ^^^^^^^^^ `B` redefined here
+ |
+ = note: `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 self::B as OtherB;
+ | ~~~~~~~~~~~~~~~~~
+
+error[E0255]: the name `D` is defined multiple times
+ --> $DIR/issue-19498.rs:9:5
+ |
+LL | use C::D;
+ | ---- previous import of the module `D` here
+LL | mod D {}
+ | ^^^^^ `D` redefined here
+ |
+ = note: `D` 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 C::D as OtherD;
+ | ~~~~~~~~~~~~~~
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0255`.
diff --git a/src/test/ui/imports/issue-24081.rs b/src/test/ui/imports/issue-24081.rs
new file mode 100644
index 000000000..10983ce11
--- /dev/null
+++ b/src/test/ui/imports/issue-24081.rs
@@ -0,0 +1,18 @@
+use std::ops::Add;
+use std::ops::Sub;
+use std::ops::Mul;
+use std::ops::Div;
+use std::ops::Rem;
+
+type Add = bool; //~ ERROR the name `Add` is defined multiple times
+//~| `Add` redefined here
+struct Sub { x: f32 } //~ ERROR the name `Sub` is defined multiple times
+//~| `Sub` redefined here
+enum Mul { A, B } //~ ERROR the name `Mul` is defined multiple times
+//~| `Mul` redefined here
+mod Div { } //~ ERROR the name `Div` is defined multiple times
+//~| `Div` redefined here
+trait Rem { } //~ ERROR the name `Rem` is defined multiple times
+//~| `Rem` redefined here
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-24081.stderr b/src/test/ui/imports/issue-24081.stderr
new file mode 100644
index 000000000..e5ed6b10a
--- /dev/null
+++ b/src/test/ui/imports/issue-24081.stderr
@@ -0,0 +1,78 @@
+error[E0255]: the name `Add` is defined multiple times
+ --> $DIR/issue-24081.rs:7:1
+ |
+LL | use std::ops::Add;
+ | ------------- previous import of the trait `Add` here
+...
+LL | type Add = bool;
+ | ^^^^^^^^^^^^^^^^ `Add` redefined here
+ |
+ = note: `Add` 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::ops::Add as OtherAdd;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0255]: the name `Sub` is defined multiple times
+ --> $DIR/issue-24081.rs:9:1
+ |
+LL | use std::ops::Sub;
+ | ------------- previous import of the trait `Sub` here
+...
+LL | struct Sub { x: f32 }
+ | ^^^^^^^^^^ `Sub` redefined here
+ |
+ = note: `Sub` 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::ops::Sub as OtherSub;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0255]: the name `Mul` is defined multiple times
+ --> $DIR/issue-24081.rs:11:1
+ |
+LL | use std::ops::Mul;
+ | ------------- previous import of the trait `Mul` here
+...
+LL | enum Mul { A, B }
+ | ^^^^^^^^ `Mul` redefined here
+ |
+ = note: `Mul` 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::ops::Mul as OtherMul;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0255]: the name `Div` is defined multiple times
+ --> $DIR/issue-24081.rs:13:1
+ |
+LL | use std::ops::Div;
+ | ------------- previous import of the trait `Div` here
+...
+LL | mod Div { }
+ | ^^^^^^^ `Div` redefined here
+ |
+ = note: `Div` 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::ops::Div as OtherDiv;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0255]: the name `Rem` is defined multiple times
+ --> $DIR/issue-24081.rs:15:1
+ |
+LL | use std::ops::Rem;
+ | ------------- previous import of the trait `Rem` here
+...
+LL | trait Rem { }
+ | ^^^^^^^^^ `Rem` redefined here
+ |
+ = note: `Rem` 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::ops::Rem as OtherRem;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0255`.
diff --git a/src/test/ui/imports/issue-24883.rs b/src/test/ui/imports/issue-24883.rs
new file mode 100644
index 000000000..819a20ddb
--- /dev/null
+++ b/src/test/ui/imports/issue-24883.rs
@@ -0,0 +1,17 @@
+// check-pass
+
+mod a {
+ pub mod b { pub struct Foo; }
+
+ pub mod c {
+ use super::b;
+ pub struct Bar(pub b::Foo);
+ }
+
+ pub use self::c::*;
+}
+
+fn main() {
+ let _ = a::c::Bar(a::b::Foo);
+ let _ = a::Bar(a::b::Foo);
+}
diff --git a/src/test/ui/imports/issue-25396.rs b/src/test/ui/imports/issue-25396.rs
new file mode 100644
index 000000000..301658d23
--- /dev/null
+++ b/src/test/ui/imports/issue-25396.rs
@@ -0,0 +1,29 @@
+#![allow(non_camel_case_types)]
+
+use foo::baz;
+use bar::baz; //~ ERROR the name `baz` is defined multiple times
+
+use foo::Quux;
+use bar::Quux; //~ ERROR the name `Quux` is defined multiple times
+
+use foo::blah;
+use bar::blah; //~ ERROR the name `blah` is defined multiple times
+
+use foo::WOMP;
+use bar::WOMP; //~ ERROR the name `WOMP` is defined multiple times
+
+fn main() {}
+
+mod foo {
+ pub mod baz {}
+ pub trait Quux { }
+ pub type blah = (f64, u32);
+ pub const WOMP: u8 = 5;
+}
+
+mod bar {
+ pub mod baz {}
+ pub type Quux = i32;
+ pub struct blah { x: i8 }
+ pub const WOMP: i8 = -5;
+}
diff --git a/src/test/ui/imports/issue-25396.stderr b/src/test/ui/imports/issue-25396.stderr
new file mode 100644
index 000000000..518d2be78
--- /dev/null
+++ b/src/test/ui/imports/issue-25396.stderr
@@ -0,0 +1,59 @@
+error[E0252]: the name `baz` is defined multiple times
+ --> $DIR/issue-25396.rs:4:5
+ |
+LL | use foo::baz;
+ | -------- previous import of the module `baz` here
+LL | use bar::baz;
+ | ^^^^^^^^ `baz` reimported here
+ |
+ = note: `baz` 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 bar::baz as other_baz;
+ | ~~~~~~~~~~~~~~~~~~~~~
+
+error[E0252]: the name `Quux` is defined multiple times
+ --> $DIR/issue-25396.rs:7:5
+ |
+LL | use foo::Quux;
+ | --------- previous import of the trait `Quux` here
+LL | use bar::Quux;
+ | ^^^^^^^^^ `Quux` reimported here
+ |
+ = note: `Quux` 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 bar::Quux as OtherQuux;
+ | ~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0252]: the name `blah` is defined multiple times
+ --> $DIR/issue-25396.rs:10:5
+ |
+LL | use foo::blah;
+ | --------- previous import of the type `blah` here
+LL | use bar::blah;
+ | ^^^^^^^^^ `blah` reimported here
+ |
+ = note: `blah` 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 bar::blah as other_blah;
+ | ~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0252]: the name `WOMP` is defined multiple times
+ --> $DIR/issue-25396.rs:13:5
+ |
+LL | use foo::WOMP;
+ | --------- previous import of the value `WOMP` here
+LL | use bar::WOMP;
+ | ^^^^^^^^^ `WOMP` reimported here
+ |
+ = note: `WOMP` must be defined only once in the value namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | use bar::WOMP as OtherWOMP;
+ | ~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/src/test/ui/imports/issue-26873-multifile/A/B.rs b/src/test/ui/imports/issue-26873-multifile/A/B.rs
new file mode 100644
index 000000000..ab7b0d816
--- /dev/null
+++ b/src/test/ui/imports/issue-26873-multifile/A/B.rs
@@ -0,0 +1,4 @@
+// run-pass
+use super::*;
+
+pub struct S;
diff --git a/src/test/ui/imports/issue-26873-multifile/A/C.rs b/src/test/ui/imports/issue-26873-multifile/A/C.rs
new file mode 100644
index 000000000..b287283df
--- /dev/null
+++ b/src/test/ui/imports/issue-26873-multifile/A/C.rs
@@ -0,0 +1,6 @@
+// run-pass
+use super::*;
+
+use super::B::S;
+
+pub struct T { i: i32 }
diff --git a/src/test/ui/imports/issue-26873-multifile/A/mod.rs b/src/test/ui/imports/issue-26873-multifile/A/mod.rs
new file mode 100644
index 000000000..0f18772bf
--- /dev/null
+++ b/src/test/ui/imports/issue-26873-multifile/A/mod.rs
@@ -0,0 +1,5 @@
+// run-pass
+pub mod B;
+pub mod C;
+
+pub use self::C::T;
diff --git a/src/test/ui/imports/issue-26873-multifile/compiletest-ignore-dir b/src/test/ui/imports/issue-26873-multifile/compiletest-ignore-dir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/test/ui/imports/issue-26873-multifile/compiletest-ignore-dir
diff --git a/src/test/ui/imports/issue-26873-multifile/issue-26873-multifile.rs b/src/test/ui/imports/issue-26873-multifile/issue-26873-multifile.rs
new file mode 100644
index 000000000..da2acf6c9
--- /dev/null
+++ b/src/test/ui/imports/issue-26873-multifile/issue-26873-multifile.rs
@@ -0,0 +1,11 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_imports)]
+#![allow(non_snake_case)]
+
+// ignore-pretty issue #37195
+
+#[path = "issue-26873-multifile/mod.rs"]
+mod multifile;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-26873-multifile/issue-26873-onefile.rs b/src/test/ui/imports/issue-26873-multifile/issue-26873-onefile.rs
new file mode 100644
index 000000000..f06c6499e
--- /dev/null
+++ b/src/test/ui/imports/issue-26873-multifile/issue-26873-onefile.rs
@@ -0,0 +1,25 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_imports)]
+#![allow(non_snake_case)]
+
+mod A {
+ pub mod B {
+ use super::*;
+
+ pub struct S;
+ }
+
+ pub mod C {
+ use super::*;
+ use super::B::S;
+
+ pub struct T;
+ }
+
+ pub use self::C::T;
+}
+
+use A::*;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-26873-multifile/mod.rs b/src/test/ui/imports/issue-26873-multifile/mod.rs
new file mode 100644
index 000000000..a1ba53f91
--- /dev/null
+++ b/src/test/ui/imports/issue-26873-multifile/mod.rs
@@ -0,0 +1,4 @@
+// run-pass
+mod A;
+
+use self::A::*;
diff --git a/src/test/ui/imports/issue-26886.rs b/src/test/ui/imports/issue-26886.rs
new file mode 100644
index 000000000..6e6d406c6
--- /dev/null
+++ b/src/test/ui/imports/issue-26886.rs
@@ -0,0 +1,8 @@
+use std::sync::{self, Arc};
+use std::sync::Arc; //~ ERROR the name `Arc` is defined multiple times
+ //~| `Arc` must be defined only once in the type namespace of this module
+use std::sync; //~ ERROR the name `sync` is defined multiple times
+ //~| `sync` must be defined only once in the type namespace of this module
+
+fn main() {
+}
diff --git a/src/test/ui/imports/issue-26886.stderr b/src/test/ui/imports/issue-26886.stderr
new file mode 100644
index 000000000..e2b925ec5
--- /dev/null
+++ b/src/test/ui/imports/issue-26886.stderr
@@ -0,0 +1,24 @@
+error[E0252]: the name `Arc` is defined multiple times
+ --> $DIR/issue-26886.rs:2:5
+ |
+LL | use std::sync::{self, Arc};
+ | --- previous import of the type `Arc` here
+LL | use std::sync::Arc;
+ | ^^^^^^^^^^^^^^ `Arc` reimported here
+ |
+ = note: `Arc` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `sync` is defined multiple times
+ --> $DIR/issue-26886.rs:4:5
+ |
+LL | use std::sync::{self, Arc};
+ | ---- previous import of the module `sync` here
+...
+LL | use std::sync;
+ | ^^^^^^^^^ `sync` reimported here
+ |
+ = note: `sync` must be defined only once in the type namespace of this module
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/src/test/ui/imports/issue-28134.rs b/src/test/ui/imports/issue-28134.rs
new file mode 100644
index 000000000..ef2a5d634
--- /dev/null
+++ b/src/test/ui/imports/issue-28134.rs
@@ -0,0 +1,5 @@
+// compile-flags: --test
+
+#![allow(soft_unstable)]
+#![test] //~ ERROR cannot determine resolution for the attribute macro `test`
+//~^ ERROR 4:1: 4:9: `test` attribute cannot be used at crate level
diff --git a/src/test/ui/imports/issue-28134.stderr b/src/test/ui/imports/issue-28134.stderr
new file mode 100644
index 000000000..33cb53f20
--- /dev/null
+++ b/src/test/ui/imports/issue-28134.stderr
@@ -0,0 +1,21 @@
+error: cannot determine resolution for the attribute macro `test`
+ --> $DIR/issue-28134.rs:4:4
+ |
+LL | #![test]
+ | ^^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error: `test` attribute cannot be used at crate level
+ --> $DIR/issue-28134.rs:4:1
+ |
+LL | #![test]
+ | ^^^^^^^^
+ |
+help: perhaps you meant to use an outer attribute
+ |
+LL | #[test]
+ | ~~~~~~~
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/imports/issue-28388-1.rs b/src/test/ui/imports/issue-28388-1.rs
new file mode 100644
index 000000000..14de62140
--- /dev/null
+++ b/src/test/ui/imports/issue-28388-1.rs
@@ -0,0 +1,5 @@
+// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc.
+
+use foo::{}; //~ ERROR unresolved import `foo`
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-28388-1.stderr b/src/test/ui/imports/issue-28388-1.stderr
new file mode 100644
index 000000000..7f5e47aa8
--- /dev/null
+++ b/src/test/ui/imports/issue-28388-1.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `foo`
+ --> $DIR/issue-28388-1.rs:3:5
+ |
+LL | use foo::{};
+ | ^^^^^^^ no `foo` 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/imports/issue-28388-2.rs b/src/test/ui/imports/issue-28388-2.rs
new file mode 100644
index 000000000..024b0388b
--- /dev/null
+++ b/src/test/ui/imports/issue-28388-2.rs
@@ -0,0 +1,10 @@
+// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc.
+
+mod m {
+ mod n {}
+}
+
+use m::n::{};
+//~^ ERROR module `n` is private
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-28388-2.stderr b/src/test/ui/imports/issue-28388-2.stderr
new file mode 100644
index 000000000..1afaf622b
--- /dev/null
+++ b/src/test/ui/imports/issue-28388-2.stderr
@@ -0,0 +1,15 @@
+error[E0603]: module `n` is private
+ --> $DIR/issue-28388-2.rs:7:8
+ |
+LL | use m::n::{};
+ | ^ private module
+ |
+note: the module `n` is defined here
+ --> $DIR/issue-28388-2.rs:4:5
+ |
+LL | mod n {}
+ | ^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0603`.
diff --git a/src/test/ui/imports/issue-2937.rs b/src/test/ui/imports/issue-2937.rs
new file mode 100644
index 000000000..335df5c07
--- /dev/null
+++ b/src/test/ui/imports/issue-2937.rs
@@ -0,0 +1,6 @@
+use m::f as x; //~ ERROR unresolved import `m::f` [E0432]
+ //~^ no `f` in `m`
+
+mod m {}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-2937.stderr b/src/test/ui/imports/issue-2937.stderr
new file mode 100644
index 000000000..428634828
--- /dev/null
+++ b/src/test/ui/imports/issue-2937.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `m::f`
+ --> $DIR/issue-2937.rs:1:5
+ |
+LL | use m::f as x;
+ | ^^^^^^^^^ no `f` in `m`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-30560.rs b/src/test/ui/imports/issue-30560.rs
new file mode 100644
index 000000000..d8d4ca608
--- /dev/null
+++ b/src/test/ui/imports/issue-30560.rs
@@ -0,0 +1,9 @@
+type Alias = ();
+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
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-30560.stderr b/src/test/ui/imports/issue-30560.stderr
new file mode 100644
index 000000000..69cfd4c06
--- /dev/null
+++ b/src/test/ui/imports/issue-30560.stderr
@@ -0,0 +1,21 @@
+error: items in traits are not importable
+ --> $DIR/issue-30560.rs:7:5
+ |
+LL | use T::*;
+ | ^^^^
+
+error[E0432]: unresolved import `Alias`
+ --> $DIR/issue-30560.rs:2:5
+ |
+LL | use Alias::*;
+ | ^^^^^ `Alias` is a type alias, not a module
+
+error[E0432]: unresolved import `std::io::Result`
+ --> $DIR/issue-30560.rs:4:14
+ |
+LL | use std::io::Result::*;
+ | ^^^^^^ `Result` is a type alias, not a module
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-31212.rs b/src/test/ui/imports/issue-31212.rs
new file mode 100644
index 000000000..556f0d18f
--- /dev/null
+++ b/src/test/ui/imports/issue-31212.rs
@@ -0,0 +1,10 @@
+// This checks that a path that cannot be resolved because of an indeterminate import
+// does not trigger an ICE.
+
+mod foo {
+ pub use self::*; //~ ERROR unresolved
+}
+
+fn main() {
+ foo::f(); //~ ERROR cannot find function `f` in module `foo`
+}
diff --git a/src/test/ui/imports/issue-31212.stderr b/src/test/ui/imports/issue-31212.stderr
new file mode 100644
index 000000000..0bb56b361
--- /dev/null
+++ b/src/test/ui/imports/issue-31212.stderr
@@ -0,0 +1,16 @@
+error[E0432]: unresolved import `self::*`
+ --> $DIR/issue-31212.rs:5:13
+ |
+LL | pub use self::*;
+ | ^^^^^^^ cannot glob-import a module into itself
+
+error[E0425]: cannot find function `f` in module `foo`
+ --> $DIR/issue-31212.rs:9:10
+ |
+LL | foo::f();
+ | ^ not found in `foo`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0425, E0432.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/src/test/ui/imports/issue-32119.rs b/src/test/ui/imports/issue-32119.rs
new file mode 100644
index 000000000..36adb5289
--- /dev/null
+++ b/src/test/ui/imports/issue-32119.rs
@@ -0,0 +1,17 @@
+// check-pass
+
+pub type T = ();
+mod foo { pub use super::T; }
+mod bar { pub use super::T; }
+
+pub use foo::*;
+pub use bar::*;
+
+mod baz {
+ pub type T = ();
+ mod foo { pub use super::T as S; }
+ mod bar { pub use super::foo::S as T; }
+ pub use self::bar::*;
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-32222.rs b/src/test/ui/imports/issue-32222.rs
new file mode 100644
index 000000000..4ed06bff8
--- /dev/null
+++ b/src/test/ui/imports/issue-32222.rs
@@ -0,0 +1,22 @@
+// check-pass
+
+mod foo {
+ pub fn bar() {}
+}
+
+pub use foo::*;
+use b::bar;
+
+mod foobar {
+ use super::*;
+}
+
+mod a {
+ pub mod bar {}
+}
+
+mod b {
+ pub use a::bar;
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-32354-suggest-import-rename.fixed b/src/test/ui/imports/issue-32354-suggest-import-rename.fixed
new file mode 100644
index 000000000..27f1b8964
--- /dev/null
+++ b/src/test/ui/imports/issue-32354-suggest-import-rename.fixed
@@ -0,0 +1,16 @@
+// run-rustfix
+
+#![allow(unused_imports)]
+
+pub mod extension1 {
+ pub trait ConstructorExtension {}
+}
+
+pub mod extension2 {
+ pub trait ConstructorExtension {}
+}
+
+use extension1::ConstructorExtension;
+use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-32354-suggest-import-rename.rs b/src/test/ui/imports/issue-32354-suggest-import-rename.rs
new file mode 100644
index 000000000..5a7f234d5
--- /dev/null
+++ b/src/test/ui/imports/issue-32354-suggest-import-rename.rs
@@ -0,0 +1,16 @@
+// run-rustfix
+
+#![allow(unused_imports)]
+
+pub mod extension1 {
+ pub trait ConstructorExtension {}
+}
+
+pub mod extension2 {
+ pub trait ConstructorExtension {}
+}
+
+use extension1::ConstructorExtension;
+use extension2::ConstructorExtension; //~ ERROR is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-32354-suggest-import-rename.stderr b/src/test/ui/imports/issue-32354-suggest-import-rename.stderr
new file mode 100644
index 000000000..4c5875ba7
--- /dev/null
+++ b/src/test/ui/imports/issue-32354-suggest-import-rename.stderr
@@ -0,0 +1,17 @@
+error[E0252]: the name `ConstructorExtension` is defined multiple times
+ --> $DIR/issue-32354-suggest-import-rename.rs:14:5
+ |
+LL | use extension1::ConstructorExtension;
+ | -------------------------------- previous import of the trait `ConstructorExtension` here
+LL | use extension2::ConstructorExtension;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here
+ |
+ = note: `ConstructorExtension` 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 extension2::ConstructorExtension as OtherConstructorExtension;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/src/test/ui/imports/issue-32833.rs b/src/test/ui/imports/issue-32833.rs
new file mode 100644
index 000000000..379eedde7
--- /dev/null
+++ b/src/test/ui/imports/issue-32833.rs
@@ -0,0 +1,7 @@
+use bar::Foo; //~ ERROR unresolved import `bar::Foo` [E0432]
+ //~^ no `Foo` in `bar`
+mod bar {
+ use Foo;
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-32833.stderr b/src/test/ui/imports/issue-32833.stderr
new file mode 100644
index 000000000..430cc0fda
--- /dev/null
+++ b/src/test/ui/imports/issue-32833.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `bar::Foo`
+ --> $DIR/issue-32833.rs:1:5
+ |
+LL | use bar::Foo;
+ | ^^^^^^^^ no `Foo` in `bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-33464.rs b/src/test/ui/imports/issue-33464.rs
new file mode 100644
index 000000000..a0edb5fdb
--- /dev/null
+++ b/src/test/ui/imports/issue-33464.rs
@@ -0,0 +1,10 @@
+// Make sure that the spans of import errors are correct.
+
+use abc::one_el;
+//~^ ERROR
+use abc::{a, bbb, cccccc};
+//~^ ERROR
+use a_very_long_name::{el, el2};
+//~^ ERROR
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-33464.stderr b/src/test/ui/imports/issue-33464.stderr
new file mode 100644
index 000000000..c4e5c5558
--- /dev/null
+++ b/src/test/ui/imports/issue-33464.stderr
@@ -0,0 +1,27 @@
+error[E0432]: unresolved import `abc`
+ --> $DIR/issue-33464.rs:3:5
+ |
+LL | use abc::one_el;
+ | ^^^ maybe a missing crate `abc`?
+ |
+ = help: consider adding `extern crate abc` to use the `abc` crate
+
+error[E0432]: unresolved import `abc`
+ --> $DIR/issue-33464.rs:5:5
+ |
+LL | use abc::{a, bbb, cccccc};
+ | ^^^ maybe a missing crate `abc`?
+ |
+ = help: consider adding `extern crate abc` to use the `abc` crate
+
+error[E0432]: unresolved import `a_very_long_name`
+ --> $DIR/issue-33464.rs:7:5
+ |
+LL | use a_very_long_name::{el, el2};
+ | ^^^^^^^^^^^^^^^^ maybe a missing crate `a_very_long_name`?
+ |
+ = help: consider adding `extern crate a_very_long_name` to use the `a_very_long_name` crate
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-36881.rs b/src/test/ui/imports/issue-36881.rs
new file mode 100644
index 000000000..04313872d
--- /dev/null
+++ b/src/test/ui/imports/issue-36881.rs
@@ -0,0 +1,6 @@
+// aux-build:issue-36881-aux.rs
+
+fn main() {
+ extern crate issue_36881_aux;
+ use issue_36881_aux::Foo; //~ ERROR unresolved import
+}
diff --git a/src/test/ui/imports/issue-36881.stderr b/src/test/ui/imports/issue-36881.stderr
new file mode 100644
index 000000000..2e1b46860
--- /dev/null
+++ b/src/test/ui/imports/issue-36881.stderr
@@ -0,0 +1,11 @@
+error[E0432]: unresolved import `issue_36881_aux`
+ --> $DIR/issue-36881.rs:5:9
+ |
+LL | use issue_36881_aux::Foo;
+ | ^^^^^^^^^^^^^^^ maybe a missing crate `issue_36881_aux`?
+ |
+ = help: consider adding `extern crate issue_36881_aux` to use the `issue_36881_aux` crate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-37887.rs b/src/test/ui/imports/issue-37887.rs
new file mode 100644
index 000000000..58f0c6b65
--- /dev/null
+++ b/src/test/ui/imports/issue-37887.rs
@@ -0,0 +1,4 @@
+fn main() {
+ extern crate libc; //~ ERROR use of unstable
+ use libc::*; //~ ERROR unresolved import
+}
diff --git a/src/test/ui/imports/issue-37887.stderr b/src/test/ui/imports/issue-37887.stderr
new file mode 100644
index 000000000..75185cad3
--- /dev/null
+++ b/src/test/ui/imports/issue-37887.stderr
@@ -0,0 +1,21 @@
+error[E0432]: unresolved import `libc`
+ --> $DIR/issue-37887.rs:3:9
+ |
+LL | use libc::*;
+ | ^^^^ maybe a missing crate `libc`?
+ |
+ = help: consider adding `extern crate libc` to use the `libc` crate
+
+error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
+ --> $DIR/issue-37887.rs:2:5
+ |
+LL | extern crate libc;
+ | ^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information
+ = help: add `#![feature(rustc_private)]` to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0432, E0658.
+For more information about an error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-38293.rs b/src/test/ui/imports/issue-38293.rs
new file mode 100644
index 000000000..3b1393600
--- /dev/null
+++ b/src/test/ui/imports/issue-38293.rs
@@ -0,0 +1,16 @@
+// Test that `fn foo::bar::{self}` only imports `bar` in the type namespace.
+
+mod foo {
+ pub fn f() { }
+}
+use foo::f::{self}; //~ ERROR unresolved import `foo::f`
+
+mod bar {
+ pub fn baz() {}
+ pub mod baz {}
+}
+use bar::baz::{self};
+
+fn main() {
+ baz(); //~ ERROR expected function, found module `baz`
+}
diff --git a/src/test/ui/imports/issue-38293.stderr b/src/test/ui/imports/issue-38293.stderr
new file mode 100644
index 000000000..d2450ab12
--- /dev/null
+++ b/src/test/ui/imports/issue-38293.stderr
@@ -0,0 +1,21 @@
+error[E0432]: unresolved import `foo::f`
+ --> $DIR/issue-38293.rs:6:14
+ |
+LL | use foo::f::{self};
+ | ^^^^ no `f` in `foo`
+
+error[E0423]: expected function, found module `baz`
+ --> $DIR/issue-38293.rs:15:5
+ |
+LL | baz();
+ | ^^^ not a function
+ |
+help: consider importing this function instead
+ |
+LL | use bar::baz;
+ |
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0423, E0432.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/src/test/ui/imports/issue-4366-2.rs b/src/test/ui/imports/issue-4366-2.rs
new file mode 100644
index 000000000..c777b7502
--- /dev/null
+++ b/src/test/ui/imports/issue-4366-2.rs
@@ -0,0 +1,26 @@
+// ensures that 'use foo:*' doesn't import non-public item
+
+use m1::*;
+
+mod foo {
+ pub fn foo() {}
+}
+mod a {
+ pub mod b {
+ use foo::foo;
+ type Bar = isize;
+ }
+ pub mod sub {
+ use a::b::*;
+ fn sub() -> Bar { 1 }
+ //~^ ERROR cannot find type `Bar` in this scope
+ }
+}
+
+mod m1 {
+ fn foo() {}
+}
+
+fn main() {
+ foo(); //~ ERROR expected function, found module `foo`
+}
diff --git a/src/test/ui/imports/issue-4366-2.stderr b/src/test/ui/imports/issue-4366-2.stderr
new file mode 100644
index 000000000..4c94634ee
--- /dev/null
+++ b/src/test/ui/imports/issue-4366-2.stderr
@@ -0,0 +1,27 @@
+error[E0412]: cannot find type `Bar` in this scope
+ --> $DIR/issue-4366-2.rs:15:21
+ |
+LL | fn sub() -> Bar { 1 }
+ | ^^^ not found in this scope
+ |
+note: type alias `a::b::Bar` exists but is inaccessible
+ --> $DIR/issue-4366-2.rs:11:9
+ |
+LL | type Bar = isize;
+ | ^^^^^^^^^^^^^^^^^ not accessible
+
+error[E0423]: expected function, found module `foo`
+ --> $DIR/issue-4366-2.rs:25:5
+ |
+LL | foo();
+ | ^^^ not a function
+ |
+help: consider importing this function instead
+ |
+LL | use foo::foo;
+ |
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0412, E0423.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/src/test/ui/imports/issue-4366.rs b/src/test/ui/imports/issue-4366.rs
new file mode 100644
index 000000000..9ec2e58ec
--- /dev/null
+++ b/src/test/ui/imports/issue-4366.rs
@@ -0,0 +1,26 @@
+// regression test for issue 4366
+
+// ensures that 'use foo:*' doesn't import non-public 'use' statements in the
+// module 'foo'
+
+use m1::*;
+
+mod foo {
+ pub fn foo() {}
+}
+mod a {
+ pub mod b {
+ use foo::foo;
+ type Bar = isize;
+ }
+ pub mod sub {
+ use a::b::*;
+ fn sub() -> isize { foo(); 1 } //~ ERROR cannot find function `foo` in this scope
+ }
+}
+
+mod m1 {
+ fn foo() {}
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-4366.stderr b/src/test/ui/imports/issue-4366.stderr
new file mode 100644
index 000000000..469ea93e9
--- /dev/null
+++ b/src/test/ui/imports/issue-4366.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find function `foo` in this scope
+ --> $DIR/issue-4366.rs:18:29
+ |
+LL | fn sub() -> isize { foo(); 1 }
+ | ^^^ not found in this scope
+ |
+help: consider importing this function
+ |
+LL | use foo::foo;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed
new file mode 100644
index 000000000..b463848ae
--- /dev/null
+++ b/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed
@@ -0,0 +1,5 @@
+// run-rustfix
+
+extern crate std as other_std;
+fn main() {}
+//~^^ ERROR the name `std` is defined multiple times [E0259]
diff --git a/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs b/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs
new file mode 100644
index 000000000..1b491ac7e
--- /dev/null
+++ b/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs
@@ -0,0 +1,5 @@
+// run-rustfix
+
+extern crate std;
+fn main() {}
+//~^^ ERROR the name `std` is defined multiple times [E0259]
diff --git a/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr
new file mode 100644
index 000000000..25aca4cb7
--- /dev/null
+++ b/src/test/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr
@@ -0,0 +1,15 @@
+error[E0259]: the name `std` is defined multiple times
+ --> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:3:1
+ |
+LL | extern crate std;
+ | ^^^^^^^^^^^^^^^^^ `std` reimported here
+ |
+ = note: `std` 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 std as other_std;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0259`.
diff --git a/src/test/ui/imports/issue-45829/auxiliary/issue-45829-a.rs b/src/test/ui/imports/issue-45829/auxiliary/issue-45829-a.rs
new file mode 100644
index 000000000..e9f7fefb6
--- /dev/null
+++ b/src/test/ui/imports/issue-45829/auxiliary/issue-45829-a.rs
@@ -0,0 +1 @@
+pub const FOO: usize = *&0;
diff --git a/src/test/ui/imports/issue-45829/auxiliary/issue-45829-b.rs b/src/test/ui/imports/issue-45829/auxiliary/issue-45829-b.rs
new file mode 100644
index 000000000..e9f7fefb6
--- /dev/null
+++ b/src/test/ui/imports/issue-45829/auxiliary/issue-45829-b.rs
@@ -0,0 +1 @@
+pub const FOO: usize = *&0;
diff --git a/src/test/ui/imports/issue-45829/import-self.rs b/src/test/ui/imports/issue-45829/import-self.rs
new file mode 100644
index 000000000..2dc4331ce
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/import-self.stderr b/src/test/ui/imports/issue-45829/import-self.stderr
new file mode 100644
index 000000000..0c9424f30
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/import-twice.rs b/src/test/ui/imports/issue-45829/import-twice.rs
new file mode 100644
index 000000000..e5a8bb7ad
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/import-twice.stderr b/src/test/ui/imports/issue-45829/import-twice.stderr
new file mode 100644
index 000000000..656b011bc
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/issue-45829.rs b/src/test/ui/imports/issue-45829/issue-45829.rs
new file mode 100644
index 000000000..1e76e4b14
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/issue-45829.stderr b/src/test/ui/imports/issue-45829/issue-45829.stderr
new file mode 100644
index 000000000..e9a9d47ce
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-extern-vs-use.rs b/src/test/ui/imports/issue-45829/rename-extern-vs-use.rs
new file mode 100644
index 000000000..aef7aa35c
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-extern-vs-use.stderr b/src/test/ui/imports/issue-45829/rename-extern-vs-use.stderr
new file mode 100644
index 000000000..98fd8a623
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-extern-with-tab.rs b/src/test/ui/imports/issue-45829/rename-extern-with-tab.rs
new file mode 100644
index 000000000..0da8b826c
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-extern-with-tab.stderr b/src/test/ui/imports/issue-45829/rename-extern-with-tab.stderr
new file mode 100644
index 000000000..2c4e8ce99
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-extern.rs b/src/test/ui/imports/issue-45829/rename-extern.rs
new file mode 100644
index 000000000..7dbda6932
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-extern.stderr b/src/test/ui/imports/issue-45829/rename-extern.stderr
new file mode 100644
index 000000000..209ae2201
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-use-vs-extern.rs b/src/test/ui/imports/issue-45829/rename-use-vs-extern.rs
new file mode 100644
index 000000000..0cf3a77fd
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-use-vs-extern.stderr b/src/test/ui/imports/issue-45829/rename-use-vs-extern.stderr
new file mode 100644
index 000000000..dfb5810c4
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-use-with-tabs.rs b/src/test/ui/imports/issue-45829/rename-use-with-tabs.rs
new file mode 100644
index 000000000..86c5fa00f
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-use-with-tabs.stderr b/src/test/ui/imports/issue-45829/rename-use-with-tabs.stderr
new file mode 100644
index 000000000..5a63af588
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-with-path.rs b/src/test/ui/imports/issue-45829/rename-with-path.rs
new file mode 100644
index 000000000..e278a8789
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename-with-path.stderr b/src/test/ui/imports/issue-45829/rename-with-path.stderr
new file mode 100644
index 000000000..2d26b0838
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename.rs b/src/test/ui/imports/issue-45829/rename.rs
new file mode 100644
index 000000000..1c45956c6
--- /dev/null
+++ b/src/test/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/src/test/ui/imports/issue-45829/rename.stderr b/src/test/ui/imports/issue-45829/rename.stderr
new file mode 100644
index 000000000..ed185ae2a
--- /dev/null
+++ b/src/test/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`.
diff --git a/src/test/ui/imports/issue-47623.rs b/src/test/ui/imports/issue-47623.rs
new file mode 100644
index 000000000..ad8aa4c1a
--- /dev/null
+++ b/src/test/ui/imports/issue-47623.rs
@@ -0,0 +1,3 @@
+use self; //~ERROR `self` imports are only allowed within a { } list
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-47623.stderr b/src/test/ui/imports/issue-47623.stderr
new file mode 100644
index 000000000..53968a296
--- /dev/null
+++ b/src/test/ui/imports/issue-47623.stderr
@@ -0,0 +1,9 @@
+error[E0429]: `self` imports are only allowed within a { } list
+ --> $DIR/issue-47623.rs:1:5
+ |
+LL | use self;
+ | ^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0429`.
diff --git a/src/test/ui/imports/issue-4865-1.rs b/src/test/ui/imports/issue-4865-1.rs
new file mode 100644
index 000000000..68fbee37d
--- /dev/null
+++ b/src/test/ui/imports/issue-4865-1.rs
@@ -0,0 +1,33 @@
+// run-pass
+#![allow(unused_imports)]
+// This should resolve fine.
+// Prior to fix, the crossed imports between a and b
+// would block on the glob import, itself never being resolved
+// because these previous imports were not resolved.
+
+pub mod a {
+ use b::fn_b;
+ use c::*;
+
+ pub fn fn_a(){
+ }
+}
+
+pub mod b {
+ use a::fn_a;
+ use c::*;
+
+ pub fn fn_b(){
+ }
+}
+
+pub mod c{
+ pub fn fn_c(){
+ }
+}
+
+use a::fn_a;
+use b::fn_b;
+
+fn main() {
+}
diff --git a/src/test/ui/imports/issue-4865-2.rs b/src/test/ui/imports/issue-4865-2.rs
new file mode 100644
index 000000000..cbe1d0d32
--- /dev/null
+++ b/src/test/ui/imports/issue-4865-2.rs
@@ -0,0 +1,24 @@
+// run-pass
+// Previously, this would have failed to resolve due to the circular
+// block between `use say` and `pub use hello::*`.
+//
+// Now, as `use say` is not `pub`, the glob import can resolve
+// without any problem and this resolves fine.
+
+pub use hello::*;
+
+pub mod say {
+ pub fn hello() { println!("hello"); }
+}
+
+pub mod hello {
+ use say;
+
+ pub fn hello() {
+ say::hello();
+ }
+}
+
+fn main() {
+ hello();
+}
diff --git a/src/test/ui/imports/issue-4865-3.rs b/src/test/ui/imports/issue-4865-3.rs
new file mode 100644
index 000000000..12f9bba18
--- /dev/null
+++ b/src/test/ui/imports/issue-4865-3.rs
@@ -0,0 +1,17 @@
+// run-pass
+#![allow(unused_imports)]
+// This should resolve fine even with the circular imports as
+// they are not `pub`.
+
+pub mod a {
+ use b::*;
+}
+
+pub mod b {
+ use a::*;
+}
+
+use a::*;
+
+fn main() {
+}
diff --git a/src/test/ui/imports/issue-52891.fixed b/src/test/ui/imports/issue-52891.fixed
new file mode 100644
index 000000000..e694b5c9b
--- /dev/null
+++ b/src/test/ui/imports/issue-52891.fixed
@@ -0,0 +1,37 @@
+// aux-build:issue-52891.rs
+// run-rustfix
+
+#![allow(warnings)]
+
+extern crate issue_52891;
+
+// Check that we don't suggest renaming duplicate imports but instead
+// suggest removing one.
+
+use issue_52891::a;
+ //~ ERROR `a` is defined multiple times
+
+use issue_52891::{b, c}; //~ ERROR `a` is defined multiple times
+use issue_52891::{d, e}; //~ ERROR `a` is defined multiple times
+use issue_52891::{f, g}; //~ ERROR `a` is defined multiple times
+
+use issue_52891::{//~ ERROR `a` is defined multiple times
+ h,
+ i};
+use issue_52891::{j,
+ //~ ERROR `a` is defined multiple times
+ k};
+use issue_52891::{l,
+ m}; //~ ERROR `a` is defined multiple times
+
+use issue_52891::a::inner;
+use issue_52891::b::inner as other_inner; //~ ERROR `inner` is defined multiple times
+
+
+//~^ ERROR `issue_52891` is defined multiple times
+
+
+#[macro_use]
+use issue_52891::n; //~ ERROR `n` is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-52891.rs b/src/test/ui/imports/issue-52891.rs
new file mode 100644
index 000000000..cd4b40629
--- /dev/null
+++ b/src/test/ui/imports/issue-52891.rs
@@ -0,0 +1,38 @@
+// aux-build:issue-52891.rs
+// run-rustfix
+
+#![allow(warnings)]
+
+extern crate issue_52891;
+
+// Check that we don't suggest renaming duplicate imports but instead
+// suggest removing one.
+
+use issue_52891::a;
+use issue_52891::a; //~ ERROR `a` is defined multiple times
+
+use issue_52891::{a, b, c}; //~ ERROR `a` is defined multiple times
+use issue_52891::{d, a, e}; //~ ERROR `a` is defined multiple times
+use issue_52891::{f, g, a}; //~ ERROR `a` is defined multiple times
+
+use issue_52891::{a, //~ ERROR `a` is defined multiple times
+ h,
+ i};
+use issue_52891::{j,
+ a, //~ ERROR `a` is defined multiple times
+ k};
+use issue_52891::{l,
+ m,
+ a}; //~ ERROR `a` is defined multiple times
+
+use issue_52891::a::inner;
+use issue_52891::b::inner; //~ ERROR `inner` is defined multiple times
+
+use issue_52891::{self};
+//~^ ERROR `issue_52891` is defined multiple times
+
+use issue_52891::n;
+#[macro_use]
+use issue_52891::n; //~ ERROR `n` is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-52891.stderr b/src/test/ui/imports/issue-52891.stderr
new file mode 100644
index 000000000..7bb1301ed
--- /dev/null
+++ b/src/test/ui/imports/issue-52891.stderr
@@ -0,0 +1,131 @@
+error[E0252]: the name `a` is defined multiple times
+ --> $DIR/issue-52891.rs:12:5
+ |
+LL | use issue_52891::a;
+ | -------------- previous import of the module `a` here
+LL | use issue_52891::a;
+ | ^^^^^^^^^^^^^^ `a` reimported here
+ |
+ = note: `a` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `a` is defined multiple times
+ --> $DIR/issue-52891.rs:14:19
+ |
+LL | use issue_52891::a;
+ | -------------- previous import of the module `a` here
+...
+LL | use issue_52891::{a, b, c};
+ | ^--
+ | |
+ | `a` reimported here
+ | help: remove unnecessary import
+ |
+ = note: `a` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `a` is defined multiple times
+ --> $DIR/issue-52891.rs:15:22
+ |
+LL | use issue_52891::a;
+ | -------------- previous import of the module `a` here
+...
+LL | use issue_52891::{d, a, e};
+ | ^--
+ | |
+ | `a` reimported here
+ | help: remove unnecessary import
+ |
+ = note: `a` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `a` is defined multiple times
+ --> $DIR/issue-52891.rs:16:25
+ |
+LL | use issue_52891::a;
+ | -------------- previous import of the module `a` here
+...
+LL | use issue_52891::{f, g, a};
+ | ^ `a` reimported here
+ |
+ = note: `a` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `a` is defined multiple times
+ --> $DIR/issue-52891.rs:18:19
+ |
+LL | use issue_52891::a;
+ | -------------- previous import of the module `a` here
+...
+LL | use issue_52891::{a,
+ | ^--
+ | |
+ | `a` reimported here
+ | help: remove unnecessary import
+ |
+ = note: `a` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `a` is defined multiple times
+ --> $DIR/issue-52891.rs:22:5
+ |
+LL | use issue_52891::a;
+ | -------------- previous import of the module `a` here
+...
+LL | a,
+ | ^--
+ | |
+ | `a` reimported here
+ | help: remove unnecessary import
+ |
+ = note: `a` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `a` is defined multiple times
+ --> $DIR/issue-52891.rs:26:5
+ |
+LL | use issue_52891::a;
+ | -------------- previous import of the module `a` here
+...
+LL | a};
+ | ^ `a` reimported here
+ |
+ = note: `a` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `inner` is defined multiple times
+ --> $DIR/issue-52891.rs:29:5
+ |
+LL | use issue_52891::a::inner;
+ | --------------------- previous import of the module `inner` here
+LL | use issue_52891::b::inner;
+ | ^^^^^^^^^^^^^^^^^^^^^ `inner` reimported here
+ |
+ = note: `inner` 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 issue_52891::b::inner as other_inner;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0254]: the name `issue_52891` is defined multiple times
+ --> $DIR/issue-52891.rs:31:19
+ |
+LL | extern crate issue_52891;
+ | ------------------------- previous import of the extern crate `issue_52891` here
+...
+LL | use issue_52891::{self};
+ | ------------------^^^^--
+ | | |
+ | | `issue_52891` reimported here
+ | help: remove unnecessary import
+ |
+ = note: `issue_52891` must be defined only once in the type namespace of this module
+
+error[E0252]: the name `n` is defined multiple times
+ --> $DIR/issue-52891.rs:36:5
+ |
+LL | use issue_52891::n;
+ | -------------- previous import of the module `n` here
+LL | #[macro_use]
+LL | use issue_52891::n;
+ | ^^^^^^^^^^^^^^ `n` reimported here
+ |
+ = note: `n` must be defined only once in the type namespace of this module
+
+error: aborting due to 10 previous errors
+
+Some errors have detailed explanations: E0252, E0254.
+For more information about an error, try `rustc --explain E0252`.
diff --git a/src/test/ui/imports/issue-53140.rs b/src/test/ui/imports/issue-53140.rs
new file mode 100644
index 000000000..7b4cc1768
--- /dev/null
+++ b/src/test/ui/imports/issue-53140.rs
@@ -0,0 +1,11 @@
+// check-pass
+
+mod m {
+ pub struct S(u8);
+
+ use S as Z;
+}
+
+use m::*;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-53269.rs b/src/test/ui/imports/issue-53269.rs
new file mode 100644
index 000000000..1031d5071
--- /dev/null
+++ b/src/test/ui/imports/issue-53269.rs
@@ -0,0 +1,11 @@
+// Ambiguity between a `macro_rules` macro and a non-existent import recovered as `Res::Err`
+
+macro_rules! mac { () => () }
+
+mod m {
+ use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
+
+ mac!(); //~ ERROR `mac` is ambiguous
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-53269.stderr b/src/test/ui/imports/issue-53269.stderr
new file mode 100644
index 000000000..29c7556da
--- /dev/null
+++ b/src/test/ui/imports/issue-53269.stderr
@@ -0,0 +1,31 @@
+error[E0432]: unresolved import `nonexistent_module`
+ --> $DIR/issue-53269.rs:6:9
+ |
+LL | use nonexistent_module::mac;
+ | ^^^^^^^^^^^^^^^^^^ maybe a missing crate `nonexistent_module`?
+ |
+ = help: consider adding `extern crate nonexistent_module` to use the `nonexistent_module` crate
+
+error[E0659]: `mac` is ambiguous
+ --> $DIR/issue-53269.rs:8:5
+ |
+LL | mac!();
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a `macro_rules` name and a non-`macro_rules` name from another module
+note: `mac` could refer to the macro defined here
+ --> $DIR/issue-53269.rs:3:1
+ |
+LL | macro_rules! mac { () => () }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: `mac` could also refer to the unresolved item imported here
+ --> $DIR/issue-53269.rs:6:9
+ |
+LL | use nonexistent_module::mac;
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ = help: use `self::mac` to refer to this unresolved item unambiguously
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0432, E0659.
+For more information about an error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-53512.rs b/src/test/ui/imports/issue-53512.rs
new file mode 100644
index 000000000..67470f854
--- /dev/null
+++ b/src/test/ui/imports/issue-53512.rs
@@ -0,0 +1,8 @@
+// Macro from prelude is shadowed by non-existent import recovered as `Res::Err`.
+
+mod m {}
+use m::assert; //~ ERROR unresolved import `m::assert`
+
+fn main() {
+ assert!(true);
+}
diff --git a/src/test/ui/imports/issue-53512.stderr b/src/test/ui/imports/issue-53512.stderr
new file mode 100644
index 000000000..05fe111b3
--- /dev/null
+++ b/src/test/ui/imports/issue-53512.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `m::assert`
+ --> $DIR/issue-53512.rs:4:5
+ |
+LL | use m::assert;
+ | ^^^^^^^^^ no `assert` in `m`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-53565.rs b/src/test/ui/imports/issue-53565.rs
new file mode 100644
index 000000000..114a53a92
--- /dev/null
+++ b/src/test/ui/imports/issue-53565.rs
@@ -0,0 +1,7 @@
+use std::time::{foo, bar, buzz};
+//~^ ERROR unresolved imports
+use std::time::{abc, def};
+//~^ ERROR unresolved imports
+fn main(){
+ println!("Hello World!");
+}
diff --git a/src/test/ui/imports/issue-53565.stderr b/src/test/ui/imports/issue-53565.stderr
new file mode 100644
index 000000000..71c3b2aaa
--- /dev/null
+++ b/src/test/ui/imports/issue-53565.stderr
@@ -0,0 +1,20 @@
+error[E0432]: unresolved imports `std::time::foo`, `std::time::bar`, `std::time::buzz`
+ --> $DIR/issue-53565.rs:1:17
+ |
+LL | use std::time::{foo, bar, buzz};
+ | ^^^ ^^^ ^^^^ no `buzz` in `time`
+ | | |
+ | | no `bar` in `time`
+ | no `foo` in `time`
+
+error[E0432]: unresolved imports `std::time::abc`, `std::time::def`
+ --> $DIR/issue-53565.rs:3:17
+ |
+LL | use std::time::{abc, def};
+ | ^^^ ^^^ no `def` in `time`
+ | |
+ | no `abc` in `time`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-55457.rs b/src/test/ui/imports/issue-55457.rs
new file mode 100644
index 000000000..c1f048897
--- /dev/null
+++ b/src/test/ui/imports/issue-55457.rs
@@ -0,0 +1,10 @@
+use NonExistent; //~ ERROR unresolved import `NonExistent`
+use non_existent::non_existent; //~ ERROR unresolved import `non_existent`
+
+#[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent`
+#[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent`
+ //~| ERROR cannot determine resolution for the derive macro `NonExistent`
+ //~| ERROR cannot determine resolution for the derive macro `NonExistent`
+struct S;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-55457.stderr b/src/test/ui/imports/issue-55457.stderr
new file mode 100644
index 000000000..788fcc830
--- /dev/null
+++ b/src/test/ui/imports/issue-55457.stderr
@@ -0,0 +1,52 @@
+error[E0432]: unresolved import `NonExistent`
+ --> $DIR/issue-55457.rs:1:5
+ |
+LL | use NonExistent;
+ | ^^^^^^^^^^^
+ | |
+ | no `NonExistent` in the root
+ | help: a similar name exists in the module: `non_existent`
+
+error[E0432]: unresolved import `non_existent`
+ --> $DIR/issue-55457.rs:2:5
+ |
+LL | use non_existent::non_existent;
+ | ^^^^^^^^^^^^ maybe a missing crate `non_existent`?
+ |
+ = help: consider adding `extern crate non_existent` to use the `non_existent` crate
+
+error: cannot determine resolution for the derive macro `NonExistent`
+ --> $DIR/issue-55457.rs:5:10
+ |
+LL | #[derive(NonExistent)]
+ | ^^^^^^^^^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error: cannot determine resolution for the attribute macro `non_existent`
+ --> $DIR/issue-55457.rs:4:3
+ |
+LL | #[non_existent]
+ | ^^^^^^^^^^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error: cannot determine resolution for the derive macro `NonExistent`
+ --> $DIR/issue-55457.rs:5:10
+ |
+LL | #[derive(NonExistent)]
+ | ^^^^^^^^^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error: cannot determine resolution for the derive macro `NonExistent`
+ --> $DIR/issue-55457.rs:5:10
+ |
+LL | #[derive(NonExistent)]
+ | ^^^^^^^^^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-55811.rs b/src/test/ui/imports/issue-55811.rs
new file mode 100644
index 000000000..2df328cca
--- /dev/null
+++ b/src/test/ui/imports/issue-55811.rs
@@ -0,0 +1,6 @@
+// check-pass
+// aux-build:issue-55811.rs
+
+extern crate issue_55811;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-55884-1.rs b/src/test/ui/imports/issue-55884-1.rs
new file mode 100644
index 000000000..21744aa5d
--- /dev/null
+++ b/src/test/ui/imports/issue-55884-1.rs
@@ -0,0 +1,21 @@
+mod m {
+ mod m1 {
+ pub struct S {}
+ }
+ mod m2 {
+ // Note this derive, it makes this struct macro-expanded,
+ // so it doesn't appear in time to participate in the initial resolution of `use m::S`,
+ // only in the later validation pass.
+ #[derive(Default)]
+ pub struct S {}
+ }
+
+ // Create a glob vs glob ambiguity
+ pub use self::m1::*;
+ pub use self::m2::*;
+}
+
+fn main() {
+ use m::S; //~ ERROR `S` is ambiguous
+ let s = S {};
+}
diff --git a/src/test/ui/imports/issue-55884-1.stderr b/src/test/ui/imports/issue-55884-1.stderr
new file mode 100644
index 000000000..c38166dde
--- /dev/null
+++ b/src/test/ui/imports/issue-55884-1.stderr
@@ -0,0 +1,23 @@
+error[E0659]: `S` is ambiguous
+ --> $DIR/issue-55884-1.rs:19:12
+ |
+LL | use m::S;
+ | ^ ambiguous name
+ |
+ = note: ambiguous because of multiple glob imports of a name in the same module
+note: `S` could refer to the struct imported here
+ --> $DIR/issue-55884-1.rs:14:13
+ |
+LL | pub use self::m1::*;
+ | ^^^^^^^^^^^
+ = help: consider adding an explicit import of `S` to disambiguate
+note: `S` could also refer to the struct imported here
+ --> $DIR/issue-55884-1.rs:15:13
+ |
+LL | pub use self::m2::*;
+ | ^^^^^^^^^^^
+ = help: consider adding an explicit import of `S` to disambiguate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/issue-55884-2.rs b/src/test/ui/imports/issue-55884-2.rs
new file mode 100644
index 000000000..75bb4206f
--- /dev/null
+++ b/src/test/ui/imports/issue-55884-2.rs
@@ -0,0 +1,14 @@
+mod options {
+ pub struct ParseOptions {}
+}
+
+mod parser {
+ pub use options::*;
+ // Private single import shadows public glob import, but arrives too late for initial
+ // resolution of `use parser::ParseOptions` because it depends on that resolution itself.
+ use ParseOptions;
+}
+
+pub use parser::ParseOptions; //~ ERROR struct import `ParseOptions` is private
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-55884-2.stderr b/src/test/ui/imports/issue-55884-2.stderr
new file mode 100644
index 000000000..5adbc4b66
--- /dev/null
+++ b/src/test/ui/imports/issue-55884-2.stderr
@@ -0,0 +1,30 @@
+error[E0603]: struct import `ParseOptions` is private
+ --> $DIR/issue-55884-2.rs:12:17
+ |
+LL | pub use parser::ParseOptions;
+ | ^^^^^^^^^^^^ private struct import
+ |
+note: the struct import `ParseOptions` is defined here...
+ --> $DIR/issue-55884-2.rs:9:9
+ |
+LL | use ParseOptions;
+ | ^^^^^^^^^^^^
+note: ...and refers to the struct import `ParseOptions` which is defined here...
+ --> $DIR/issue-55884-2.rs:12:9
+ |
+LL | pub use parser::ParseOptions;
+ | ^^^^^^^^^^^^^^^^^^^^ consider importing it directly
+note: ...and refers to the struct import `ParseOptions` which is defined here...
+ --> $DIR/issue-55884-2.rs:6:13
+ |
+LL | pub use options::*;
+ | ^^^^^^^^^^ consider importing it directly
+note: ...and refers to the struct `ParseOptions` which is defined here
+ --> $DIR/issue-55884-2.rs:2:5
+ |
+LL | pub struct ParseOptions {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^ consider importing it directly
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0603`.
diff --git a/src/test/ui/imports/issue-56125.rs b/src/test/ui/imports/issue-56125.rs
new file mode 100644
index 000000000..ec5747b4b
--- /dev/null
+++ b/src/test/ui/imports/issue-56125.rs
@@ -0,0 +1,21 @@
+// edition:2018
+// compile-flags:--extern issue_56125
+// aux-build:issue-56125.rs
+
+mod m1 {
+ use issue_56125::last_segment::*;
+ //~^ ERROR `issue_56125` is ambiguous
+}
+
+mod m2 {
+ use issue_56125::non_last_segment::non_last_segment::*;
+ //~^ ERROR `issue_56125` is ambiguous
+}
+
+mod m3 {
+ mod empty {}
+ use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125`
+ use issue_56125::*; //~ ERROR `issue_56125` is ambiguous
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-56125.stderr b/src/test/ui/imports/issue-56125.stderr
new file mode 100644
index 000000000..2e4ba8623
--- /dev/null
+++ b/src/test/ui/imports/issue-56125.stderr
@@ -0,0 +1,58 @@
+error[E0432]: unresolved import `empty::issue_56125`
+ --> $DIR/issue-56125.rs:17:9
+ |
+LL | use empty::issue_56125;
+ | ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty`
+
+error[E0659]: `issue_56125` is ambiguous
+ --> $DIR/issue-56125.rs:6:9
+ |
+LL | use issue_56125::last_segment::*;
+ | ^^^^^^^^^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple potential import sources
+ = note: `issue_56125` could refer to a crate passed with `--extern`
+ = help: use `::issue_56125` to refer to this crate unambiguously
+note: `issue_56125` could also refer to the module imported here
+ --> $DIR/issue-56125.rs:6:9
+ |
+LL | use issue_56125::last_segment::*;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: use `self::issue_56125` to refer to this module unambiguously
+
+error[E0659]: `issue_56125` is ambiguous
+ --> $DIR/issue-56125.rs:11:9
+ |
+LL | use issue_56125::non_last_segment::non_last_segment::*;
+ | ^^^^^^^^^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple potential import sources
+ = note: `issue_56125` could refer to a crate passed with `--extern`
+ = help: use `::issue_56125` to refer to this crate unambiguously
+note: `issue_56125` could also refer to the module imported here
+ --> $DIR/issue-56125.rs:11:9
+ |
+LL | use issue_56125::non_last_segment::non_last_segment::*;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: use `self::issue_56125` to refer to this module unambiguously
+
+error[E0659]: `issue_56125` is ambiguous
+ --> $DIR/issue-56125.rs:18:9
+ |
+LL | use issue_56125::*;
+ | ^^^^^^^^^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple potential import sources
+ = note: `issue_56125` could refer to a crate passed with `--extern`
+ = help: use `::issue_56125` to refer to this crate unambiguously
+note: `issue_56125` could also refer to the module imported here
+ --> $DIR/issue-56125.rs:18:9
+ |
+LL | use issue_56125::*;
+ | ^^^^^^^^^^^^^^
+ = help: use `self::issue_56125` to refer to this module unambiguously
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0432, E0659.
+For more information about an error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-56263.rs b/src/test/ui/imports/issue-56263.rs
new file mode 100644
index 000000000..363781f2d
--- /dev/null
+++ b/src/test/ui/imports/issue-56263.rs
@@ -0,0 +1,8 @@
+// check-pass
+// edition:2018
+
+use ::std;
+
+fn main() {
+ let std = 10;
+}
diff --git a/src/test/ui/imports/issue-57015.rs b/src/test/ui/imports/issue-57015.rs
new file mode 100644
index 000000000..27688fd34
--- /dev/null
+++ b/src/test/ui/imports/issue-57015.rs
@@ -0,0 +1,13 @@
+mod glob_ok {
+ pub mod something {
+ pub mod something_else {}
+ }
+}
+
+mod single_err {}
+
+use glob_ok::*; // glob_ok::something
+use single_err::something; //~ ERROR unresolved import `single_err::something`
+use something::something_else;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-57015.stderr b/src/test/ui/imports/issue-57015.stderr
new file mode 100644
index 000000000..d200d23ab
--- /dev/null
+++ b/src/test/ui/imports/issue-57015.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `single_err::something`
+ --> $DIR/issue-57015.rs:10:5
+ |
+LL | use single_err::something;
+ | ^^^^^^^^^^^^^^^^^^^^^ no `something` in `single_err`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-57539.rs b/src/test/ui/imports/issue-57539.rs
new file mode 100644
index 000000000..90b74eb46
--- /dev/null
+++ b/src/test/ui/imports/issue-57539.rs
@@ -0,0 +1,8 @@
+// edition:2018
+
+mod core {
+ use core; //~ ERROR `core` is ambiguous
+ use crate::*;
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-57539.stderr b/src/test/ui/imports/issue-57539.stderr
new file mode 100644
index 000000000..1a3ca4eda
--- /dev/null
+++ b/src/test/ui/imports/issue-57539.stderr
@@ -0,0 +1,19 @@
+error[E0659]: `core` is ambiguous
+ --> $DIR/issue-57539.rs:4:9
+ |
+LL | use core;
+ | ^^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple potential import sources
+ = note: `core` could refer to a built-in crate
+ = help: use `::core` to refer to this crate unambiguously
+note: `core` could also refer to the module imported here
+ --> $DIR/issue-57539.rs:5:9
+ |
+LL | use crate::*;
+ | ^^^^^^^^
+ = help: use `self::core` to refer to this module unambiguously
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/issue-59764.rs b/src/test/ui/imports/issue-59764.rs
new file mode 100644
index 000000000..09dee8c27
--- /dev/null
+++ b/src/test/ui/imports/issue-59764.rs
@@ -0,0 +1,136 @@
+// aux-build:issue-59764.rs
+// compile-flags:--extern issue_59764
+// edition:2018
+
+#![allow(warnings)]
+
+// This tests the suggestion to import macros from the root of a crate. This aims to capture
+// the case where a user attempts to import a macro from the definition location instead of the
+// root of the crate and the macro is annotated with `#![macro_export]`.
+
+// Edge cases..
+
+mod multiple_imports_same_line_at_end {
+ use issue_59764::foo::{baz, makro};
+ //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+}
+
+mod multiple_imports_multiline_at_end_trailing_comma {
+ use issue_59764::foo::{
+ baz,
+ makro, //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+ };
+}
+
+mod multiple_imports_multiline_at_end {
+ use issue_59764::foo::{
+ baz,
+ makro //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+ };
+}
+
+mod multiple_imports_same_line_in_middle {
+ use issue_59764::foo::{baz, makro, foobar};
+ //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+}
+
+mod multiple_imports_multiline_in_middle_trailing_comma {
+ use issue_59764::foo::{
+ baz,
+ makro, //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+ foobar,
+ };
+}
+
+mod multiple_imports_multiline_in_middle {
+ use issue_59764::foo::{
+ baz,
+ makro, //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+ foobar
+ };
+}
+
+mod nested_imports {
+ use issue_59764::{foobaz, foo::makro};
+ //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+}
+
+mod nested_multiple_imports {
+ use issue_59764::{foobaz, foo::{baz, makro}};
+ //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+}
+
+mod nested_multiline_multiple_imports_trailing_comma {
+ use issue_59764::{
+ foobaz,
+ foo::{
+ baz,
+ makro, //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+ },
+ };
+}
+
+mod nested_multiline_multiple_imports {
+ use issue_59764::{
+ foobaz,
+ foo::{
+ baz,
+ makro //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+ }
+ };
+}
+
+mod doubly_nested_multiple_imports {
+ use issue_59764::{foobaz, foo::{baz, makro, barbaz::{barfoo}}};
+ //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+}
+
+mod doubly_multiline_nested_multiple_imports {
+ use issue_59764::{
+ foobaz,
+ foo::{
+ baz,
+ makro, //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+ barbaz::{
+ barfoo,
+ }
+ }
+ };
+}
+
+mod renamed_import {
+ use issue_59764::foo::makro as baz;
+ //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+}
+
+mod renamed_multiple_imports {
+ use issue_59764::foo::{baz, makro as foobar};
+ //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+}
+
+mod lots_of_whitespace {
+ use
+ issue_59764::{
+
+ foobaz,
+
+
+ foo::{baz,
+
+ makro as foobar} //~ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+
+ };
+}
+
+// Simple case..
+
+use issue_59764::foo::makro;
+//~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
+
+makro!(bar);
+//~^ ERROR cannot determine resolution for the macro `makro`
+
+fn main() {
+ bar();
+ //~^ ERROR cannot find function `bar` in this scope [E0425]
+}
diff --git a/src/test/ui/imports/issue-59764.stderr b/src/test/ui/imports/issue-59764.stderr
new file mode 100644
index 000000000..b969515e2
--- /dev/null
+++ b/src/test/ui/imports/issue-59764.stderr
@@ -0,0 +1,246 @@
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:14:33
+ |
+LL | use issue_59764::foo::{baz, makro};
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL - use issue_59764::foo::{baz, makro};
+LL + use issue_59764::{makro, foo::{baz}};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:21:9
+ |
+LL | makro,
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ use issue_59764::{makro, foo::{
+LL | baz,
+LL ~
+LL ~ }};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:28:9
+ |
+LL | makro
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ use issue_59764::{makro, foo::{
+LL | baz,
+LL ~
+LL ~ }};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:33:33
+ |
+LL | use issue_59764::foo::{baz, makro, foobar};
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL - use issue_59764::foo::{baz, makro, foobar};
+LL + use issue_59764::{makro, foo::{baz, foobar}};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:40:9
+ |
+LL | makro,
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ use issue_59764::{makro, foo::{
+LL | baz,
+LL ~
+LL | foobar,
+LL ~ }};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:48:9
+ |
+LL | makro,
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ use issue_59764::{makro, foo::{
+LL | baz,
+LL ~
+LL | foobar
+LL ~ }};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:54:31
+ |
+LL | use issue_59764::{foobaz, foo::makro};
+ | ^^^^^^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL - use issue_59764::{foobaz, foo::makro};
+LL + use issue_59764::{makro, foobaz};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:59:42
+ |
+LL | use issue_59764::{foobaz, foo::{baz, makro}};
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL - use issue_59764::{foobaz, foo::{baz, makro}};
+LL + use issue_59764::{makro, foobaz, foo::{baz}};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:68:13
+ |
+LL | makro,
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ use issue_59764::{makro,
+LL | foobaz,
+LL | foo::{
+LL | baz,
+LL ~
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:78:13
+ |
+LL | makro
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ use issue_59764::{makro,
+LL | foobaz,
+LL | foo::{
+LL | baz,
+LL ~
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:84:42
+ |
+LL | use issue_59764::{foobaz, foo::{baz, makro, barbaz::{barfoo}}};
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL - use issue_59764::{foobaz, foo::{baz, makro, barbaz::{barfoo}}};
+LL + use issue_59764::{makro, foobaz, foo::{baz, barbaz::{barfoo}}};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:93:13
+ |
+LL | makro,
+ | ^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ use issue_59764::{makro,
+LL | foobaz,
+LL | foo::{
+LL | baz,
+LL ~
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:102:9
+ |
+LL | use issue_59764::foo::makro as baz;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL | use issue_59764::makro as baz;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:107:33
+ |
+LL | use issue_59764::foo::{baz, makro as foobar};
+ | ^^^^^^^^^^^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL - use issue_59764::foo::{baz, makro as foobar};
+LL + use issue_59764::{makro as foobar, foo::{baz}};
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:120:17
+ |
+LL | makro as foobar}
+ | ^^^^^^^^^^^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL ~ issue_59764::{makro as foobar,
+LL |
+ ...
+LL |
+LL ~ foo::{baz}
+ |
+
+error[E0432]: unresolved import `issue_59764::foo::makro`
+ --> $DIR/issue-59764.rs:127:5
+ |
+LL | use issue_59764::foo::makro;
+ | ^^^^^^^^^^^^^^^^^^^^^^^ no `makro` in `foo`
+ |
+ = note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
+help: a macro with this name exists at the root of the crate
+ |
+LL | use issue_59764::makro;
+ | ~~~~~~~~~~~~~~~~~~
+
+error: cannot determine resolution for the macro `makro`
+ --> $DIR/issue-59764.rs:130:1
+ |
+LL | makro!(bar);
+ | ^^^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error[E0425]: cannot find function `bar` in this scope
+ --> $DIR/issue-59764.rs:134:5
+ |
+LL | bar();
+ | ^^^ not found in this scope
+
+error: aborting due to 18 previous errors
+
+Some errors have detailed explanations: E0425, E0432.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/src/test/ui/imports/issue-62767.rs b/src/test/ui/imports/issue-62767.rs
new file mode 100644
index 000000000..01184eea9
--- /dev/null
+++ b/src/test/ui/imports/issue-62767.rs
@@ -0,0 +1,30 @@
+// check-pass
+
+// Minimized case from #62767.
+mod m {
+ pub enum Same {
+ Same,
+ }
+}
+
+use m::*;
+
+// The variant `Same` introduced by this import is also considered when resolving the prefix
+// `Same::` during import validation to avoid effects similar to time travel (#74556).
+use Same::Same;
+
+// Case from #74556.
+mod foo {
+ pub mod bar {
+ pub mod bar {
+ pub fn foobar() {}
+ }
+ }
+}
+
+use foo::*;
+use bar::bar;
+
+use bar::foobar;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-68103.rs b/src/test/ui/imports/issue-68103.rs
new file mode 100644
index 000000000..e775678fc
--- /dev/null
+++ b/src/test/ui/imports/issue-68103.rs
@@ -0,0 +1,6 @@
+// check-pass
+
+pub extern crate self as name;
+pub use name::name as bug;
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-8208.rs b/src/test/ui/imports/issue-8208.rs
new file mode 100644
index 000000000..1c566938f
--- /dev/null
+++ b/src/test/ui/imports/issue-8208.rs
@@ -0,0 +1,17 @@
+use self::*; //~ ERROR: unresolved import `self::*` [E0432]
+ //~^ cannot glob-import a module into itself
+
+mod foo {
+ use foo::*; //~ ERROR: unresolved import `foo::*` [E0432]
+ //~^ cannot glob-import a module into itself
+
+ mod bar {
+ use super::bar::*;
+ //~^ ERROR: unresolved import `super::bar::*` [E0432]
+ //~| cannot glob-import a module into itself
+ }
+
+}
+
+fn main() {
+}
diff --git a/src/test/ui/imports/issue-8208.stderr b/src/test/ui/imports/issue-8208.stderr
new file mode 100644
index 000000000..e59aea12c
--- /dev/null
+++ b/src/test/ui/imports/issue-8208.stderr
@@ -0,0 +1,21 @@
+error[E0432]: unresolved import `self::*`
+ --> $DIR/issue-8208.rs:1:5
+ |
+LL | use self::*;
+ | ^^^^^^^ cannot glob-import a module into itself
+
+error[E0432]: unresolved import `foo::*`
+ --> $DIR/issue-8208.rs:5:9
+ |
+LL | use foo::*;
+ | ^^^^^^ cannot glob-import a module into itself
+
+error[E0432]: unresolved import `super::bar::*`
+ --> $DIR/issue-8208.rs:9:13
+ |
+LL | use super::bar::*;
+ | ^^^^^^^^^^^^^ cannot glob-import a module into itself
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/issue-8640.rs b/src/test/ui/imports/issue-8640.rs
new file mode 100644
index 000000000..51a02a32e
--- /dev/null
+++ b/src/test/ui/imports/issue-8640.rs
@@ -0,0 +1,10 @@
+#[allow(unused_imports)]
+
+mod foo {
+ use baz::bar;
+ mod bar {}
+ //~^ ERROR the name `bar` is defined multiple times
+}
+mod baz { pub mod bar {} }
+
+fn main() {}
diff --git a/src/test/ui/imports/issue-8640.stderr b/src/test/ui/imports/issue-8640.stderr
new file mode 100644
index 000000000..ab44f067f
--- /dev/null
+++ b/src/test/ui/imports/issue-8640.stderr
@@ -0,0 +1,17 @@
+error[E0255]: the name `bar` is defined multiple times
+ --> $DIR/issue-8640.rs:5:5
+ |
+LL | use baz::bar;
+ | -------- previous import of the module `bar` here
+LL | mod bar {}
+ | ^^^^^^^ `bar` redefined 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 | use baz::bar as other_bar;
+ | ~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0255`.
diff --git a/src/test/ui/imports/local-modularized-tricky-fail-1.rs b/src/test/ui/imports/local-modularized-tricky-fail-1.rs
new file mode 100644
index 000000000..37fe0ecee
--- /dev/null
+++ b/src/test/ui/imports/local-modularized-tricky-fail-1.rs
@@ -0,0 +1,47 @@
+#![feature(decl_macro)]
+
+macro_rules! define_exported { () => {
+ #[macro_export]
+ macro_rules! exported {
+ () => ()
+ }
+}}
+macro_rules! define_panic { () => {
+ #[macro_export]
+ macro_rules! panic {
+ () => ()
+ }
+}}
+macro_rules! define_include { () => {
+ #[macro_export]
+ macro_rules! include {
+ () => ()
+ }
+}}
+
+use inner1::*;
+
+mod inner1 {
+ pub macro exported() {}
+}
+
+exported!(); //~ ERROR `exported` is ambiguous
+ //~| ERROR `exported` is ambiguous
+
+mod inner2 {
+ define_exported!();
+}
+
+fn main() {
+ panic!(); //~ ERROR `panic` is ambiguous
+}
+
+mod inner3 {
+ define_panic!();
+}
+
+mod inner4 {
+ define_include!();
+}
+
+include!(); //~ ERROR `include` is ambiguous
diff --git a/src/test/ui/imports/local-modularized-tricky-fail-1.stderr b/src/test/ui/imports/local-modularized-tricky-fail-1.stderr
new file mode 100644
index 000000000..c048d2ea2
--- /dev/null
+++ b/src/test/ui/imports/local-modularized-tricky-fail-1.stderr
@@ -0,0 +1,95 @@
+error[E0659]: `exported` is ambiguous
+ --> $DIR/local-modularized-tricky-fail-1.rs:28:1
+ |
+LL | exported!();
+ | ^^^^^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
+note: `exported` could refer to the macro defined here
+ --> $DIR/local-modularized-tricky-fail-1.rs:5:5
+ |
+LL | / macro_rules! exported {
+LL | | () => ()
+LL | | }
+ | |_____^
+...
+LL | define_exported!();
+ | ------------------ in this macro invocation
+note: `exported` could also refer to the macro imported here
+ --> $DIR/local-modularized-tricky-fail-1.rs:22:5
+ |
+LL | use inner1::*;
+ | ^^^^^^^^^
+ = help: consider adding an explicit import of `exported` to disambiguate
+ = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0659]: `exported` is ambiguous
+ --> $DIR/local-modularized-tricky-fail-1.rs:28:1
+ |
+LL | exported!();
+ | ^^^^^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
+note: `exported` could refer to the macro defined here
+ --> $DIR/local-modularized-tricky-fail-1.rs:5:5
+ |
+LL | / macro_rules! exported {
+LL | | () => ()
+LL | | }
+ | |_____^
+...
+LL | define_exported!();
+ | ------------------ in this macro invocation
+note: `exported` could also refer to the macro imported here
+ --> $DIR/local-modularized-tricky-fail-1.rs:22:5
+ |
+LL | use inner1::*;
+ | ^^^^^^^^^
+ = help: consider adding an explicit import of `exported` to disambiguate
+ = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0659]: `panic` is ambiguous
+ --> $DIR/local-modularized-tricky-fail-1.rs:36:5
+ |
+LL | panic!();
+ | ^^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
+ = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro defined here
+ --> $DIR/local-modularized-tricky-fail-1.rs:11:5
+ |
+LL | / macro_rules! panic {
+LL | | () => ()
+LL | | }
+ | |_____^
+...
+LL | define_panic!();
+ | --------------- in this macro invocation
+ = help: use `crate::panic` to refer to this macro unambiguously
+ = note: this error originates in the macro `define_panic` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0659]: `include` is ambiguous
+ --> $DIR/local-modularized-tricky-fail-1.rs:47:1
+ |
+LL | include!();
+ | ^^^^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
+ = note: `include` could refer to a macro from prelude
+note: `include` could also refer to the macro defined here
+ --> $DIR/local-modularized-tricky-fail-1.rs:17:5
+ |
+LL | / macro_rules! include {
+LL | | () => ()
+LL | | }
+ | |_____^
+...
+LL | define_include!();
+ | ----------------- in this macro invocation
+ = help: use `crate::include` to refer to this macro unambiguously
+ = note: this error originates in the macro `define_include` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/local-modularized-tricky-fail-2.rs b/src/test/ui/imports/local-modularized-tricky-fail-2.rs
new file mode 100644
index 000000000..386de88bc
--- /dev/null
+++ b/src/test/ui/imports/local-modularized-tricky-fail-2.rs
@@ -0,0 +1,22 @@
+// Crate-local macro expanded `macro_export` macros cannot be accessed with module-relative paths.
+
+macro_rules! define_exported { () => {
+ #[macro_export]
+ macro_rules! exported {
+ () => ()
+ }
+}}
+
+define_exported!();
+
+mod m {
+ use exported;
+ //~^ ERROR macro-expanded `macro_export` macros from the current crate cannot
+ //~| WARN this was previously accepted
+}
+
+fn main() {
+ ::exported!();
+ //~^ ERROR macro-expanded `macro_export` macros from the current crate cannot
+ //~| WARN this was previously accepted
+}
diff --git a/src/test/ui/imports/local-modularized-tricky-fail-2.stderr b/src/test/ui/imports/local-modularized-tricky-fail-2.stderr
new file mode 100644
index 000000000..3c20f552f
--- /dev/null
+++ b/src/test/ui/imports/local-modularized-tricky-fail-2.stderr
@@ -0,0 +1,43 @@
+error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
+ --> $DIR/local-modularized-tricky-fail-2.rs:13:9
+ |
+LL | use exported;
+ | ^^^^^^^^
+ |
+ = note: `#[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)]` on by default
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234>
+note: the macro is defined here
+ --> $DIR/local-modularized-tricky-fail-2.rs:5:5
+ |
+LL | / macro_rules! exported {
+LL | | () => ()
+LL | | }
+ | |_____^
+...
+LL | define_exported!();
+ | ------------------ in this macro invocation
+ = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
+ --> $DIR/local-modularized-tricky-fail-2.rs:19:5
+ |
+LL | ::exported!();
+ | ^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234>
+note: the macro is defined here
+ --> $DIR/local-modularized-tricky-fail-2.rs:5:5
+ |
+LL | / macro_rules! exported {
+LL | | () => ()
+LL | | }
+ | |_____^
+...
+LL | define_exported!();
+ | ------------------ in this macro invocation
+ = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/imports/local-modularized-tricky-pass-1.rs b/src/test/ui/imports/local-modularized-tricky-pass-1.rs
new file mode 100644
index 000000000..b52ddaf89
--- /dev/null
+++ b/src/test/ui/imports/local-modularized-tricky-pass-1.rs
@@ -0,0 +1,19 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+macro_rules! define_exported { () => {
+ #[macro_export]
+ macro_rules! exported {
+ () => ()
+ }
+}}
+
+mod inner1 {
+ use super::*;
+ exported!();
+}
+
+mod inner2 {
+ define_exported!();
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/local-modularized-tricky-pass-2.rs b/src/test/ui/imports/local-modularized-tricky-pass-2.rs
new file mode 100644
index 000000000..d5efbdf78
--- /dev/null
+++ b/src/test/ui/imports/local-modularized-tricky-pass-2.rs
@@ -0,0 +1,50 @@
+// check-pass
+//
+// `#[macro_export] macro_rules` that doesn't originate from macro expansions can be placed
+// into the root module soon enough to act as usual items and shadow globs and preludes.
+
+#![feature(decl_macro)]
+
+// `macro_export` shadows globs
+use inner1::*;
+
+mod inner1 {
+ pub macro exported() {}
+}
+
+exported!();
+
+mod deep {
+ fn deep() {
+ type Deeper = [u8; {
+ #[macro_export]
+ macro_rules! exported {
+ () => ( struct Б; )
+ }
+
+ 0
+ }];
+ }
+}
+
+// `macro_export` shadows std prelude
+fn main() {
+ panic!();
+}
+
+mod inner3 {
+ #[macro_export]
+ macro_rules! panic {
+ () => ( struct Г; )
+ }
+}
+
+// `macro_export` shadows builtin macros
+include!();
+
+mod inner4 {
+ #[macro_export]
+ macro_rules! include {
+ () => ( struct Д; )
+ }
+}
diff --git a/src/test/ui/imports/local-modularized.rs b/src/test/ui/imports/local-modularized.rs
new file mode 100644
index 000000000..8eeb1cf07
--- /dev/null
+++ b/src/test/ui/imports/local-modularized.rs
@@ -0,0 +1,35 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+#[macro_export(local_inner_macros)]
+macro_rules! dollar_crate_exported {
+ (1) => { $crate::exported!(); };
+ (2) => { exported!(); };
+}
+
+// Before `exported` is defined
+exported!();
+
+mod inner {
+
+ ::exported!();
+ crate::exported!();
+ dollar_crate_exported!(1);
+ dollar_crate_exported!(2);
+
+ mod inner_inner {
+ #[macro_export]
+ macro_rules! exported {
+ () => ()
+ }
+ }
+
+ // After `exported` is defined
+ ::exported!();
+ crate::exported!();
+ dollar_crate_exported!(1);
+ dollar_crate_exported!(2);
+}
+
+exported!();
+
+fn main() {}
diff --git a/src/test/ui/imports/macro-paths.rs b/src/test/ui/imports/macro-paths.rs
new file mode 100644
index 000000000..cc584e05a
--- /dev/null
+++ b/src/test/ui/imports/macro-paths.rs
@@ -0,0 +1,28 @@
+// aux-build:two_macros.rs
+
+extern crate two_macros;
+
+mod foo {
+ pub mod bar {
+ pub use two_macros::m;
+ }
+}
+
+fn f() {
+ use foo::*;
+ bar::m! { //~ ERROR ambiguous
+ mod bar { pub use two_macros::m; }
+ }
+}
+
+pub mod baz {
+ pub use two_macros::m;
+}
+
+fn g() {
+ baz::m! { //~ ERROR ambiguous
+ mod baz { pub use two_macros::m; }
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/macro-paths.stderr b/src/test/ui/imports/macro-paths.stderr
new file mode 100644
index 000000000..5f113ce2b
--- /dev/null
+++ b/src/test/ui/imports/macro-paths.stderr
@@ -0,0 +1,43 @@
+error[E0659]: `bar` is ambiguous
+ --> $DIR/macro-paths.rs:13:5
+ |
+LL | bar::m! {
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
+note: `bar` could refer to the module defined here
+ --> $DIR/macro-paths.rs:14:9
+ |
+LL | mod bar { pub use two_macros::m; }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: `bar` could also refer to the module imported here
+ --> $DIR/macro-paths.rs:12:9
+ |
+LL | use foo::*;
+ | ^^^^^^
+ = help: consider adding an explicit import of `bar` to disambiguate
+
+error[E0659]: `baz` is ambiguous
+ --> $DIR/macro-paths.rs:23:5
+ |
+LL | baz::m! {
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
+note: `baz` could refer to the module defined here
+ --> $DIR/macro-paths.rs:24:9
+ |
+LL | mod baz { pub use two_macros::m; }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: `baz` could also refer to the module defined here
+ --> $DIR/macro-paths.rs:18:1
+ |
+LL | / pub mod baz {
+LL | | pub use two_macros::m;
+LL | | }
+ | |_^
+ = help: use `crate::baz` to refer to this module unambiguously
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/macros.rs b/src/test/ui/imports/macros.rs
new file mode 100644
index 000000000..f39711898
--- /dev/null
+++ b/src/test/ui/imports/macros.rs
@@ -0,0 +1,42 @@
+// aux-build:two_macros.rs
+
+extern crate two_macros; // two identity macros `m` and `n`
+
+mod foo {
+ pub use two_macros::n as m;
+}
+
+mod m1 {
+ m!(use two_macros::*;);
+ use foo::m; // This shadows the glob import
+}
+
+mod m2 {
+ use two_macros::*;
+ m! { //~ ERROR ambiguous
+ //~| ERROR ambiguous
+ use foo::m;
+ }
+}
+
+mod m3 {
+ use two_macros::m;
+ fn f() {
+ use two_macros::n as m; // This shadows the above import
+ m!();
+ }
+
+ fn g() {
+ m! { //~ ERROR ambiguous
+ use two_macros::n as m;
+ }
+ }
+}
+
+mod m4 {
+ macro_rules! m { () => {} }
+ use two_macros::m;
+ m!();
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/macros.stderr b/src/test/ui/imports/macros.stderr
new file mode 100644
index 000000000..110548d1d
--- /dev/null
+++ b/src/test/ui/imports/macros.stderr
@@ -0,0 +1,60 @@
+error[E0659]: `m` is ambiguous
+ --> $DIR/macros.rs:16:5
+ |
+LL | m! {
+ | ^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
+note: `m` could refer to the macro imported here
+ --> $DIR/macros.rs:18:13
+ |
+LL | use foo::m;
+ | ^^^^^^
+note: `m` could also refer to the macro imported here
+ --> $DIR/macros.rs:15:9
+ |
+LL | use two_macros::*;
+ | ^^^^^^^^^^^^^
+ = help: consider adding an explicit import of `m` to disambiguate
+
+error[E0659]: `m` is ambiguous
+ --> $DIR/macros.rs:16:5
+ |
+LL | m! {
+ | ^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
+note: `m` could refer to the macro imported here
+ --> $DIR/macros.rs:18:13
+ |
+LL | use foo::m;
+ | ^^^^^^
+note: `m` could also refer to the macro imported here
+ --> $DIR/macros.rs:15:9
+ |
+LL | use two_macros::*;
+ | ^^^^^^^^^^^^^
+ = help: consider adding an explicit import of `m` to disambiguate
+
+error[E0659]: `m` is ambiguous
+ --> $DIR/macros.rs:30:9
+ |
+LL | m! {
+ | ^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
+note: `m` could refer to the macro imported here
+ --> $DIR/macros.rs:31:17
+ |
+LL | use two_macros::n as m;
+ | ^^^^^^^^^^^^^^^^^^
+note: `m` could also refer to the macro imported here
+ --> $DIR/macros.rs:23:9
+ |
+LL | use two_macros::m;
+ | ^^^^^^^^^^^^^
+ = help: use `self::m` to refer to this macro unambiguously
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/no-std-inject.rs b/src/test/ui/imports/no-std-inject.rs
new file mode 100644
index 000000000..e9664a4dd
--- /dev/null
+++ b/src/test/ui/imports/no-std-inject.rs
@@ -0,0 +1,6 @@
+#![no_std]
+
+extern crate core; //~ ERROR: the name `core` is defined multiple times
+extern crate std;
+
+fn main() {}
diff --git a/src/test/ui/imports/no-std-inject.stderr b/src/test/ui/imports/no-std-inject.stderr
new file mode 100644
index 000000000..8e2268048
--- /dev/null
+++ b/src/test/ui/imports/no-std-inject.stderr
@@ -0,0 +1,15 @@
+error[E0259]: the name `core` is defined multiple times
+ --> $DIR/no-std-inject.rs:3:1
+ |
+LL | extern crate 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 | extern crate core as other_core;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0259`.
diff --git a/src/test/ui/imports/overlapping_pub_trait.rs b/src/test/ui/imports/overlapping_pub_trait.rs
new file mode 100644
index 000000000..69aba3ae9
--- /dev/null
+++ b/src/test/ui/imports/overlapping_pub_trait.rs
@@ -0,0 +1,15 @@
+// aux-build:overlapping_pub_trait_source.rs
+
+/*
+ * This crate declares two public paths, `m::Tr` and `prelude::_`. Make sure we prefer the former.
+ */
+extern crate overlapping_pub_trait_source;
+//~^ HELP the following trait is implemented but not in scope; perhaps add a `use` for it:
+//~| SUGGESTION overlapping_pub_trait_source::m::Tr
+
+fn main() {
+ use overlapping_pub_trait_source::S;
+ S.method();
+ //~^ ERROR no method named `method` found for struct `S` in the current scope [E0599]
+ //~| HELP items from traits can only be used if the trait is in scope
+}
diff --git a/src/test/ui/imports/overlapping_pub_trait.stderr b/src/test/ui/imports/overlapping_pub_trait.stderr
new file mode 100644
index 000000000..d0c845a5e
--- /dev/null
+++ b/src/test/ui/imports/overlapping_pub_trait.stderr
@@ -0,0 +1,20 @@
+error[E0599]: no method named `method` found for struct `S` in the current scope
+ --> $DIR/overlapping_pub_trait.rs:12:7
+ |
+LL | S.method();
+ | ^^^^^^ method not found in `S`
+ |
+ ::: $DIR/auxiliary/overlapping_pub_trait_source.rs:11:23
+ |
+LL | pub trait Tr { fn method(&self); }
+ | ------ the method is available for `S` here
+ |
+ = help: items from traits can only be used if the trait is in scope
+help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+ |
+LL | use overlapping_pub_trait_source::m::Tr;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/imports/reexport-star.rs b/src/test/ui/imports/reexport-star.rs
new file mode 100644
index 000000000..639ab1a0f
--- /dev/null
+++ b/src/test/ui/imports/reexport-star.rs
@@ -0,0 +1,16 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+mod a {
+ pub fn f() {}
+ pub fn g() {}
+}
+
+mod b {
+ pub use a::*;
+}
+
+pub fn main() {
+ b::f();
+ b::g();
+}
diff --git a/src/test/ui/imports/reexports.rs b/src/test/ui/imports/reexports.rs
new file mode 100644
index 000000000..d76cc41be
--- /dev/null
+++ b/src/test/ui/imports/reexports.rs
@@ -0,0 +1,37 @@
+#![warn(unused_imports)]
+
+mod a {
+ fn foo() {}
+ mod foo {}
+
+ mod a {
+ pub use super::foo; //~ ERROR cannot be re-exported
+ pub use super::*;
+ //~^ WARNING glob import doesn't reexport anything because no candidate is public enough
+ }
+}
+
+mod b {
+ pub fn foo() {}
+ mod foo {
+ pub struct S;
+ }
+
+ pub mod a {
+ pub use super::foo; // This is OK since the value `foo` is visible enough.
+ fn f(_: foo::S) {} // `foo` is imported in the type namespace (but not `pub` re-exported).
+ }
+
+ pub mod b {
+ pub use super::*; // This is also OK since the value `foo` is visible enough.
+ fn f(_: foo::S) {} // Again, the module `foo` is imported (but not `pub` re-exported).
+ }
+}
+
+mod c {
+ // Test that `foo` is not re-exported.
+ use b::a::foo::S; //~ ERROR `foo`
+ use b::b::foo::S as T; //~ ERROR `foo`
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/reexports.stderr b/src/test/ui/imports/reexports.stderr
new file mode 100644
index 000000000..8cbff0ac7
--- /dev/null
+++ b/src/test/ui/imports/reexports.stderr
@@ -0,0 +1,62 @@
+error[E0364]: `foo` is private, and cannot be re-exported
+ --> $DIR/reexports.rs:8:17
+ |
+LL | pub use super::foo;
+ | ^^^^^^^^^^
+ |
+note: consider marking `foo` as `pub` in the imported module
+ --> $DIR/reexports.rs:8:17
+ |
+LL | pub use super::foo;
+ | ^^^^^^^^^^
+
+error[E0603]: module import `foo` is private
+ --> $DIR/reexports.rs:33:15
+ |
+LL | use b::a::foo::S;
+ | ^^^ private module import
+ |
+note: the module import `foo` is defined here...
+ --> $DIR/reexports.rs:21:17
+ |
+LL | pub use super::foo; // This is OK since the value `foo` is visible enough.
+ | ^^^^^^^^^^
+note: ...and refers to the module `foo` which is defined here
+ --> $DIR/reexports.rs:16:5
+ |
+LL | mod foo {
+ | ^^^^^^^
+
+error[E0603]: module import `foo` is private
+ --> $DIR/reexports.rs:34:15
+ |
+LL | use b::b::foo::S as T;
+ | ^^^ private module import
+ |
+note: the module import `foo` is defined here...
+ --> $DIR/reexports.rs:26:17
+ |
+LL | pub use super::*; // This is also OK since the value `foo` is visible enough.
+ | ^^^^^^^^
+note: ...and refers to the module `foo` which is defined here
+ --> $DIR/reexports.rs:16:5
+ |
+LL | mod foo {
+ | ^^^^^^^
+
+warning: glob import doesn't reexport anything because no candidate is public enough
+ --> $DIR/reexports.rs:9:17
+ |
+LL | pub use super::*;
+ | ^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/reexports.rs:1:9
+ |
+LL | #![warn(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors; 1 warning emitted
+
+Some errors have detailed explanations: E0364, E0603.
+For more information about an error, try `rustc --explain E0364`.
diff --git a/src/test/ui/imports/resolve_self_super_hint.rs b/src/test/ui/imports/resolve_self_super_hint.rs
new file mode 100644
index 000000000..a14ec5b72
--- /dev/null
+++ b/src/test/ui/imports/resolve_self_super_hint.rs
@@ -0,0 +1,27 @@
+mod a {
+ extern crate alloc;
+ use alloc::HashMap;
+ //~^ ERROR unresolved import `alloc` [E0432]
+ //~| HELP a similar path exists
+ //~| SUGGESTION self::alloc
+ mod b {
+ use alloc::HashMap;
+ //~^ ERROR unresolved import `alloc` [E0432]
+ //~| HELP a similar path exists
+ //~| SUGGESTION super::alloc
+ mod c {
+ use alloc::HashMap;
+ //~^ ERROR unresolved import `alloc` [E0432]
+ //~| HELP a similar path exists
+ //~| SUGGESTION a::alloc
+ mod d {
+ use alloc::HashMap;
+ //~^ ERROR unresolved import `alloc` [E0432]
+ //~| HELP a similar path exists
+ //~| SUGGESTION a::alloc
+ }
+ }
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/resolve_self_super_hint.stderr b/src/test/ui/imports/resolve_self_super_hint.stderr
new file mode 100644
index 000000000..bc862553b
--- /dev/null
+++ b/src/test/ui/imports/resolve_self_super_hint.stderr
@@ -0,0 +1,33 @@
+error[E0432]: unresolved import `alloc`
+ --> $DIR/resolve_self_super_hint.rs:3:9
+ |
+LL | use alloc::HashMap;
+ | ^^^^^ help: a similar path exists: `self::alloc`
+
+error[E0432]: unresolved import `alloc`
+ --> $DIR/resolve_self_super_hint.rs:8:13
+ |
+LL | use alloc::HashMap;
+ | ^^^^^ help: a similar path exists: `super::alloc`
+
+error[E0432]: unresolved import `alloc`
+ --> $DIR/resolve_self_super_hint.rs:13:17
+ |
+LL | use alloc::HashMap;
+ | ^^^^^
+ | |
+ | unresolved import
+ | help: a similar path exists: `a::alloc`
+
+error[E0432]: unresolved import `alloc`
+ --> $DIR/resolve_self_super_hint.rs:18:21
+ |
+LL | use alloc::HashMap;
+ | ^^^^^
+ | |
+ | unresolved import
+ | help: a similar path exists: `a::alloc`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/rfc-1560-warning-cycle.rs b/src/test/ui/imports/rfc-1560-warning-cycle.rs
new file mode 100644
index 000000000..cfa7179fb
--- /dev/null
+++ b/src/test/ui/imports/rfc-1560-warning-cycle.rs
@@ -0,0 +1,13 @@
+pub struct Foo;
+
+mod bar {
+ struct Foo;
+
+ mod baz {
+ use *;
+ use bar::*;
+ fn f(_: Foo) {} //~ ERROR `Foo` is ambiguous
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/rfc-1560-warning-cycle.stderr b/src/test/ui/imports/rfc-1560-warning-cycle.stderr
new file mode 100644
index 000000000..fd7e99165
--- /dev/null
+++ b/src/test/ui/imports/rfc-1560-warning-cycle.stderr
@@ -0,0 +1,23 @@
+error[E0659]: `Foo` is ambiguous
+ --> $DIR/rfc-1560-warning-cycle.rs:9:17
+ |
+LL | fn f(_: Foo) {}
+ | ^^^ ambiguous name
+ |
+ = note: ambiguous because of multiple glob imports of a name in the same module
+note: `Foo` could refer to the struct imported here
+ --> $DIR/rfc-1560-warning-cycle.rs:7:13
+ |
+LL | use *;
+ | ^
+ = help: consider adding an explicit import of `Foo` to disambiguate
+note: `Foo` could also refer to the struct imported here
+ --> $DIR/rfc-1560-warning-cycle.rs:8:13
+ |
+LL | use bar::*;
+ | ^^^^^^
+ = help: consider adding an explicit import of `Foo` to disambiguate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/shadow_builtin_macros.rs b/src/test/ui/imports/shadow_builtin_macros.rs
new file mode 100644
index 000000000..02c27d5ce
--- /dev/null
+++ b/src/test/ui/imports/shadow_builtin_macros.rs
@@ -0,0 +1,52 @@
+// aux-build:two_macros.rs
+
+mod foo {
+ extern crate two_macros;
+ pub use self::two_macros::m as panic;
+}
+
+mod m1 {
+ use foo::panic; // ok
+ fn f() { panic!(); }
+}
+
+mod m2 {
+ use foo::*;
+ fn f() { panic!(); } //~ ERROR ambiguous
+}
+
+mod m3 {
+ ::two_macros::m!(use foo::panic;);
+ fn f() { panic!(); } //~ ERROR ambiguous
+}
+
+mod m4 {
+ macro_rules! panic { () => {} } // ok
+ panic!();
+}
+
+mod m5 {
+ macro_rules! m { () => {
+ macro_rules! panic { () => {} }
+ } }
+ m!();
+ panic!(); //~ ERROR `panic` is ambiguous
+}
+
+#[macro_use(n)]
+extern crate two_macros;
+mod bar {
+ pub use two_macros::m as n;
+}
+
+mod m6 {
+ use bar::n; // ok
+ n!();
+}
+
+mod m7 {
+ use bar::*;
+ n!(); //~ ERROR ambiguous
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/shadow_builtin_macros.stderr b/src/test/ui/imports/shadow_builtin_macros.stderr
new file mode 100644
index 000000000..6ffb31c20
--- /dev/null
+++ b/src/test/ui/imports/shadow_builtin_macros.stderr
@@ -0,0 +1,72 @@
+error[E0659]: `panic` is ambiguous
+ --> $DIR/shadow_builtin_macros.rs:15:14
+ |
+LL | fn f() { panic!(); }
+ | ^^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
+ = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro imported here
+ --> $DIR/shadow_builtin_macros.rs:14:9
+ |
+LL | use foo::*;
+ | ^^^^^^
+ = help: consider adding an explicit import of `panic` to disambiguate
+ = help: or use `self::panic` to refer to this macro unambiguously
+
+error[E0659]: `panic` is ambiguous
+ --> $DIR/shadow_builtin_macros.rs:33:5
+ |
+LL | panic!();
+ | ^^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
+ = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro defined here
+ --> $DIR/shadow_builtin_macros.rs:30:9
+ |
+LL | macro_rules! panic { () => {} }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | } }
+LL | m!();
+ | ---- in this macro invocation
+ = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0659]: `n` is ambiguous
+ --> $DIR/shadow_builtin_macros.rs:49:5
+ |
+LL | n!();
+ | ^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
+note: `n` could refer to the macro imported here
+ --> $DIR/shadow_builtin_macros.rs:48:9
+ |
+LL | use bar::*;
+ | ^^^^^^
+ = help: consider adding an explicit import of `n` to disambiguate
+ = help: or use `self::n` to refer to this macro unambiguously
+note: `n` could also refer to the macro imported here
+ --> $DIR/shadow_builtin_macros.rs:36:13
+ |
+LL | #[macro_use(n)]
+ | ^
+
+error[E0659]: `panic` is ambiguous
+ --> $DIR/shadow_builtin_macros.rs:20:14
+ |
+LL | fn f() { panic!(); }
+ | ^^^^^ ambiguous name
+ |
+ = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
+ = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro imported here
+ --> $DIR/shadow_builtin_macros.rs:19:26
+ |
+LL | ::two_macros::m!(use foo::panic;);
+ | ^^^^^^^^^^
+ = help: use `self::panic` to refer to this macro unambiguously
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/imports/tool-mod-child.rs b/src/test/ui/imports/tool-mod-child.rs
new file mode 100644
index 000000000..4581dc2e2
--- /dev/null
+++ b/src/test/ui/imports/tool-mod-child.rs
@@ -0,0 +1,7 @@
+use clippy::a; //~ ERROR unresolved import `clippy`
+use clippy::a::b; //~ ERROR failed to resolve: maybe a missing crate `clippy`?
+
+use rustdoc::a; //~ ERROR unresolved import `rustdoc`
+use rustdoc::a::b; //~ ERROR failed to resolve: maybe a missing crate `rustdoc`?
+
+fn main() {}
diff --git a/src/test/ui/imports/tool-mod-child.stderr b/src/test/ui/imports/tool-mod-child.stderr
new file mode 100644
index 000000000..6caf15bc7
--- /dev/null
+++ b/src/test/ui/imports/tool-mod-child.stderr
@@ -0,0 +1,36 @@
+error[E0433]: failed to resolve: maybe a missing crate `clippy`?
+ --> $DIR/tool-mod-child.rs:2:5
+ |
+LL | use clippy::a::b;
+ | ^^^^^^ maybe a missing crate `clippy`?
+ |
+ = help: consider adding `extern crate clippy` to use the `clippy` crate
+
+error[E0432]: unresolved import `clippy`
+ --> $DIR/tool-mod-child.rs:1:5
+ |
+LL | use clippy::a;
+ | ^^^^^^ maybe a missing crate `clippy`?
+ |
+ = help: consider adding `extern crate clippy` to use the `clippy` crate
+
+error[E0433]: failed to resolve: maybe a missing crate `rustdoc`?
+ --> $DIR/tool-mod-child.rs:5:5
+ |
+LL | use rustdoc::a::b;
+ | ^^^^^^^ maybe a missing crate `rustdoc`?
+ |
+ = help: consider adding `extern crate rustdoc` to use the `rustdoc` crate
+
+error[E0432]: unresolved import `rustdoc`
+ --> $DIR/tool-mod-child.rs:4:5
+ |
+LL | use rustdoc::a;
+ | ^^^^^^^ maybe a missing crate `rustdoc`?
+ |
+ = help: consider adding `extern crate rustdoc` to use the `rustdoc` crate
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0432, E0433.
+For more information about an error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/unnamed_pub_trait.rs b/src/test/ui/imports/unnamed_pub_trait.rs
new file mode 100644
index 000000000..c38fb17b9
--- /dev/null
+++ b/src/test/ui/imports/unnamed_pub_trait.rs
@@ -0,0 +1,16 @@
+// aux-build:unnamed_pub_trait_source.rs
+
+/*
+ * This crate declares an unnameable public path for our item. Make sure we don't suggest
+ * importing it by name, and instead we suggest importing it by glob.
+ */
+extern crate unnamed_pub_trait_source;
+//~^ HELP the following trait is implemented but not in scope; perhaps add a `use` for it:
+//~| SUGGESTION unnamed_pub_trait_source::prelude::*; // trait Tr
+
+fn main() {
+ use unnamed_pub_trait_source::S;
+ S.method();
+ //~^ ERROR no method named `method` found for struct `S` in the current scope [E0599]
+ //~| HELP items from traits can only be used if the trait is in scope
+}
diff --git a/src/test/ui/imports/unnamed_pub_trait.stderr b/src/test/ui/imports/unnamed_pub_trait.stderr
new file mode 100644
index 000000000..319dfd7e1
--- /dev/null
+++ b/src/test/ui/imports/unnamed_pub_trait.stderr
@@ -0,0 +1,20 @@
+error[E0599]: no method named `method` found for struct `S` in the current scope
+ --> $DIR/unnamed_pub_trait.rs:13:7
+ |
+LL | S.method();
+ | ^^^^^^ method not found in `S`
+ |
+ ::: $DIR/auxiliary/unnamed_pub_trait_source.rs:7:23
+ |
+LL | pub trait Tr { fn method(&self); }
+ | ------ the method is available for `S` here
+ |
+ = help: items from traits can only be used if the trait is in scope
+help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+ |
+LL | use unnamed_pub_trait_source::prelude::*; // trait Tr
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/imports/unresolved-imports-used.rs b/src/test/ui/imports/unresolved-imports-used.rs
new file mode 100644
index 000000000..75cf88019
--- /dev/null
+++ b/src/test/ui/imports/unresolved-imports-used.rs
@@ -0,0 +1,18 @@
+// There should be *one* unused import error.
+#![deny(unused_imports)]
+
+mod qux {
+ fn quz() {}
+ pub fn quy() {}
+}
+
+use qux::quz; //~ ERROR function `quz` is private
+use qux::bar; //~ ERROR unresolved import `qux::bar`
+use foo::bar; //~ ERROR unresolved import `foo`
+use baz::*; //~ ERROR unresolved import `baz`
+use qux::bar2; //~ ERROR unresolved import `qux::bar2`
+use foo2::bar2;//~ ERROR unresolved import `foo2`
+use baz2::*; //~ ERROR unresolved import `baz2`
+use qux::quy; //~ ERROR unused import
+
+fn main() {}
diff --git a/src/test/ui/imports/unresolved-imports-used.stderr b/src/test/ui/imports/unresolved-imports-used.stderr
new file mode 100644
index 000000000..73f9d1bfb
--- /dev/null
+++ b/src/test/ui/imports/unresolved-imports-used.stderr
@@ -0,0 +1,72 @@
+error[E0432]: unresolved import `qux::bar`
+ --> $DIR/unresolved-imports-used.rs:10:5
+ |
+LL | use qux::bar;
+ | ^^^^^^^^ no `bar` in `qux`
+
+error[E0432]: unresolved import `qux::bar2`
+ --> $DIR/unresolved-imports-used.rs:13:5
+ |
+LL | use qux::bar2;
+ | ^^^^^^^^^ no `bar2` in `qux`
+
+error[E0432]: unresolved import `foo`
+ --> $DIR/unresolved-imports-used.rs:11: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 `baz`
+ --> $DIR/unresolved-imports-used.rs:12:5
+ |
+LL | use baz::*;
+ | ^^^ maybe a missing crate `baz`?
+ |
+ = help: consider adding `extern crate baz` to use the `baz` crate
+
+error[E0432]: unresolved import `foo2`
+ --> $DIR/unresolved-imports-used.rs:14:5
+ |
+LL | use foo2::bar2;
+ | ^^^^ maybe a missing crate `foo2`?
+ |
+ = help: consider adding `extern crate foo2` to use the `foo2` crate
+
+error[E0432]: unresolved import `baz2`
+ --> $DIR/unresolved-imports-used.rs:15:5
+ |
+LL | use baz2::*;
+ | ^^^^ maybe a missing crate `baz2`?
+ |
+ = help: consider adding `extern crate baz2` to use the `baz2` crate
+
+error[E0603]: function `quz` is private
+ --> $DIR/unresolved-imports-used.rs:9:10
+ |
+LL | use qux::quz;
+ | ^^^ private function
+ |
+note: the function `quz` is defined here
+ --> $DIR/unresolved-imports-used.rs:5:4
+ |
+LL | fn quz() {}
+ | ^^^^^^^^
+
+error: unused import: `qux::quy`
+ --> $DIR/unresolved-imports-used.rs:16:5
+ |
+LL | use qux::quy;
+ | ^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unresolved-imports-used.rs:2:9
+ |
+LL | #![deny(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0432, E0603.
+For more information about an error, try `rustc --explain E0432`.
diff --git a/src/test/ui/imports/unused-import-issue-87973.fixed b/src/test/ui/imports/unused-import-issue-87973.fixed
new file mode 100644
index 000000000..5c194d18a
--- /dev/null
+++ b/src/test/ui/imports/unused-import-issue-87973.fixed
@@ -0,0 +1,8 @@
+// run-rustfix
+#![deny(unused_imports)]
+
+// Check that attributes get removed too. See #87973.
+
+//~^ ERROR unused import
+
+fn main() {}
diff --git a/src/test/ui/imports/unused-import-issue-87973.rs b/src/test/ui/imports/unused-import-issue-87973.rs
new file mode 100644
index 000000000..c31f0f979
--- /dev/null
+++ b/src/test/ui/imports/unused-import-issue-87973.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+#![deny(unused_imports)]
+
+// Check that attributes get removed too. See #87973.
+#[deprecated]
+#[allow(unsafe_code)]
+#[cfg(not(foo))]
+use std::fs;
+//~^ ERROR unused import
+
+fn main() {}
diff --git a/src/test/ui/imports/unused-import-issue-87973.stderr b/src/test/ui/imports/unused-import-issue-87973.stderr
new file mode 100644
index 000000000..81b7ea791
--- /dev/null
+++ b/src/test/ui/imports/unused-import-issue-87973.stderr
@@ -0,0 +1,14 @@
+error: unused import: `std::fs`
+ --> $DIR/unused-import-issue-87973.rs:8:5
+ |
+LL | use std::fs;
+ | ^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unused-import-issue-87973.rs:2:9
+ |
+LL | #![deny(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/imports/unused-imports-in-test-mode.rs b/src/test/ui/imports/unused-imports-in-test-mode.rs
new file mode 100644
index 000000000..039f59a88
--- /dev/null
+++ b/src/test/ui/imports/unused-imports-in-test-mode.rs
@@ -0,0 +1,102 @@
+// compile-flags: --test
+
+#![deny(unused_imports)]
+
+use std::io::BufRead; //~ ERROR unused import: `std::io::BufRead`
+
+fn a() {}
+fn b() {}
+
+mod test {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+mod tests {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+mod test_a {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+mod a_test {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+mod tests_a {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+mod a_tests {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+mod fastest_search {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+#[cfg(test)]
+mod test_has_attr {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+mod test_has_no_attr {
+ #[cfg(test)]
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b; //~ ERROR unused import: `crate::b`
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/unused-imports-in-test-mode.stderr b/src/test/ui/imports/unused-imports-in-test-mode.stderr
new file mode 100644
index 000000000..c5faaa114
--- /dev/null
+++ b/src/test/ui/imports/unused-imports-in-test-mode.stderr
@@ -0,0 +1,68 @@
+error: unused import: `std::io::BufRead`
+ --> $DIR/unused-imports-in-test-mode.rs:5:5
+ |
+LL | use std::io::BufRead;
+ | ^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unused-imports-in-test-mode.rs:3:9
+ |
+LL | #![deny(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:16:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:26:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:36:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:46:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:56:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:66:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:76:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:87:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: unused import: `crate::b`
+ --> $DIR/unused-imports-in-test-mode.rs:98:13
+ |
+LL | use crate::b;
+ | ^^^^^^^^
+
+error: aborting due to 10 previous errors
+
diff --git a/src/test/ui/imports/unused-imports-in-test-module.rs b/src/test/ui/imports/unused-imports-in-test-module.rs
new file mode 100644
index 000000000..7849c3fcd
--- /dev/null
+++ b/src/test/ui/imports/unused-imports-in-test-module.rs
@@ -0,0 +1,89 @@
+#![deny(unused_imports)]
+
+use std::io::BufRead; //~ ERROR unused import: `std::io::BufRead`
+
+fn a() {}
+fn b() {}
+
+mod test {
+ use super::a; //~ ERROR unused import: `super::a`
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+mod tests {
+ use super::a; //~ ERROR unused import: `super::a`
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+mod test_a {
+ use super::a; //~ ERROR unused import: `super::a`
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+mod a_test {
+ use super::a; //~ ERROR unused import: `super::a`
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+mod tests_a {
+ use super::a; //~ ERROR unused import: `super::a`
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+mod a_tests {
+ use super::a; //~ ERROR unused import: `super::a`
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+mod fastest_search {
+ use super::a; //~ ERROR unused import: `super::a`
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+#[cfg(test)]
+mod test_has_attr {
+ use super::a;
+
+ #[test]
+ fn foo() {
+ a();
+ use crate::b;
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/unused-imports-in-test-module.stderr b/src/test/ui/imports/unused-imports-in-test-module.stderr
new file mode 100644
index 000000000..1598368eb
--- /dev/null
+++ b/src/test/ui/imports/unused-imports-in-test-module.stderr
@@ -0,0 +1,92 @@
+error: unused import: `std::io::BufRead`
+ --> $DIR/unused-imports-in-test-module.rs:3:5
+ |
+LL | use std::io::BufRead;
+ | ^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unused-imports-in-test-module.rs:1:9
+ |
+LL | #![deny(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+error: unused import: `super::a`
+ --> $DIR/unused-imports-in-test-module.rs:9:9
+ |
+LL | use super::a;
+ | ^^^^^^^^
+ |
+help: consider adding a `#[cfg(test)]` to the containing module
+ --> $DIR/unused-imports-in-test-module.rs:8:1
+ |
+LL | mod test {
+ | ^^^^^^^^
+
+error: unused import: `super::a`
+ --> $DIR/unused-imports-in-test-module.rs:19:9
+ |
+LL | use super::a;
+ | ^^^^^^^^
+ |
+help: consider adding a `#[cfg(test)]` to the containing module
+ --> $DIR/unused-imports-in-test-module.rs:18:1
+ |
+LL | mod tests {
+ | ^^^^^^^^^
+
+error: unused import: `super::a`
+ --> $DIR/unused-imports-in-test-module.rs:29:9
+ |
+LL | use super::a;
+ | ^^^^^^^^
+ |
+help: consider adding a `#[cfg(test)]` to the containing module
+ --> $DIR/unused-imports-in-test-module.rs:28:1
+ |
+LL | mod test_a {
+ | ^^^^^^^^^^
+
+error: unused import: `super::a`
+ --> $DIR/unused-imports-in-test-module.rs:39:9
+ |
+LL | use super::a;
+ | ^^^^^^^^
+ |
+help: consider adding a `#[cfg(test)]` to the containing module
+ --> $DIR/unused-imports-in-test-module.rs:38:1
+ |
+LL | mod a_test {
+ | ^^^^^^^^^^
+
+error: unused import: `super::a`
+ --> $DIR/unused-imports-in-test-module.rs:49:9
+ |
+LL | use super::a;
+ | ^^^^^^^^
+ |
+help: consider adding a `#[cfg(test)]` to the containing module
+ --> $DIR/unused-imports-in-test-module.rs:48:1
+ |
+LL | mod tests_a {
+ | ^^^^^^^^^^^
+
+error: unused import: `super::a`
+ --> $DIR/unused-imports-in-test-module.rs:59:9
+ |
+LL | use super::a;
+ | ^^^^^^^^
+ |
+help: consider adding a `#[cfg(test)]` to the containing module
+ --> $DIR/unused-imports-in-test-module.rs:58:1
+ |
+LL | mod a_tests {
+ | ^^^^^^^^^^^
+
+error: unused import: `super::a`
+ --> $DIR/unused-imports-in-test-module.rs:69:9
+ |
+LL | use super::a;
+ | ^^^^^^^^
+
+error: aborting due to 8 previous errors
+
diff --git a/src/test/ui/imports/unused-macro-use.rs b/src/test/ui/imports/unused-macro-use.rs
new file mode 100644
index 000000000..9f63eb4b4
--- /dev/null
+++ b/src/test/ui/imports/unused-macro-use.rs
@@ -0,0 +1,11 @@
+#![deny(unused)]
+
+#[macro_use] //~ ERROR unused `#[macro_use]` import
+extern crate core;
+
+#[macro_use(
+ panic //~ ERROR unused `#[macro_use]` import
+)]
+extern crate core as core_2;
+
+fn main() {}
diff --git a/src/test/ui/imports/unused-macro-use.stderr b/src/test/ui/imports/unused-macro-use.stderr
new file mode 100644
index 000000000..7137a90e4
--- /dev/null
+++ b/src/test/ui/imports/unused-macro-use.stderr
@@ -0,0 +1,21 @@
+error: unused `#[macro_use]` import
+ --> $DIR/unused-macro-use.rs:3:1
+ |
+LL | #[macro_use]
+ | ^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unused-macro-use.rs:1:9
+ |
+LL | #![deny(unused)]
+ | ^^^^^^
+ = note: `#[deny(unused_imports)]` implied by `#[deny(unused)]`
+
+error: unused `#[macro_use]` import
+ --> $DIR/unused-macro-use.rs:7:5
+ |
+LL | panic
+ | ^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/imports/unused.rs b/src/test/ui/imports/unused.rs
new file mode 100644
index 000000000..c22e95ec3
--- /dev/null
+++ b/src/test/ui/imports/unused.rs
@@ -0,0 +1,27 @@
+#![deny(unused)]
+
+mod foo {
+ fn f() {}
+
+ mod m1 {
+ pub(super) use super::f; //~ ERROR unused
+ }
+
+ mod m2 {
+ #[allow(unused)]
+ use super::m1::*; // (despite this glob import)
+ }
+
+ mod m3 {
+ pub(super) use super::f; // Check that this is counted as used (cf. issue #36249).
+ }
+
+ pub mod m4 {
+ use super::m3::*;
+ pub fn g() { f(); }
+ }
+}
+
+fn main() {
+ foo::m4::g();
+}
diff --git a/src/test/ui/imports/unused.stderr b/src/test/ui/imports/unused.stderr
new file mode 100644
index 000000000..08128d794
--- /dev/null
+++ b/src/test/ui/imports/unused.stderr
@@ -0,0 +1,15 @@
+error: unused import: `super::f`
+ --> $DIR/unused.rs:7:24
+ |
+LL | pub(super) use super::f;
+ | ^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/unused.rs:1:9
+ |
+LL | #![deny(unused)]
+ | ^^^^^^
+ = note: `#[deny(unused_imports)]` implied by `#[deny(unused)]`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/imports/use-mod.rs b/src/test/ui/imports/use-mod.rs
new file mode 100644
index 000000000..84da2e708
--- /dev/null
+++ b/src/test/ui/imports/use-mod.rs
@@ -0,0 +1,33 @@
+// run-pass
+
+#![allow(unused_imports)]
+// pretty-expanded FIXME #23616
+
+pub use foo::bar::{self, First};
+use self::bar::Second;
+
+mod foo {
+ pub use self::bar::baz::{self};
+
+ pub mod bar {
+ pub mod baz {
+ pub struct Fourth;
+ }
+ pub struct First;
+ pub struct Second;
+ }
+
+ pub struct Third;
+}
+
+mod baz {
+ use super::foo::{bar, self};
+ pub use foo::Third;
+}
+
+fn main() {
+ let _ = First;
+ let _ = Second;
+ let _ = baz::Third;
+ let _ = foo::baz::Fourth;
+}