about summary refs log tree commit diff
path: root/tests/ui/resolve
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/resolve')
-rw-r--r--tests/ui/resolve/associated-fn-called-as-fn.rs32
-rw-r--r--tests/ui/resolve/associated-fn-called-as-fn.stderr15
-rw-r--r--tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs3
-rw-r--r--tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs3
-rw-r--r--tests/ui/resolve/auxiliary/extern-prelude-vec.rs3
-rw-r--r--tests/ui/resolve/auxiliary/extern-prelude.rs5
-rw-r--r--tests/ui/resolve/auxiliary/issue-19452-aux.rs3
-rw-r--r--tests/ui/resolve/auxiliary/issue-21221-3.rs19
-rw-r--r--tests/ui/resolve/auxiliary/issue-21221-4.rs12
-rw-r--r--tests/ui/resolve/auxiliary/issue-30535.rs5
-rw-r--r--tests/ui/resolve/auxiliary/issue-3907.rs3
-rw-r--r--tests/ui/resolve/auxiliary/issue-80079.rs18
-rw-r--r--tests/ui/resolve/auxiliary/namespaced_enums.rs10
-rw-r--r--tests/ui/resolve/auxiliary/privacy-struct-ctor.rs9
-rw-r--r--tests/ui/resolve/bad-env-capture.rs6
-rw-r--r--tests/ui/resolve/bad-env-capture.stderr24
-rw-r--r--tests/ui/resolve/bad-env-capture2.rs5
-rw-r--r--tests/ui/resolve/bad-env-capture2.stderr24
-rw-r--r--tests/ui/resolve/bad-env-capture3.rs8
-rw-r--r--tests/ui/resolve/bad-env-capture3.stderr24
-rw-r--r--tests/ui/resolve/bad-expr-path.rs8
-rw-r--r--tests/ui/resolve/bad-expr-path.stderr31
-rw-r--r--tests/ui/resolve/bad-expr-path2.rs10
-rw-r--r--tests/ui/resolve/bad-expr-path2.stderr31
-rw-r--r--tests/ui/resolve/bad-module.rs7
-rw-r--r--tests/ui/resolve/bad-module.stderr15
-rw-r--r--tests/ui/resolve/bad-type-env-capture.rs4
-rw-r--r--tests/ui/resolve/bad-type-env-capture.stderr13
-rw-r--r--tests/ui/resolve/blind-item-local-shadow.rs13
-rw-r--r--tests/ui/resolve/blind-item-mixed-crate-use-item.rs26
-rw-r--r--tests/ui/resolve/blind-item-mixed-use-item.rs20
-rw-r--r--tests/ui/resolve/block-with-trait-parent.rs14
-rw-r--r--tests/ui/resolve/crate-called-as-function.rs3
-rw-r--r--tests/ui/resolve/crate-called-as-function.stderr9
-rw-r--r--tests/ui/resolve/crate-in-paths.rs10
-rw-r--r--tests/ui/resolve/crate-in-paths.stderr14
-rw-r--r--tests/ui/resolve/editions-crate-root-2015.rs21
-rw-r--r--tests/ui/resolve/editions-crate-root-2015.stderr32
-rw-r--r--tests/ui/resolve/editions-crate-root-2018.rs21
-rw-r--r--tests/ui/resolve/editions-crate-root-2018.stderr28
-rw-r--r--tests/ui/resolve/enums-are-namespaced-xc.rs11
-rw-r--r--tests/ui/resolve/enums-are-namespaced-xc.stderr52
-rw-r--r--tests/ui/resolve/enums-pats-not-idents.rs3
-rw-r--r--tests/ui/resolve/enums-pats-not-idents.stderr9
-rw-r--r--tests/ui/resolve/export-fully-qualified.rs11
-rw-r--r--tests/ui/resolve/export-fully-qualified.stderr9
-rw-r--r--tests/ui/resolve/extern-prelude-fail.rs9
-rw-r--r--tests/ui/resolve/extern-prelude-fail.stderr20
-rw-r--r--tests/ui/resolve/extern-prelude.rs31
-rw-r--r--tests/ui/resolve/filter-intrinsics.rs10
-rw-r--r--tests/ui/resolve/filter-intrinsics.stderr25
-rw-r--r--tests/ui/resolve/impl-items-vis-unresolved.rs26
-rw-r--r--tests/ui/resolve/impl-items-vis-unresolved.stderr9
-rw-r--r--tests/ui/resolve/issue-100365.rs50
-rw-r--r--tests/ui/resolve/issue-100365.stderr54
-rw-r--r--tests/ui/resolve/issue-101749-2.rs16
-rw-r--r--tests/ui/resolve/issue-101749-2.stderr9
-rw-r--r--tests/ui/resolve/issue-101749.fixed19
-rw-r--r--tests/ui/resolve/issue-101749.rs19
-rw-r--r--tests/ui/resolve/issue-101749.stderr14
-rw-r--r--tests/ui/resolve/issue-10200.rs9
-rw-r--r--tests/ui/resolve/issue-10200.stderr12
-rw-r--r--tests/ui/resolve/issue-102946.rs7
-rw-r--r--tests/ui/resolve/issue-102946.stderr26
-rw-r--r--tests/ui/resolve/issue-103202.rs7
-rw-r--r--tests/ui/resolve/issue-103202.stderr9
-rw-r--r--tests/ui/resolve/issue-103474.rs28
-rw-r--r--tests/ui/resolve/issue-103474.stderr35
-rw-r--r--tests/ui/resolve/issue-104700-inner_scope.rs11
-rw-r--r--tests/ui/resolve/issue-104700-inner_scope.stderr21
-rw-r--r--tests/ui/resolve/issue-105069.rs11
-rw-r--r--tests/ui/resolve/issue-105069.stderr21
-rw-r--r--tests/ui/resolve/issue-12796.rs9
-rw-r--r--tests/ui/resolve/issue-12796.stderr12
-rw-r--r--tests/ui/resolve/issue-14254.rs105
-rw-r--r--tests/ui/resolve/issue-14254.stderr182
-rw-r--r--tests/ui/resolve/issue-16058.rs18
-rw-r--r--tests/ui/resolve/issue-16058.stderr18
-rw-r--r--tests/ui/resolve/issue-17518.rs7
-rw-r--r--tests/ui/resolve/issue-17518.stderr14
-rw-r--r--tests/ui/resolve/issue-18252.rs8
-rw-r--r--tests/ui/resolve/issue-18252.stderr9
-rw-r--r--tests/ui/resolve/issue-19452.rs15
-rw-r--r--tests/ui/resolve/issue-19452.stderr15
-rw-r--r--tests/ui/resolve/issue-21221-1.rs75
-rw-r--r--tests/ui/resolve/issue-21221-1.stderr51
-rw-r--r--tests/ui/resolve/issue-21221-2.rs21
-rw-r--r--tests/ui/resolve/issue-21221-2.stderr16
-rw-r--r--tests/ui/resolve/issue-21221-3.rs19
-rw-r--r--tests/ui/resolve/issue-21221-3.stderr14
-rw-r--r--tests/ui/resolve/issue-21221-4.rs15
-rw-r--r--tests/ui/resolve/issue-21221-4.stderr14
-rw-r--r--tests/ui/resolve/issue-22692.rs60
-rw-r--r--tests/ui/resolve/issue-22692.stderr88
-rw-r--r--tests/ui/resolve/issue-2330.rs13
-rw-r--r--tests/ui/resolve/issue-2330.stderr9
-rw-r--r--tests/ui/resolve/issue-23305.rs8
-rw-r--r--tests/ui/resolve/issue-23305.stderr10
-rw-r--r--tests/ui/resolve/issue-2356.rs94
-rw-r--r--tests/ui/resolve/issue-2356.stderr134
-rw-r--r--tests/ui/resolve/issue-23716.rs17
-rw-r--r--tests/ui/resolve/issue-23716.stderr21
-rw-r--r--tests/ui/resolve/issue-24968.rs30
-rw-r--r--tests/ui/resolve/issue-24968.stderr57
-rw-r--r--tests/ui/resolve/issue-26545.rs12
-rw-r--r--tests/ui/resolve/issue-26545.stderr14
-rw-r--r--tests/ui/resolve/issue-3021-c.rs9
-rw-r--r--tests/ui/resolve/issue-3021-c.stderr25
-rw-r--r--tests/ui/resolve/issue-3021.rs18
-rw-r--r--tests/ui/resolve/issue-3021.stderr11
-rw-r--r--tests/ui/resolve/issue-30535.rs9
-rw-r--r--tests/ui/resolve/issue-30535.stderr12
-rw-r--r--tests/ui/resolve/issue-31845.rs12
-rw-r--r--tests/ui/resolve/issue-31845.stderr9
-rw-r--r--tests/ui/resolve/issue-33876.rs12
-rw-r--r--tests/ui/resolve/issue-33876.stderr9
-rw-r--r--tests/ui/resolve/issue-35675.rs42
-rw-r--r--tests/ui/resolve/issue-35675.stderr75
-rw-r--r--tests/ui/resolve/issue-3907-2.rs14
-rw-r--r--tests/ui/resolve/issue-3907-2.stderr15
-rw-r--r--tests/ui/resolve/issue-3907.rs20
-rw-r--r--tests/ui/resolve/issue-3907.stderr18
-rw-r--r--tests/ui/resolve/issue-39226.rs14
-rw-r--r--tests/ui/resolve/issue-39226.stderr21
-rw-r--r--tests/ui/resolve/issue-39559-2.rs18
-rw-r--r--tests/ui/resolve/issue-39559-2.stderr19
-rw-r--r--tests/ui/resolve/issue-39559.rs19
-rw-r--r--tests/ui/resolve/issue-39559.stderr11
-rw-r--r--tests/ui/resolve/issue-42944.rs21
-rw-r--r--tests/ui/resolve/issue-42944.stderr28
-rw-r--r--tests/ui/resolve/issue-49074.rs13
-rw-r--r--tests/ui/resolve/issue-49074.stderr16
-rw-r--r--tests/ui/resolve/issue-5035-2.rs7
-rw-r--r--tests/ui/resolve/issue-5035-2.stderr20
-rw-r--r--tests/ui/resolve/issue-5035.rs9
-rw-r--r--tests/ui/resolve/issue-5035.stderr28
-rw-r--r--tests/ui/resolve/issue-50599.rs6
-rw-r--r--tests/ui/resolve/issue-50599.stderr27
-rw-r--r--tests/ui/resolve/issue-5099.rs13
-rw-r--r--tests/ui/resolve/issue-5099.stderr48
-rw-r--r--tests/ui/resolve/issue-54379.rs14
-rw-r--r--tests/ui/resolve/issue-54379.stderr19
-rw-r--r--tests/ui/resolve/issue-55673.rs12
-rw-r--r--tests/ui/resolve/issue-55673.stderr9
-rw-r--r--tests/ui/resolve/issue-57523.rs21
-rw-r--r--tests/ui/resolve/issue-5927.rs7
-rw-r--r--tests/ui/resolve/issue-5927.stderr16
-rw-r--r--tests/ui/resolve/issue-60057.rs19
-rw-r--r--tests/ui/resolve/issue-60057.stderr15
-rw-r--r--tests/ui/resolve/issue-65025-extern-static-parent-generics.rs10
-rw-r--r--tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr12
-rw-r--r--tests/ui/resolve/issue-65035-static-with-parent-generics.rs26
-rw-r--r--tests/ui/resolve/issue-65035-static-with-parent-generics.stderr45
-rw-r--r--tests/ui/resolve/issue-6702.rs9
-rw-r--r--tests/ui/resolve/issue-6702.stderr14
-rw-r--r--tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs6
-rw-r--r--tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.stderr9
-rw-r--r--tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs19
-rw-r--r--tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr53
-rw-r--r--tests/ui/resolve/issue-73427.rs50
-rw-r--r--tests/ui/resolve/issue-73427.stderr168
-rw-r--r--tests/ui/resolve/issue-80079.rs12
-rw-r--r--tests/ui/resolve/issue-80079.stderr9
-rw-r--r--tests/ui/resolve/issue-81508.rs22
-rw-r--r--tests/ui/resolve/issue-81508.stderr21
-rw-r--r--tests/ui/resolve/issue-82156.rs3
-rw-r--r--tests/ui/resolve/issue-82156.stderr9
-rw-r--r--tests/ui/resolve/issue-82865.rs13
-rw-r--r--tests/ui/resolve/issue-82865.stderr23
-rw-r--r--tests/ui/resolve/issue-85348.rs12
-rw-r--r--tests/ui/resolve/issue-85348.stderr30
-rw-r--r--tests/ui/resolve/issue-85671.rs37
-rw-r--r--tests/ui/resolve/issue-88472.rs38
-rw-r--r--tests/ui/resolve/issue-88472.stderr42
-rw-r--r--tests/ui/resolve/issue-90113.rs21
-rw-r--r--tests/ui/resolve/issue-90113.stderr14
-rw-r--r--tests/ui/resolve/levenshtein.rs31
-rw-r--r--tests/ui/resolve/levenshtein.stderr70
-rw-r--r--tests/ui/resolve/macro-determinacy-non-module.rs7
-rw-r--r--tests/ui/resolve/missing-in-namespace.rs4
-rw-r--r--tests/ui/resolve/missing-in-namespace.stderr19
-rw-r--r--tests/ui/resolve/name-clash-nullary.rs3
-rw-r--r--tests/ui/resolve/name-clash-nullary.stderr14
-rw-r--r--tests/ui/resolve/name-collision-in-trait-fn-sig.rs11
-rw-r--r--tests/ui/resolve/no-implicit-prelude-nested.rs54
-rw-r--r--tests/ui/resolve/no-implicit-prelude-nested.stderr187
-rw-r--r--tests/ui/resolve/no-implicit-prelude.rs18
-rw-r--r--tests/ui/resolve/no-implicit-prelude.stderr65
-rw-r--r--tests/ui/resolve/no-std-1.rs10
-rw-r--r--tests/ui/resolve/no-std-2.rs10
-rw-r--r--tests/ui/resolve/no-std-3.rs17
-rw-r--r--tests/ui/resolve/pathless-extern-ok.rs9
-rw-r--r--tests/ui/resolve/point-at-type-parameter-shadowing-another-type.rs21
-rw-r--r--tests/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr15
-rw-r--r--tests/ui/resolve/privacy-enum-ctor.rs71
-rw-r--r--tests/ui/resolve/privacy-enum-ctor.stderr395
-rw-r--r--tests/ui/resolve/privacy-struct-ctor.rs47
-rw-r--r--tests/ui/resolve/privacy-struct-ctor.stderr139
-rw-r--r--tests/ui/resolve/raw-ident-in-path.rs5
-rw-r--r--tests/ui/resolve/raw-ident-in-path.stderr9
-rw-r--r--tests/ui/resolve/resolve-assoc-suggestions.rs39
-rw-r--r--tests/ui/resolve/resolve-assoc-suggestions.stderr58
-rw-r--r--tests/ui/resolve/resolve-bad-import-prefix.rs14
-rw-r--r--tests/ui/resolve/resolve-bad-import-prefix.stderr9
-rw-r--r--tests/ui/resolve/resolve-bad-visibility.rs15
-rw-r--r--tests/ui/resolve/resolve-bad-visibility.stderr38
-rw-r--r--tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.rs4
-rw-r--r--tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr11
-rw-r--r--tests/ui/resolve/resolve-conflict-import-vs-extern-crate.rs4
-rw-r--r--tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr15
-rw-r--r--tests/ui/resolve/resolve-conflict-import-vs-import.fixed9
-rw-r--r--tests/ui/resolve/resolve-conflict-import-vs-import.rs9
-rw-r--r--tests/ui/resolve/resolve-conflict-import-vs-import.stderr13
-rw-r--r--tests/ui/resolve/resolve-conflict-item-vs-extern-crate.rs5
-rw-r--r--tests/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr11
-rw-r--r--tests/ui/resolve/resolve-conflict-item-vs-import.rs8
-rw-r--r--tests/ui/resolve/resolve-conflict-item-vs-import.stderr18
-rw-r--r--tests/ui/resolve/resolve-conflict-type-vs-import.rs7
-rw-r--r--tests/ui/resolve/resolve-conflict-type-vs-import.stderr18
-rw-r--r--tests/ui/resolve/resolve-hint-macro.fixed11
-rw-r--r--tests/ui/resolve/resolve-hint-macro.rs11
-rw-r--r--tests/ui/resolve/resolve-hint-macro.stderr53
-rw-r--r--tests/ui/resolve/resolve-inconsistent-binding-mode.rs41
-rw-r--r--tests/ui/resolve/resolve-inconsistent-binding-mode.stderr72
-rw-r--r--tests/ui/resolve/resolve-inconsistent-names.rs36
-rw-r--r--tests/ui/resolve/resolve-inconsistent-names.stderr104
-rw-r--r--tests/ui/resolve/resolve-issue-2428.rs8
-rw-r--r--tests/ui/resolve/resolve-label.rs13
-rw-r--r--tests/ui/resolve/resolve-label.stderr14
-rw-r--r--tests/ui/resolve/resolve-primitive-fallback.rs10
-rw-r--r--tests/ui/resolve/resolve-primitive-fallback.stderr39
-rw-r--r--tests/ui/resolve/resolve-pseudo-shadowing.rs11
-rw-r--r--tests/ui/resolve/resolve-self-in-impl-2.rs7
-rw-r--r--tests/ui/resolve/resolve-self-in-impl-2.stderr16
-rw-r--r--tests/ui/resolve/resolve-self-in-impl.rs21
-rw-r--r--tests/ui/resolve/resolve-self-in-impl.stderr62
-rw-r--r--tests/ui/resolve/resolve-speculative-adjustment.rs30
-rw-r--r--tests/ui/resolve/resolve-speculative-adjustment.stderr27
-rw-r--r--tests/ui/resolve/resolve-type-param-in-item-in-trait.rs35
-rw-r--r--tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr47
-rw-r--r--tests/ui/resolve/resolve-unknown-trait.rs10
-rw-r--r--tests/ui/resolve/resolve-unknown-trait.stderr21
-rw-r--r--tests/ui/resolve/resolve-variant-assoc-item.rs7
-rw-r--r--tests/ui/resolve/resolve-variant-assoc-item.stderr15
-rw-r--r--tests/ui/resolve/shadow-const-param.rs20
-rw-r--r--tests/ui/resolve/shadow-const-param.stderr20
-rw-r--r--tests/ui/resolve/suggest-path-for-tuple-struct.rs26
-rw-r--r--tests/ui/resolve/suggest-path-for-tuple-struct.stderr15
-rw-r--r--tests/ui/resolve/suggest-path-instead-of-mod-dot-item.rs111
-rw-r--r--tests/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr140
-rw-r--r--tests/ui/resolve/token-error-correct-2.rs7
-rw-r--r--tests/ui/resolve/token-error-correct-2.stderr18
-rw-r--r--tests/ui/resolve/token-error-correct-3.rs25
-rw-r--r--tests/ui/resolve/token-error-correct-3.stderr25
-rw-r--r--tests/ui/resolve/token-error-correct-4.fixed10
-rw-r--r--tests/ui/resolve/token-error-correct-4.rs10
-rw-r--r--tests/ui/resolve/token-error-correct-4.stderr16
-rw-r--r--tests/ui/resolve/token-error-correct.rs9
-rw-r--r--tests/ui/resolve/token-error-correct.stderr20
-rw-r--r--tests/ui/resolve/tuple-struct-alias.rs9
-rw-r--r--tests/ui/resolve/tuple-struct-alias.stderr26
-rw-r--r--tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs46
-rw-r--r--tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr109
-rw-r--r--tests/ui/resolve/typo-suggestion-mistyped-in-path.rs42
-rw-r--r--tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr54
-rw-r--r--tests/ui/resolve/typo-suggestion-named-underscore.rs14
-rw-r--r--tests/ui/resolve/typo-suggestion-named-underscore.stderr16
-rw-r--r--tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs9
-rw-r--r--tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr21
-rw-r--r--tests/ui/resolve/unresolved_static_type_field.rs14
-rw-r--r--tests/ui/resolve/unresolved_static_type_field.stderr9
-rw-r--r--tests/ui/resolve/use-self-in-inner-fn.rs14
-rw-r--r--tests/ui/resolve/use-self-in-inner-fn.stderr15
-rw-r--r--tests/ui/resolve/use_suggestion.rs7
-rw-r--r--tests/ui/resolve/use_suggestion.stderr38
-rw-r--r--tests/ui/resolve/use_suggestion_placement.fixed35
-rw-r--r--tests/ui/resolve/use_suggestion_placement.rs29
-rw-r--r--tests/ui/resolve/use_suggestion_placement.stderr37
-rw-r--r--tests/ui/resolve/visibility-indeterminate.rs7
-rw-r--r--tests/ui/resolve/visibility-indeterminate.stderr15
280 files changed, 7170 insertions, 0 deletions
diff --git a/tests/ui/resolve/associated-fn-called-as-fn.rs b/tests/ui/resolve/associated-fn-called-as-fn.rs
new file mode 100644
index 00000000000..f31f3d67b5b
--- /dev/null
+++ b/tests/ui/resolve/associated-fn-called-as-fn.rs
@@ -0,0 +1,32 @@
+struct S;
+impl Foo for S {
+    fn parse(s:&str) {
+        for c in s.chars() {
+            match c {
+                '0'..='9' => collect_primary(&c), //~ ERROR cannot find function `collect_primary`
+                //~^ HELP you might have meant to call the associated function
+                '+' | '-' => println!("We got a sign: {}", c),
+                _ => println!("Not a number!")
+            }
+        }
+    }
+}
+trait Foo {
+    fn collect_primary(ch:&char) { }
+    fn parse(s:&str);
+}
+trait Bar {
+    fn collect_primary(ch:&char) { }
+    fn parse(s:&str) {
+        for c in s.chars() {
+            match c {
+                '0'..='9' => collect_primary(&c), //~ ERROR cannot find function `collect_primary`
+                //~^ HELP you might have meant to call the associated function
+                '+' | '-' => println!("We got a sign: {}", c),
+                _ => println!("Not a number!")
+            }
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/associated-fn-called-as-fn.stderr b/tests/ui/resolve/associated-fn-called-as-fn.stderr
new file mode 100644
index 00000000000..fbdea30d551
--- /dev/null
+++ b/tests/ui/resolve/associated-fn-called-as-fn.stderr
@@ -0,0 +1,15 @@
+error[E0425]: cannot find function `collect_primary` in this scope
+  --> $DIR/associated-fn-called-as-fn.rs:6:30
+   |
+LL |                 '0'..='9' => collect_primary(&c),
+   |                              ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary`
+
+error[E0425]: cannot find function `collect_primary` in this scope
+  --> $DIR/associated-fn-called-as-fn.rs:23:30
+   |
+LL |                 '0'..='9' => collect_primary(&c),
+   |                              ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs b/tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs
new file mode 100644
index 00000000000..cf769f31bf7
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs
@@ -0,0 +1,3 @@
+#![crate_type="lib"]
+
+pub const X: () = ();
diff --git a/tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs b/tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs
new file mode 100644
index 00000000000..81c16ede909
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs
@@ -0,0 +1,3 @@
+#![crate_type="lib"]
+
+pub const Y: () = ();
diff --git a/tests/ui/resolve/auxiliary/extern-prelude-vec.rs b/tests/ui/resolve/auxiliary/extern-prelude-vec.rs
new file mode 100644
index 00000000000..a643c888910
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/extern-prelude-vec.rs
@@ -0,0 +1,3 @@
+#![crate_name = "Vec"]
+
+pub fn new(arg1: f32, arg2: ()) {}
diff --git a/tests/ui/resolve/auxiliary/extern-prelude.rs b/tests/ui/resolve/auxiliary/extern-prelude.rs
new file mode 100644
index 00000000000..2fdfd85a1da
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/extern-prelude.rs
@@ -0,0 +1,5 @@
+pub struct S;
+
+impl S {
+    pub fn external(&self) {}
+}
diff --git a/tests/ui/resolve/auxiliary/issue-19452-aux.rs b/tests/ui/resolve/auxiliary/issue-19452-aux.rs
new file mode 100644
index 00000000000..9c7bcec51df
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/issue-19452-aux.rs
@@ -0,0 +1,3 @@
+pub enum Homura {
+    Madoka { age: u32 }
+}
diff --git a/tests/ui/resolve/auxiliary/issue-21221-3.rs b/tests/ui/resolve/auxiliary/issue-21221-3.rs
new file mode 100644
index 00000000000..176c23180d9
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/issue-21221-3.rs
@@ -0,0 +1,19 @@
+// testing whether the lookup mechanism picks up types
+// defined in the outside crate
+
+#![crate_type="lib"]
+
+pub mod outer {
+    // should suggest this
+    pub trait OuterTrait {}
+
+    // should not suggest this since the module is private
+    mod private_module {
+        pub trait OuterTrait {}
+    }
+
+    // should not suggest since the trait is private
+    pub mod public_module {
+        trait OuterTrait {}
+    }
+}
diff --git a/tests/ui/resolve/auxiliary/issue-21221-4.rs b/tests/ui/resolve/auxiliary/issue-21221-4.rs
new file mode 100644
index 00000000000..5e0d6cbdfef
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/issue-21221-4.rs
@@ -0,0 +1,12 @@
+// testing whether the lookup mechanism picks up types
+// defined in the outside crate
+
+#![crate_type="lib"]
+
+mod foo {
+    // should not be suggested => foo is private
+    pub trait T {}
+}
+
+// should be suggested
+pub use foo::T;
diff --git a/tests/ui/resolve/auxiliary/issue-30535.rs b/tests/ui/resolve/auxiliary/issue-30535.rs
new file mode 100644
index 00000000000..3608d4a2f14
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/issue-30535.rs
@@ -0,0 +1,5 @@
+#![crate_type="lib"]
+
+pub enum Foo {
+    FooV { data: () }
+}
diff --git a/tests/ui/resolve/auxiliary/issue-3907.rs b/tests/ui/resolve/auxiliary/issue-3907.rs
new file mode 100644
index 00000000000..5dc502930ae
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/issue-3907.rs
@@ -0,0 +1,3 @@
+pub trait Foo {
+    fn bar();
+}
diff --git a/tests/ui/resolve/auxiliary/issue-80079.rs b/tests/ui/resolve/auxiliary/issue-80079.rs
new file mode 100644
index 00000000000..190ca75aba8
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/issue-80079.rs
@@ -0,0 +1,18 @@
+#![crate_type = "lib"]
+
+pub mod public {
+    use private_import;
+
+    // should not be suggested since it is private
+    struct Foo;
+
+    mod private_module {
+        // should not be suggested since it is private
+        pub struct Foo;
+    }
+}
+
+mod private_import {
+    // should not be suggested since it is private
+    pub struct Foo;
+}
diff --git a/tests/ui/resolve/auxiliary/namespaced_enums.rs b/tests/ui/resolve/auxiliary/namespaced_enums.rs
new file mode 100644
index 00000000000..d3548c76cf2
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/namespaced_enums.rs
@@ -0,0 +1,10 @@
+pub enum Foo {
+    A,
+    B(isize),
+    C { a: isize },
+}
+
+impl Foo {
+    pub fn foo() {}
+    pub fn bar(&self) {}
+}
diff --git a/tests/ui/resolve/auxiliary/privacy-struct-ctor.rs b/tests/ui/resolve/auxiliary/privacy-struct-ctor.rs
new file mode 100644
index 00000000000..6d0bc728524
--- /dev/null
+++ b/tests/ui/resolve/auxiliary/privacy-struct-ctor.rs
@@ -0,0 +1,9 @@
+pub mod m {
+    pub struct S(u8);
+
+    pub mod n {
+        pub(in m) struct Z(pub(in m::n) u8);
+    }
+}
+
+pub use m::S;
diff --git a/tests/ui/resolve/bad-env-capture.rs b/tests/ui/resolve/bad-env-capture.rs
new file mode 100644
index 00000000000..83fd2544fc8
--- /dev/null
+++ b/tests/ui/resolve/bad-env-capture.rs
@@ -0,0 +1,6 @@
+// error-pattern: can't capture dynamic environment in a fn item
+fn foo() {
+    let x: isize;
+    fn bar() { log(debug, x); }
+}
+fn main() { foo(); }
diff --git a/tests/ui/resolve/bad-env-capture.stderr b/tests/ui/resolve/bad-env-capture.stderr
new file mode 100644
index 00000000000..59b1fabfd7c
--- /dev/null
+++ b/tests/ui/resolve/bad-env-capture.stderr
@@ -0,0 +1,24 @@
+error[E0434]: can't capture dynamic environment in a fn item
+  --> $DIR/bad-env-capture.rs:4:27
+   |
+LL |     fn bar() { log(debug, x); }
+   |                           ^
+   |
+   = help: use the `|| { ... }` closure form instead
+
+error[E0425]: cannot find value `debug` in this scope
+  --> $DIR/bad-env-capture.rs:4:20
+   |
+LL |     fn bar() { log(debug, x); }
+   |                    ^^^^^ not found in this scope
+
+error[E0425]: cannot find function `log` in this scope
+  --> $DIR/bad-env-capture.rs:4:16
+   |
+LL |     fn bar() { log(debug, x); }
+   |                ^^^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0425, E0434.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/bad-env-capture2.rs b/tests/ui/resolve/bad-env-capture2.rs
new file mode 100644
index 00000000000..b04569c9d72
--- /dev/null
+++ b/tests/ui/resolve/bad-env-capture2.rs
@@ -0,0 +1,5 @@
+// error-pattern: can't capture dynamic environment in a fn item
+fn foo(x: isize) {
+    fn bar() { log(debug, x); }
+}
+fn main() { foo(2); }
diff --git a/tests/ui/resolve/bad-env-capture2.stderr b/tests/ui/resolve/bad-env-capture2.stderr
new file mode 100644
index 00000000000..811c259de6b
--- /dev/null
+++ b/tests/ui/resolve/bad-env-capture2.stderr
@@ -0,0 +1,24 @@
+error[E0434]: can't capture dynamic environment in a fn item
+  --> $DIR/bad-env-capture2.rs:3:27
+   |
+LL |     fn bar() { log(debug, x); }
+   |                           ^
+   |
+   = help: use the `|| { ... }` closure form instead
+
+error[E0425]: cannot find value `debug` in this scope
+  --> $DIR/bad-env-capture2.rs:3:20
+   |
+LL |     fn bar() { log(debug, x); }
+   |                    ^^^^^ not found in this scope
+
+error[E0425]: cannot find function `log` in this scope
+  --> $DIR/bad-env-capture2.rs:3:16
+   |
+LL |     fn bar() { log(debug, x); }
+   |                ^^^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0425, E0434.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/bad-env-capture3.rs b/tests/ui/resolve/bad-env-capture3.rs
new file mode 100644
index 00000000000..62f12fd1a6d
--- /dev/null
+++ b/tests/ui/resolve/bad-env-capture3.rs
@@ -0,0 +1,8 @@
+// error-pattern: can't capture dynamic environment in a fn item
+fn foo(x: isize) {
+    fn mth() {
+        fn bar() { log(debug, x); }
+    }
+}
+
+fn main() { foo(2); }
diff --git a/tests/ui/resolve/bad-env-capture3.stderr b/tests/ui/resolve/bad-env-capture3.stderr
new file mode 100644
index 00000000000..eab37fde96e
--- /dev/null
+++ b/tests/ui/resolve/bad-env-capture3.stderr
@@ -0,0 +1,24 @@
+error[E0434]: can't capture dynamic environment in a fn item
+  --> $DIR/bad-env-capture3.rs:4:31
+   |
+LL |         fn bar() { log(debug, x); }
+   |                               ^
+   |
+   = help: use the `|| { ... }` closure form instead
+
+error[E0425]: cannot find value `debug` in this scope
+  --> $DIR/bad-env-capture3.rs:4:24
+   |
+LL |         fn bar() { log(debug, x); }
+   |                        ^^^^^ not found in this scope
+
+error[E0425]: cannot find function `log` in this scope
+  --> $DIR/bad-env-capture3.rs:4:20
+   |
+LL |         fn bar() { log(debug, x); }
+   |                    ^^^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0425, E0434.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/bad-expr-path.rs b/tests/ui/resolve/bad-expr-path.rs
new file mode 100644
index 00000000000..31fc9cf2cb5
--- /dev/null
+++ b/tests/ui/resolve/bad-expr-path.rs
@@ -0,0 +1,8 @@
+mod m1 {}
+
+fn main(arguments: Vec<String>) { //~ ERROR `main` function has wrong type
+    log(debug, m1::arguments);
+    //~^ ERROR cannot find function `log` in this scope
+    //~| ERROR cannot find value `debug` in this scope
+    //~| ERROR cannot find value `arguments` in module `m1`
+}
diff --git a/tests/ui/resolve/bad-expr-path.stderr b/tests/ui/resolve/bad-expr-path.stderr
new file mode 100644
index 00000000000..8261e8e53b0
--- /dev/null
+++ b/tests/ui/resolve/bad-expr-path.stderr
@@ -0,0 +1,31 @@
+error[E0425]: cannot find value `debug` in this scope
+  --> $DIR/bad-expr-path.rs:4:9
+   |
+LL |     log(debug, m1::arguments);
+   |         ^^^^^ not found in this scope
+
+error[E0425]: cannot find value `arguments` in module `m1`
+  --> $DIR/bad-expr-path.rs:4:20
+   |
+LL |     log(debug, m1::arguments);
+   |                    ^^^^^^^^^ not found in `m1`
+
+error[E0425]: cannot find function `log` in this scope
+  --> $DIR/bad-expr-path.rs:4:5
+   |
+LL |     log(debug, m1::arguments);
+   |     ^^^ not found in this scope
+
+error[E0580]: `main` function has wrong type
+  --> $DIR/bad-expr-path.rs:3:1
+   |
+LL | fn main(arguments: Vec<String>) {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
+   |
+   = note: expected fn pointer `fn()`
+              found fn pointer `fn(Vec<String>)`
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0425, E0580.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/bad-expr-path2.rs b/tests/ui/resolve/bad-expr-path2.rs
new file mode 100644
index 00000000000..eb88edb9071
--- /dev/null
+++ b/tests/ui/resolve/bad-expr-path2.rs
@@ -0,0 +1,10 @@
+mod m1 {
+    pub mod arguments {}
+}
+
+fn main(arguments: Vec<String>) { //~ ERROR `main` function has wrong type
+    log(debug, m1::arguments);
+    //~^ ERROR cannot find function `log` in this scope
+    //~| ERROR cannot find value `debug` in this scope
+    //~| ERROR expected value, found module `m1::arguments`
+}
diff --git a/tests/ui/resolve/bad-expr-path2.stderr b/tests/ui/resolve/bad-expr-path2.stderr
new file mode 100644
index 00000000000..6e11296d9fc
--- /dev/null
+++ b/tests/ui/resolve/bad-expr-path2.stderr
@@ -0,0 +1,31 @@
+error[E0425]: cannot find value `debug` in this scope
+  --> $DIR/bad-expr-path2.rs:6:9
+   |
+LL |     log(debug, m1::arguments);
+   |         ^^^^^ not found in this scope
+
+error[E0423]: expected value, found module `m1::arguments`
+  --> $DIR/bad-expr-path2.rs:6:16
+   |
+LL |     log(debug, m1::arguments);
+   |                ^^^^^^^^^^^^^ not a value
+
+error[E0425]: cannot find function `log` in this scope
+  --> $DIR/bad-expr-path2.rs:6:5
+   |
+LL |     log(debug, m1::arguments);
+   |     ^^^ not found in this scope
+
+error[E0580]: `main` function has wrong type
+  --> $DIR/bad-expr-path2.rs:5:1
+   |
+LL | fn main(arguments: Vec<String>) {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
+   |
+   = note: expected fn pointer `fn()`
+              found fn pointer `fn(Vec<String>)`
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0423, E0425, E0580.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/bad-module.rs b/tests/ui/resolve/bad-module.rs
new file mode 100644
index 00000000000..b23e97c2cf6
--- /dev/null
+++ b/tests/ui/resolve/bad-module.rs
@@ -0,0 +1,7 @@
+fn main() {
+    let foo = thing::len(Vec::new());
+    //~^ ERROR failed to resolve: use of undeclared crate or module `thing`
+
+    let foo = foo::bar::baz();
+    //~^ ERROR failed to resolve: use of undeclared crate or module `foo`
+}
diff --git a/tests/ui/resolve/bad-module.stderr b/tests/ui/resolve/bad-module.stderr
new file mode 100644
index 00000000000..558760c6793
--- /dev/null
+++ b/tests/ui/resolve/bad-module.stderr
@@ -0,0 +1,15 @@
+error[E0433]: failed to resolve: use of undeclared crate or module `foo`
+  --> $DIR/bad-module.rs:5:15
+   |
+LL |     let foo = foo::bar::baz();
+   |               ^^^ use of undeclared crate or module `foo`
+
+error[E0433]: failed to resolve: use of undeclared crate or module `thing`
+  --> $DIR/bad-module.rs:2:15
+   |
+LL |     let foo = thing::len(Vec::new());
+   |               ^^^^^ use of undeclared crate or module `thing`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/bad-type-env-capture.rs b/tests/ui/resolve/bad-type-env-capture.rs
new file mode 100644
index 00000000000..53dfb13139a
--- /dev/null
+++ b/tests/ui/resolve/bad-type-env-capture.rs
@@ -0,0 +1,4 @@
+fn foo<T>() {
+    fn bar(b: T) { } //~ ERROR can't use generic parameters from outer
+}
+fn main() { }
diff --git a/tests/ui/resolve/bad-type-env-capture.stderr b/tests/ui/resolve/bad-type-env-capture.stderr
new file mode 100644
index 00000000000..b6282c2d070
--- /dev/null
+++ b/tests/ui/resolve/bad-type-env-capture.stderr
@@ -0,0 +1,13 @@
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/bad-type-env-capture.rs:2:15
+   |
+LL | fn foo<T>() {
+   |        - type parameter from outer function
+LL |     fn bar(b: T) { }
+   |           -   ^ use of generic parameter from outer function
+   |           |
+   |           help: try using a local generic parameter instead: `<T>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/blind-item-local-shadow.rs b/tests/ui/resolve/blind-item-local-shadow.rs
new file mode 100644
index 00000000000..942aeb6fdf4
--- /dev/null
+++ b/tests/ui/resolve/blind-item-local-shadow.rs
@@ -0,0 +1,13 @@
+// run-pass
+
+#![allow(dead_code)]
+#![allow(unused_imports)]
+mod bar {
+    pub fn foo() -> bool { true }
+}
+
+fn main() {
+    let foo = || false;
+    use bar::foo;
+    assert_eq!(foo(), false);
+}
diff --git a/tests/ui/resolve/blind-item-mixed-crate-use-item.rs b/tests/ui/resolve/blind-item-mixed-crate-use-item.rs
new file mode 100644
index 00000000000..36d8ab151e4
--- /dev/null
+++ b/tests/ui/resolve/blind-item-mixed-crate-use-item.rs
@@ -0,0 +1,26 @@
+// run-pass
+// aux-build:blind-item-mixed-crate-use-item-foo.rs
+// aux-build:blind-item-mixed-crate-use-item-foo2.rs
+
+// pretty-expanded FIXME #23616
+
+mod m {
+    pub fn f<T>(_: T, _: (), _: ()) { }
+    pub fn g<T>(_: T, _: (), _: ()) { }
+}
+
+const BAR: () = ();
+struct Data;
+use m::f;
+extern crate blind_item_mixed_crate_use_item_foo as foo;
+
+fn main() {
+    const BAR2: () = ();
+    struct Data2;
+    use m::g;
+
+    extern crate blind_item_mixed_crate_use_item_foo2 as foo2;
+
+    f(Data, BAR, foo::X);
+    g(Data2, BAR2, foo2::Y);
+}
diff --git a/tests/ui/resolve/blind-item-mixed-use-item.rs b/tests/ui/resolve/blind-item-mixed-use-item.rs
new file mode 100644
index 00000000000..4a39054967b
--- /dev/null
+++ b/tests/ui/resolve/blind-item-mixed-use-item.rs
@@ -0,0 +1,20 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+mod m {
+    pub fn f<T>(_: T, _: ()) { }
+    pub fn g<T>(_: T, _: ()) { }
+}
+
+const BAR: () = ();
+struct Data;
+use m::f;
+
+fn main() {
+    const BAR2: () = ();
+    struct Data2;
+    use m::g;
+
+    f(Data, BAR);
+    g(Data2, BAR2);
+}
diff --git a/tests/ui/resolve/block-with-trait-parent.rs b/tests/ui/resolve/block-with-trait-parent.rs
new file mode 100644
index 00000000000..bc86f94e921
--- /dev/null
+++ b/tests/ui/resolve/block-with-trait-parent.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+trait Trait {
+    fn method(&self) {
+        // Items inside a block turn it into a module internally.
+        struct S;
+        impl Trait for S {}
+
+        // OK, `Trait` is in scope here from method resolution point of view.
+        S.method();
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/crate-called-as-function.rs b/tests/ui/resolve/crate-called-as-function.rs
new file mode 100644
index 00000000000..e8f52c0c029
--- /dev/null
+++ b/tests/ui/resolve/crate-called-as-function.rs
@@ -0,0 +1,3 @@
+fn main() {
+    ::foo() //~ cannot find external crate `foo` in the crate root
+}
diff --git a/tests/ui/resolve/crate-called-as-function.stderr b/tests/ui/resolve/crate-called-as-function.stderr
new file mode 100644
index 00000000000..eb42349aff1
--- /dev/null
+++ b/tests/ui/resolve/crate-called-as-function.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find external crate `foo` in the crate root
+  --> $DIR/crate-called-as-function.rs:2:7
+   |
+LL |     ::foo()
+   |       ^^^ not found in the crate root
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/crate-in-paths.rs b/tests/ui/resolve/crate-in-paths.rs
new file mode 100644
index 00000000000..7ebd259189d
--- /dev/null
+++ b/tests/ui/resolve/crate-in-paths.rs
@@ -0,0 +1,10 @@
+// edition:2018
+
+mod bar {
+    pub(crate) struct Foo;
+}
+
+fn main() {
+    Foo;
+    //~^ ERROR cannot find value `Foo` in this scope [E0425]
+}
diff --git a/tests/ui/resolve/crate-in-paths.stderr b/tests/ui/resolve/crate-in-paths.stderr
new file mode 100644
index 00000000000..b7cf4950759
--- /dev/null
+++ b/tests/ui/resolve/crate-in-paths.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find value `Foo` in this scope
+  --> $DIR/crate-in-paths.rs:8:5
+   |
+LL |     Foo;
+   |     ^^^ not found in this scope
+   |
+help: consider importing this unit struct
+   |
+LL | use crate::bar::Foo;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/editions-crate-root-2015.rs b/tests/ui/resolve/editions-crate-root-2015.rs
new file mode 100644
index 00000000000..4c890e3ae69
--- /dev/null
+++ b/tests/ui/resolve/editions-crate-root-2015.rs
@@ -0,0 +1,21 @@
+// edition:2015
+
+mod inner {
+    fn global_inner(_: ::nonexistant::Foo) {
+        //~^ ERROR failed to resolve: maybe a missing crate `nonexistant`?
+    }
+    fn crate_inner(_: crate::nonexistant::Foo) {
+        //~^ ERROR failed to resolve: maybe a missing crate `nonexistant`?
+    }
+
+    fn bare_global(_: ::nonexistant) {
+        //~^ ERROR cannot find type `nonexistant` in the crate root
+    }
+    fn bare_crate(_: crate::nonexistant) {
+        //~^ ERROR cannot find type `nonexistant` in the crate root
+    }
+}
+
+fn main() {
+
+}
diff --git a/tests/ui/resolve/editions-crate-root-2015.stderr b/tests/ui/resolve/editions-crate-root-2015.stderr
new file mode 100644
index 00000000000..00cdd0c58f4
--- /dev/null
+++ b/tests/ui/resolve/editions-crate-root-2015.stderr
@@ -0,0 +1,32 @@
+error[E0433]: failed to resolve: maybe a missing crate `nonexistant`?
+  --> $DIR/editions-crate-root-2015.rs:4:26
+   |
+LL |     fn global_inner(_: ::nonexistant::Foo) {
+   |                          ^^^^^^^^^^^ maybe a missing crate `nonexistant`?
+   |
+   = help: consider adding `extern crate nonexistant` to use the `nonexistant` crate
+
+error[E0433]: failed to resolve: maybe a missing crate `nonexistant`?
+  --> $DIR/editions-crate-root-2015.rs:7:30
+   |
+LL |     fn crate_inner(_: crate::nonexistant::Foo) {
+   |                              ^^^^^^^^^^^ maybe a missing crate `nonexistant`?
+   |
+   = help: consider adding `extern crate nonexistant` to use the `nonexistant` crate
+
+error[E0412]: cannot find type `nonexistant` in the crate root
+  --> $DIR/editions-crate-root-2015.rs:11:25
+   |
+LL |     fn bare_global(_: ::nonexistant) {
+   |                         ^^^^^^^^^^^ not found in the crate root
+
+error[E0412]: cannot find type `nonexistant` in the crate root
+  --> $DIR/editions-crate-root-2015.rs:14:29
+   |
+LL |     fn bare_crate(_: crate::nonexistant) {
+   |                             ^^^^^^^^^^^ not found in the crate root
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0412, E0433.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/editions-crate-root-2018.rs b/tests/ui/resolve/editions-crate-root-2018.rs
new file mode 100644
index 00000000000..61e4329bbb3
--- /dev/null
+++ b/tests/ui/resolve/editions-crate-root-2018.rs
@@ -0,0 +1,21 @@
+// edition:2018
+
+mod inner {
+    fn global_inner(_: ::nonexistant::Foo) {
+        //~^ ERROR failed to resolve: could not find `nonexistant` in the list of imported crates
+    }
+    fn crate_inner(_: crate::nonexistant::Foo) {
+        //~^ ERROR failed to resolve: could not find `nonexistant` in the crate root
+    }
+
+    fn bare_global(_: ::nonexistant) {
+        //~^ ERROR cannot find crate `nonexistant` in the list of imported crates
+    }
+    fn bare_crate(_: crate::nonexistant) {
+        //~^ ERROR cannot find type `nonexistant` in the crate root
+    }
+}
+
+fn main() {
+
+}
diff --git a/tests/ui/resolve/editions-crate-root-2018.stderr b/tests/ui/resolve/editions-crate-root-2018.stderr
new file mode 100644
index 00000000000..967a5a2fca1
--- /dev/null
+++ b/tests/ui/resolve/editions-crate-root-2018.stderr
@@ -0,0 +1,28 @@
+error[E0433]: failed to resolve: could not find `nonexistant` in the list of imported crates
+  --> $DIR/editions-crate-root-2018.rs:4:26
+   |
+LL |     fn global_inner(_: ::nonexistant::Foo) {
+   |                          ^^^^^^^^^^^ could not find `nonexistant` in the list of imported crates
+
+error[E0433]: failed to resolve: could not find `nonexistant` in the crate root
+  --> $DIR/editions-crate-root-2018.rs:7:30
+   |
+LL |     fn crate_inner(_: crate::nonexistant::Foo) {
+   |                              ^^^^^^^^^^^ could not find `nonexistant` in the crate root
+
+error[E0412]: cannot find crate `nonexistant` in the list of imported crates
+  --> $DIR/editions-crate-root-2018.rs:11:25
+   |
+LL |     fn bare_global(_: ::nonexistant) {
+   |                         ^^^^^^^^^^^ not found in the list of imported crates
+
+error[E0412]: cannot find type `nonexistant` in the crate root
+  --> $DIR/editions-crate-root-2018.rs:14:29
+   |
+LL |     fn bare_crate(_: crate::nonexistant) {
+   |                             ^^^^^^^^^^^ not found in the crate root
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0412, E0433.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/enums-are-namespaced-xc.rs b/tests/ui/resolve/enums-are-namespaced-xc.rs
new file mode 100644
index 00000000000..dfc16d6ce44
--- /dev/null
+++ b/tests/ui/resolve/enums-are-namespaced-xc.rs
@@ -0,0 +1,11 @@
+// aux-build:namespaced_enums.rs
+extern crate namespaced_enums;
+
+fn main() {
+    let _ = namespaced_enums::A;
+    //~^ ERROR cannot find value `A`
+    let _ = namespaced_enums::B(10);
+    //~^ ERROR cannot find function, tuple struct or tuple variant `B`
+    let _ = namespaced_enums::C { a: 10 };
+    //~^ ERROR cannot find struct, variant or union type `C`
+}
diff --git a/tests/ui/resolve/enums-are-namespaced-xc.stderr b/tests/ui/resolve/enums-are-namespaced-xc.stderr
new file mode 100644
index 00000000000..6448e596d56
--- /dev/null
+++ b/tests/ui/resolve/enums-are-namespaced-xc.stderr
@@ -0,0 +1,52 @@
+error[E0425]: cannot find value `A` in crate `namespaced_enums`
+  --> $DIR/enums-are-namespaced-xc.rs:5:31
+   |
+LL |     let _ = namespaced_enums::A;
+   |                               ^ not found in `namespaced_enums`
+   |
+help: consider importing this unit variant
+   |
+LL | use namespaced_enums::Foo::A;
+   |
+help: if you import `A`, refer to it directly
+   |
+LL -     let _ = namespaced_enums::A;
+LL +     let _ = A;
+   |
+
+error[E0425]: cannot find function, tuple struct or tuple variant `B` in crate `namespaced_enums`
+  --> $DIR/enums-are-namespaced-xc.rs:7:31
+   |
+LL |     let _ = namespaced_enums::B(10);
+   |                               ^ not found in `namespaced_enums`
+   |
+help: consider importing this tuple variant
+   |
+LL | use namespaced_enums::Foo::B;
+   |
+help: if you import `B`, refer to it directly
+   |
+LL -     let _ = namespaced_enums::B(10);
+LL +     let _ = B(10);
+   |
+
+error[E0422]: cannot find struct, variant or union type `C` in crate `namespaced_enums`
+  --> $DIR/enums-are-namespaced-xc.rs:9:31
+   |
+LL |     let _ = namespaced_enums::C { a: 10 };
+   |                               ^ not found in `namespaced_enums`
+   |
+help: consider importing this variant
+   |
+LL | use namespaced_enums::Foo::C;
+   |
+help: if you import `C`, refer to it directly
+   |
+LL -     let _ = namespaced_enums::C { a: 10 };
+LL +     let _ = C { a: 10 };
+   |
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0422, E0425.
+For more information about an error, try `rustc --explain E0422`.
diff --git a/tests/ui/resolve/enums-pats-not-idents.rs b/tests/ui/resolve/enums-pats-not-idents.rs
new file mode 100644
index 00000000000..5b918eef6d6
--- /dev/null
+++ b/tests/ui/resolve/enums-pats-not-idents.rs
@@ -0,0 +1,3 @@
+fn main() {
+    let a(1) = 13; //~ ERROR cannot find tuple struct or tuple variant `a` in this scope
+}
diff --git a/tests/ui/resolve/enums-pats-not-idents.stderr b/tests/ui/resolve/enums-pats-not-idents.stderr
new file mode 100644
index 00000000000..072b88716ad
--- /dev/null
+++ b/tests/ui/resolve/enums-pats-not-idents.stderr
@@ -0,0 +1,9 @@
+error[E0531]: cannot find tuple struct or tuple variant `a` in this scope
+  --> $DIR/enums-pats-not-idents.rs:2:9
+   |
+LL |     let a(1) = 13;
+   |         ^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0531`.
diff --git a/tests/ui/resolve/export-fully-qualified.rs b/tests/ui/resolve/export-fully-qualified.rs
new file mode 100644
index 00000000000..4e73a2c5488
--- /dev/null
+++ b/tests/ui/resolve/export-fully-qualified.rs
@@ -0,0 +1,11 @@
+// In this test baz isn't resolved when called as foo.baz even though
+// it's called from inside foo. This is somewhat surprising and may
+// want to change eventually.
+
+mod foo {
+    pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of undeclared crate or module `foo`
+
+    fn baz() { }
+}
+
+fn main() { }
diff --git a/tests/ui/resolve/export-fully-qualified.stderr b/tests/ui/resolve/export-fully-qualified.stderr
new file mode 100644
index 00000000000..7ee352e1232
--- /dev/null
+++ b/tests/ui/resolve/export-fully-qualified.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: use of undeclared crate or module `foo`
+  --> $DIR/export-fully-qualified.rs:6:20
+   |
+LL |     pub fn bar() { foo::baz(); }
+   |                    ^^^ use of undeclared crate or module `foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/extern-prelude-fail.rs b/tests/ui/resolve/extern-prelude-fail.rs
new file mode 100644
index 00000000000..7d387025ad4
--- /dev/null
+++ b/tests/ui/resolve/extern-prelude-fail.rs
@@ -0,0 +1,9 @@
+// compile-flags:--extern extern_prelude
+// aux-build:extern-prelude.rs
+
+// Extern prelude names are not available by absolute paths
+
+fn main() {
+    use extern_prelude::S; //~ ERROR unresolved import `extern_prelude`
+    let s = ::extern_prelude::S; //~ ERROR failed to resolve
+}
diff --git a/tests/ui/resolve/extern-prelude-fail.stderr b/tests/ui/resolve/extern-prelude-fail.stderr
new file mode 100644
index 00000000000..a1591914b4d
--- /dev/null
+++ b/tests/ui/resolve/extern-prelude-fail.stderr
@@ -0,0 +1,20 @@
+error[E0432]: unresolved import `extern_prelude`
+  --> $DIR/extern-prelude-fail.rs:7:9
+   |
+LL |     use extern_prelude::S;
+   |         ^^^^^^^^^^^^^^ maybe a missing crate `extern_prelude`?
+   |
+   = help: consider adding `extern crate extern_prelude` to use the `extern_prelude` crate
+
+error[E0433]: failed to resolve: maybe a missing crate `extern_prelude`?
+  --> $DIR/extern-prelude-fail.rs:8:15
+   |
+LL |     let s = ::extern_prelude::S;
+   |               ^^^^^^^^^^^^^^ maybe a missing crate `extern_prelude`?
+   |
+   = help: consider adding `extern crate extern_prelude` to use the `extern_prelude` crate
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0432, E0433.
+For more information about an error, try `rustc --explain E0432`.
diff --git a/tests/ui/resolve/extern-prelude.rs b/tests/ui/resolve/extern-prelude.rs
new file mode 100644
index 00000000000..50fed6034aa
--- /dev/null
+++ b/tests/ui/resolve/extern-prelude.rs
@@ -0,0 +1,31 @@
+// build-pass (FIXME(62277): could be check-pass?)
+// compile-flags:--extern extern_prelude --extern Vec
+// aux-build:extern-prelude.rs
+// aux-build:extern-prelude-vec.rs
+
+fn basic() {
+    // It works
+    let s = extern_prelude::S;
+    s.external();
+}
+
+fn shadow_mod() {
+    // Local module shadows `extern_prelude` from extern prelude
+    mod extern_prelude {
+        pub struct S;
+
+        impl S {
+            pub fn internal(&self) {}
+        }
+    }
+
+    let s = extern_prelude::S;
+    s.internal(); // OK
+}
+
+fn shadow_prelude() {
+    // Extern prelude shadows standard library prelude
+    let x = Vec::new(0f32, ()); // OK
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/filter-intrinsics.rs b/tests/ui/resolve/filter-intrinsics.rs
new file mode 100644
index 00000000000..c0956ef85af
--- /dev/null
+++ b/tests/ui/resolve/filter-intrinsics.rs
@@ -0,0 +1,10 @@
+fn main() {
+    // Should suggest only `std::mem::size_of`
+    let _ = size_of::<usize>();
+    //~^ ERROR cannot find
+
+    // Should suggest `std::intrinsics::fabsf64`,
+    // since there is no non-intrinsic to suggest.
+    let _ = fabsf64(1.0);
+    //~^ ERROR cannot find
+}
diff --git a/tests/ui/resolve/filter-intrinsics.stderr b/tests/ui/resolve/filter-intrinsics.stderr
new file mode 100644
index 00000000000..955070891fb
--- /dev/null
+++ b/tests/ui/resolve/filter-intrinsics.stderr
@@ -0,0 +1,25 @@
+error[E0425]: cannot find function `size_of` in this scope
+  --> $DIR/filter-intrinsics.rs:3:13
+   |
+LL |     let _ = size_of::<usize>();
+   |             ^^^^^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL | use std::mem::size_of;
+   |
+
+error[E0425]: cannot find function `fabsf64` in this scope
+  --> $DIR/filter-intrinsics.rs:8:13
+   |
+LL |     let _ = fabsf64(1.0);
+   |             ^^^^^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL | use std::intrinsics::fabsf64;
+   |
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/impl-items-vis-unresolved.rs b/tests/ui/resolve/impl-items-vis-unresolved.rs
new file mode 100644
index 00000000000..1494c1cf968
--- /dev/null
+++ b/tests/ui/resolve/impl-items-vis-unresolved.rs
@@ -0,0 +1,26 @@
+// Visibilities on impl items expanded from macros are resolved (issue #64705).
+
+macro_rules! perftools_inline {
+    ($($item:tt)*) => (
+        $($item)*
+    );
+}
+
+mod state {
+    pub struct RawFloatState;
+    impl RawFloatState {
+        perftools_inline! {
+            pub(super) fn new() {} // OK
+        }
+    }
+}
+
+pub struct RawFloatState;
+impl RawFloatState {
+    perftools_inline! {
+        pub(super) fn new() {}
+        //~^ ERROR failed to resolve: there are too many leading `super` keywords
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/impl-items-vis-unresolved.stderr b/tests/ui/resolve/impl-items-vis-unresolved.stderr
new file mode 100644
index 00000000000..f2293d28ea1
--- /dev/null
+++ b/tests/ui/resolve/impl-items-vis-unresolved.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: there are too many leading `super` keywords
+  --> $DIR/impl-items-vis-unresolved.rs:21:13
+   |
+LL |         pub(super) fn new() {}
+   |             ^^^^^ there are too many leading `super` keywords
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/issue-100365.rs b/tests/ui/resolve/issue-100365.rs
new file mode 100644
index 00000000000..1d883503606
--- /dev/null
+++ b/tests/ui/resolve/issue-100365.rs
@@ -0,0 +1,50 @@
+fn main() {
+    let addr = Into::<std::net::IpAddr>.into([127, 0, 0, 1]);
+    //~^ ERROR expected value, found trait `Into`
+    //~| HELP use the path separator
+
+    let _ = Into.into(());
+    //~^ ERROR expected value, found trait `Into`
+    //~| HELP use the path separator
+
+    let _ = Into::<()>.into;
+    //~^ ERROR expected value, found trait `Into`
+    //~| HELP use the path separator
+}
+
+macro_rules! Trait {
+    () => {
+        ::std::iter::Iterator
+        //~^ ERROR expected value, found trait `std::iter::Iterator`
+        //~| ERROR expected value, found trait `std::iter::Iterator`
+    };
+}
+
+macro_rules! create {
+    () => {
+        Into::<String>.into("")
+        //~^ ERROR expected value, found trait `Into`
+        //~| HELP use the path separator
+    };
+}
+
+fn interaction_with_macros() {
+    //
+    // Note that if the receiver is a macro call, we do not want to suggest to replace
+    // `.` with `::` as that would be a syntax error.
+    // Since the receiver is a trait and not a type, we cannot suggest to surround
+    // it with angle brackets. It would be interpreted as a trait object type void of
+    // `dyn` which is most likely not what the user intended to write.
+    // `<_ as Trait!()>::` is also not an option as it's equally syntactically invalid.
+    //
+
+    Trait!().map(std::convert::identity); // no `help` here!
+
+    Trait!().map; // no `help` here!
+
+    //
+    // Ensure that the suggestion is shown for expressions inside of macro definitions.
+    //
+
+    let _ = create!();
+}
diff --git a/tests/ui/resolve/issue-100365.stderr b/tests/ui/resolve/issue-100365.stderr
new file mode 100644
index 00000000000..372d7726668
--- /dev/null
+++ b/tests/ui/resolve/issue-100365.stderr
@@ -0,0 +1,54 @@
+error[E0423]: expected value, found trait `Into`
+  --> $DIR/issue-100365.rs:2:16
+   |
+LL |     let addr = Into::<std::net::IpAddr>.into([127, 0, 0, 1]);
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found trait `Into`
+  --> $DIR/issue-100365.rs:6:13
+   |
+LL |     let _ = Into.into(());
+   |             ^^^^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found trait `Into`
+  --> $DIR/issue-100365.rs:10:13
+   |
+LL |     let _ = Into::<()>.into;
+   |             ^^^^^^^^^^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found trait `std::iter::Iterator`
+  --> $DIR/issue-100365.rs:17:9
+   |
+LL |         ::std::iter::Iterator
+   |         ^^^^^^^^^^^^^^^^^^^^^ not a value
+...
+LL |     Trait!().map(std::convert::identity); // no `help` here!
+   |     -------- in this macro invocation
+   |
+   = note: this error originates in the macro `Trait` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found trait `std::iter::Iterator`
+  --> $DIR/issue-100365.rs:17:9
+   |
+LL |         ::std::iter::Iterator
+   |         ^^^^^^^^^^^^^^^^^^^^^ not a value
+...
+LL |     Trait!().map; // no `help` here!
+   |     -------- in this macro invocation
+   |
+   = note: this error originates in the macro `Trait` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found trait `Into`
+  --> $DIR/issue-100365.rs:25:9
+   |
+LL |         Into::<String>.into("")
+   |         ^^^^^^^^^^^^^^- help: use the path separator to refer to an item: `::`
+...
+LL |     let _ = create!();
+   |             --------- in this macro invocation
+   |
+   = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/issue-101749-2.rs b/tests/ui/resolve/issue-101749-2.rs
new file mode 100644
index 00000000000..4d3d469447c
--- /dev/null
+++ b/tests/ui/resolve/issue-101749-2.rs
@@ -0,0 +1,16 @@
+struct Rectangle {
+    width: i32,
+    height: i32,
+}
+impl Rectangle {
+    fn new(width: i32, height: i32) -> Self {
+        Self { width, height }
+    }
+}
+
+fn main() {
+    let rect = Rectangle::new(3, 4);
+    // `area` is not implemented for `Rectangle`, so this should not suggest
+    let _ = rect::area();
+    //~^ ERROR failed to resolve: use of undeclared crate or module `rect`
+}
diff --git a/tests/ui/resolve/issue-101749-2.stderr b/tests/ui/resolve/issue-101749-2.stderr
new file mode 100644
index 00000000000..370d4b14540
--- /dev/null
+++ b/tests/ui/resolve/issue-101749-2.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: use of undeclared crate or module `rect`
+  --> $DIR/issue-101749-2.rs:14:13
+   |
+LL |     let _ = rect::area();
+   |             ^^^^ use of undeclared crate or module `rect`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/issue-101749.fixed b/tests/ui/resolve/issue-101749.fixed
new file mode 100644
index 00000000000..3e5544296e4
--- /dev/null
+++ b/tests/ui/resolve/issue-101749.fixed
@@ -0,0 +1,19 @@
+// run-rustfix
+struct Rectangle {
+    width: i32,
+    height: i32,
+}
+impl Rectangle {
+    fn new(width: i32, height: i32) -> Self {
+        Self { width, height }
+    }
+    fn area(&self) -> i32 {
+        self.height * self.width
+    }
+}
+
+fn main() {
+    let rect = Rectangle::new(3, 4);
+    let _ = rect.area();
+    //~^ ERROR failed to resolve: use of undeclared crate or module `rect`
+}
diff --git a/tests/ui/resolve/issue-101749.rs b/tests/ui/resolve/issue-101749.rs
new file mode 100644
index 00000000000..fd67ccab6fa
--- /dev/null
+++ b/tests/ui/resolve/issue-101749.rs
@@ -0,0 +1,19 @@
+// run-rustfix
+struct Rectangle {
+    width: i32,
+    height: i32,
+}
+impl Rectangle {
+    fn new(width: i32, height: i32) -> Self {
+        Self { width, height }
+    }
+    fn area(&self) -> i32 {
+        self.height * self.width
+    }
+}
+
+fn main() {
+    let rect = Rectangle::new(3, 4);
+    let _ = rect::area();
+    //~^ ERROR failed to resolve: use of undeclared crate or module `rect`
+}
diff --git a/tests/ui/resolve/issue-101749.stderr b/tests/ui/resolve/issue-101749.stderr
new file mode 100644
index 00000000000..dd29d7fc051
--- /dev/null
+++ b/tests/ui/resolve/issue-101749.stderr
@@ -0,0 +1,14 @@
+error[E0433]: failed to resolve: use of undeclared crate or module `rect`
+  --> $DIR/issue-101749.rs:17:13
+   |
+LL |     let _ = rect::area();
+   |             ^^^^ use of undeclared crate or module `rect`
+   |
+help: you may have meant to call an instance method
+   |
+LL |     let _ = rect.area();
+   |                 ~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/issue-10200.rs b/tests/ui/resolve/issue-10200.rs
new file mode 100644
index 00000000000..fe36a7e00bf
--- /dev/null
+++ b/tests/ui/resolve/issue-10200.rs
@@ -0,0 +1,9 @@
+struct Foo(bool);
+fn foo(_: usize) -> Foo { Foo(false) }
+
+fn main() {
+    match Foo(true) {
+        foo(x) //~ ERROR expected tuple struct or tuple variant, found function `foo`
+        => ()
+    }
+}
diff --git a/tests/ui/resolve/issue-10200.stderr b/tests/ui/resolve/issue-10200.stderr
new file mode 100644
index 00000000000..e60489f5b82
--- /dev/null
+++ b/tests/ui/resolve/issue-10200.stderr
@@ -0,0 +1,12 @@
+error[E0532]: expected tuple struct or tuple variant, found function `foo`
+  --> $DIR/issue-10200.rs:6:9
+   |
+LL | struct Foo(bool);
+   | ----------------- similarly named tuple struct `Foo` defined here
+...
+LL |         foo(x)
+   |         ^^^ help: a tuple struct with a similar name exists (notice the capitalization): `Foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0532`.
diff --git a/tests/ui/resolve/issue-102946.rs b/tests/ui/resolve/issue-102946.rs
new file mode 100644
index 00000000000..c6feca6f32f
--- /dev/null
+++ b/tests/ui/resolve/issue-102946.rs
@@ -0,0 +1,7 @@
+impl Error for str::Utf8Error {
+    //~^ ERROR cannot find trait `Error` in this scope
+    //~| ERROR ambiguous associated type
+    fn description(&self)  {}
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-102946.stderr b/tests/ui/resolve/issue-102946.stderr
new file mode 100644
index 00000000000..65be0258e6d
--- /dev/null
+++ b/tests/ui/resolve/issue-102946.stderr
@@ -0,0 +1,26 @@
+error[E0405]: cannot find trait `Error` in this scope
+  --> $DIR/issue-102946.rs:1:6
+   |
+LL | impl Error for str::Utf8Error {
+   |      ^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL | use std::error::Error;
+   |
+
+error[E0223]: ambiguous associated type
+  --> $DIR/issue-102946.rs:1:16
+   |
+LL | impl Error for str::Utf8Error {
+   |                ^^^^^^^^^^^^^^
+   |
+help: you are looking for the module in `std`, not the primitive type
+   |
+LL | impl Error for std::str::Utf8Error {
+   |                +++++
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0223, E0405.
+For more information about an error, try `rustc --explain E0223`.
diff --git a/tests/ui/resolve/issue-103202.rs b/tests/ui/resolve/issue-103202.rs
new file mode 100644
index 00000000000..469d9d7c860
--- /dev/null
+++ b/tests/ui/resolve/issue-103202.rs
@@ -0,0 +1,7 @@
+struct S {}
+
+impl S {
+    fn f(self: &S::x) {} //~ ERROR ambiguous associated type
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-103202.stderr b/tests/ui/resolve/issue-103202.stderr
new file mode 100644
index 00000000000..880389371ef
--- /dev/null
+++ b/tests/ui/resolve/issue-103202.stderr
@@ -0,0 +1,9 @@
+error[E0223]: ambiguous associated type
+  --> $DIR/issue-103202.rs:4:17
+   |
+LL |     fn f(self: &S::x) {}
+   |                 ^^^^ help: use fully-qualified syntax: `<S as Trait>::x`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0223`.
diff --git a/tests/ui/resolve/issue-103474.rs b/tests/ui/resolve/issue-103474.rs
new file mode 100644
index 00000000000..14f2259e1d4
--- /dev/null
+++ b/tests/ui/resolve/issue-103474.rs
@@ -0,0 +1,28 @@
+struct S {}
+impl S {
+    fn first(&self) {}
+
+    fn second(&self) {
+        first()
+        //~^ ERROR cannot find function `first` in this scope
+    }
+
+    fn third(&self) {
+        no_method_err()
+        //~^ ERROR cannot find function `no_method_err` in this scope
+    }
+}
+
+// https://github.com/rust-lang/rust/pull/103531#discussion_r1004728080
+struct Foo {
+    i: i32,
+}
+
+impl Foo {
+    fn needs_self() {
+        this.i
+        //~^ ERROR cannot find value `this` in this scope
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-103474.stderr b/tests/ui/resolve/issue-103474.stderr
new file mode 100644
index 00000000000..415d231552a
--- /dev/null
+++ b/tests/ui/resolve/issue-103474.stderr
@@ -0,0 +1,35 @@
+error[E0425]: cannot find value `this` in this scope
+  --> $DIR/issue-103474.rs:23:9
+   |
+LL |         this.i
+   |         ^^^^ not found in this scope
+   |
+help: you might have meant to use `self` here instead
+   |
+LL |         self.i
+   |         ~~~~
+help: if you meant to use `self`, you are also missing a `self` receiver argument
+   |
+LL |     fn needs_self(&self) {
+   |                   +++++
+
+error[E0425]: cannot find function `first` in this scope
+  --> $DIR/issue-103474.rs:6:9
+   |
+LL |         first()
+   |         ^^^^^ not found in this scope
+   |
+help: consider using the associated function
+   |
+LL |         self.first()
+   |         +++++
+
+error[E0425]: cannot find function `no_method_err` in this scope
+  --> $DIR/issue-103474.rs:11:9
+   |
+LL |         no_method_err()
+   |         ^^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-104700-inner_scope.rs b/tests/ui/resolve/issue-104700-inner_scope.rs
new file mode 100644
index 00000000000..e8f28c113e3
--- /dev/null
+++ b/tests/ui/resolve/issue-104700-inner_scope.rs
@@ -0,0 +1,11 @@
+fn main() {
+    let foo = 1;
+    {
+        let bar = 2;
+        let test_func = |x| x > 3;
+    }
+    if bar == 2 { //~ ERROR cannot find value
+        println!("yes");
+    }
+    test_func(1); //~ ERROR cannot find function
+}
diff --git a/tests/ui/resolve/issue-104700-inner_scope.stderr b/tests/ui/resolve/issue-104700-inner_scope.stderr
new file mode 100644
index 00000000000..051b234fc72
--- /dev/null
+++ b/tests/ui/resolve/issue-104700-inner_scope.stderr
@@ -0,0 +1,21 @@
+error[E0425]: cannot find value `bar` in this scope
+  --> $DIR/issue-104700-inner_scope.rs:7:8
+   |
+LL |     if bar == 2 {
+   |        ^^^
+   |
+help: the binding `bar` is available in a different scope in the same function
+  --> $DIR/issue-104700-inner_scope.rs:4:13
+   |
+LL |         let bar = 2;
+   |             ^^^
+
+error[E0425]: cannot find function `test_func` in this scope
+  --> $DIR/issue-104700-inner_scope.rs:10:5
+   |
+LL |     test_func(1);
+   |     ^^^^^^^^^ not found in this scope
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-105069.rs b/tests/ui/resolve/issue-105069.rs
new file mode 100644
index 00000000000..73455cf7711
--- /dev/null
+++ b/tests/ui/resolve/issue-105069.rs
@@ -0,0 +1,11 @@
+use self::A::*;
+use V; //~ ERROR `V` is ambiguous
+use self::B::*;
+enum A {
+    V
+}
+enum B {
+    V
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-105069.stderr b/tests/ui/resolve/issue-105069.stderr
new file mode 100644
index 00000000000..1e6c9c6e2dc
--- /dev/null
+++ b/tests/ui/resolve/issue-105069.stderr
@@ -0,0 +1,21 @@
+error[E0659]: `V` is ambiguous
+  --> $DIR/issue-105069.rs:2:5
+   |
+LL | use V;
+   |     ^ ambiguous name
+   |
+   = note: ambiguous because of multiple potential import sources
+note: `V` could refer to the variant imported here
+  --> $DIR/issue-105069.rs:1:5
+   |
+LL | use self::A::*;
+   |     ^^^^^^^^^^
+note: `V` could also refer to the variant imported here
+  --> $DIR/issue-105069.rs:3:5
+   |
+LL | use self::B::*;
+   |     ^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/tests/ui/resolve/issue-12796.rs b/tests/ui/resolve/issue-12796.rs
new file mode 100644
index 00000000000..942d6b9a568
--- /dev/null
+++ b/tests/ui/resolve/issue-12796.rs
@@ -0,0 +1,9 @@
+trait Trait {
+    fn outer(&self) {
+        fn inner(_: &Self) {
+            //~^ ERROR can't use generic parameters from outer function
+        }
+    }
+}
+
+fn main() { }
diff --git a/tests/ui/resolve/issue-12796.stderr b/tests/ui/resolve/issue-12796.stderr
new file mode 100644
index 00000000000..a01fd2d6542
--- /dev/null
+++ b/tests/ui/resolve/issue-12796.stderr
@@ -0,0 +1,12 @@
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-12796.rs:3:22
+   |
+LL |         fn inner(_: &Self) {
+   |                      ^^^^
+   |                      |
+   |                      use of generic parameter from outer function
+   |                      can't use `Self` here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/issue-14254.rs b/tests/ui/resolve/issue-14254.rs
new file mode 100644
index 00000000000..78add29ca0c
--- /dev/null
+++ b/tests/ui/resolve/issue-14254.rs
@@ -0,0 +1,105 @@
+trait Foo {
+    fn bar(&self);
+    fn baz(&self) { }
+    fn bah(_: Option<&Self>) { }
+}
+
+struct BarTy {
+    x : isize,
+    y : f64,
+}
+
+impl BarTy {
+    fn a() {}
+    fn b(&self) {}
+}
+
+impl Foo for *const BarTy {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        a;
+        //~^ ERROR cannot find value `a`
+    }
+}
+
+impl<'a> Foo for &'a BarTy {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        x;
+        //~^ ERROR cannot find value `x`
+        y;
+        //~^ ERROR cannot find value `y`
+        a;
+        //~^ ERROR cannot find value `a`
+        bah;
+        //~^ ERROR cannot find value `bah`
+        b;
+        //~^ ERROR cannot find value `b`
+    }
+}
+
+impl<'a> Foo for &'a mut BarTy {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        x;
+        //~^ ERROR cannot find value `x`
+        y;
+        //~^ ERROR cannot find value `y`
+        a;
+        //~^ ERROR cannot find value `a`
+        bah;
+        //~^ ERROR cannot find value `bah`
+        b;
+        //~^ ERROR cannot find value `b`
+    }
+}
+
+impl Foo for Box<BarTy> {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        bah;
+        //~^ ERROR cannot find value `bah`
+    }
+}
+
+impl Foo for *const isize {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        bah;
+        //~^ ERROR cannot find value `bah`
+    }
+}
+
+impl<'a> Foo for &'a isize {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        bah;
+        //~^ ERROR cannot find value `bah`
+    }
+}
+
+impl<'a> Foo for &'a mut isize {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        bah;
+        //~^ ERROR cannot find value `bah`
+    }
+}
+
+impl Foo for Box<isize> {
+    fn bar(&self) {
+        baz();
+        //~^ ERROR cannot find function `baz`
+        bah;
+        //~^ ERROR cannot find value `bah`
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-14254.stderr b/tests/ui/resolve/issue-14254.stderr
new file mode 100644
index 00000000000..690a40f7edd
--- /dev/null
+++ b/tests/ui/resolve/issue-14254.stderr
@@ -0,0 +1,182 @@
+error[E0425]: cannot find value `a` in this scope
+  --> $DIR/issue-14254.rs:21:9
+   |
+LL |         a;
+   |         ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+  --> $DIR/issue-14254.rs:30:9
+   |
+LL |         x;
+   |         ^ help: you might have meant to use the available field: `self.x`
+
+error[E0425]: cannot find value `y` in this scope
+  --> $DIR/issue-14254.rs:32:9
+   |
+LL |         y;
+   |         ^ help: you might have meant to use the available field: `self.y`
+
+error[E0425]: cannot find value `a` in this scope
+  --> $DIR/issue-14254.rs:34:9
+   |
+LL |         a;
+   |         ^ not found in this scope
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/issue-14254.rs:36:9
+   |
+LL |         bah;
+   |         ^^^
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+
+error[E0425]: cannot find value `b` in this scope
+  --> $DIR/issue-14254.rs:38:9
+   |
+LL |         b;
+   |         ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+  --> $DIR/issue-14254.rs:47:9
+   |
+LL |         x;
+   |         ^ help: you might have meant to use the available field: `self.x`
+
+error[E0425]: cannot find value `y` in this scope
+  --> $DIR/issue-14254.rs:49:9
+   |
+LL |         y;
+   |         ^ help: you might have meant to use the available field: `self.y`
+
+error[E0425]: cannot find value `a` in this scope
+  --> $DIR/issue-14254.rs:51:9
+   |
+LL |         a;
+   |         ^ not found in this scope
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/issue-14254.rs:53:9
+   |
+LL |         bah;
+   |         ^^^
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+
+error[E0425]: cannot find value `b` in this scope
+  --> $DIR/issue-14254.rs:55:9
+   |
+LL |         b;
+   |         ^ not found in this scope
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/issue-14254.rs:64:9
+   |
+LL |         bah;
+   |         ^^^
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/issue-14254.rs:73:9
+   |
+LL |         bah;
+   |         ^^^
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/issue-14254.rs:82:9
+   |
+LL |         bah;
+   |         ^^^
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/issue-14254.rs:91:9
+   |
+LL |         bah;
+   |         ^^^
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/issue-14254.rs:100:9
+   |
+LL |         bah;
+   |         ^^^
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:19:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:28:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:45:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:62:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:71:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:80:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:89:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/issue-14254.rs:98:9
+   |
+LL |         baz();
+   |         ^^^ help: you might have meant to call the method: `self.baz`
+
+error: aborting due to 24 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-16058.rs b/tests/ui/resolve/issue-16058.rs
new file mode 100644
index 00000000000..048aaf65fbf
--- /dev/null
+++ b/tests/ui/resolve/issue-16058.rs
@@ -0,0 +1,18 @@
+// ignore-sgx std::os::fortanix_sgx::usercalls::raw::Result changes compiler suggestions
+
+pub struct GslResult {
+    pub val: f64,
+    pub err: f64
+}
+
+impl GslResult {
+    pub fn new() -> GslResult {
+        Result {
+//~^ ERROR expected struct, variant or union type, found enum `Result`
+            val: 0f64,
+            err: 0f64
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-16058.stderr b/tests/ui/resolve/issue-16058.stderr
new file mode 100644
index 00000000000..c47d22cef5f
--- /dev/null
+++ b/tests/ui/resolve/issue-16058.stderr
@@ -0,0 +1,18 @@
+error[E0574]: expected struct, variant or union type, found enum `Result`
+  --> $DIR/issue-16058.rs:10:9
+   |
+LL |         Result {
+   |         ^^^^^^ not a struct, variant or union type
+   |
+help: consider importing one of these items instead
+   |
+LL | use std::fmt::Result;
+   |
+LL | use std::io::Result;
+   |
+LL | use std::thread::Result;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0574`.
diff --git a/tests/ui/resolve/issue-17518.rs b/tests/ui/resolve/issue-17518.rs
new file mode 100644
index 00000000000..edaebc8122c
--- /dev/null
+++ b/tests/ui/resolve/issue-17518.rs
@@ -0,0 +1,7 @@
+enum SomeEnum {
+    E
+}
+
+fn main() {
+    E { name: "foobar" }; //~ ERROR cannot find struct, variant or union type `E`
+}
diff --git a/tests/ui/resolve/issue-17518.stderr b/tests/ui/resolve/issue-17518.stderr
new file mode 100644
index 00000000000..034d0d01bfb
--- /dev/null
+++ b/tests/ui/resolve/issue-17518.stderr
@@ -0,0 +1,14 @@
+error[E0422]: cannot find struct, variant or union type `E` in this scope
+  --> $DIR/issue-17518.rs:6:5
+   |
+LL |     E { name: "foobar" };
+   |     ^ not found in this scope
+   |
+help: consider importing this variant
+   |
+LL | use SomeEnum::E;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0422`.
diff --git a/tests/ui/resolve/issue-18252.rs b/tests/ui/resolve/issue-18252.rs
new file mode 100644
index 00000000000..f6ebe292076
--- /dev/null
+++ b/tests/ui/resolve/issue-18252.rs
@@ -0,0 +1,8 @@
+enum Foo {
+    Variant { x: usize }
+}
+
+fn main() {
+    let f = Foo::Variant(42);
+    //~^ ERROR expected value, found struct variant `Foo::Variant`
+}
diff --git a/tests/ui/resolve/issue-18252.stderr b/tests/ui/resolve/issue-18252.stderr
new file mode 100644
index 00000000000..d9006c0a6c2
--- /dev/null
+++ b/tests/ui/resolve/issue-18252.stderr
@@ -0,0 +1,9 @@
+error[E0533]: expected value, found struct variant `Foo::Variant`
+  --> $DIR/issue-18252.rs:6:13
+   |
+LL |     let f = Foo::Variant(42);
+   |             ^^^^^^^^^^^^ not a value
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0533`.
diff --git a/tests/ui/resolve/issue-19452.rs b/tests/ui/resolve/issue-19452.rs
new file mode 100644
index 00000000000..1d3aa49eac6
--- /dev/null
+++ b/tests/ui/resolve/issue-19452.rs
@@ -0,0 +1,15 @@
+// aux-build:issue-19452-aux.rs
+
+extern crate issue_19452_aux;
+
+enum Homura {
+    Madoka { age: u32 }
+}
+
+fn main() {
+    let homura = Homura::Madoka;
+    //~^ ERROR expected value, found struct variant `Homura::Madoka`
+
+    let homura = issue_19452_aux::Homura::Madoka;
+    //~^ ERROR expected value, found struct variant `issue_19452_aux::Homura::Madoka`
+}
diff --git a/tests/ui/resolve/issue-19452.stderr b/tests/ui/resolve/issue-19452.stderr
new file mode 100644
index 00000000000..eff89241fd2
--- /dev/null
+++ b/tests/ui/resolve/issue-19452.stderr
@@ -0,0 +1,15 @@
+error[E0533]: expected value, found struct variant `Homura::Madoka`
+  --> $DIR/issue-19452.rs:10:18
+   |
+LL |     let homura = Homura::Madoka;
+   |                  ^^^^^^^^^^^^^^ not a value
+
+error[E0533]: expected value, found struct variant `issue_19452_aux::Homura::Madoka`
+  --> $DIR/issue-19452.rs:13:18
+   |
+LL |     let homura = issue_19452_aux::Homura::Madoka;
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a value
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0533`.
diff --git a/tests/ui/resolve/issue-21221-1.rs b/tests/ui/resolve/issue-21221-1.rs
new file mode 100644
index 00000000000..b180624d2f4
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-1.rs
@@ -0,0 +1,75 @@
+mod mul1 {
+    pub trait Mul {}
+}
+
+mod mul2 {
+    pub trait Mul {}
+}
+
+mod mul3 {
+    enum Mul {
+      Yes,
+      No
+    }
+}
+
+mod mul4 {
+    type Mul = String;
+}
+
+mod mul5 {
+    struct Mul{
+        left_term: u32,
+        right_term: u32
+    }
+}
+
+#[derive(Debug)]
+struct Foo;
+
+// When we comment the next line:
+//use mul1::Mul;
+
+// BEFORE, we got the following error for the `impl` below:
+//   error: use of undeclared trait name `Mul` [E0405]
+// AFTER, we get this message:
+//   error: trait `Mul` is not in scope.
+//   help: ...
+//   help: you can import several candidates into scope (`use ...;`):
+//   help:   `mul1::Mul`
+//   help:   `mul2::Mul`
+//   help:   `std::ops::Mul`
+
+impl Mul for Foo {
+//~^ ERROR cannot find trait `Mul`
+}
+
+// BEFORE, we got:
+//   error: use of undeclared type name `Mul` [E0412]
+// AFTER, we get:
+//   error: type name `Mul` is not in scope. Maybe you meant:
+//   help: ...
+//   help: you can import several candidates into scope (`use ...;`):
+//   help:   `mul1::Mul`
+//   help:   `mul2::Mul`
+//   help:   `mul3::Mul`
+//   help:   `mul4::Mul`
+//   help:   and 2 other candidates
+fn getMul() -> Mul {
+//~^ ERROR cannot find type `Mul`
+}
+
+// Let's also test what happens if the trait doesn't exist:
+impl ThisTraitReallyDoesntExistInAnyModuleReally for Foo {
+//~^ ERROR cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally`
+}
+
+// Let's also test what happens if there's just one alternative:
+impl Div for Foo {
+//~^ ERROR cannot find trait `Div`
+}
+
+fn main() {
+    let foo = Foo();
+    println!("Hello, {:?}!", foo);
+}
diff --git a/tests/ui/resolve/issue-21221-1.stderr b/tests/ui/resolve/issue-21221-1.stderr
new file mode 100644
index 00000000000..538eeead9fc
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-1.stderr
@@ -0,0 +1,51 @@
+error[E0405]: cannot find trait `Mul` in this scope
+  --> $DIR/issue-21221-1.rs:43:6
+   |
+LL | impl Mul for Foo {
+   |      ^^^ not found in this scope
+   |
+help: consider importing one of these items
+   |
+LL | use mul1::Mul;
+   |
+LL | use mul2::Mul;
+   |
+LL | use std::ops::Mul;
+   |
+
+error[E0412]: cannot find type `Mul` in this scope
+  --> $DIR/issue-21221-1.rs:58:16
+   |
+LL | fn getMul() -> Mul {
+   |                ^^^ not found in this scope
+   |
+help: consider importing one of these items
+   |
+LL | use mul1::Mul;
+   |
+LL | use mul2::Mul;
+   |
+LL | use std::ops::Mul;
+   |
+
+error[E0405]: cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally` in this scope
+  --> $DIR/issue-21221-1.rs:63:6
+   |
+LL | impl ThisTraitReallyDoesntExistInAnyModuleReally for Foo {
+   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0405]: cannot find trait `Div` in this scope
+  --> $DIR/issue-21221-1.rs:68:6
+   |
+LL | impl Div for Foo {
+   |      ^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL | use std::ops::Div;
+   |
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0405, E0412.
+For more information about an error, try `rustc --explain E0405`.
diff --git a/tests/ui/resolve/issue-21221-2.rs b/tests/ui/resolve/issue-21221-2.rs
new file mode 100644
index 00000000000..dc13e46cb48
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-2.rs
@@ -0,0 +1,21 @@
+pub mod foo {
+    pub mod bar {
+        // note: trait T is not public, but being in the current
+        // crate, it's fine to show it, since the programmer can
+        // decide to make it public based on the suggestion ...
+        pub trait T {}
+    }
+    // imports should be ignored:
+    use self::bar::T;
+}
+
+pub mod baz {
+    pub use foo;
+    pub use std::ops::{Mul as T};
+}
+
+struct Foo;
+impl T for Foo { }
+//~^ ERROR cannot find trait `T`
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-21221-2.stderr b/tests/ui/resolve/issue-21221-2.stderr
new file mode 100644
index 00000000000..d4fd7cb1257
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-2.stderr
@@ -0,0 +1,16 @@
+error[E0405]: cannot find trait `T` in this scope
+  --> $DIR/issue-21221-2.rs:18:6
+   |
+LL | impl T for Foo { }
+   |      ^ not found in this scope
+   |
+help: consider importing one of these items
+   |
+LL | use baz::T;
+   |
+LL | use foo::bar::T;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0405`.
diff --git a/tests/ui/resolve/issue-21221-3.rs b/tests/ui/resolve/issue-21221-3.rs
new file mode 100644
index 00000000000..f0c0a9fd61a
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-3.rs
@@ -0,0 +1,19 @@
+// testing whether the lookup mechanism picks up types
+// defined in the outside crate
+
+// aux-build:issue-21221-3.rs
+
+extern crate issue_21221_3;
+
+struct Foo;
+
+// NOTE: This shows only traits accessible from the current
+// crate, thus the two private entities:
+//   `issue_21221_3::outer::private_module::OuterTrait` and
+//   `issue_21221_3::outer::public_module::OuterTrait`
+// are hidden from the view.
+impl OuterTrait for Foo {}
+//~^ ERROR cannot find trait `OuterTrait`
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/tests/ui/resolve/issue-21221-3.stderr b/tests/ui/resolve/issue-21221-3.stderr
new file mode 100644
index 00000000000..f12e5b09bac
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-3.stderr
@@ -0,0 +1,14 @@
+error[E0405]: cannot find trait `OuterTrait` in this scope
+  --> $DIR/issue-21221-3.rs:15:6
+   |
+LL | impl OuterTrait for Foo {}
+   |      ^^^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL | use issue_21221_3::outer::OuterTrait;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0405`.
diff --git a/tests/ui/resolve/issue-21221-4.rs b/tests/ui/resolve/issue-21221-4.rs
new file mode 100644
index 00000000000..88d5bd06ca5
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-4.rs
@@ -0,0 +1,15 @@
+// testing whether the lookup mechanism picks up types
+// defined in the outside crate
+
+// aux-build:issue-21221-4.rs
+
+extern crate issue_21221_4;
+
+struct Foo;
+
+impl T for Foo {}
+//~^ ERROR cannot find trait `T`
+
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/tests/ui/resolve/issue-21221-4.stderr b/tests/ui/resolve/issue-21221-4.stderr
new file mode 100644
index 00000000000..fc15444d0c0
--- /dev/null
+++ b/tests/ui/resolve/issue-21221-4.stderr
@@ -0,0 +1,14 @@
+error[E0405]: cannot find trait `T` in this scope
+  --> $DIR/issue-21221-4.rs:10:6
+   |
+LL | impl T for Foo {}
+   |      ^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL | use issue_21221_4::T;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0405`.
diff --git a/tests/ui/resolve/issue-22692.rs b/tests/ui/resolve/issue-22692.rs
new file mode 100644
index 00000000000..31a76261408
--- /dev/null
+++ b/tests/ui/resolve/issue-22692.rs
@@ -0,0 +1,60 @@
+fn main() {
+    let _ = String.new();
+    //~^ ERROR expected value, found struct `String`
+    //~| HELP use the path separator
+
+    let _ = String.default;
+    //~^ ERROR expected value, found struct `String`
+    //~| HELP use the path separator
+
+    let _ = Vec::<()>.with_capacity(1);
+    //~^ ERROR expected value, found struct `Vec`
+    //~| HELP use the path separator
+}
+
+macro_rules! Type {
+    () => {
+        ::std::cell::Cell
+        //~^ ERROR expected value, found struct `std::cell::Cell`
+        //~| ERROR expected value, found struct `std::cell::Cell`
+        //~| ERROR expected value, found struct `std::cell::Cell`
+    };
+}
+
+macro_rules! create {
+    (type method) => {
+        Vec.new()
+        //~^ ERROR expected value, found struct `Vec`
+        //~| HELP use the path separator
+    };
+    (type field) => {
+        Vec.new
+        //~^ ERROR expected value, found struct `Vec`
+        //~| HELP use the path separator
+    };
+    (macro method) => {
+        Type!().new(0)
+        //~^ HELP use the path separator
+    };
+}
+
+fn interaction_with_macros() {
+    //
+    // Verify that we do not only suggest to replace `.` with `::` if the receiver is a
+    // macro call but that we also correctly suggest to surround it with angle brackets.
+    //
+
+    Type!().get();
+    //~^ HELP use the path separator
+
+    Type! {}.get;
+    //~^ HELP use the path separator
+
+    //
+    // Ensure that the suggestion is shown for expressions inside of macro definitions.
+    //
+
+    let _ = create!(type method);
+    let _ = create!(type field);
+    let _ = create!(macro method);
+}
diff --git a/tests/ui/resolve/issue-22692.stderr b/tests/ui/resolve/issue-22692.stderr
new file mode 100644
index 00000000000..6962aa161e9
--- /dev/null
+++ b/tests/ui/resolve/issue-22692.stderr
@@ -0,0 +1,88 @@
+error[E0423]: expected value, found struct `String`
+  --> $DIR/issue-22692.rs:2:13
+   |
+LL |     let _ = String.new();
+   |             ^^^^^^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found struct `String`
+  --> $DIR/issue-22692.rs:6:13
+   |
+LL |     let _ = String.default;
+   |             ^^^^^^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found struct `Vec`
+  --> $DIR/issue-22692.rs:10:13
+   |
+LL |     let _ = Vec::<()>.with_capacity(1);
+   |             ^^^^^^^^^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found struct `std::cell::Cell`
+  --> $DIR/issue-22692.rs:17:9
+   |
+LL |         ::std::cell::Cell
+   |         ^^^^^^^^^^^^^^^^^
+...
+LL |     Type!().get();
+   |     ------- in this macro invocation
+   |
+   = note: this error originates in the macro `Type` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: use the path separator to refer to an item
+   |
+LL |     <Type!()>::get();
+   |     ~~~~~~~~~~~
+
+error[E0423]: expected value, found struct `std::cell::Cell`
+  --> $DIR/issue-22692.rs:17:9
+   |
+LL |         ::std::cell::Cell
+   |         ^^^^^^^^^^^^^^^^^
+...
+LL |     Type! {}.get;
+   |     -------- in this macro invocation
+   |
+   = note: this error originates in the macro `Type` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: use the path separator to refer to an item
+   |
+LL |     <Type! {}>::get;
+   |     ~~~~~~~~~~~~
+
+error[E0423]: expected value, found struct `Vec`
+  --> $DIR/issue-22692.rs:26:9
+   |
+LL |         Vec.new()
+   |         ^^^- help: use the path separator to refer to an item: `::`
+...
+LL |     let _ = create!(type method);
+   |             -------------------- in this macro invocation
+   |
+   = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found struct `Vec`
+  --> $DIR/issue-22692.rs:31:9
+   |
+LL |         Vec.new
+   |         ^^^- help: use the path separator to refer to an item: `::`
+...
+LL |     let _ = create!(type field);
+   |             ------------------- in this macro invocation
+   |
+   = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found struct `std::cell::Cell`
+  --> $DIR/issue-22692.rs:17:9
+   |
+LL |         ::std::cell::Cell
+   |         ^^^^^^^^^^^^^^^^^
+...
+LL |     let _ = create!(macro method);
+   |             --------------------- in this macro invocation
+   |
+   = note: this error originates in the macro `Type` which comes from the expansion of the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: use the path separator to refer to an item
+   |
+LL |         <Type!()>::new(0)
+   |         ~~~~~~~~~~~
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/issue-2330.rs b/tests/ui/resolve/issue-2330.rs
new file mode 100644
index 00000000000..4560caba0cf
--- /dev/null
+++ b/tests/ui/resolve/issue-2330.rs
@@ -0,0 +1,13 @@
+enum Chan { }
+
+trait Channel<T> {
+    fn send(&self, v: T);
+}
+
+// `Chan` is not a trait, it's an enum
+impl Chan for isize { //~ ERROR expected trait, found enum `Chan`
+    fn send(&self, v: isize) { panic!() }
+}
+
+fn main() {
+}
diff --git a/tests/ui/resolve/issue-2330.stderr b/tests/ui/resolve/issue-2330.stderr
new file mode 100644
index 00000000000..877cf68b586
--- /dev/null
+++ b/tests/ui/resolve/issue-2330.stderr
@@ -0,0 +1,9 @@
+error[E0404]: expected trait, found enum `Chan`
+  --> $DIR/issue-2330.rs:8:6
+   |
+LL | impl Chan for isize {
+   |      ^^^^ not a trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0404`.
diff --git a/tests/ui/resolve/issue-23305.rs b/tests/ui/resolve/issue-23305.rs
new file mode 100644
index 00000000000..6d7fe7c50a2
--- /dev/null
+++ b/tests/ui/resolve/issue-23305.rs
@@ -0,0 +1,8 @@
+pub trait ToNbt<T> {
+    fn new(val: T) -> Self;
+}
+
+impl dyn ToNbt<Self> {}
+//~^ ERROR `Self` is not valid in the self type of an impl block
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-23305.stderr b/tests/ui/resolve/issue-23305.stderr
new file mode 100644
index 00000000000..aad1b583a32
--- /dev/null
+++ b/tests/ui/resolve/issue-23305.stderr
@@ -0,0 +1,10 @@
+error: `Self` is not valid in the self type of an impl block
+  --> $DIR/issue-23305.rs:5:16
+   |
+LL | impl dyn ToNbt<Self> {}
+   |                ^^^^
+   |
+   = note: replace `Self` with a different type
+
+error: aborting due to previous error
+
diff --git a/tests/ui/resolve/issue-2356.rs b/tests/ui/resolve/issue-2356.rs
new file mode 100644
index 00000000000..fe9bf4d443e
--- /dev/null
+++ b/tests/ui/resolve/issue-2356.rs
@@ -0,0 +1,94 @@
+trait Groom {
+    fn shave(other: usize);
+}
+
+pub struct Cat {
+  whiskers: isize,
+}
+
+pub enum MaybeDog {
+    Dog,
+    NoDog
+}
+
+impl MaybeDog {
+  fn bark() {
+    // If this provides a suggestion, it's a bug as MaybeDog doesn't impl Groom
+    shave();
+    //~^ ERROR cannot find function `shave`
+  }
+}
+
+impl Clone for Cat {
+  fn clone(&self) -> Self {
+    clone();
+    //~^ ERROR cannot find function `clone`
+    loop {}
+  }
+}
+impl Default for Cat {
+  fn default() -> Self {
+    default();
+    //~^ ERROR cannot find function `default` in this scope [E0425]
+    loop {}
+  }
+}
+
+impl Groom for Cat {
+  fn shave(other: usize) {
+    whiskers -= other;
+    //~^ ERROR cannot find value `whiskers`
+    shave(4);
+    //~^ ERROR cannot find function `shave`
+    purr();
+    //~^ ERROR cannot find function `purr`
+  }
+}
+
+impl Cat {
+    fn static_method() {}
+
+    fn purr_louder() {
+        static_method();
+        //~^ ERROR cannot find function `static_method`
+        purr();
+        //~^ ERROR cannot find function `purr`
+        purr();
+        //~^ ERROR cannot find function `purr`
+        purr();
+        //~^ ERROR cannot find function `purr`
+    }
+}
+
+impl Cat {
+  fn meow() {
+    if self.whiskers > 3 {
+        //~^ ERROR expected value, found module `self`
+        println!("MEOW");
+    }
+  }
+
+  fn purr(&self) {
+    grow_older();
+    //~^ ERROR cannot find function `grow_older`
+    shave();
+    //~^ ERROR cannot find function `shave`
+  }
+
+  fn burn_whiskers(&mut self) {
+    whiskers = 0;
+    //~^ ERROR cannot find value `whiskers`
+  }
+
+  pub fn grow_older(other:usize) {
+    whiskers = 4;
+    //~^ ERROR cannot find value `whiskers`
+    purr_louder();
+    //~^ ERROR cannot find function `purr_louder`
+  }
+}
+
+fn main() {
+    self += 1;
+    //~^ ERROR expected value, found module `self`
+}
diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr
new file mode 100644
index 00000000000..36f3da7c955
--- /dev/null
+++ b/tests/ui/resolve/issue-2356.stderr
@@ -0,0 +1,134 @@
+error[E0425]: cannot find function `default` in this scope
+  --> $DIR/issue-2356.rs:31:5
+   |
+LL |     default();
+   |     ^^^^^^^
+   |
+help: you might have meant to call the associated function
+   |
+LL |     Self::default();
+   |     ~~~~~~~~~~~~~
+help: consider importing this function
+   |
+LL | use std::default::default;
+   |
+
+error[E0425]: cannot find value `whiskers` in this scope
+  --> $DIR/issue-2356.rs:39:5
+   |
+LL |     whiskers -= other;
+   |     ^^^^^^^^ a field by this name exists in `Self`
+
+error[E0424]: expected value, found module `self`
+  --> $DIR/issue-2356.rs:65:8
+   |
+LL |   fn meow() {
+   |      ---- this function doesn't have a `self` parameter
+LL |     if self.whiskers > 3 {
+   |        ^^^^ `self` value is a keyword only available in methods with a `self` parameter
+   |
+help: add a `self` receiver parameter to make the associated `fn` a method
+   |
+LL |   fn meow(&self) {
+   |           +++++
+
+error[E0425]: cannot find value `whiskers` in this scope
+  --> $DIR/issue-2356.rs:79:5
+   |
+LL |     whiskers = 0;
+   |     ^^^^^^^^ help: you might have meant to use the available field: `self.whiskers`
+
+error[E0425]: cannot find value `whiskers` in this scope
+  --> $DIR/issue-2356.rs:84:5
+   |
+LL |     whiskers = 4;
+   |     ^^^^^^^^ a field by this name exists in `Self`
+
+error[E0424]: expected value, found module `self`
+  --> $DIR/issue-2356.rs:92:5
+   |
+LL | fn main() {
+   |    ---- this function can't have a `self` parameter
+LL |     self += 1;
+   |     ^^^^ `self` value is a keyword only available in methods with a `self` parameter
+
+error[E0425]: cannot find function `shave` in this scope
+  --> $DIR/issue-2356.rs:17:5
+   |
+LL |     shave();
+   |     ^^^^^ not found in this scope
+
+error[E0425]: cannot find function `clone` in this scope
+  --> $DIR/issue-2356.rs:24:5
+   |
+LL |     clone();
+   |     ^^^^^ help: you might have meant to call the method: `self.clone`
+
+error[E0425]: cannot find function `shave` in this scope
+  --> $DIR/issue-2356.rs:41:5
+   |
+LL |     shave(4);
+   |     ^^^^^ help: you might have meant to call the associated function: `Self::shave`
+
+error[E0425]: cannot find function `purr` in this scope
+  --> $DIR/issue-2356.rs:43:5
+   |
+LL |     purr();
+   |     ^^^^ not found in this scope
+
+error[E0425]: cannot find function `static_method` in this scope
+  --> $DIR/issue-2356.rs:52:9
+   |
+LL |         static_method();
+   |         ^^^^^^^^^^^^^ not found in this scope
+   |
+help: consider using the associated function
+   |
+LL |         Self::static_method();
+   |         ++++++
+
+error[E0425]: cannot find function `purr` in this scope
+  --> $DIR/issue-2356.rs:54:9
+   |
+LL |         purr();
+   |         ^^^^ not found in this scope
+
+error[E0425]: cannot find function `purr` in this scope
+  --> $DIR/issue-2356.rs:56:9
+   |
+LL |         purr();
+   |         ^^^^ not found in this scope
+
+error[E0425]: cannot find function `purr` in this scope
+  --> $DIR/issue-2356.rs:58:9
+   |
+LL |         purr();
+   |         ^^^^ not found in this scope
+
+error[E0425]: cannot find function `grow_older` in this scope
+  --> $DIR/issue-2356.rs:72:5
+   |
+LL |     grow_older();
+   |     ^^^^^^^^^^ not found in this scope
+   |
+help: consider using the associated function
+   |
+LL |     Self::grow_older();
+   |     ++++++
+
+error[E0425]: cannot find function `shave` in this scope
+  --> $DIR/issue-2356.rs:74:5
+   |
+LL |     shave();
+   |     ^^^^^ not found in this scope
+
+error[E0425]: cannot find function `purr_louder` in this scope
+  --> $DIR/issue-2356.rs:86:5
+   |
+LL |     purr_louder();
+   |     ^^^^^^^^^^^ not found in this scope
+
+error: aborting due to 17 previous errors
+
+Some errors have detailed explanations: E0424, E0425.
+For more information about an error, try `rustc --explain E0424`.
diff --git a/tests/ui/resolve/issue-23716.rs b/tests/ui/resolve/issue-23716.rs
new file mode 100644
index 00000000000..e9139c0aa14
--- /dev/null
+++ b/tests/ui/resolve/issue-23716.rs
@@ -0,0 +1,17 @@
+static foo: i32 = 0;
+
+fn bar(foo: i32) {}
+//~^ ERROR function parameters cannot shadow statics
+//~| cannot be named the same as a static
+
+mod submod {
+    pub static answer: i32 = 42;
+}
+
+use self::submod::answer;
+
+fn question(answer: i32) {}
+//~^ ERROR function parameters cannot shadow statics
+//~| cannot be named the same as a static
+fn main() {
+}
diff --git a/tests/ui/resolve/issue-23716.stderr b/tests/ui/resolve/issue-23716.stderr
new file mode 100644
index 00000000000..8b89c350c84
--- /dev/null
+++ b/tests/ui/resolve/issue-23716.stderr
@@ -0,0 +1,21 @@
+error[E0530]: function parameters cannot shadow statics
+  --> $DIR/issue-23716.rs:3:8
+   |
+LL | static foo: i32 = 0;
+   | -------------------- the static `foo` is defined here
+LL |
+LL | fn bar(foo: i32) {}
+   |        ^^^ cannot be named the same as a static
+
+error[E0530]: function parameters cannot shadow statics
+  --> $DIR/issue-23716.rs:13:13
+   |
+LL | use self::submod::answer;
+   |     -------------------- the static `answer` is imported here
+LL |
+LL | fn question(answer: i32) {}
+   |             ^^^^^^ cannot be named the same as a static
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0530`.
diff --git a/tests/ui/resolve/issue-24968.rs b/tests/ui/resolve/issue-24968.rs
new file mode 100644
index 00000000000..19e16abcee3
--- /dev/null
+++ b/tests/ui/resolve/issue-24968.rs
@@ -0,0 +1,30 @@
+// Also includes more Self usages per #93796
+
+fn foo(_: Self) {
+//~^ ERROR cannot find type `Self`
+}
+
+fn foo2() {
+    let x: Self;
+    //~^ ERROR cannot find type `Self`
+}
+
+type Foo<T>
+where
+    Self: Clone,
+//~^ ERROR cannot find type `Self`
+= Vec<T>;
+
+const FOO: Self = 0;
+//~^ ERROR cannot find type `Self`
+
+const FOO2: u32 = Self::bar();
+//~^ ERROR failed to resolve: `Self`
+
+static FOO_S: Self = 0;
+//~^ ERROR cannot find type `Self`
+
+static FOO_S2: u32 = Self::bar();
+//~^ ERROR failed to resolve: `Self`
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-24968.stderr b/tests/ui/resolve/issue-24968.stderr
new file mode 100644
index 00000000000..82f5a1d5b57
--- /dev/null
+++ b/tests/ui/resolve/issue-24968.stderr
@@ -0,0 +1,57 @@
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:3:11
+   |
+LL | fn foo(_: Self) {
+   |    ---    ^^^^ `Self` is only available in impls, traits, and type definitions
+   |    |
+   |    `Self` not allowed in a function
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:8:12
+   |
+LL | fn foo2() {
+   |    ---- `Self` not allowed in a function
+LL |     let x: Self;
+   |            ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:14:5
+   |
+LL | type Foo<T>
+   |      --- `Self` not allowed in a type alias
+LL | where
+LL |     Self: Clone,
+   |     ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:18:12
+   |
+LL | const FOO: Self = 0;
+   |       ---  ^^^^ `Self` is only available in impls, traits, and type definitions
+   |       |
+   |       `Self` not allowed in a constant item
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:24:15
+   |
+LL | static FOO_S: Self = 0;
+   |        -----  ^^^^ `Self` is only available in impls, traits, and type definitions
+   |        |
+   |        `Self` not allowed in a static item
+
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
+  --> $DIR/issue-24968.rs:21:19
+   |
+LL | const FOO2: u32 = Self::bar();
+   |                   ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
+  --> $DIR/issue-24968.rs:27:22
+   |
+LL | static FOO_S2: u32 = Self::bar();
+   |                      ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0411, E0433.
+For more information about an error, try `rustc --explain E0411`.
diff --git a/tests/ui/resolve/issue-26545.rs b/tests/ui/resolve/issue-26545.rs
new file mode 100644
index 00000000000..5652ee74706
--- /dev/null
+++ b/tests/ui/resolve/issue-26545.rs
@@ -0,0 +1,12 @@
+mod foo {
+    pub struct B(pub ());
+}
+
+mod baz {
+    fn foo() {
+        B(());
+        //~^ ERROR cannot find function, tuple struct or tuple variant `B` in this scope [E0425]
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-26545.stderr b/tests/ui/resolve/issue-26545.stderr
new file mode 100644
index 00000000000..d3c86692501
--- /dev/null
+++ b/tests/ui/resolve/issue-26545.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find function, tuple struct or tuple variant `B` in this scope
+  --> $DIR/issue-26545.rs:7:9
+   |
+LL |         B(());
+   |         ^ not found in this scope
+   |
+help: consider importing this tuple struct
+   |
+LL |     use foo::B;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-3021-c.rs b/tests/ui/resolve/issue-3021-c.rs
new file mode 100644
index 00000000000..94ed1fdf781
--- /dev/null
+++ b/tests/ui/resolve/issue-3021-c.rs
@@ -0,0 +1,9 @@
+fn siphash<T>() {
+
+    trait U {
+        fn g(&self, x: T) -> T;  //~ ERROR can't use generic parameters from outer function
+        //~^ ERROR can't use generic parameters from outer function
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-3021-c.stderr b/tests/ui/resolve/issue-3021-c.stderr
new file mode 100644
index 00000000000..5176efc3a6b
--- /dev/null
+++ b/tests/ui/resolve/issue-3021-c.stderr
@@ -0,0 +1,25 @@
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-3021-c.rs:4:24
+   |
+LL | fn siphash<T>() {
+   |            - type parameter from outer function
+LL |
+LL |     trait U {
+   |            - help: try using a local generic parameter instead: `<T>`
+LL |         fn g(&self, x: T) -> T;
+   |                        ^ use of generic parameter from outer function
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-3021-c.rs:4:30
+   |
+LL | fn siphash<T>() {
+   |            - type parameter from outer function
+LL |
+LL |     trait U {
+   |            - help: try using a local generic parameter instead: `<T>`
+LL |         fn g(&self, x: T) -> T;
+   |                              ^ use of generic parameter from outer function
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/issue-3021.rs b/tests/ui/resolve/issue-3021.rs
new file mode 100644
index 00000000000..a672261f8d6
--- /dev/null
+++ b/tests/ui/resolve/issue-3021.rs
@@ -0,0 +1,18 @@
+trait SipHash {
+    fn reset(&self);
+}
+
+fn siphash(k0 : u64) {
+    struct SipState {
+        v0: u64,
+    }
+
+    impl SipHash for SipState {
+        fn reset(&self) {
+           self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR can't capture dynamic environment
+        }
+    }
+    panic!();
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-3021.stderr b/tests/ui/resolve/issue-3021.stderr
new file mode 100644
index 00000000000..d5b015eec35
--- /dev/null
+++ b/tests/ui/resolve/issue-3021.stderr
@@ -0,0 +1,11 @@
+error[E0434]: can't capture dynamic environment in a fn item
+  --> $DIR/issue-3021.rs:12:22
+   |
+LL |            self.v0 = k0 ^ 0x736f6d6570736575;
+   |                      ^^
+   |
+   = help: use the `|| { ... }` closure form instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0434`.
diff --git a/tests/ui/resolve/issue-30535.rs b/tests/ui/resolve/issue-30535.rs
new file mode 100644
index 00000000000..d48f00d5aca
--- /dev/null
+++ b/tests/ui/resolve/issue-30535.rs
@@ -0,0 +1,9 @@
+// aux-build:issue-30535.rs
+
+extern crate issue_30535 as foo;
+
+fn bar(
+    _: foo::Foo::FooV //~ ERROR expected type, found variant `foo::Foo::FooV`
+) {}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-30535.stderr b/tests/ui/resolve/issue-30535.stderr
new file mode 100644
index 00000000000..e3692934b62
--- /dev/null
+++ b/tests/ui/resolve/issue-30535.stderr
@@ -0,0 +1,12 @@
+error[E0573]: expected type, found variant `foo::Foo::FooV`
+  --> $DIR/issue-30535.rs:6:8
+   |
+LL |     _: foo::Foo::FooV
+   |        ^^^^^^^^^^^^^^
+   |        |
+   |        not a type
+   |        help: try using the variant's enum: `foo::Foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0573`.
diff --git a/tests/ui/resolve/issue-31845.rs b/tests/ui/resolve/issue-31845.rs
new file mode 100644
index 00000000000..f6dc11502ba
--- /dev/null
+++ b/tests/ui/resolve/issue-31845.rs
@@ -0,0 +1,12 @@
+// Checks lexical scopes cannot see through normal module boundaries
+
+fn f() {
+    fn g() {}
+    mod foo {
+        fn h() {
+           g(); //~ ERROR cannot find function `g` in this scope
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-31845.stderr b/tests/ui/resolve/issue-31845.stderr
new file mode 100644
index 00000000000..56281938559
--- /dev/null
+++ b/tests/ui/resolve/issue-31845.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find function `g` in this scope
+  --> $DIR/issue-31845.rs:7:12
+   |
+LL |            g();
+   |            ^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-33876.rs b/tests/ui/resolve/issue-33876.rs
new file mode 100644
index 00000000000..e233ec631cc
--- /dev/null
+++ b/tests/ui/resolve/issue-33876.rs
@@ -0,0 +1,12 @@
+use std::any::Any;
+
+struct Foo;
+
+trait Bar {}
+
+impl Bar for Foo {}
+
+fn main() {
+    let any: &dyn Any = &Bar; //~ ERROR expected value, found trait `Bar`
+    if any.is::<u32>() { println!("u32"); }
+}
diff --git a/tests/ui/resolve/issue-33876.stderr b/tests/ui/resolve/issue-33876.stderr
new file mode 100644
index 00000000000..52308f2a7f0
--- /dev/null
+++ b/tests/ui/resolve/issue-33876.stderr
@@ -0,0 +1,9 @@
+error[E0423]: expected value, found trait `Bar`
+  --> $DIR/issue-33876.rs:10:26
+   |
+LL |     let any: &dyn Any = &Bar;
+   |                          ^^^ not a value
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/issue-35675.rs b/tests/ui/resolve/issue-35675.rs
new file mode 100644
index 00000000000..683761667d4
--- /dev/null
+++ b/tests/ui/resolve/issue-35675.rs
@@ -0,0 +1,42 @@
+// these two HELPs are actually in a new line between this line and the `enum Fruit` line
+enum Fruit {
+    Apple(i64),
+    Orange(i64),
+}
+
+fn should_return_fruit() -> Apple {
+    //~^ ERROR cannot find type `Apple` in this scope
+    Apple(5)
+    //~^ ERROR cannot find function, tuple struct or tuple variant `Apple` in this scope
+}
+
+fn should_return_fruit_too() -> Fruit::Apple {
+    //~^ ERROR expected type, found variant `Fruit::Apple`
+    Apple(5)
+    //~^ ERROR cannot find function, tuple struct or tuple variant `Apple` in this scope
+}
+
+fn foo() -> Ok {
+    //~^ ERROR expected type, found variant `Ok`
+    Ok(())
+}
+
+fn bar() -> Variant3 {
+    //~^ ERROR cannot find type `Variant3` in this scope
+}
+
+fn qux() -> Some {
+    //~^ ERROR expected type, found variant `Some`
+    Some(1)
+}
+
+fn main() {}
+
+mod x {
+    pub enum Enum {
+        Variant1,
+        Variant2(),
+        Variant3(usize),
+        Variant4 {},
+    }
+}
diff --git a/tests/ui/resolve/issue-35675.stderr b/tests/ui/resolve/issue-35675.stderr
new file mode 100644
index 00000000000..4a06196d548
--- /dev/null
+++ b/tests/ui/resolve/issue-35675.stderr
@@ -0,0 +1,75 @@
+error[E0412]: cannot find type `Apple` in this scope
+  --> $DIR/issue-35675.rs:7:29
+   |
+LL | fn should_return_fruit() -> Apple {
+   |                             ^^^^^ not found in this scope
+   |
+help: there is an enum variant `Fruit::Apple`; try using the variant's enum
+   |
+LL | fn should_return_fruit() -> Fruit {
+   |                             ~~~~~
+
+error[E0425]: cannot find function, tuple struct or tuple variant `Apple` in this scope
+  --> $DIR/issue-35675.rs:9:5
+   |
+LL |     Apple(5)
+   |     ^^^^^ not found in this scope
+   |
+help: consider importing this tuple variant
+   |
+LL | use Fruit::Apple;
+   |
+
+error[E0573]: expected type, found variant `Fruit::Apple`
+  --> $DIR/issue-35675.rs:13:33
+   |
+LL | fn should_return_fruit_too() -> Fruit::Apple {
+   |                                 ^^^^^^^^^^^^
+   |                                 |
+   |                                 not a type
+   |                                 help: try using the variant's enum: `Fruit`
+
+error[E0425]: cannot find function, tuple struct or tuple variant `Apple` in this scope
+  --> $DIR/issue-35675.rs:15:5
+   |
+LL |     Apple(5)
+   |     ^^^^^ not found in this scope
+   |
+help: consider importing this tuple variant
+   |
+LL | use Fruit::Apple;
+   |
+
+error[E0573]: expected type, found variant `Ok`
+  --> $DIR/issue-35675.rs:19:13
+   |
+LL | fn foo() -> Ok {
+   |             ^^
+   |             |
+   |             not a type
+   |             help: try using the variant's enum: `std::result::Result`
+
+error[E0412]: cannot find type `Variant3` in this scope
+  --> $DIR/issue-35675.rs:24:13
+   |
+LL | fn bar() -> Variant3 {
+   |             ^^^^^^^^ not found in this scope
+   |
+help: there is an enum variant `x::Enum::Variant3`; try using the variant's enum
+   |
+LL | fn bar() -> x::Enum {
+   |             ~~~~~~~
+
+error[E0573]: expected type, found variant `Some`
+  --> $DIR/issue-35675.rs:28:13
+   |
+LL | fn qux() -> Some {
+   |             ^^^^
+   |             |
+   |             not a type
+   |             help: try using the variant's enum: `std::option::Option`
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0412, E0425, E0573.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/issue-3907-2.rs b/tests/ui/resolve/issue-3907-2.rs
new file mode 100644
index 00000000000..46f145e63e1
--- /dev/null
+++ b/tests/ui/resolve/issue-3907-2.rs
@@ -0,0 +1,14 @@
+// aux-build:issue-3907.rs
+
+extern crate issue_3907;
+
+type Foo = dyn issue_3907::Foo + 'static;
+
+struct S {
+    name: isize
+}
+
+fn bar(_x: Foo) {}
+//~^ ERROR E0038
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-3907-2.stderr b/tests/ui/resolve/issue-3907-2.stderr
new file mode 100644
index 00000000000..782cfeec4bc
--- /dev/null
+++ b/tests/ui/resolve/issue-3907-2.stderr
@@ -0,0 +1,15 @@
+error[E0038]: the trait `issue_3907::Foo` cannot be made into an object
+  --> $DIR/issue-3907-2.rs:11:12
+   |
+LL | fn bar(_x: Foo) {}
+   |            ^^^ `issue_3907::Foo` cannot be made into an object
+   |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $DIR/auxiliary/issue-3907.rs:2:8
+   |
+LL |     fn bar();
+   |        ^^^ the trait cannot be made into an object because associated function `bar` has no `self` parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/resolve/issue-3907.rs b/tests/ui/resolve/issue-3907.rs
new file mode 100644
index 00000000000..6211de42717
--- /dev/null
+++ b/tests/ui/resolve/issue-3907.rs
@@ -0,0 +1,20 @@
+// aux-build:issue-3907.rs
+
+extern crate issue_3907;
+
+type Foo = dyn issue_3907::Foo;
+
+struct S {
+    name: isize
+}
+
+impl Foo for S { //~ ERROR expected trait, found type alias `Foo`
+    fn bar() { }
+}
+
+fn main() {
+    let s = S {
+        name: 0
+    };
+    s.bar();
+}
diff --git a/tests/ui/resolve/issue-3907.stderr b/tests/ui/resolve/issue-3907.stderr
new file mode 100644
index 00000000000..6fc61cae843
--- /dev/null
+++ b/tests/ui/resolve/issue-3907.stderr
@@ -0,0 +1,18 @@
+error[E0404]: expected trait, found type alias `Foo`
+  --> $DIR/issue-3907.rs:11:6
+   |
+LL | impl Foo for S {
+   |      ^^^ type aliases cannot be used as traits
+   |
+help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias
+   |
+LL | trait Foo = dyn issue_3907::Foo;
+   |
+help: consider importing this trait instead
+   |
+LL | use issue_3907::Foo;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0404`.
diff --git a/tests/ui/resolve/issue-39226.rs b/tests/ui/resolve/issue-39226.rs
new file mode 100644
index 00000000000..0f784f02b41
--- /dev/null
+++ b/tests/ui/resolve/issue-39226.rs
@@ -0,0 +1,14 @@
+struct Handle {}
+
+struct Something {
+    handle: Handle
+}
+
+fn main() {
+    let handle: Handle = Handle {};
+
+    let s: Something = Something {
+        handle: Handle
+        //~^ ERROR expected value, found struct `Handle`
+    };
+}
diff --git a/tests/ui/resolve/issue-39226.stderr b/tests/ui/resolve/issue-39226.stderr
new file mode 100644
index 00000000000..5045ec6c30e
--- /dev/null
+++ b/tests/ui/resolve/issue-39226.stderr
@@ -0,0 +1,21 @@
+error[E0423]: expected value, found struct `Handle`
+  --> $DIR/issue-39226.rs:11:17
+   |
+LL | struct Handle {}
+   | ---------------- `Handle` defined here
+...
+LL |         handle: Handle
+   |                 ^^^^^^
+   |
+help: use struct literal syntax instead
+   |
+LL |         handle: Handle {}
+   |                 ~~~~~~~~~
+help: a local variable with a similar name exists
+   |
+LL |         handle: handle
+   |                 ~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/issue-39559-2.rs b/tests/ui/resolve/issue-39559-2.rs
new file mode 100644
index 00000000000..07d3a82b1ed
--- /dev/null
+++ b/tests/ui/resolve/issue-39559-2.rs
@@ -0,0 +1,18 @@
+trait Dim {
+    fn dim() -> usize;
+}
+
+enum Dim3 {}
+
+impl Dim for Dim3 {
+    fn dim() -> usize {
+        3
+    }
+}
+
+fn main() {
+    let array: [usize; Dim3::dim()]
+    //~^ ERROR E0015
+        = [0; Dim3::dim()];
+        //~^ ERROR E0015
+}
diff --git a/tests/ui/resolve/issue-39559-2.stderr b/tests/ui/resolve/issue-39559-2.stderr
new file mode 100644
index 00000000000..ea27e7bd250
--- /dev/null
+++ b/tests/ui/resolve/issue-39559-2.stderr
@@ -0,0 +1,19 @@
+error[E0015]: cannot call non-const fn `<Dim3 as Dim>::dim` in constants
+  --> $DIR/issue-39559-2.rs:14:24
+   |
+LL |     let array: [usize; Dim3::dim()]
+   |                        ^^^^^^^^^^^
+   |
+   = note: calls in constants are limited to constant functions, tuple structs and tuple variants
+
+error[E0015]: cannot call non-const fn `<Dim3 as Dim>::dim` in constants
+  --> $DIR/issue-39559-2.rs:16:15
+   |
+LL |         = [0; Dim3::dim()];
+   |               ^^^^^^^^^^^
+   |
+   = note: calls in constants are limited to constant functions, tuple structs and tuple variants
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0015`.
diff --git a/tests/ui/resolve/issue-39559.rs b/tests/ui/resolve/issue-39559.rs
new file mode 100644
index 00000000000..58d25940733
--- /dev/null
+++ b/tests/ui/resolve/issue-39559.rs
@@ -0,0 +1,19 @@
+trait Dim {
+    fn dim() -> usize;
+}
+
+enum Dim3 {}
+
+impl Dim for Dim3 {
+    fn dim() -> usize {
+        3
+    }
+}
+
+pub struct Vector<T, D: Dim> {
+    entries: [T; D::dim()],
+    //~^ ERROR generic parameters may not be used
+    _dummy: D,
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-39559.stderr b/tests/ui/resolve/issue-39559.stderr
new file mode 100644
index 00000000000..7626f827fc5
--- /dev/null
+++ b/tests/ui/resolve/issue-39559.stderr
@@ -0,0 +1,11 @@
+error: generic parameters may not be used in const operations
+  --> $DIR/issue-39559.rs:14:18
+   |
+LL |     entries: [T; D::dim()],
+   |                  ^^^^^^ cannot perform const operation using `D`
+   |
+   = note: type parameters may not be used in const expressions
+   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
+
+error: aborting due to previous error
+
diff --git a/tests/ui/resolve/issue-42944.rs b/tests/ui/resolve/issue-42944.rs
new file mode 100644
index 00000000000..a4404857a56
--- /dev/null
+++ b/tests/ui/resolve/issue-42944.rs
@@ -0,0 +1,21 @@
+mod foo {
+    pub struct Bx(());
+}
+
+mod bar {
+    use foo::Bx;
+
+    fn foo() {
+        Bx(());
+        //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423]
+    }
+}
+
+mod baz {
+    fn foo() {
+        Bx(());
+        //~^ ERROR cannot find function, tuple struct or tuple variant `Bx` in this scope [E0425]
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-42944.stderr b/tests/ui/resolve/issue-42944.stderr
new file mode 100644
index 00000000000..0ee9fd391fe
--- /dev/null
+++ b/tests/ui/resolve/issue-42944.stderr
@@ -0,0 +1,28 @@
+error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this scope
+  --> $DIR/issue-42944.rs:16:9
+   |
+LL |         Bx(());
+   |         ^^ not found in this scope
+   |
+note: tuple struct `foo::Bx` exists but is inaccessible
+  --> $DIR/issue-42944.rs:2:5
+   |
+LL |     pub struct Bx(());
+   |     ^^^^^^^^^^^^^^^^^^ not accessible
+
+error[E0423]: cannot initialize a tuple struct which contains private fields
+  --> $DIR/issue-42944.rs:9:9
+   |
+LL |         Bx(());
+   |         ^^
+   |
+note: constructor is not visible here due to private fields
+  --> $DIR/issue-42944.rs:2:19
+   |
+LL |     pub struct Bx(());
+   |                   ^^ private field
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0423, E0425.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/issue-49074.rs b/tests/ui/resolve/issue-49074.rs
new file mode 100644
index 00000000000..752bb345b70
--- /dev/null
+++ b/tests/ui/resolve/issue-49074.rs
@@ -0,0 +1,13 @@
+// Check that unknown attribute error is shown even if there are unresolved macros.
+
+#[marco_use] // typo
+//~^ ERROR cannot find attribute `marco_use` in this scope
+mod foo {
+    macro_rules! bar {
+        () => ();
+    }
+}
+
+fn main() {
+   bar!(); //~ ERROR cannot find macro `bar` in this scope
+}
diff --git a/tests/ui/resolve/issue-49074.stderr b/tests/ui/resolve/issue-49074.stderr
new file mode 100644
index 00000000000..bbfeb4ea948
--- /dev/null
+++ b/tests/ui/resolve/issue-49074.stderr
@@ -0,0 +1,16 @@
+error: cannot find macro `bar` in this scope
+  --> $DIR/issue-49074.rs:12:4
+   |
+LL |    bar!();
+   |    ^^^
+   |
+   = help: have you added the `#[macro_use]` on the module/import?
+
+error: cannot find attribute `marco_use` in this scope
+  --> $DIR/issue-49074.rs:3:3
+   |
+LL | #[marco_use] // typo
+   |   ^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_use`
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/resolve/issue-5035-2.rs b/tests/ui/resolve/issue-5035-2.rs
new file mode 100644
index 00000000000..b831bb4be34
--- /dev/null
+++ b/tests/ui/resolve/issue-5035-2.rs
@@ -0,0 +1,7 @@
+trait I {}
+type K = dyn I + 'static;
+
+fn foo(_x: K) {}
+//~^ ERROR the size for values of type
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-5035-2.stderr b/tests/ui/resolve/issue-5035-2.stderr
new file mode 100644
index 00000000000..558e6b7b118
--- /dev/null
+++ b/tests/ui/resolve/issue-5035-2.stderr
@@ -0,0 +1,20 @@
+error[E0277]: the size for values of type `(dyn I + 'static)` cannot be known at compilation time
+  --> $DIR/issue-5035-2.rs:4:8
+   |
+LL | fn foo(_x: K) {}
+   |        ^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `(dyn I + 'static)`
+   = help: unsized fn params are gated as an unstable feature
+help: you can use `impl Trait` as the argument type
+   |
+LL | fn foo(_x: impl K) {}
+   |            ++++
+help: function arguments must have a statically known size, borrowed types always have a known size
+   |
+LL | fn foo(_x: &K) {}
+   |            +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/resolve/issue-5035.rs b/tests/ui/resolve/issue-5035.rs
new file mode 100644
index 00000000000..49fa312f9d2
--- /dev/null
+++ b/tests/ui/resolve/issue-5035.rs
@@ -0,0 +1,9 @@
+trait I {}
+type K = dyn I;
+impl K for isize {} //~ ERROR expected trait, found type alias `K`
+
+use ImportError; //~ ERROR unresolved import `ImportError` [E0432]
+                 //~^ no `ImportError` in the root
+impl ImportError for () {} // check that this is not an additional error (cf. issue #35142)
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-5035.stderr b/tests/ui/resolve/issue-5035.stderr
new file mode 100644
index 00000000000..32b972b21ff
--- /dev/null
+++ b/tests/ui/resolve/issue-5035.stderr
@@ -0,0 +1,28 @@
+error[E0432]: unresolved import `ImportError`
+  --> $DIR/issue-5035.rs:5:5
+   |
+LL | use ImportError;
+   |     ^^^^^^^^^^^ no `ImportError` in the root
+
+error[E0404]: expected trait, found type alias `K`
+  --> $DIR/issue-5035.rs:3:6
+   |
+LL | trait I {}
+   | ------- similarly named trait `I` defined here
+LL | type K = dyn I;
+LL | impl K for isize {}
+   |      ^ type aliases cannot be used as traits
+   |
+help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias
+   |
+LL | trait K = dyn I;
+   |
+help: a trait with a similar name exists
+   |
+LL | impl I for isize {}
+   |      ~
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0404, E0432.
+For more information about an error, try `rustc --explain E0404`.
diff --git a/tests/ui/resolve/issue-50599.rs b/tests/ui/resolve/issue-50599.rs
new file mode 100644
index 00000000000..72238a59198
--- /dev/null
+++ b/tests/ui/resolve/issue-50599.rs
@@ -0,0 +1,6 @@
+fn main() {
+    const N: u32 = 1_000;
+    const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value
+    let mut digits = [0u32; M];
+    //~^ constant
+}
diff --git a/tests/ui/resolve/issue-50599.stderr b/tests/ui/resolve/issue-50599.stderr
new file mode 100644
index 00000000000..b07482c83cc
--- /dev/null
+++ b/tests/ui/resolve/issue-50599.stderr
@@ -0,0 +1,27 @@
+error[E0425]: cannot find value `LOG10_2` in module `std::f64`
+  --> $DIR/issue-50599.rs:3:48
+   |
+LL |     const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize;
+   |                                                ^^^^^^^ not found in `std::f64`
+   |
+help: consider importing one of these items
+   |
+LL | use std::f32::consts::LOG10_2;
+   |
+LL | use std::f64::consts::LOG10_2;
+   |
+help: if you import `LOG10_2`, refer to it directly
+   |
+LL -     const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize;
+LL +     const M: usize = (f64::from(N) * LOG10_2) as usize;
+   |
+
+note: erroneous constant used
+  --> $DIR/issue-50599.rs:4:29
+   |
+LL |     let mut digits = [0u32; M];
+   |                             ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-5099.rs b/tests/ui/resolve/issue-5099.rs
new file mode 100644
index 00000000000..b5abccb4b19
--- /dev/null
+++ b/tests/ui/resolve/issue-5099.rs
@@ -0,0 +1,13 @@
+trait B <A> {
+    fn a() -> A {
+        this.a //~ ERROR cannot find value `this` in this scope
+    }
+    fn b(x: i32) {
+        this.b(x); //~ ERROR cannot find value `this` in this scope
+    }
+    fn c() {
+        let _ = || this.a; //~ ERROR cannot find value `this` in this scope
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-5099.stderr b/tests/ui/resolve/issue-5099.stderr
new file mode 100644
index 00000000000..e9b2a9c4d48
--- /dev/null
+++ b/tests/ui/resolve/issue-5099.stderr
@@ -0,0 +1,48 @@
+error[E0425]: cannot find value `this` in this scope
+  --> $DIR/issue-5099.rs:3:9
+   |
+LL |         this.a
+   |         ^^^^ not found in this scope
+   |
+help: you might have meant to use `self` here instead
+   |
+LL |         self.a
+   |         ~~~~
+help: if you meant to use `self`, you are also missing a `self` receiver argument
+   |
+LL |     fn a(&self) -> A {
+   |          +++++
+
+error[E0425]: cannot find value `this` in this scope
+  --> $DIR/issue-5099.rs:6:9
+   |
+LL |         this.b(x);
+   |         ^^^^ not found in this scope
+   |
+help: you might have meant to use `self` here instead
+   |
+LL |         self.b(x);
+   |         ~~~~
+help: if you meant to use `self`, you are also missing a `self` receiver argument
+   |
+LL |     fn b(&self, x: i32) {
+   |          ++++++
+
+error[E0425]: cannot find value `this` in this scope
+  --> $DIR/issue-5099.rs:9:20
+   |
+LL |         let _ = || this.a;
+   |                    ^^^^ not found in this scope
+   |
+help: you might have meant to use `self` here instead
+   |
+LL |         let _ = || self.a;
+   |                    ~~~~
+help: if you meant to use `self`, you are also missing a `self` receiver argument
+   |
+LL |     fn c(&self) {
+   |          +++++
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-54379.rs b/tests/ui/resolve/issue-54379.rs
new file mode 100644
index 00000000000..807c54393f2
--- /dev/null
+++ b/tests/ui/resolve/issue-54379.rs
@@ -0,0 +1,14 @@
+struct MyStruct {
+    pub s1: Option<String>,
+}
+
+fn main() {
+    let thing = MyStruct { s1: None };
+
+    match thing {
+        MyStruct { .., Some(_) } => {},
+        //~^ ERROR expected `,`
+        //~| ERROR expected `}`, found `,`
+        _ => {}
+    }
+}
diff --git a/tests/ui/resolve/issue-54379.stderr b/tests/ui/resolve/issue-54379.stderr
new file mode 100644
index 00000000000..750727273eb
--- /dev/null
+++ b/tests/ui/resolve/issue-54379.stderr
@@ -0,0 +1,19 @@
+error: expected `}`, found `,`
+  --> $DIR/issue-54379.rs:9:22
+   |
+LL |         MyStruct { .., Some(_) } => {},
+   |                    --^
+   |                    | |
+   |                    | expected `}`
+   |                    `..` must be at the end and cannot have a trailing comma
+
+error: expected `,`
+  --> $DIR/issue-54379.rs:9:28
+   |
+LL |         MyStruct { .., Some(_) } => {},
+   |         --------           ^
+   |         |
+   |         while parsing the fields for this pattern
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/resolve/issue-55673.rs b/tests/ui/resolve/issue-55673.rs
new file mode 100644
index 00000000000..0436bd39742
--- /dev/null
+++ b/tests/ui/resolve/issue-55673.rs
@@ -0,0 +1,12 @@
+trait Foo {
+    type Bar;
+}
+
+fn foo<T: Foo>()
+where
+    T::Baa: std::fmt::Debug,
+    //~^ ERROR associated type `Baa` not found for `T`
+{
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-55673.stderr b/tests/ui/resolve/issue-55673.stderr
new file mode 100644
index 00000000000..39318f95905
--- /dev/null
+++ b/tests/ui/resolve/issue-55673.stderr
@@ -0,0 +1,9 @@
+error[E0220]: associated type `Baa` not found for `T`
+  --> $DIR/issue-55673.rs:7:8
+   |
+LL |     T::Baa: std::fmt::Debug,
+   |        ^^^ there is a similarly named associated type `Bar` in the trait `Foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0220`.
diff --git a/tests/ui/resolve/issue-57523.rs b/tests/ui/resolve/issue-57523.rs
new file mode 100644
index 00000000000..976238cc3bd
--- /dev/null
+++ b/tests/ui/resolve/issue-57523.rs
@@ -0,0 +1,21 @@
+// check-pass
+
+struct S(u8);
+
+impl S {
+    fn method1() -> Self {
+        Self(0)
+    }
+}
+
+macro_rules! define_method { () => {
+    impl S {
+        fn method2() -> Self {
+            Self(0) // OK
+        }
+    }
+}}
+
+define_method!();
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-5927.rs b/tests/ui/resolve/issue-5927.rs
new file mode 100644
index 00000000000..14f95827be8
--- /dev/null
+++ b/tests/ui/resolve/issue-5927.rs
@@ -0,0 +1,7 @@
+fn main() {
+    let z = match 3 {
+        x(1) => x(1) //~ ERROR cannot find tuple struct or tuple variant `x` in this scope
+        //~^ ERROR cannot find function `x` in this scope
+    };
+    assert!(z == 3);
+}
diff --git a/tests/ui/resolve/issue-5927.stderr b/tests/ui/resolve/issue-5927.stderr
new file mode 100644
index 00000000000..d6cd6853dbd
--- /dev/null
+++ b/tests/ui/resolve/issue-5927.stderr
@@ -0,0 +1,16 @@
+error[E0531]: cannot find tuple struct or tuple variant `x` in this scope
+  --> $DIR/issue-5927.rs:3:9
+   |
+LL |         x(1) => x(1)
+   |         ^ not found in this scope
+
+error[E0425]: cannot find function `x` in this scope
+  --> $DIR/issue-5927.rs:3:17
+   |
+LL |         x(1) => x(1)
+   |                 ^ not found in this scope
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0425, E0531.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-60057.rs b/tests/ui/resolve/issue-60057.rs
new file mode 100644
index 00000000000..b52343adaee
--- /dev/null
+++ b/tests/ui/resolve/issue-60057.rs
@@ -0,0 +1,19 @@
+struct A {
+    banana: u8,
+}
+
+impl A {
+    fn new(peach: u8) -> A {
+        A {
+            banana: banana //~ ERROR cannot find value `banana` in this scope
+        }
+    }
+
+    fn foo(&self, peach: u8) -> A {
+        A {
+            banana: banana //~ ERROR cannot find value `banana` in this scope
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-60057.stderr b/tests/ui/resolve/issue-60057.stderr
new file mode 100644
index 00000000000..4d915fcd9fe
--- /dev/null
+++ b/tests/ui/resolve/issue-60057.stderr
@@ -0,0 +1,15 @@
+error[E0425]: cannot find value `banana` in this scope
+  --> $DIR/issue-60057.rs:8:21
+   |
+LL |             banana: banana
+   |                     ^^^^^^ a field by this name exists in `Self`
+
+error[E0425]: cannot find value `banana` in this scope
+  --> $DIR/issue-60057.rs:14:21
+   |
+LL |             banana: banana
+   |                     ^^^^^^ help: you might have meant to use the available field: `self.banana`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-65025-extern-static-parent-generics.rs b/tests/ui/resolve/issue-65025-extern-static-parent-generics.rs
new file mode 100644
index 00000000000..ce45f630e48
--- /dev/null
+++ b/tests/ui/resolve/issue-65025-extern-static-parent-generics.rs
@@ -0,0 +1,10 @@
+unsafe fn foo<A>() {
+    extern "C" {
+        static baz: *const A;
+        //~^ ERROR can't use generic parameters from outer function
+    }
+
+    let bar: *const u64 = core::mem::transmute(&baz);
+}
+
+fn main() { }
diff --git a/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr b/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr
new file mode 100644
index 00000000000..6bbf76dd1fb
--- /dev/null
+++ b/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr
@@ -0,0 +1,12 @@
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-65025-extern-static-parent-generics.rs:3:28
+   |
+LL | unsafe fn foo<A>() {
+   |               - type parameter from outer function
+LL |     extern "C" {
+LL |         static baz: *const A;
+   |                            ^ use of generic parameter from outer function
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/issue-65035-static-with-parent-generics.rs b/tests/ui/resolve/issue-65035-static-with-parent-generics.rs
new file mode 100644
index 00000000000..f96c04841dd
--- /dev/null
+++ b/tests/ui/resolve/issue-65035-static-with-parent-generics.rs
@@ -0,0 +1,26 @@
+fn f<T>() {
+    extern "C" {
+        static a: *const T;
+        //~^ ERROR can't use generic parameters from outer function
+    }
+}
+
+fn g<T: Default>() {
+    static a: *const T = Default::default();
+    //~^ ERROR can't use generic parameters from outer function
+}
+
+fn h<const N: usize>() {
+    extern "C" {
+        static a: [u8; N];
+        //~^ ERROR can't use generic parameters from outer function
+    }
+}
+
+fn i<const N: usize>() {
+    static a: [u8; N] = [0; N];
+    //~^ ERROR can't use generic parameters from outer function
+    //~| ERROR can't use generic parameters from outer function
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr b/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr
new file mode 100644
index 00000000000..7ed572f80b8
--- /dev/null
+++ b/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr
@@ -0,0 +1,45 @@
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-65035-static-with-parent-generics.rs:3:26
+   |
+LL | fn f<T>() {
+   |      - type parameter from outer function
+LL |     extern "C" {
+LL |         static a: *const T;
+   |                          ^ use of generic parameter from outer function
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-65035-static-with-parent-generics.rs:9:22
+   |
+LL | fn g<T: Default>() {
+   |      - type parameter from outer function
+LL |     static a: *const T = Default::default();
+   |                      ^ use of generic parameter from outer function
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-65035-static-with-parent-generics.rs:15:24
+   |
+LL | fn h<const N: usize>() {
+   |            - const parameter from outer function
+LL |     extern "C" {
+LL |         static a: [u8; N];
+   |                        ^ use of generic parameter from outer function
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-65035-static-with-parent-generics.rs:21:20
+   |
+LL | fn i<const N: usize>() {
+   |            - const parameter from outer function
+LL |     static a: [u8; N] = [0; N];
+   |                    ^ use of generic parameter from outer function
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/issue-65035-static-with-parent-generics.rs:21:29
+   |
+LL | fn i<const N: usize>() {
+   |            - const parameter from outer function
+LL |     static a: [u8; N] = [0; N];
+   |                             ^ use of generic parameter from outer function
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/issue-6702.rs b/tests/ui/resolve/issue-6702.rs
new file mode 100644
index 00000000000..954dc36f38e
--- /dev/null
+++ b/tests/ui/resolve/issue-6702.rs
@@ -0,0 +1,9 @@
+struct Monster {
+    damage: isize
+}
+
+
+fn main() {
+    let _m = Monster();
+    //~^ ERROR expected function, tuple struct or tuple variant, found struct `Monster`
+}
diff --git a/tests/ui/resolve/issue-6702.stderr b/tests/ui/resolve/issue-6702.stderr
new file mode 100644
index 00000000000..a118f94191d
--- /dev/null
+++ b/tests/ui/resolve/issue-6702.stderr
@@ -0,0 +1,14 @@
+error[E0423]: expected function, tuple struct or tuple variant, found struct `Monster`
+  --> $DIR/issue-6702.rs:7:14
+   |
+LL | / struct Monster {
+LL | |     damage: isize
+LL | | }
+   | |_- `Monster` defined here
+...
+LL |       let _m = Monster();
+   |                ^^^^^^^^^ help: use struct literal syntax instead: `Monster { damage: val }`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs b/tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs
new file mode 100644
index 00000000000..c377ecea94d
--- /dev/null
+++ b/tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs
@@ -0,0 +1,6 @@
+fn main() {}
+
+trait Foo {
+    fn fn_with_type_named_same_as_local_in_param(b: b);
+    //~^ ERROR cannot find type `b` in this scope [E0412]
+}
diff --git a/tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.stderr b/tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.stderr
new file mode 100644
index 00000000000..109409d2731
--- /dev/null
+++ b/tests/ui/resolve/issue-69401-trait-fn-no-body-ty-local.stderr
@@ -0,0 +1,9 @@
+error[E0412]: cannot find type `b` in this scope
+  --> $DIR/issue-69401-trait-fn-no-body-ty-local.rs:4:53
+   |
+LL |     fn fn_with_type_named_same_as_local_in_param(b: b);
+   |                                                     ^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs
new file mode 100644
index 00000000000..49462f52fb4
--- /dev/null
+++ b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs
@@ -0,0 +1,19 @@
+// edition:2018
+
+async fn free(); //~ ERROR without a body
+
+struct A;
+impl A {
+    async fn inherent(); //~ ERROR without body
+}
+
+trait B {
+    async fn associated();
+    //~^ ERROR cannot be declared `async`
+}
+impl B for A {
+    async fn associated(); //~ ERROR without body
+    //~^ ERROR cannot be declared `async`
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr
new file mode 100644
index 00000000000..1354abb4f14
--- /dev/null
+++ b/tests/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr
@@ -0,0 +1,53 @@
+error: free function without a body
+  --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:3:1
+   |
+LL | async fn free();
+   | ^^^^^^^^^^^^^^^-
+   |                |
+   |                help: provide a definition for the function: `{ <body> }`
+
+error: associated function in `impl` without body
+  --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:7:5
+   |
+LL |     async fn inherent();
+   |     ^^^^^^^^^^^^^^^^^^^-
+   |                        |
+   |                        help: provide a definition for the function: `{ <body> }`
+
+error: associated function in `impl` without body
+  --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5
+   |
+LL |     async fn associated();
+   |     ^^^^^^^^^^^^^^^^^^^^^-
+   |                          |
+   |                          help: provide a definition for the function: `{ <body> }`
+
+error[E0706]: functions in traits cannot be declared `async`
+  --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:5
+   |
+LL |     async fn associated();
+   |     -----^^^^^^^^^^^^^^^^^
+   |     |
+   |     `async` because of this
+   |
+   = note: `async` trait functions are not currently supported
+   = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
+   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+   = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
+
+error[E0706]: functions in traits cannot be declared `async`
+  --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5
+   |
+LL |     async fn associated();
+   |     -----^^^^^^^^^^^^^^^^^
+   |     |
+   |     `async` because of this
+   |
+   = note: `async` trait functions are not currently supported
+   = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
+   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+   = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0706`.
diff --git a/tests/ui/resolve/issue-73427.rs b/tests/ui/resolve/issue-73427.rs
new file mode 100644
index 00000000000..5c2459a5903
--- /dev/null
+++ b/tests/ui/resolve/issue-73427.rs
@@ -0,0 +1,50 @@
+enum A {
+    StructWithFields { x: () },
+    TupleWithFields(()),
+    Struct {},
+    Tuple(),
+    Unit,
+}
+
+enum B {
+    StructWithFields { x: () },
+    TupleWithFields(()),
+}
+
+enum C {
+    StructWithFields { x: () },
+    TupleWithFields(()),
+    Unit,
+}
+
+enum D {
+    TupleWithFields(()),
+    Unit,
+}
+
+enum E {
+    TupleWithFields(()),
+}
+
+fn main() {
+    // Only variants without fields are suggested (and others mentioned in a note) where an enum
+    // is used rather than a variant.
+
+    A.foo();
+    //~^ ERROR expected value, found enum `A`
+    B.foo();
+    //~^ ERROR expected value, found enum `B`
+    C.foo();
+    //~^ ERROR expected value, found enum `C`
+    D.foo();
+    //~^ ERROR expected value, found enum `D`
+    E.foo();
+    //~^ ERROR expected value, found enum `E`
+
+    // Only tuple variants are suggested in calls or tuple struct pattern matching.
+
+    let x = A(3);
+    //~^ ERROR expected function, tuple struct or tuple variant, found enum `A`
+    if let A(3) = x { }
+    //~^ ERROR expected tuple struct or tuple variant, found enum `A`
+}
diff --git a/tests/ui/resolve/issue-73427.stderr b/tests/ui/resolve/issue-73427.stderr
new file mode 100644
index 00000000000..4af5f29d809
--- /dev/null
+++ b/tests/ui/resolve/issue-73427.stderr
@@ -0,0 +1,168 @@
+error[E0423]: expected value, found enum `A`
+  --> $DIR/issue-73427.rs:33:5
+   |
+LL |     A.foo();
+   |     ^
+   |
+note: the enum is defined here
+  --> $DIR/issue-73427.rs:1:1
+   |
+LL | / enum A {
+LL | |     StructWithFields { x: () },
+LL | |     TupleWithFields(()),
+LL | |     Struct {},
+LL | |     Tuple(),
+LL | |     Unit,
+LL | | }
+   | |_^
+help: you might have meant to use one of the following enum variants
+   |
+LL |     (A::Tuple()).foo();
+   |     ~~~~~~~~~~~~
+LL |     A::Unit.foo();
+   |     ~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |     (A::TupleWithFields(/* fields */)).foo();
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `B`
+  --> $DIR/issue-73427.rs:35:5
+   |
+LL |     B.foo();
+   |     ^ help: the following enum variant is available: `(B::TupleWithFields(/* fields */))`
+   |
+note: the enum is defined here
+  --> $DIR/issue-73427.rs:9:1
+   |
+LL | / enum B {
+LL | |     StructWithFields { x: () },
+LL | |     TupleWithFields(()),
+LL | | }
+   | |_^
+
+error[E0423]: expected value, found enum `C`
+  --> $DIR/issue-73427.rs:37:5
+   |
+LL |     C.foo();
+   |     ^
+   |
+note: the enum is defined here
+  --> $DIR/issue-73427.rs:14:1
+   |
+LL | / enum C {
+LL | |     StructWithFields { x: () },
+LL | |     TupleWithFields(()),
+LL | |     Unit,
+LL | | }
+   | |_^
+help: you might have meant to use the following enum variant
+   |
+LL |     C::Unit.foo();
+   |     ~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |     (C::TupleWithFields(/* fields */)).foo();
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `D`
+  --> $DIR/issue-73427.rs:39:5
+   |
+LL |     D.foo();
+   |     ^
+   |
+note: the enum is defined here
+  --> $DIR/issue-73427.rs:20:1
+   |
+LL | / enum D {
+LL | |     TupleWithFields(()),
+LL | |     Unit,
+LL | | }
+   | |_^
+help: you might have meant to use the following enum variant
+   |
+LL |     D::Unit.foo();
+   |     ~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |     (D::TupleWithFields(/* fields */)).foo();
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `E`
+  --> $DIR/issue-73427.rs:41:5
+   |
+LL |     E.foo();
+   |     ^
+   |
+note: the enum is defined here
+  --> $DIR/issue-73427.rs:25:1
+   |
+LL | / enum E {
+LL | |     TupleWithFields(()),
+LL | | }
+   | |_^
+help: the following enum variant is available
+   |
+LL |     (E::TupleWithFields(/* fields */)).foo();
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+help: consider importing one of these items instead
+   |
+LL | use std::f32::consts::E;
+   |
+LL | use std::f64::consts::E;
+   |
+
+error[E0532]: expected tuple struct or tuple variant, found enum `A`
+  --> $DIR/issue-73427.rs:48:12
+   |
+LL |     if let A(3) = x { }
+   |            ^
+   |
+   = help: you might have meant to match against the enum's non-tuple variant
+note: the enum is defined here
+  --> $DIR/issue-73427.rs:1:1
+   |
+LL | / enum A {
+LL | |     StructWithFields { x: () },
+LL | |     TupleWithFields(()),
+LL | |     Struct {},
+LL | |     Tuple(),
+LL | |     Unit,
+LL | | }
+   | |_^
+help: try to match against one of the enum's variants
+   |
+LL |     if let A::Tuple(3) = x { }
+   |            ~~~~~~~~
+LL |     if let A::TupleWithFields(3) = x { }
+   |            ~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected function, tuple struct or tuple variant, found enum `A`
+  --> $DIR/issue-73427.rs:46:13
+   |
+LL |     let x = A(3);
+   |             ^
+   |
+   = help: you might have meant to construct the enum's non-tuple variant
+note: the enum is defined here
+  --> $DIR/issue-73427.rs:1:1
+   |
+LL | / enum A {
+LL | |     StructWithFields { x: () },
+LL | |     TupleWithFields(()),
+LL | |     Struct {},
+LL | |     Tuple(),
+LL | |     Unit,
+LL | | }
+   | |_^
+help: try to construct one of the enum's variants
+   |
+LL |     let x = A::Tuple(3);
+   |             ~~~~~~~~
+LL |     let x = A::TupleWithFields(3);
+   |             ~~~~~~~~~~~~~~~~~~
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0423, E0532.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/issue-80079.rs b/tests/ui/resolve/issue-80079.rs
new file mode 100644
index 00000000000..4795ed062c8
--- /dev/null
+++ b/tests/ui/resolve/issue-80079.rs
@@ -0,0 +1,12 @@
+// aux-build:issue-80079.rs
+
+// using a module from another crate should not cause errors to suggest private
+// items in that module
+
+extern crate issue_80079;
+
+use issue_80079::public;
+
+fn main() {
+    let _ = Foo; //~ ERROR cannot find value `Foo` in this scope
+}
diff --git a/tests/ui/resolve/issue-80079.stderr b/tests/ui/resolve/issue-80079.stderr
new file mode 100644
index 00000000000..93e8c0341a1
--- /dev/null
+++ b/tests/ui/resolve/issue-80079.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `Foo` in this scope
+  --> $DIR/issue-80079.rs:11:13
+   |
+LL |     let _ = Foo;
+   |             ^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/issue-81508.rs b/tests/ui/resolve/issue-81508.rs
new file mode 100644
index 00000000000..23605cd2fd9
--- /dev/null
+++ b/tests/ui/resolve/issue-81508.rs
@@ -0,0 +1,22 @@
+// Confusing diagnostic when using variable as a type:
+//
+// Previous warnings indicate Foo is not used, when in fact it is
+// used improperly as a variable or constant. New warning points
+// out user may be trying to use variable as a type. Test demonstrates
+// cases for both local variable and const.
+
+fn main() {
+    let Baz: &str = "";
+
+    println!("{}", Baz::Bar); //~ ERROR: failed to resolve: use of undeclared type `Baz`
+}
+
+#[allow(non_upper_case_globals)]
+pub const Foo: &str = "";
+
+mod submod {
+    use super::Foo;
+    fn function() {
+        println!("{}", Foo::Bar); //~ ERROR: failed to resolve: use of undeclared type `Foo`
+    }
+}
diff --git a/tests/ui/resolve/issue-81508.stderr b/tests/ui/resolve/issue-81508.stderr
new file mode 100644
index 00000000000..7258174ba89
--- /dev/null
+++ b/tests/ui/resolve/issue-81508.stderr
@@ -0,0 +1,21 @@
+error[E0433]: failed to resolve: use of undeclared type `Baz`
+  --> $DIR/issue-81508.rs:11:20
+   |
+LL |     let Baz: &str = "";
+   |         --- help: `Baz` is defined here, but is not a type
+LL |
+LL |     println!("{}", Baz::Bar);
+   |                    ^^^ use of undeclared type `Baz`
+
+error[E0433]: failed to resolve: use of undeclared type `Foo`
+  --> $DIR/issue-81508.rs:20:24
+   |
+LL |     use super::Foo;
+   |         ---------- help: `Foo` is defined here, but is not a type
+LL |     fn function() {
+LL |         println!("{}", Foo::Bar);
+   |                        ^^^ use of undeclared type `Foo`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/issue-82156.rs b/tests/ui/resolve/issue-82156.rs
new file mode 100644
index 00000000000..6215259e486
--- /dev/null
+++ b/tests/ui/resolve/issue-82156.rs
@@ -0,0 +1,3 @@
+fn main() {
+    super(); //~ ERROR failed to resolve: there are too many leading `super` keywords
+}
diff --git a/tests/ui/resolve/issue-82156.stderr b/tests/ui/resolve/issue-82156.stderr
new file mode 100644
index 00000000000..d53599dcce6
--- /dev/null
+++ b/tests/ui/resolve/issue-82156.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: there are too many leading `super` keywords
+  --> $DIR/issue-82156.rs:2:5
+   |
+LL |     super();
+   |     ^^^^^ there are too many leading `super` keywords
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/issue-82865.rs b/tests/ui/resolve/issue-82865.rs
new file mode 100644
index 00000000000..07d88c413bf
--- /dev/null
+++ b/tests/ui/resolve/issue-82865.rs
@@ -0,0 +1,13 @@
+// Regression test for #82865.
+
+#![feature(decl_macro)]
+
+use x::y::z; //~ ERROR: failed to resolve: maybe a missing crate `x`?
+
+macro mac () {
+    Box::z //~ ERROR: no function or associated item
+}
+
+fn main() {
+    mac!();
+}
diff --git a/tests/ui/resolve/issue-82865.stderr b/tests/ui/resolve/issue-82865.stderr
new file mode 100644
index 00000000000..730fd6d6026
--- /dev/null
+++ b/tests/ui/resolve/issue-82865.stderr
@@ -0,0 +1,23 @@
+error[E0433]: failed to resolve: maybe a missing crate `x`?
+  --> $DIR/issue-82865.rs:5:5
+   |
+LL | use x::y::z;
+   |     ^ maybe a missing crate `x`?
+   |
+   = help: consider adding `extern crate x` to use the `x` crate
+
+error[E0599]: no function or associated item named `z` found for struct `Box<_, _>` in the current scope
+  --> $DIR/issue-82865.rs:8:10
+   |
+LL |     Box::z
+   |          ^ function or associated item not found in `Box<_, _>`
+...
+LL |     mac!();
+   |     ------ in this macro invocation
+   |
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0433, E0599.
+For more information about an error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/issue-85348.rs b/tests/ui/resolve/issue-85348.rs
new file mode 100644
index 00000000000..3a33c193408
--- /dev/null
+++ b/tests/ui/resolve/issue-85348.rs
@@ -0,0 +1,12 @@
+// Checks whether shadowing a const parameter leads to an ICE (#85348).
+
+impl<const N: usize> ArrayWindowsExample {
+//~^ ERROR: cannot find type `ArrayWindowsExample` in this scope [E0412]
+    fn next() {
+        let mut N;
+        //~^ ERROR: let bindings cannot shadow const parameters [E0530]
+        //~| ERROR: type annotations needed [E0282]
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-85348.stderr b/tests/ui/resolve/issue-85348.stderr
new file mode 100644
index 00000000000..42b43f825d1
--- /dev/null
+++ b/tests/ui/resolve/issue-85348.stderr
@@ -0,0 +1,30 @@
+error[E0530]: let bindings cannot shadow const parameters
+  --> $DIR/issue-85348.rs:6:17
+   |
+LL | impl<const N: usize> ArrayWindowsExample {
+   |            - the const parameter `N` is defined here
+...
+LL |         let mut N;
+   |                 ^ cannot be named the same as a const parameter
+
+error[E0412]: cannot find type `ArrayWindowsExample` in this scope
+  --> $DIR/issue-85348.rs:3:22
+   |
+LL | impl<const N: usize> ArrayWindowsExample {
+   |                      ^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0282]: type annotations needed
+  --> $DIR/issue-85348.rs:6:13
+   |
+LL |         let mut N;
+   |             ^^^^^
+   |
+help: consider giving `N` an explicit type
+   |
+LL |         let mut N: /* Type */;
+   |                  ++++++++++++
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0282, E0412, E0530.
+For more information about an error, try `rustc --explain E0282`.
diff --git a/tests/ui/resolve/issue-85671.rs b/tests/ui/resolve/issue-85671.rs
new file mode 100644
index 00000000000..337ec307ef3
--- /dev/null
+++ b/tests/ui/resolve/issue-85671.rs
@@ -0,0 +1,37 @@
+// check-pass
+
+// Some trait with a function that returns a slice:
+pub trait AsSlice {
+    type Element;
+    fn as_slice(&self) -> &[Self::Element];
+}
+
+// Some type
+pub struct A<Cont>(Cont);
+
+// Here we say that if A wraps a slice, then it implements AsSlice
+impl<'a, Element> AsSlice for A<&'a [Element]> {
+    type Element = Element;
+    fn as_slice(&self) -> &[Self::Element] {
+        self.0
+    }
+}
+
+impl<Cont> A<Cont> {
+    // We want this function to work
+    pub fn failing<Coef>(&self)
+    where
+        Self: AsSlice<Element = Coef>,
+    {
+        self.as_ref_a().as_ref_a();
+    }
+
+    pub fn as_ref_a<Coef>(&self) -> A<&[<Self as AsSlice>::Element]>
+    where
+        Self: AsSlice<Element = Coef>,
+    {
+        A(self.as_slice())
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-88472.rs b/tests/ui/resolve/issue-88472.rs
new file mode 100644
index 00000000000..6bf7caeddbf
--- /dev/null
+++ b/tests/ui/resolve/issue-88472.rs
@@ -0,0 +1,38 @@
+// Regression test for #88472, where a suggestion was issued to
+// import an inaccessible struct.
+
+#![warn(unused_imports)]
+//~^ NOTE: the lint level is defined here
+
+mod a {
+    struct Foo;
+    //~^ NOTE: struct `a::Foo` exists but is inaccessible
+    //~| NOTE: not accessible
+}
+
+mod b {
+    use crate::a::*;
+    //~^ WARNING: unused import
+    type Bar = Foo;
+    //~^ ERROR: cannot find type `Foo` in this scope [E0412]
+    //~| NOTE: not found in this scope
+}
+
+mod c {
+    enum Eee {}
+    //~^ NOTE: these enums exist but are inaccessible
+    //~| NOTE: `c::Eee`: not accessible
+
+    mod d {
+        enum Eee {}
+        //~^ NOTE: `c::d::Eee`: not accessible
+    }
+}
+
+mod e {
+    type Baz = Eee;
+    //~^ ERROR: cannot find type `Eee` in this scope [E0412]
+    //~| NOTE: not found in this scope
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-88472.stderr b/tests/ui/resolve/issue-88472.stderr
new file mode 100644
index 00000000000..8431fc97766
--- /dev/null
+++ b/tests/ui/resolve/issue-88472.stderr
@@ -0,0 +1,42 @@
+error[E0412]: cannot find type `Foo` in this scope
+  --> $DIR/issue-88472.rs:16:16
+   |
+LL |     type Bar = Foo;
+   |                ^^^ not found in this scope
+   |
+note: struct `a::Foo` exists but is inaccessible
+  --> $DIR/issue-88472.rs:8:5
+   |
+LL |     struct Foo;
+   |     ^^^^^^^^^^^ not accessible
+
+error[E0412]: cannot find type `Eee` in this scope
+  --> $DIR/issue-88472.rs:33:16
+   |
+LL |     type Baz = Eee;
+   |                ^^^ not found in this scope
+   |
+note: these enums exist but are inaccessible
+  --> $DIR/issue-88472.rs:22:5
+   |
+LL |     enum Eee {}
+   |     ^^^^^^^^ `c::Eee`: not accessible
+...
+LL |         enum Eee {}
+   |         ^^^^^^^^ `c::d::Eee`: not accessible
+
+warning: unused import: `crate::a::*`
+  --> $DIR/issue-88472.rs:14:9
+   |
+LL |     use crate::a::*;
+   |         ^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-88472.rs:4:9
+   |
+LL | #![warn(unused_imports)]
+   |         ^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/issue-90113.rs b/tests/ui/resolve/issue-90113.rs
new file mode 100644
index 00000000000..f6658b45ed1
--- /dev/null
+++ b/tests/ui/resolve/issue-90113.rs
@@ -0,0 +1,21 @@
+mod list {
+    pub use self::List::Cons;
+
+    pub enum List<T> {
+        Cons(T, Box<List<T>>),
+    }
+}
+
+mod alias {
+    use crate::list::List;
+
+    pub type Foo = List<String>;
+}
+
+fn foo(l: crate::alias::Foo) {
+    match l {
+        Cons(..) => {} //~ ERROR: cannot find tuple struct or tuple variant `Cons` in this scope
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-90113.stderr b/tests/ui/resolve/issue-90113.stderr
new file mode 100644
index 00000000000..1b78720571c
--- /dev/null
+++ b/tests/ui/resolve/issue-90113.stderr
@@ -0,0 +1,14 @@
+error[E0531]: cannot find tuple struct or tuple variant `Cons` in this scope
+  --> $DIR/issue-90113.rs:17:9
+   |
+LL |         Cons(..) => {}
+   |         ^^^^ not found in this scope
+   |
+help: consider importing this tuple variant
+   |
+LL | use list::List::Cons;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0531`.
diff --git a/tests/ui/resolve/levenshtein.rs b/tests/ui/resolve/levenshtein.rs
new file mode 100644
index 00000000000..a6f47162568
--- /dev/null
+++ b/tests/ui/resolve/levenshtein.rs
@@ -0,0 +1,31 @@
+const MAX_ITEM: usize = 10;
+
+fn foo_bar() {}
+
+fn foo(c: esize) {} // Misspelled primitive type name.
+//~^ ERROR cannot find
+
+enum Bar { }
+
+type A = Baz; // Misspelled type name.
+//~^ ERROR cannot find
+type B = Opiton<u8>; // Misspelled type name from the prelude.
+//~^ ERROR cannot find
+
+mod m {
+    type A = Baz; // No suggestion here, Bar is not visible
+    //~^ ERROR cannot find
+
+    pub struct First;
+    pub struct Second;
+}
+
+fn main() {
+    let v = [0u32; MAXITEM]; // Misspelled constant name.
+    //~^ ERROR cannot find
+    foobar(); // Misspelled function name.
+    //~^ ERROR cannot find
+    let b: m::first = m::second; // Misspelled item in module.
+    //~^ ERROR cannot find
+    //~| ERROR cannot find
+}
diff --git a/tests/ui/resolve/levenshtein.stderr b/tests/ui/resolve/levenshtein.stderr
new file mode 100644
index 00000000000..cf478210132
--- /dev/null
+++ b/tests/ui/resolve/levenshtein.stderr
@@ -0,0 +1,70 @@
+error[E0412]: cannot find type `esize` in this scope
+  --> $DIR/levenshtein.rs:5:11
+   |
+LL | fn foo(c: esize) {} // Misspelled primitive type name.
+   |           ^^^^^ help: a builtin type with a similar name exists: `isize`
+
+error[E0412]: cannot find type `Baz` in this scope
+  --> $DIR/levenshtein.rs:10:10
+   |
+LL | enum Bar { }
+   | -------- similarly named enum `Bar` defined here
+LL |
+LL | type A = Baz; // Misspelled type name.
+   |          ^^^ help: an enum with a similar name exists: `Bar`
+
+error[E0412]: cannot find type `Opiton` in this scope
+  --> $DIR/levenshtein.rs:12:10
+   |
+LL | type B = Opiton<u8>; // Misspelled type name from the prelude.
+   |          ^^^^^^ help: an enum with a similar name exists: `Option`
+  --> $SRC_DIR/core/src/option.rs:LL:COL
+   |
+   = note: similarly named enum `Option` defined here
+
+error[E0412]: cannot find type `Baz` in this scope
+  --> $DIR/levenshtein.rs:16:14
+   |
+LL |     type A = Baz; // No suggestion here, Bar is not visible
+   |              ^^^ not found in this scope
+
+error[E0425]: cannot find value `MAXITEM` in this scope
+  --> $DIR/levenshtein.rs:24:20
+   |
+LL | const MAX_ITEM: usize = 10;
+   | --------------------------- similarly named constant `MAX_ITEM` defined here
+...
+LL |     let v = [0u32; MAXITEM]; // Misspelled constant name.
+   |                    ^^^^^^^ help: a constant with a similar name exists: `MAX_ITEM`
+
+error[E0412]: cannot find type `first` in module `m`
+  --> $DIR/levenshtein.rs:28:15
+   |
+LL |     pub struct First;
+   |     ----------------- similarly named struct `First` defined here
+...
+LL |     let b: m::first = m::second; // Misspelled item in module.
+   |               ^^^^^ help: a struct with a similar name exists (notice the capitalization): `First`
+
+error[E0425]: cannot find value `second` in module `m`
+  --> $DIR/levenshtein.rs:28:26
+   |
+LL |     pub struct Second;
+   |     ------------------ similarly named unit struct `Second` defined here
+...
+LL |     let b: m::first = m::second; // Misspelled item in module.
+   |                          ^^^^^^ help: a unit struct with a similar name exists (notice the capitalization): `Second`
+
+error[E0425]: cannot find function `foobar` in this scope
+  --> $DIR/levenshtein.rs:26:5
+   |
+LL | fn foo_bar() {}
+   | ------------ similarly named function `foo_bar` defined here
+...
+LL |     foobar(); // Misspelled function name.
+   |     ^^^^^^ help: a function with a similar name exists: `foo_bar`
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0412, E0425.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/macro-determinacy-non-module.rs b/tests/ui/resolve/macro-determinacy-non-module.rs
new file mode 100644
index 00000000000..3215e0cd346
--- /dev/null
+++ b/tests/ui/resolve/macro-determinacy-non-module.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+use std as line;
+
+const C: u32 = line!();
+
+fn main() {}
diff --git a/tests/ui/resolve/missing-in-namespace.rs b/tests/ui/resolve/missing-in-namespace.rs
new file mode 100644
index 00000000000..e1dedb072b7
--- /dev/null
+++ b/tests/ui/resolve/missing-in-namespace.rs
@@ -0,0 +1,4 @@
+fn main() {
+    let _map = std::hahmap::HashMap::new();
+    //~^ ERROR failed to resolve: could not find `hahmap` in `std
+}
diff --git a/tests/ui/resolve/missing-in-namespace.stderr b/tests/ui/resolve/missing-in-namespace.stderr
new file mode 100644
index 00000000000..fc925ba3b6a
--- /dev/null
+++ b/tests/ui/resolve/missing-in-namespace.stderr
@@ -0,0 +1,19 @@
+error[E0433]: failed to resolve: could not find `hahmap` in `std`
+  --> $DIR/missing-in-namespace.rs:2:21
+   |
+LL |     let _map = std::hahmap::HashMap::new();
+   |                     ^^^^^^ could not find `hahmap` in `std`
+   |
+help: consider importing this struct
+   |
+LL | use std::collections::HashMap;
+   |
+help: if you import `HashMap`, refer to it directly
+   |
+LL -     let _map = std::hahmap::HashMap::new();
+LL +     let _map = HashMap::new();
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/name-clash-nullary.rs b/tests/ui/resolve/name-clash-nullary.rs
new file mode 100644
index 00000000000..b5f5e121492
--- /dev/null
+++ b/tests/ui/resolve/name-clash-nullary.rs
@@ -0,0 +1,3 @@
+fn main() {
+  let None: isize = 42; //~ ERROR mismatched types
+}
diff --git a/tests/ui/resolve/name-clash-nullary.stderr b/tests/ui/resolve/name-clash-nullary.stderr
new file mode 100644
index 00000000000..76c4b5914c1
--- /dev/null
+++ b/tests/ui/resolve/name-clash-nullary.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/name-clash-nullary.rs:2:7
+   |
+LL |   let None: isize = 42;
+   |       ^^^^  ----- expected due to this
+   |       |
+   |       expected `isize`, found enum `Option`
+   |
+   = note: expected type `isize`
+              found enum `Option<_>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/resolve/name-collision-in-trait-fn-sig.rs b/tests/ui/resolve/name-collision-in-trait-fn-sig.rs
new file mode 100644
index 00000000000..fba4ffa1c6e
--- /dev/null
+++ b/tests/ui/resolve/name-collision-in-trait-fn-sig.rs
@@ -0,0 +1,11 @@
+// check-pass
+// This is currently stable behavior, which was almost accidentally made an
+// error in #102161 since there is no test exercising it. I am not sure if
+// this _should_ be the desired behavior, but at least we should know if it
+// changes.
+
+fn main() {}
+
+trait Foo {
+    fn fn_with_type_named_same_as_local_in_param(b: i32, b: i32);
+}
diff --git a/tests/ui/resolve/no-implicit-prelude-nested.rs b/tests/ui/resolve/no-implicit-prelude-nested.rs
new file mode 100644
index 00000000000..c314967da4f
--- /dev/null
+++ b/tests/ui/resolve/no-implicit-prelude-nested.rs
@@ -0,0 +1,54 @@
+// Test that things from the prelude aren't in scope. Use many of them
+// so that renaming some things won't magically make this test fail
+// for the wrong reason (e.g., if `Add` changes to `Addition`, and
+// `no_implicit_prelude` stops working, then the `impl Add` will still
+// fail with the same error message).
+
+#[no_implicit_prelude]
+mod foo {
+    mod baz {
+        struct Test;
+        impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
+        impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone`
+        impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
+        impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
+        impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
+
+        fn foo() {
+            drop(2) //~ ERROR cannot find function `drop` in this scope
+        }
+    }
+
+    struct Test;
+    impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
+    impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone`
+    impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
+    impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
+    impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
+
+    fn foo() {
+        drop(2) //~ ERROR cannot find function `drop` in this scope
+    }
+}
+
+fn qux() {
+    #[no_implicit_prelude]
+    mod qux_inner {
+        struct Test;
+        impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
+        impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone`
+        impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
+        impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
+        impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
+
+        fn foo() {
+            drop(2) //~ ERROR cannot find function `drop` in this scope
+        }
+    }
+}
+
+
+fn main() {
+    // these should work fine
+    drop(2)
+}
diff --git a/tests/ui/resolve/no-implicit-prelude-nested.stderr b/tests/ui/resolve/no-implicit-prelude-nested.stderr
new file mode 100644
index 00000000000..198b630c52c
--- /dev/null
+++ b/tests/ui/resolve/no-implicit-prelude-nested.stderr
@@ -0,0 +1,187 @@
+error[E0405]: cannot find trait `Add` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:11:14
+   |
+LL |         impl Add for Test {}
+   |              ^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |         use std::ops::Add;
+   |
+
+error[E0404]: expected trait, found derive macro `Clone`
+  --> $DIR/no-implicit-prelude-nested.rs:12:14
+   |
+LL |         impl Clone for Test {}
+   |              ^^^^^ not a trait
+   |
+help: consider importing this trait instead
+   |
+LL |         use std::clone::Clone;
+   |
+
+error[E0405]: cannot find trait `Iterator` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:13:14
+   |
+LL |         impl Iterator for Test {}
+   |              ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |         use std::iter::Iterator;
+   |
+
+error[E0405]: cannot find trait `ToString` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:14:14
+   |
+LL |         impl ToString for Test {}
+   |              ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |         use std::string::ToString;
+   |
+
+error[E0405]: cannot find trait `Writer` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:15:14
+   |
+LL |         impl Writer for Test {}
+   |              ^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `drop` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:18:13
+   |
+LL |             drop(2)
+   |             ^^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL |         use std::mem::drop;
+   |
+
+error[E0405]: cannot find trait `Add` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:23:10
+   |
+LL |     impl Add for Test {}
+   |          ^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |     use std::ops::Add;
+   |
+
+error[E0404]: expected trait, found derive macro `Clone`
+  --> $DIR/no-implicit-prelude-nested.rs:24:10
+   |
+LL |     impl Clone for Test {}
+   |          ^^^^^ not a trait
+   |
+help: consider importing this trait instead
+   |
+LL |     use std::clone::Clone;
+   |
+
+error[E0405]: cannot find trait `Iterator` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:25:10
+   |
+LL |     impl Iterator for Test {}
+   |          ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |     use std::iter::Iterator;
+   |
+
+error[E0405]: cannot find trait `ToString` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:26:10
+   |
+LL |     impl ToString for Test {}
+   |          ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |     use std::string::ToString;
+   |
+
+error[E0405]: cannot find trait `Writer` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:27:10
+   |
+LL |     impl Writer for Test {}
+   |          ^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `drop` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:30:9
+   |
+LL |         drop(2)
+   |         ^^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL |     use std::mem::drop;
+   |
+
+error[E0405]: cannot find trait `Add` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:38:14
+   |
+LL |         impl Add for Test {}
+   |              ^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |         use std::ops::Add;
+   |
+
+error[E0404]: expected trait, found derive macro `Clone`
+  --> $DIR/no-implicit-prelude-nested.rs:39:14
+   |
+LL |         impl Clone for Test {}
+   |              ^^^^^ not a trait
+   |
+help: consider importing this trait instead
+   |
+LL |         use std::clone::Clone;
+   |
+
+error[E0405]: cannot find trait `Iterator` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:40:14
+   |
+LL |         impl Iterator for Test {}
+   |              ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |         use std::iter::Iterator;
+   |
+
+error[E0405]: cannot find trait `ToString` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:41:14
+   |
+LL |         impl ToString for Test {}
+   |              ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL |         use std::string::ToString;
+   |
+
+error[E0405]: cannot find trait `Writer` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:42:14
+   |
+LL |         impl Writer for Test {}
+   |              ^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `drop` in this scope
+  --> $DIR/no-implicit-prelude-nested.rs:45:13
+   |
+LL |             drop(2)
+   |             ^^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL |         use std::mem::drop;
+   |
+
+error: aborting due to 18 previous errors
+
+Some errors have detailed explanations: E0404, E0405, E0425.
+For more information about an error, try `rustc --explain E0404`.
diff --git a/tests/ui/resolve/no-implicit-prelude.rs b/tests/ui/resolve/no-implicit-prelude.rs
new file mode 100644
index 00000000000..4b0ca4d524e
--- /dev/null
+++ b/tests/ui/resolve/no-implicit-prelude.rs
@@ -0,0 +1,18 @@
+#![no_implicit_prelude]
+
+// Test that things from the prelude aren't in scope. Use many of them
+// so that renaming some things won't magically make this test fail
+// for the wrong reason (e.g., if `Add` changes to `Addition`, and
+// `no_implicit_prelude` stops working, then the `impl Add` will still
+// fail with the same error message).
+
+struct Test;
+impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope
+impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone`
+impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope
+impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope
+impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope
+
+fn main() {
+    drop(2) //~ ERROR cannot find function `drop` in this scope
+}
diff --git a/tests/ui/resolve/no-implicit-prelude.stderr b/tests/ui/resolve/no-implicit-prelude.stderr
new file mode 100644
index 00000000000..36a9b65b7d1
--- /dev/null
+++ b/tests/ui/resolve/no-implicit-prelude.stderr
@@ -0,0 +1,65 @@
+error[E0405]: cannot find trait `Add` in this scope
+  --> $DIR/no-implicit-prelude.rs:10:6
+   |
+LL | impl Add for Test {}
+   |      ^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL | use std::ops::Add;
+   |
+
+error[E0404]: expected trait, found derive macro `Clone`
+  --> $DIR/no-implicit-prelude.rs:11:6
+   |
+LL | impl Clone for Test {}
+   |      ^^^^^ not a trait
+   |
+help: consider importing this trait instead
+   |
+LL | use std::clone::Clone;
+   |
+
+error[E0405]: cannot find trait `Iterator` in this scope
+  --> $DIR/no-implicit-prelude.rs:12:6
+   |
+LL | impl Iterator for Test {}
+   |      ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL | use std::iter::Iterator;
+   |
+
+error[E0405]: cannot find trait `ToString` in this scope
+  --> $DIR/no-implicit-prelude.rs:13:6
+   |
+LL | impl ToString for Test {}
+   |      ^^^^^^^^ not found in this scope
+   |
+help: consider importing this trait
+   |
+LL | use std::string::ToString;
+   |
+
+error[E0405]: cannot find trait `Writer` in this scope
+  --> $DIR/no-implicit-prelude.rs:14:6
+   |
+LL | impl Writer for Test {}
+   |      ^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `drop` in this scope
+  --> $DIR/no-implicit-prelude.rs:17:5
+   |
+LL |     drop(2)
+   |     ^^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL | use std::mem::drop;
+   |
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0404, E0405, E0425.
+For more information about an error, try `rustc --explain E0404`.
diff --git a/tests/ui/resolve/no-std-1.rs b/tests/ui/resolve/no-std-1.rs
new file mode 100644
index 00000000000..5b59e9b4eb3
--- /dev/null
+++ b/tests/ui/resolve/no-std-1.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+#![no_std]
+
+extern crate std;
+
+fn main() {
+    let a = Some("foo");
+    a.unwrap();
+}
diff --git a/tests/ui/resolve/no-std-2.rs b/tests/ui/resolve/no-std-2.rs
new file mode 100644
index 00000000000..487d41649f4
--- /dev/null
+++ b/tests/ui/resolve/no-std-2.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+#![no_std]
+
+extern crate std;
+
+fn main() {
+    let a = core::option::Option::Some("foo");
+    a.unwrap();
+}
diff --git a/tests/ui/resolve/no-std-3.rs b/tests/ui/resolve/no-std-3.rs
new file mode 100644
index 00000000000..f6c4ed5794c
--- /dev/null
+++ b/tests/ui/resolve/no-std-3.rs
@@ -0,0 +1,17 @@
+// run-pass
+
+#![no_std]
+
+extern crate std;
+
+mod foo {
+    pub fn test() -> Option<i32> {
+        Some(2)
+    }
+}
+
+fn main() {
+    let a = core::option::Option::Some("foo");
+    a.unwrap();
+    foo::test().unwrap();
+}
diff --git a/tests/ui/resolve/pathless-extern-ok.rs b/tests/ui/resolve/pathless-extern-ok.rs
new file mode 100644
index 00000000000..0ffa5eb8940
--- /dev/null
+++ b/tests/ui/resolve/pathless-extern-ok.rs
@@ -0,0 +1,9 @@
+// edition:2018
+// compile-flags:--extern alloc
+// build-pass
+
+// Test that `--extern alloc` will load from the sysroot without error.
+
+fn main() {
+    let _: Vec<i32> = alloc::vec::Vec::new();
+}
diff --git a/tests/ui/resolve/point-at-type-parameter-shadowing-another-type.rs b/tests/ui/resolve/point-at-type-parameter-shadowing-another-type.rs
new file mode 100644
index 00000000000..bd496875e80
--- /dev/null
+++ b/tests/ui/resolve/point-at-type-parameter-shadowing-another-type.rs
@@ -0,0 +1,21 @@
+trait Foo<T> {
+    fn foo(&self, name: T) -> usize;
+}
+
+struct Bar {
+    baz: Baz,
+}
+
+struct Baz {
+    num: usize,
+}
+
+impl<Baz> Foo<Baz> for Bar {
+    fn foo(&self, _name: Baz) -> usize {
+        match self.baz {
+            Baz { num } => num, //~ ERROR expected struct, variant or union type, found type parameter `Baz`
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr b/tests/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr
new file mode 100644
index 00000000000..5790e425c0a
--- /dev/null
+++ b/tests/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr
@@ -0,0 +1,15 @@
+error[E0574]: expected struct, variant or union type, found type parameter `Baz`
+  --> $DIR/point-at-type-parameter-shadowing-another-type.rs:16:13
+   |
+LL | struct Baz {
+   |        --- you might have meant to refer to this struct
+...
+LL | impl<Baz> Foo<Baz> for Bar {
+   |      --- found this type parameter
+...
+LL |             Baz { num } => num,
+   |             ^^^ not a struct, variant or union type
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0574`.
diff --git a/tests/ui/resolve/privacy-enum-ctor.rs b/tests/ui/resolve/privacy-enum-ctor.rs
new file mode 100644
index 00000000000..f0d2cf8c04e
--- /dev/null
+++ b/tests/ui/resolve/privacy-enum-ctor.rs
@@ -0,0 +1,71 @@
+mod m {
+    pub enum E {
+        Fn(u8),
+        Struct {
+            s: u8,
+        },
+        Unit,
+    }
+
+    pub mod n {
+        pub(in m) enum Z {
+            Fn(u8),
+            Struct {
+                s: u8,
+            },
+            Unit,
+        }
+    }
+
+    use m::n::Z; // OK, only the type is imported
+
+    fn f() {
+        n::Z;
+        //~^ ERROR expected value, found enum `n::Z`
+        Z;
+        //~^ ERROR expected value, found enum `Z`
+        let _: Z = Z::Fn;
+        //~^ ERROR mismatched types
+        let _: Z = Z::Struct;
+        //~^ ERROR expected value, found struct variant `Z::Struct`
+        let _ = Z::Unit();
+        //~^ ERROR expected function, found enum variant `Z::Unit`
+        let _ = Z::Unit {};
+        // This is ok, it is equivalent to not having braces
+    }
+}
+
+use m::E; // OK, only the type is imported
+
+fn main() {
+    let _: E = m::E;
+    //~^ ERROR expected value, found enum `m::E`
+    let _: E = m::E::Fn;
+    //~^ ERROR mismatched types
+    let _: E = m::E::Struct;
+    //~^ ERROR expected value, found struct variant `m::E::Struct`
+    let _: E = m::E::Unit();
+    //~^ ERROR expected function, found enum variant `m::E::Unit`
+    let _: E = E;
+    //~^ ERROR expected value, found enum `E`
+    let _: E = E::Fn;
+    //~^ ERROR mismatched types
+    let _: E = E::Struct;
+    //~^ ERROR expected value, found struct variant `E::Struct`
+    let _: E = E::Unit();
+    //~^ ERROR expected function, found enum variant `E::Unit`
+    let _: Z = m::n::Z;
+    //~^ ERROR cannot find type `Z` in this scope
+    //~| ERROR expected value, found enum `m::n::Z`
+    //~| ERROR enum `Z` is private
+    let _: Z = m::n::Z::Fn;
+    //~^ ERROR cannot find type `Z` in this scope
+    //~| ERROR enum `Z` is private
+    let _: Z = m::n::Z::Struct;
+    //~^ ERROR cannot find type `Z` in this scope
+    //~| ERROR expected value, found struct variant `m::n::Z::Struct`
+    //~| ERROR enum `Z` is private
+    let _: Z = m::n::Z::Unit {};
+    //~^ ERROR cannot find type `Z` in this scope
+    //~| ERROR enum `Z` is private
+}
diff --git a/tests/ui/resolve/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr
new file mode 100644
index 00000000000..d734fa76b4a
--- /dev/null
+++ b/tests/ui/resolve/privacy-enum-ctor.stderr
@@ -0,0 +1,395 @@
+error[E0423]: expected value, found enum `n::Z`
+  --> $DIR/privacy-enum-ctor.rs:23:9
+   |
+LL |         n::Z;
+   |         ^^^^
+   |
+note: the enum is defined here
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL | /         pub(in m) enum Z {
+LL | |             Fn(u8),
+LL | |             Struct {
+LL | |                 s: u8,
+LL | |             },
+LL | |             Unit,
+LL | |         }
+   | |_________^
+help: you might have meant to use the following enum variant
+   |
+LL |         m::Z::Unit;
+   |         ~~~~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |         (m::Z::Fn(/* fields */));
+   |         ~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `Z`
+  --> $DIR/privacy-enum-ctor.rs:25:9
+   |
+LL |         Z;
+   |         ^
+   |
+note: the enum is defined here
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL | /         pub(in m) enum Z {
+LL | |             Fn(u8),
+LL | |             Struct {
+LL | |                 s: u8,
+LL | |             },
+LL | |             Unit,
+LL | |         }
+   | |_________^
+help: you might have meant to use the following enum variant
+   |
+LL |         m::Z::Unit;
+   |         ~~~~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |         (m::Z::Fn(/* fields */));
+   |         ~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `m::E`
+  --> $DIR/privacy-enum-ctor.rs:41:16
+   |
+LL |     fn f() {
+   |     ------ similarly named function `f` defined here
+...
+LL |     let _: E = m::E;
+   |                ^^^^
+   |
+note: the enum is defined here
+  --> $DIR/privacy-enum-ctor.rs:2:5
+   |
+LL | /     pub enum E {
+LL | |         Fn(u8),
+LL | |         Struct {
+LL | |             s: u8,
+LL | |         },
+LL | |         Unit,
+LL | |     }
+   | |_____^
+help: you might have meant to use the following enum variant
+   |
+LL |     let _: E = E::Unit;
+   |                ~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |     let _: E = (E::Fn(/* fields */));
+   |                ~~~~~~~~~~~~~~~~~~~~~
+help: a function with a similar name exists
+   |
+LL |     let _: E = m::f;
+   |                   ~
+help: consider importing one of these items instead
+   |
+LL | use std::f32::consts::E;
+   |
+LL | use std::f64::consts::E;
+   |
+help: if you import `E`, refer to it directly
+   |
+LL -     let _: E = m::E;
+LL +     let _: E = E;
+   |
+
+error[E0423]: expected value, found enum `E`
+  --> $DIR/privacy-enum-ctor.rs:49:16
+   |
+LL |     let _: E = E;
+   |                ^
+   |
+note: the enum is defined here
+  --> $DIR/privacy-enum-ctor.rs:2:5
+   |
+LL | /     pub enum E {
+LL | |         Fn(u8),
+LL | |         Struct {
+LL | |             s: u8,
+LL | |         },
+LL | |         Unit,
+LL | |     }
+   | |_____^
+help: you might have meant to use the following enum variant
+   |
+LL |     let _: E = E::Unit;
+   |                ~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |     let _: E = (E::Fn(/* fields */));
+   |                ~~~~~~~~~~~~~~~~~~~~~
+help: consider importing one of these items instead
+   |
+LL | use std::f32::consts::E;
+   |
+LL | use std::f64::consts::E;
+   |
+
+error[E0412]: cannot find type `Z` in this scope
+  --> $DIR/privacy-enum-ctor.rs:57:12
+   |
+LL |     pub enum E {
+   |     ---------- similarly named enum `E` defined here
+...
+LL |     let _: Z = m::n::Z;
+   |            ^ help: an enum with a similar name exists: `E`
+   |
+note: enum `m::Z` exists but is inaccessible
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^ not accessible
+
+error[E0423]: expected value, found enum `m::n::Z`
+  --> $DIR/privacy-enum-ctor.rs:57:16
+   |
+LL |     let _: Z = m::n::Z;
+   |                ^^^^^^^
+   |
+note: the enum is defined here
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL | /         pub(in m) enum Z {
+LL | |             Fn(u8),
+LL | |             Struct {
+LL | |                 s: u8,
+LL | |             },
+LL | |             Unit,
+LL | |         }
+   | |_________^
+help: you might have meant to use the following enum variant
+   |
+LL |     let _: Z = m::Z::Unit;
+   |                ~~~~~~~~~~
+help: alternatively, the following enum variant is available
+   |
+LL |     let _: Z = (m::Z::Fn(/* fields */));
+   |                ~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0412]: cannot find type `Z` in this scope
+  --> $DIR/privacy-enum-ctor.rs:61:12
+   |
+LL |     pub enum E {
+   |     ---------- similarly named enum `E` defined here
+...
+LL |     let _: Z = m::n::Z::Fn;
+   |            ^ help: an enum with a similar name exists: `E`
+   |
+note: enum `m::Z` exists but is inaccessible
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^ not accessible
+
+error[E0412]: cannot find type `Z` in this scope
+  --> $DIR/privacy-enum-ctor.rs:64:12
+   |
+LL |     pub enum E {
+   |     ---------- similarly named enum `E` defined here
+...
+LL |     let _: Z = m::n::Z::Struct;
+   |            ^ help: an enum with a similar name exists: `E`
+   |
+note: enum `m::Z` exists but is inaccessible
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^ not accessible
+
+error[E0412]: cannot find type `Z` in this scope
+  --> $DIR/privacy-enum-ctor.rs:68:12
+   |
+LL |     pub enum E {
+   |     ---------- similarly named enum `E` defined here
+...
+LL |     let _: Z = m::n::Z::Unit {};
+   |            ^ help: an enum with a similar name exists: `E`
+   |
+note: enum `m::Z` exists but is inaccessible
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^ not accessible
+
+error[E0603]: enum `Z` is private
+  --> $DIR/privacy-enum-ctor.rs:57:22
+   |
+LL |     let _: Z = m::n::Z;
+   |                      ^ private enum
+   |
+note: the enum `Z` is defined here
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^
+
+error[E0603]: enum `Z` is private
+  --> $DIR/privacy-enum-ctor.rs:61:22
+   |
+LL |     let _: Z = m::n::Z::Fn;
+   |                      ^ private enum
+   |
+note: the enum `Z` is defined here
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^
+
+error[E0603]: enum `Z` is private
+  --> $DIR/privacy-enum-ctor.rs:64:22
+   |
+LL |     let _: Z = m::n::Z::Struct;
+   |                      ^ private enum
+   |
+note: the enum `Z` is defined here
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^
+
+error[E0603]: enum `Z` is private
+  --> $DIR/privacy-enum-ctor.rs:68:22
+   |
+LL |     let _: Z = m::n::Z::Unit {};
+   |                      ^ private enum
+   |
+note: the enum `Z` is defined here
+  --> $DIR/privacy-enum-ctor.rs:11:9
+   |
+LL |         pub(in m) enum Z {
+   |         ^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/privacy-enum-ctor.rs:27:20
+   |
+LL |             Fn(u8),
+   |             -- fn(u8) -> Z {Z::Fn} defined here
+...
+LL |         let _: Z = Z::Fn;
+   |                -   ^^^^^ expected enum `Z`, found fn item
+   |                |
+   |                expected due to this
+   |
+   = note: expected enum `Z`
+           found fn item `fn(u8) -> Z {Z::Fn}`
+help: use parentheses to construct this tuple variant
+   |
+LL |         let _: Z = Z::Fn(/* u8 */);
+   |                         ++++++++++
+
+error[E0533]: expected value, found struct variant `Z::Struct`
+  --> $DIR/privacy-enum-ctor.rs:29:20
+   |
+LL |         let _: Z = Z::Struct;
+   |                    ^^^^^^^^^ not a value
+
+error[E0618]: expected function, found enum variant `Z::Unit`
+  --> $DIR/privacy-enum-ctor.rs:31:17
+   |
+LL |             Unit,
+   |             ---- enum variant `Z::Unit` defined here
+...
+LL |         let _ = Z::Unit();
+   |                 ^^^^^^^--
+   |                 |
+   |                 call expression requires function
+   |
+help: `Z::Unit` is a unit enum variant, and does not take parentheses to be constructed
+   |
+LL -         let _ = Z::Unit();
+LL +         let _ = Z::Unit;
+   |
+
+error[E0308]: mismatched types
+  --> $DIR/privacy-enum-ctor.rs:43:16
+   |
+LL |         Fn(u8),
+   |         -- fn(u8) -> E {E::Fn} defined here
+...
+LL |     let _: E = m::E::Fn;
+   |            -   ^^^^^^^^ expected enum `E`, found fn item
+   |            |
+   |            expected due to this
+   |
+   = note: expected enum `E`
+           found fn item `fn(u8) -> E {E::Fn}`
+help: use parentheses to construct this tuple variant
+   |
+LL |     let _: E = m::E::Fn(/* u8 */);
+   |                        ++++++++++
+
+error[E0533]: expected value, found struct variant `m::E::Struct`
+  --> $DIR/privacy-enum-ctor.rs:45:16
+   |
+LL |     let _: E = m::E::Struct;
+   |                ^^^^^^^^^^^^ not a value
+
+error[E0618]: expected function, found enum variant `m::E::Unit`
+  --> $DIR/privacy-enum-ctor.rs:47:16
+   |
+LL |         Unit,
+   |         ---- enum variant `m::E::Unit` defined here
+...
+LL |     let _: E = m::E::Unit();
+   |                ^^^^^^^^^^--
+   |                |
+   |                call expression requires function
+   |
+help: `m::E::Unit` is a unit enum variant, and does not take parentheses to be constructed
+   |
+LL -     let _: E = m::E::Unit();
+LL +     let _: E = m::E::Unit;
+   |
+
+error[E0308]: mismatched types
+  --> $DIR/privacy-enum-ctor.rs:51:16
+   |
+LL |         Fn(u8),
+   |         -- fn(u8) -> E {E::Fn} defined here
+...
+LL |     let _: E = E::Fn;
+   |            -   ^^^^^ expected enum `E`, found fn item
+   |            |
+   |            expected due to this
+   |
+   = note: expected enum `E`
+           found fn item `fn(u8) -> E {E::Fn}`
+help: use parentheses to construct this tuple variant
+   |
+LL |     let _: E = E::Fn(/* u8 */);
+   |                     ++++++++++
+
+error[E0533]: expected value, found struct variant `E::Struct`
+  --> $DIR/privacy-enum-ctor.rs:53:16
+   |
+LL |     let _: E = E::Struct;
+   |                ^^^^^^^^^ not a value
+
+error[E0618]: expected function, found enum variant `E::Unit`
+  --> $DIR/privacy-enum-ctor.rs:55:16
+   |
+LL |         Unit,
+   |         ---- enum variant `E::Unit` defined here
+...
+LL |     let _: E = E::Unit();
+   |                ^^^^^^^--
+   |                |
+   |                call expression requires function
+   |
+help: `E::Unit` is a unit enum variant, and does not take parentheses to be constructed
+   |
+LL -     let _: E = E::Unit();
+LL +     let _: E = E::Unit;
+   |
+
+error[E0533]: expected value, found struct variant `m::n::Z::Struct`
+  --> $DIR/privacy-enum-ctor.rs:64:16
+   |
+LL |     let _: Z = m::n::Z::Struct;
+   |                ^^^^^^^^^^^^^^^ not a value
+
+error: aborting due to 23 previous errors
+
+Some errors have detailed explanations: E0308, E0412, E0423, E0533, E0603, E0618.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/resolve/privacy-struct-ctor.rs b/tests/ui/resolve/privacy-struct-ctor.rs
new file mode 100644
index 00000000000..0eecc7f8cc5
--- /dev/null
+++ b/tests/ui/resolve/privacy-struct-ctor.rs
@@ -0,0 +1,47 @@
+// aux-build:privacy-struct-ctor.rs
+
+extern crate privacy_struct_ctor as xcrate;
+
+mod m {
+    pub struct S(u8);
+    pub struct S2 {
+        s: u8
+    }
+
+    pub mod n {
+        pub(in m) struct Z(pub(in m::n) u8);
+    }
+
+    use m::n::Z; // OK, only the type is imported
+
+    fn f() {
+        n::Z;
+        //~^ ERROR tuple struct constructor `Z` is private
+        Z;
+        //~^ ERROR expected value, found struct `Z`
+    }
+}
+
+use m::S; // OK, only the type is imported
+use m::S2; // OK, only the type is imported
+
+fn main() {
+    m::S;
+    //~^ ERROR tuple struct constructor `S` is private
+    let _: S = m::S(2);
+    //~^ ERROR tuple struct constructor `S` is private
+    S;
+    //~^ ERROR expected value, found struct `S`
+    m::n::Z;
+    //~^ ERROR tuple struct constructor `Z` is private
+
+    S2;
+    //~^ ERROR expected value, found struct `S2`
+
+    xcrate::m::S;
+    //~^ ERROR tuple struct constructor `S` is private
+    xcrate::S;
+    //~^ ERROR expected value, found struct `xcrate::S`
+    xcrate::m::n::Z;
+    //~^ ERROR tuple struct constructor `Z` is private
+}
diff --git a/tests/ui/resolve/privacy-struct-ctor.stderr b/tests/ui/resolve/privacy-struct-ctor.stderr
new file mode 100644
index 00000000000..17a666a401c
--- /dev/null
+++ b/tests/ui/resolve/privacy-struct-ctor.stderr
@@ -0,0 +1,139 @@
+error[E0423]: expected value, found struct `Z`
+  --> $DIR/privacy-struct-ctor.rs:20:9
+   |
+LL |     pub struct S(u8);
+   |     ----------------- similarly named tuple struct `S` defined here
+...
+LL |         Z;
+   |         ^
+   |         |
+   |         constructor is not visible here due to private fields
+   |         help: a tuple struct with a similar name exists: `S`
+
+error[E0423]: expected value, found struct `S`
+  --> $DIR/privacy-struct-ctor.rs:33:5
+   |
+LL |     S;
+   |     ^ constructor is not visible here due to private fields
+
+error[E0423]: expected value, found struct `S2`
+  --> $DIR/privacy-struct-ctor.rs:38:5
+   |
+LL | /     pub struct S2 {
+LL | |         s: u8
+LL | |     }
+   | |_____- `S2` defined here
+...
+LL |       S2;
+   |       ^^ help: use struct literal syntax instead: `S2 { s: val }`
+
+error[E0423]: expected value, found struct `xcrate::S`
+  --> $DIR/privacy-struct-ctor.rs:43:5
+   |
+LL |     xcrate::S;
+   |     ^^^^^^^^^ constructor is not visible here due to private fields
+   |
+note: tuple struct `m::S` exists but is inaccessible
+  --> $DIR/privacy-struct-ctor.rs:6:5
+   |
+LL |     pub struct S(u8);
+   |     ^^^^^^^^^^^^^^^^^ not accessible
+
+error[E0603]: tuple struct constructor `Z` is private
+  --> $DIR/privacy-struct-ctor.rs:18:12
+   |
+LL |         pub(in m) struct Z(pub(in m::n) u8);
+   |                            --------------- a constructor is private if any of the fields is private
+...
+LL |         n::Z;
+   |            ^ private tuple struct constructor
+   |
+note: the tuple struct constructor `Z` is defined here
+  --> $DIR/privacy-struct-ctor.rs:12:9
+   |
+LL |         pub(in m) struct Z(pub(in m::n) u8);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0603]: tuple struct constructor `S` is private
+  --> $DIR/privacy-struct-ctor.rs:29:8
+   |
+LL |     pub struct S(u8);
+   |                  -- a constructor is private if any of the fields is private
+...
+LL |     m::S;
+   |        ^ private tuple struct constructor
+   |
+note: the tuple struct constructor `S` is defined here
+  --> $DIR/privacy-struct-ctor.rs:6:5
+   |
+LL |     pub struct S(u8);
+   |     ^^^^^^^^^^^^^^^^^
+
+error[E0603]: tuple struct constructor `S` is private
+  --> $DIR/privacy-struct-ctor.rs:31:19
+   |
+LL |     pub struct S(u8);
+   |                  -- a constructor is private if any of the fields is private
+...
+LL |     let _: S = m::S(2);
+   |                   ^ private tuple struct constructor
+   |
+note: the tuple struct constructor `S` is defined here
+  --> $DIR/privacy-struct-ctor.rs:6:5
+   |
+LL |     pub struct S(u8);
+   |     ^^^^^^^^^^^^^^^^^
+
+error[E0603]: tuple struct constructor `Z` is private
+  --> $DIR/privacy-struct-ctor.rs:35:11
+   |
+LL |         pub(in m) struct Z(pub(in m::n) u8);
+   |                            --------------- a constructor is private if any of the fields is private
+...
+LL |     m::n::Z;
+   |           ^ private tuple struct constructor
+   |
+note: the tuple struct constructor `Z` is defined here
+  --> $DIR/privacy-struct-ctor.rs:12:9
+   |
+LL |         pub(in m) struct Z(pub(in m::n) u8);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0603]: tuple struct constructor `S` is private
+  --> $DIR/privacy-struct-ctor.rs:41:16
+   |
+LL |     xcrate::m::S;
+   |                ^ private tuple struct constructor
+   |
+  ::: $DIR/auxiliary/privacy-struct-ctor.rs:2:18
+   |
+LL |     pub struct S(u8);
+   |                  -- a constructor is private if any of the fields is private
+   |
+note: the tuple struct constructor `S` is defined here
+  --> $DIR/auxiliary/privacy-struct-ctor.rs:2:5
+   |
+LL |     pub struct S(u8);
+   |     ^^^^^^^^^^^^
+
+error[E0603]: tuple struct constructor `Z` is private
+  --> $DIR/privacy-struct-ctor.rs:45:19
+   |
+LL |     xcrate::m::n::Z;
+   |                   ^ private tuple struct constructor
+   |
+  ::: $DIR/auxiliary/privacy-struct-ctor.rs:5:28
+   |
+LL |         pub(in m) struct Z(pub(in m::n) u8);
+   |                            --------------- a constructor is private if any of the fields is private
+   |
+note: the tuple struct constructor `Z` is defined here
+  --> $DIR/auxiliary/privacy-struct-ctor.rs:5:9
+   |
+LL |         pub(in m) struct Z(pub(in m::n) u8);
+   |         ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 10 previous errors
+
+Some errors have detailed explanations: E0423, E0603.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/raw-ident-in-path.rs b/tests/ui/resolve/raw-ident-in-path.rs
new file mode 100644
index 00000000000..7f1163bebde
--- /dev/null
+++ b/tests/ui/resolve/raw-ident-in-path.rs
@@ -0,0 +1,5 @@
+// Regression test for issue #63882.
+
+type A = crate::r#break; //~ ERROR cannot find type `r#break` in the crate root
+
+fn main() {}
diff --git a/tests/ui/resolve/raw-ident-in-path.stderr b/tests/ui/resolve/raw-ident-in-path.stderr
new file mode 100644
index 00000000000..771dacbbb20
--- /dev/null
+++ b/tests/ui/resolve/raw-ident-in-path.stderr
@@ -0,0 +1,9 @@
+error[E0412]: cannot find type `r#break` in the crate root
+  --> $DIR/raw-ident-in-path.rs:3:17
+   |
+LL | type A = crate::r#break;
+   |                 ^^^^^^^ not found in the crate root
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/resolve-assoc-suggestions.rs b/tests/ui/resolve/resolve-assoc-suggestions.rs
new file mode 100644
index 00000000000..ee9bce60ce6
--- /dev/null
+++ b/tests/ui/resolve/resolve-assoc-suggestions.rs
@@ -0,0 +1,39 @@
+// Make sure associated items are recommended only in appropriate contexts.
+
+struct S {
+    field: u8,
+}
+
+trait Tr {
+    fn method(&self);
+    type Type;
+}
+
+impl Tr for S {
+    type Type = u8;
+
+    fn method(&self) {
+        let _: field;
+        //~^ ERROR cannot find type `field`
+        let field(..);
+        //~^ ERROR cannot find tuple struct or tuple variant `field`
+        field;
+        //~^ ERROR cannot find value `field`
+
+        let _: Type;
+        //~^ ERROR cannot find type `Type`
+        let Type(..);
+        //~^ ERROR cannot find tuple struct or tuple variant `Type`
+        Type;
+        //~^ ERROR cannot find value `Type`
+
+        let _: method;
+        //~^ ERROR cannot find type `method`
+        let method(..);
+        //~^ ERROR cannot find tuple struct or tuple variant `method`
+        method;
+        //~^ ERROR cannot find value `method`
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/resolve-assoc-suggestions.stderr b/tests/ui/resolve/resolve-assoc-suggestions.stderr
new file mode 100644
index 00000000000..8def9aa2025
--- /dev/null
+++ b/tests/ui/resolve/resolve-assoc-suggestions.stderr
@@ -0,0 +1,58 @@
+error[E0412]: cannot find type `field` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:16:16
+   |
+LL |         let _: field;
+   |                ^^^^^ not found in this scope
+
+error[E0531]: cannot find tuple struct or tuple variant `field` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:18:13
+   |
+LL |         let field(..);
+   |             ^^^^^ not found in this scope
+
+error[E0425]: cannot find value `field` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:20:9
+   |
+LL |         field;
+   |         ^^^^^ help: you might have meant to use the available field: `self.field`
+
+error[E0412]: cannot find type `Type` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:23:16
+   |
+LL |         let _: Type;
+   |                ^^^^ help: you might have meant to use the associated type: `Self::Type`
+
+error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:25:13
+   |
+LL |         let Type(..);
+   |             ^^^^ not found in this scope
+
+error[E0425]: cannot find value `Type` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:27:9
+   |
+LL |         Type;
+   |         ^^^^ not found in this scope
+
+error[E0412]: cannot find type `method` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:30:16
+   |
+LL |         let _: method;
+   |                ^^^^^^ not found in this scope
+
+error[E0531]: cannot find tuple struct or tuple variant `method` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:32:13
+   |
+LL |         let method(..);
+   |             ^^^^^^ not found in this scope
+
+error[E0425]: cannot find value `method` in this scope
+  --> $DIR/resolve-assoc-suggestions.rs:34:9
+   |
+LL |         method;
+   |         ^^^^^^ help: you might have meant to refer to the method: `self.method`
+
+error: aborting due to 9 previous errors
+
+Some errors have detailed explanations: E0412, E0425, E0531.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/resolve-bad-import-prefix.rs b/tests/ui/resolve/resolve-bad-import-prefix.rs
new file mode 100644
index 00000000000..325c69b43c1
--- /dev/null
+++ b/tests/ui/resolve/resolve-bad-import-prefix.rs
@@ -0,0 +1,14 @@
+mod m {}
+enum E {}
+struct S;
+trait Tr {}
+
+use {}; // OK
+use ::{}; // OK
+use m::{}; // OK
+use E::{}; // OK
+use S::{}; // FIXME, this and `use S::{self};` should be an error
+use Tr::{}; // FIXME, this and `use Tr::{self};` should be an error
+use Nonexistent::{}; //~ ERROR unresolved import `Nonexistent`
+
+fn main () {}
diff --git a/tests/ui/resolve/resolve-bad-import-prefix.stderr b/tests/ui/resolve/resolve-bad-import-prefix.stderr
new file mode 100644
index 00000000000..852b9c6afff
--- /dev/null
+++ b/tests/ui/resolve/resolve-bad-import-prefix.stderr
@@ -0,0 +1,9 @@
+error[E0432]: unresolved import `Nonexistent`
+  --> $DIR/resolve-bad-import-prefix.rs:12:5
+   |
+LL | use Nonexistent::{};
+   |     ^^^^^^^^^^^^^^^ no `Nonexistent` in the root
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0432`.
diff --git a/tests/ui/resolve/resolve-bad-visibility.rs b/tests/ui/resolve/resolve-bad-visibility.rs
new file mode 100644
index 00000000000..7d48bb97b10
--- /dev/null
+++ b/tests/ui/resolve/resolve-bad-visibility.rs
@@ -0,0 +1,15 @@
+enum E {}
+trait Tr {}
+
+pub(in E) struct S; //~ ERROR expected module, found enum `E`
+pub(in Tr) struct Z; //~ ERROR expected module, found trait `Tr`
+pub(in std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules
+pub(in nonexistent) struct G; //~ ERROR failed to resolve
+pub(in too_soon) struct H; //~ ERROR failed to resolve
+
+// Visibilities are resolved eagerly without waiting for modules becoming fully populated.
+// Visibilities can only use ancestor modules legally which are always available in time,
+// so the worst thing that can happen due to eager resolution is a suboptimal error message.
+mod too_soon {}
+
+fn main () {}
diff --git a/tests/ui/resolve/resolve-bad-visibility.stderr b/tests/ui/resolve/resolve-bad-visibility.stderr
new file mode 100644
index 00000000000..2ac41b87562
--- /dev/null
+++ b/tests/ui/resolve/resolve-bad-visibility.stderr
@@ -0,0 +1,38 @@
+error[E0577]: expected module, found enum `E`
+  --> $DIR/resolve-bad-visibility.rs:4:8
+   |
+LL | pub(in E) struct S;
+   |        ^ not a module
+
+error[E0577]: expected module, found trait `Tr`
+  --> $DIR/resolve-bad-visibility.rs:5:8
+   |
+LL | pub(in Tr) struct Z;
+   |        ^^ not a module
+
+error[E0742]: visibilities can only be restricted to ancestor modules
+  --> $DIR/resolve-bad-visibility.rs:6:8
+   |
+LL | pub(in std::vec) struct F;
+   |        ^^^^^^^^
+
+error[E0433]: failed to resolve: maybe a missing crate `nonexistent`?
+  --> $DIR/resolve-bad-visibility.rs:7:8
+   |
+LL | pub(in nonexistent) struct G;
+   |        ^^^^^^^^^^^ maybe a missing crate `nonexistent`?
+   |
+   = help: consider adding `extern crate nonexistent` to use the `nonexistent` crate
+
+error[E0433]: failed to resolve: maybe a missing crate `too_soon`?
+  --> $DIR/resolve-bad-visibility.rs:8:8
+   |
+LL | pub(in too_soon) struct H;
+   |        ^^^^^^^^ maybe a missing crate `too_soon`?
+   |
+   = help: consider adding `extern crate too_soon` to use the `too_soon` crate
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0433, E0577, E0742.
+For more information about an error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.rs b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.rs
new file mode 100644
index 00000000000..3cb6ab52e0a
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.rs
@@ -0,0 +1,4 @@
+extern crate std;
+//~^ ERROR the name `std` is defined multiple times
+
+fn main(){}
diff --git a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr
new file mode 100644
index 00000000000..ea6cb9eb00d
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr
@@ -0,0 +1,11 @@
+error[E0259]: the name `std` is defined multiple times
+   |
+   = 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/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.rs b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.rs
new file mode 100644
index 00000000000..10772e7a43a
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.rs
@@ -0,0 +1,4 @@
+use std::slice as std; //~ ERROR the name `std` is defined multiple times
+
+fn main() {
+}
diff --git a/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr
new file mode 100644
index 00000000000..abf068a1f68
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr
@@ -0,0 +1,15 @@
+error[E0254]: the name `std` is defined multiple times
+  --> $DIR/resolve-conflict-import-vs-extern-crate.rs:1:5
+   |
+LL | use std::slice as 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 | use std::slice as other_std;
+   |     ~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0254`.
diff --git a/tests/ui/resolve/resolve-conflict-import-vs-import.fixed b/tests/ui/resolve/resolve-conflict-import-vs-import.fixed
new file mode 100644
index 00000000000..e429513b51d
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-import-vs-import.fixed
@@ -0,0 +1,9 @@
+// run-rustfix
+
+#[allow(unused_imports)]
+use std::mem::transmute;
+
+//~^ ERROR the name `transmute` is defined multiple times
+
+fn main() {
+}
diff --git a/tests/ui/resolve/resolve-conflict-import-vs-import.rs b/tests/ui/resolve/resolve-conflict-import-vs-import.rs
new file mode 100644
index 00000000000..43853117af6
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-import-vs-import.rs
@@ -0,0 +1,9 @@
+// run-rustfix
+
+#[allow(unused_imports)]
+use std::mem::transmute;
+use std::mem::transmute;
+//~^ ERROR the name `transmute` is defined multiple times
+
+fn main() {
+}
diff --git a/tests/ui/resolve/resolve-conflict-import-vs-import.stderr b/tests/ui/resolve/resolve-conflict-import-vs-import.stderr
new file mode 100644
index 00000000000..632be50f4c4
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-import-vs-import.stderr
@@ -0,0 +1,13 @@
+error[E0252]: the name `transmute` is defined multiple times
+  --> $DIR/resolve-conflict-import-vs-import.rs:5:5
+   |
+LL | use std::mem::transmute;
+   |     ------------------- previous import of the value `transmute` here
+LL | use std::mem::transmute;
+   |     ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here
+   |
+   = note: `transmute` must be defined only once in the value namespace of this module
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/tests/ui/resolve/resolve-conflict-item-vs-extern-crate.rs b/tests/ui/resolve/resolve-conflict-item-vs-extern-crate.rs
new file mode 100644
index 00000000000..12260624935
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-item-vs-extern-crate.rs
@@ -0,0 +1,5 @@
+fn std() {}
+mod std {}    //~ ERROR the name `std` is defined multiple times
+
+fn main() {
+}
diff --git a/tests/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr
new file mode 100644
index 00000000000..7b9fb6c63f6
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr
@@ -0,0 +1,11 @@
+error[E0260]: the name `std` is defined multiple times
+  --> $DIR/resolve-conflict-item-vs-extern-crate.rs:2:1
+   |
+LL | mod std {}
+   | ^^^^^^^ `std` redefined here
+   |
+   = note: `std` 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 E0260`.
diff --git a/tests/ui/resolve/resolve-conflict-item-vs-import.rs b/tests/ui/resolve/resolve-conflict-item-vs-import.rs
new file mode 100644
index 00000000000..4308c7a2750
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-item-vs-import.rs
@@ -0,0 +1,8 @@
+use std::mem::transmute;
+
+fn transmute() {}
+//~^ ERROR the name `transmute` is defined multiple times
+//~| `transmute` redefined here
+//~| `transmute` must be defined only once in the value namespace of this module
+fn main() {
+}
diff --git a/tests/ui/resolve/resolve-conflict-item-vs-import.stderr b/tests/ui/resolve/resolve-conflict-item-vs-import.stderr
new file mode 100644
index 00000000000..5e5c9f6b3d8
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-item-vs-import.stderr
@@ -0,0 +1,18 @@
+error[E0255]: the name `transmute` is defined multiple times
+  --> $DIR/resolve-conflict-item-vs-import.rs:3:1
+   |
+LL | use std::mem::transmute;
+   |     ------------------- previous import of the value `transmute` here
+LL |
+LL | fn transmute() {}
+   | ^^^^^^^^^^^^^^ `transmute` redefined here
+   |
+   = note: `transmute` 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 std::mem::transmute as other_transmute;
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0255`.
diff --git a/tests/ui/resolve/resolve-conflict-type-vs-import.rs b/tests/ui/resolve/resolve-conflict-type-vs-import.rs
new file mode 100644
index 00000000000..3abce839691
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-type-vs-import.rs
@@ -0,0 +1,7 @@
+use std::slice::Iter;
+
+struct Iter;
+//~^ ERROR the name `Iter` is defined multiple times
+
+fn main() {
+}
diff --git a/tests/ui/resolve/resolve-conflict-type-vs-import.stderr b/tests/ui/resolve/resolve-conflict-type-vs-import.stderr
new file mode 100644
index 00000000000..198ef10311e
--- /dev/null
+++ b/tests/ui/resolve/resolve-conflict-type-vs-import.stderr
@@ -0,0 +1,18 @@
+error[E0255]: the name `Iter` is defined multiple times
+  --> $DIR/resolve-conflict-type-vs-import.rs:3:1
+   |
+LL | use std::slice::Iter;
+   |     ---------------- previous import of the type `Iter` here
+LL |
+LL | struct Iter;
+   | ^^^^^^^^^^^^ `Iter` redefined here
+   |
+   = note: `Iter` 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::slice::Iter as OtherIter;
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0255`.
diff --git a/tests/ui/resolve/resolve-hint-macro.fixed b/tests/ui/resolve/resolve-hint-macro.fixed
new file mode 100644
index 00000000000..54e01608498
--- /dev/null
+++ b/tests/ui/resolve/resolve-hint-macro.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+fn main() {
+    assert_eq!(1, 1);
+    //~^ ERROR expected function, found macro `assert_eq`
+    assert_eq! { 1, 1 };
+    //~^ ERROR expected struct, variant or union type, found macro `assert_eq`
+    //~| ERROR expected identifier, found `1`
+    //~| ERROR expected identifier, found `1`
+    assert![true];
+    //~^ ERROR expected value, found macro `assert`
+}
diff --git a/tests/ui/resolve/resolve-hint-macro.rs b/tests/ui/resolve/resolve-hint-macro.rs
new file mode 100644
index 00000000000..f16e8c07553
--- /dev/null
+++ b/tests/ui/resolve/resolve-hint-macro.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+fn main() {
+    assert_eq(1, 1);
+    //~^ ERROR expected function, found macro `assert_eq`
+    assert_eq { 1, 1 };
+    //~^ ERROR expected struct, variant or union type, found macro `assert_eq`
+    //~| ERROR expected identifier, found `1`
+    //~| ERROR expected identifier, found `1`
+    assert[true];
+    //~^ ERROR expected value, found macro `assert`
+}
diff --git a/tests/ui/resolve/resolve-hint-macro.stderr b/tests/ui/resolve/resolve-hint-macro.stderr
new file mode 100644
index 00000000000..1e7ab48ef90
--- /dev/null
+++ b/tests/ui/resolve/resolve-hint-macro.stderr
@@ -0,0 +1,53 @@
+error: expected identifier, found `1`
+  --> $DIR/resolve-hint-macro.rs:5:17
+   |
+LL |     assert_eq { 1, 1 };
+   |     ---------   ^ expected identifier
+   |     |
+   |     while parsing this struct
+
+error: expected identifier, found `1`
+  --> $DIR/resolve-hint-macro.rs:5:20
+   |
+LL |     assert_eq { 1, 1 };
+   |     ---------      ^ expected identifier
+   |     |
+   |     while parsing this struct
+
+error[E0574]: expected struct, variant or union type, found macro `assert_eq`
+  --> $DIR/resolve-hint-macro.rs:5:5
+   |
+LL |     assert_eq { 1, 1 };
+   |     ^^^^^^^^^ not a struct, variant or union type
+   |
+help: use `!` to invoke the macro
+   |
+LL |     assert_eq! { 1, 1 };
+   |              +
+
+error[E0423]: expected value, found macro `assert`
+  --> $DIR/resolve-hint-macro.rs:9:5
+   |
+LL |     assert[true];
+   |     ^^^^^^ not a value
+   |
+help: use `!` to invoke the macro
+   |
+LL |     assert![true];
+   |           +
+
+error[E0423]: expected function, found macro `assert_eq`
+  --> $DIR/resolve-hint-macro.rs:3:5
+   |
+LL |     assert_eq(1, 1);
+   |     ^^^^^^^^^ not a function
+   |
+help: use `!` to invoke the macro
+   |
+LL |     assert_eq!(1, 1);
+   |              +
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0423, E0574.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/resolve-inconsistent-binding-mode.rs b/tests/ui/resolve/resolve-inconsistent-binding-mode.rs
new file mode 100644
index 00000000000..43e9378b7d0
--- /dev/null
+++ b/tests/ui/resolve/resolve-inconsistent-binding-mode.rs
@@ -0,0 +1,41 @@
+enum Opts {
+    A(isize),
+    B(isize),
+    C(isize),
+}
+
+fn matcher1(x: Opts) {
+    match x {
+        Opts::A(ref i) | Opts::B(i) => {}
+        //~^ ERROR variable `i` is bound inconsistently
+        //~^^ ERROR mismatched types
+        Opts::C(_) => {}
+    }
+}
+
+fn matcher2(x: Opts) {
+    match x {
+        Opts::A(ref i) | Opts::B(i) => {}
+        //~^ ERROR variable `i` is bound inconsistently
+        //~^^ ERROR mismatched types
+        Opts::C(_) => {}
+    }
+}
+
+fn matcher4(x: Opts) {
+    match x {
+        Opts::A(ref mut i) | Opts::B(ref i) => {}
+        //~^ ERROR variable `i` is bound inconsistently
+        //~^^ ERROR mismatched types
+        Opts::C(_) => {}
+    }
+}
+
+fn matcher5(x: Opts) {
+    match x {
+        Opts::A(ref i) | Opts::B(ref i) => {}
+        Opts::C(_) => {}
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/resolve-inconsistent-binding-mode.stderr b/tests/ui/resolve/resolve-inconsistent-binding-mode.stderr
new file mode 100644
index 00000000000..c805c9eb125
--- /dev/null
+++ b/tests/ui/resolve/resolve-inconsistent-binding-mode.stderr
@@ -0,0 +1,72 @@
+error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|`
+  --> $DIR/resolve-inconsistent-binding-mode.rs:9:34
+   |
+LL |         Opts::A(ref i) | Opts::B(i) => {}
+   |                     -            ^ bound in different ways
+   |                     |
+   |                     first binding
+
+error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|`
+  --> $DIR/resolve-inconsistent-binding-mode.rs:18:34
+   |
+LL |         Opts::A(ref i) | Opts::B(i) => {}
+   |                     -            ^ bound in different ways
+   |                     |
+   |                     first binding
+
+error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|`
+  --> $DIR/resolve-inconsistent-binding-mode.rs:27:42
+   |
+LL |         Opts::A(ref mut i) | Opts::B(ref i) => {}
+   |                         - first binding  ^ bound in different ways
+
+error[E0308]: mismatched types
+  --> $DIR/resolve-inconsistent-binding-mode.rs:9:34
+   |
+LL |     match x {
+   |           - this expression has type `Opts`
+LL |         Opts::A(ref i) | Opts::B(i) => {}
+   |                 -----            ^ expected `&isize`, found `isize`
+   |                 |
+   |                 first introduced with type `&isize` here
+   |
+   = note: in the same arm, a binding must have the same type in all alternatives
+help: consider adding `ref`
+   |
+LL |         Opts::A(ref i) | Opts::B(ref i) => {}
+   |                                  +++
+
+error[E0308]: mismatched types
+  --> $DIR/resolve-inconsistent-binding-mode.rs:18:34
+   |
+LL |     match x {
+   |           - this expression has type `Opts`
+LL |         Opts::A(ref i) | Opts::B(i) => {}
+   |                 -----            ^ expected `&isize`, found `isize`
+   |                 |
+   |                 first introduced with type `&isize` here
+   |
+   = note: in the same arm, a binding must have the same type in all alternatives
+help: consider adding `ref`
+   |
+LL |         Opts::A(ref i) | Opts::B(ref i) => {}
+   |                                  +++
+
+error[E0308]: mismatched types
+  --> $DIR/resolve-inconsistent-binding-mode.rs:27:38
+   |
+LL |     match x {
+   |           - this expression has type `Opts`
+LL |         Opts::A(ref mut i) | Opts::B(ref i) => {}
+   |                 ---------            ^^^^^ types differ in mutability
+   |                 |
+   |                 first introduced with type `&mut isize` here
+   |
+   = note: expected mutable reference `&mut isize`
+                      found reference `&isize`
+   = note: in the same arm, a binding must have the same type in all alternatives
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0308, E0409.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/resolve/resolve-inconsistent-names.rs b/tests/ui/resolve/resolve-inconsistent-names.rs
new file mode 100644
index 00000000000..9a40b20346c
--- /dev/null
+++ b/tests/ui/resolve/resolve-inconsistent-names.rs
@@ -0,0 +1,36 @@
+#![allow(non_camel_case_types)]
+
+enum E { A, B, c }
+
+pub mod m {
+    const CONST1: usize = 10;
+    pub const Const2: usize = 20;
+}
+
+fn main() {
+    let y = 1;
+    match y {
+       a | b => {} //~  ERROR variable `a` is not bound in all patterns
+                   //~| ERROR variable `b` is not bound in all patterns
+    }
+
+    let x = (E::A, E::B);
+    match x {
+        (A, B) | (ref B, c) | (c, A) => ()
+        //~^ ERROR variable `A` is not bound in all patterns
+        //~| ERROR variable `B` is not bound in all patterns
+        //~| ERROR variable `B` is bound inconsistently
+        //~| ERROR mismatched types
+        //~| ERROR variable `c` is not bound in all patterns
+        //~| HELP if you meant to match on unit variant `E::A`, use the full path in the pattern
+        //~| HELP consider removing `ref`
+    }
+
+    let z = (10, 20);
+    match z {
+        (CONST1, _) | (_, Const2) => ()
+        //~^ ERROR variable `CONST1` is not bound in all patterns
+        //~| ERROR variable `Const2` is not bound in all patterns
+        //~| HELP if you meant to match on constant `m::Const2`, use the full path in the pattern
+    }
+}
diff --git a/tests/ui/resolve/resolve-inconsistent-names.stderr b/tests/ui/resolve/resolve-inconsistent-names.stderr
new file mode 100644
index 00000000000..773c9f6cd11
--- /dev/null
+++ b/tests/ui/resolve/resolve-inconsistent-names.stderr
@@ -0,0 +1,104 @@
+error[E0408]: variable `a` is not bound in all patterns
+  --> $DIR/resolve-inconsistent-names.rs:13:12
+   |
+LL |        a | b => {}
+   |        -   ^ pattern doesn't bind `a`
+   |        |
+   |        variable not in all patterns
+
+error[E0408]: variable `b` is not bound in all patterns
+  --> $DIR/resolve-inconsistent-names.rs:13:8
+   |
+LL |        a | b => {}
+   |        ^   - variable not in all patterns
+   |        |
+   |        pattern doesn't bind `b`
+
+error[E0408]: variable `A` is not bound in all patterns
+  --> $DIR/resolve-inconsistent-names.rs:19:18
+   |
+LL |         (A, B) | (ref B, c) | (c, A) => ()
+   |          -       ^^^^^^^^^^       - variable not in all patterns
+   |          |       |
+   |          |       pattern doesn't bind `A`
+   |          variable not in all patterns
+   |
+help: if you meant to match on unit variant `E::A`, use the full path in the pattern
+   |
+LL |         (E::A, B) | (ref B, c) | (c, A) => ()
+   |          ~~~~
+
+error[E0408]: variable `B` is not bound in all patterns
+  --> $DIR/resolve-inconsistent-names.rs:19:31
+   |
+LL |         (A, B) | (ref B, c) | (c, A) => ()
+   |             -         -       ^^^^^^ pattern doesn't bind `B`
+   |             |         |
+   |             |         variable not in all patterns
+   |             variable not in all patterns
+
+error[E0408]: variable `c` is not bound in all patterns
+  --> $DIR/resolve-inconsistent-names.rs:19:9
+   |
+LL |         (A, B) | (ref B, c) | (c, A) => ()
+   |         ^^^^^^           -     - variable not in all patterns
+   |         |                |
+   |         |                variable not in all patterns
+   |         pattern doesn't bind `c`
+
+error[E0409]: variable `B` is bound inconsistently across alternatives separated by `|`
+  --> $DIR/resolve-inconsistent-names.rs:19:23
+   |
+LL |         (A, B) | (ref B, c) | (c, A) => ()
+   |             -         ^ bound in different ways
+   |             |
+   |             first binding
+
+error[E0408]: variable `CONST1` is not bound in all patterns
+  --> $DIR/resolve-inconsistent-names.rs:31:23
+   |
+LL |         (CONST1, _) | (_, Const2) => ()
+   |          ------       ^^^^^^^^^^^ pattern doesn't bind `CONST1`
+   |          |
+   |          variable not in all patterns
+   |
+note: you might have meant to match on constant `m::CONST1`, which exists but is inaccessible
+  --> $DIR/resolve-inconsistent-names.rs:6:5
+   |
+LL |     const CONST1: usize = 10;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ not accessible
+
+error[E0408]: variable `Const2` is not bound in all patterns
+  --> $DIR/resolve-inconsistent-names.rs:31:9
+   |
+LL |         (CONST1, _) | (_, Const2) => ()
+   |         ^^^^^^^^^^^       ------ variable not in all patterns
+   |         |
+   |         pattern doesn't bind `Const2`
+   |
+help: if you meant to match on constant `m::Const2`, use the full path in the pattern
+   |
+LL |         (CONST1, _) | (_, m::Const2) => ()
+   |                           ~~~~~~~~~
+
+error[E0308]: mismatched types
+  --> $DIR/resolve-inconsistent-names.rs:19:19
+   |
+LL |     match x {
+   |           - this expression has type `(E, E)`
+LL |         (A, B) | (ref B, c) | (c, A) => ()
+   |             -     ^^^^^ expected enum `E`, found `&E`
+   |             |
+   |             first introduced with type `E` here
+   |
+   = note: in the same arm, a binding must have the same type in all alternatives
+help: consider removing `ref`
+   |
+LL -         (A, B) | (ref B, c) | (c, A) => ()
+LL +         (A, B) | (B, c) | (c, A) => ()
+   |
+
+error: aborting due to 9 previous errors
+
+Some errors have detailed explanations: E0308, E0408, E0409.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/resolve/resolve-issue-2428.rs b/tests/ui/resolve/resolve-issue-2428.rs
new file mode 100644
index 00000000000..5f3473e9feb
--- /dev/null
+++ b/tests/ui/resolve/resolve-issue-2428.rs
@@ -0,0 +1,8 @@
+// run-pass
+
+#![allow(non_camel_case_types)]
+#![allow(non_upper_case_globals)]
+
+const foo: isize = 4 >> 1;
+enum bs { thing = foo }
+pub fn main() { assert_eq!(bs::thing as isize, foo); }
diff --git a/tests/ui/resolve/resolve-label.rs b/tests/ui/resolve/resolve-label.rs
new file mode 100644
index 00000000000..ac5410cd355
--- /dev/null
+++ b/tests/ui/resolve/resolve-label.rs
@@ -0,0 +1,13 @@
+fn f() {
+    'l: loop {
+        fn g() {
+            loop {
+                break 'l; //~ ERROR use of unreachable label
+            }
+        }
+    }
+
+    loop { 'w: while break 'w { } }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/resolve-label.stderr b/tests/ui/resolve/resolve-label.stderr
new file mode 100644
index 00000000000..5729348ef21
--- /dev/null
+++ b/tests/ui/resolve/resolve-label.stderr
@@ -0,0 +1,14 @@
+error[E0767]: use of unreachable label `'l`
+  --> $DIR/resolve-label.rs:5:23
+   |
+LL |     'l: loop {
+   |     -- unreachable label defined here
+...
+LL |                 break 'l;
+   |                       ^^ unreachable label `'l`
+   |
+   = note: labels are unreachable through functions, closures, async blocks and modules
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0767`.
diff --git a/tests/ui/resolve/resolve-primitive-fallback.rs b/tests/ui/resolve/resolve-primitive-fallback.rs
new file mode 100644
index 00000000000..05cabd9e3cd
--- /dev/null
+++ b/tests/ui/resolve/resolve-primitive-fallback.rs
@@ -0,0 +1,10 @@
+fn main() {
+    // Make sure primitive type fallback doesn't work in value namespace
+    std::mem::size_of(u16);
+    //~^ ERROR expected value, found builtin type `u16`
+    //~| ERROR function takes 0 arguments but 1 argument was supplied
+
+    // Make sure primitive type fallback doesn't work with global paths
+    let _: ::u8;
+    //~^ ERROR cannot find type `u8` in the crate root
+}
diff --git a/tests/ui/resolve/resolve-primitive-fallback.stderr b/tests/ui/resolve/resolve-primitive-fallback.stderr
new file mode 100644
index 00000000000..964302e924c
--- /dev/null
+++ b/tests/ui/resolve/resolve-primitive-fallback.stderr
@@ -0,0 +1,39 @@
+error[E0423]: expected value, found builtin type `u16`
+  --> $DIR/resolve-primitive-fallback.rs:3:23
+   |
+LL |     std::mem::size_of(u16);
+   |                       ^^^ not a value
+
+error[E0412]: cannot find type `u8` in the crate root
+  --> $DIR/resolve-primitive-fallback.rs:8:14
+   |
+LL |     let _: ::u8;
+   |              ^^ not found in the crate root
+   |
+help: consider importing this builtin type
+   |
+LL | use std::primitive::u8;
+   |
+help: if you import `u8`, refer to it directly
+   |
+LL -     let _: ::u8;
+LL +     let _: u8;
+   |
+
+error[E0061]: this function takes 0 arguments but 1 argument was supplied
+  --> $DIR/resolve-primitive-fallback.rs:3:5
+   |
+LL |     std::mem::size_of(u16);
+   |     ^^^^^^^^^^^^^^^^^ --- argument unexpected
+   |
+note: function defined here
+  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+help: remove the extra argument
+   |
+LL |     std::mem::size_of();
+   |                      ~~
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0061, E0412, E0423.
+For more information about an error, try `rustc --explain E0061`.
diff --git a/tests/ui/resolve/resolve-pseudo-shadowing.rs b/tests/ui/resolve/resolve-pseudo-shadowing.rs
new file mode 100644
index 00000000000..85c684ca032
--- /dev/null
+++ b/tests/ui/resolve/resolve-pseudo-shadowing.rs
@@ -0,0 +1,11 @@
+// run-pass
+// check that type parameters can't "shadow" qualified paths.
+
+fn check<Clone>(_c: Clone) {
+    fn check2() {
+        let _ = <() as std::clone::Clone>::clone(&());
+    }
+    check2();
+}
+
+fn main() { check(()); }
diff --git a/tests/ui/resolve/resolve-self-in-impl-2.rs b/tests/ui/resolve/resolve-self-in-impl-2.rs
new file mode 100644
index 00000000000..f586760c8b0
--- /dev/null
+++ b/tests/ui/resolve/resolve-self-in-impl-2.rs
@@ -0,0 +1,7 @@
+struct S<T = u8>(T);
+trait Tr<T = u8> {}
+
+impl Self for S {} //~ ERROR expected trait, found self type `Self`
+impl Self::N for S {} //~ ERROR cannot find trait `N` in `Self`
+
+fn main() {}
diff --git a/tests/ui/resolve/resolve-self-in-impl-2.stderr b/tests/ui/resolve/resolve-self-in-impl-2.stderr
new file mode 100644
index 00000000000..3791fe90a6b
--- /dev/null
+++ b/tests/ui/resolve/resolve-self-in-impl-2.stderr
@@ -0,0 +1,16 @@
+error[E0411]: expected trait, found self type `Self`
+  --> $DIR/resolve-self-in-impl-2.rs:4:6
+   |
+LL | impl Self for S {}
+   |      ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error[E0405]: cannot find trait `N` in `Self`
+  --> $DIR/resolve-self-in-impl-2.rs:5:12
+   |
+LL | impl Self::N for S {}
+   |            ^ not found in `Self`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0405, E0411.
+For more information about an error, try `rustc --explain E0405`.
diff --git a/tests/ui/resolve/resolve-self-in-impl.rs b/tests/ui/resolve/resolve-self-in-impl.rs
new file mode 100644
index 00000000000..d0872d1b76f
--- /dev/null
+++ b/tests/ui/resolve/resolve-self-in-impl.rs
@@ -0,0 +1,21 @@
+#![feature(associated_type_defaults)]
+
+struct S<T = u8>(T);
+trait Tr<T = u8> {
+    type A = ();
+}
+
+impl Tr<Self> for S {} // OK
+impl<T: Tr<Self>> Tr<T> for S {} // OK
+impl Tr for S where Self: Copy {} // OK
+impl Tr for S where S<Self>: Copy {} // OK
+impl Tr for S where Self::A: Copy {} // OK
+
+impl Tr for Self {} //~ ERROR `Self` is not valid in the self type of an impl block
+impl Tr for S<Self> {} //~ ERROR `Self` is not valid in the self type of an impl block
+impl Self {} //~ ERROR `Self` is not valid in the self type of an impl block
+impl S<Self> {} //~ ERROR `Self` is not valid in the self type of an impl block
+impl (Self, Self) {} //~ ERROR `Self` is not valid in the self type of an impl block
+impl Tr<Self::A> for S {} //~ ERROR cycle detected
+
+fn main() {}
diff --git a/tests/ui/resolve/resolve-self-in-impl.stderr b/tests/ui/resolve/resolve-self-in-impl.stderr
new file mode 100644
index 00000000000..b3042d41346
--- /dev/null
+++ b/tests/ui/resolve/resolve-self-in-impl.stderr
@@ -0,0 +1,62 @@
+error: `Self` is not valid in the self type of an impl block
+  --> $DIR/resolve-self-in-impl.rs:16:6
+   |
+LL | impl Self {}
+   |      ^^^^
+   |
+   = note: replace `Self` with a different type
+
+error: `Self` is not valid in the self type of an impl block
+  --> $DIR/resolve-self-in-impl.rs:17:8
+   |
+LL | impl S<Self> {}
+   |        ^^^^
+   |
+   = note: replace `Self` with a different type
+
+error: `Self` is not valid in the self type of an impl block
+  --> $DIR/resolve-self-in-impl.rs:18:7
+   |
+LL | impl (Self, Self) {}
+   |       ^^^^  ^^^^
+   |
+   = note: replace `Self` with a different type
+
+error: `Self` is not valid in the self type of an impl block
+  --> $DIR/resolve-self-in-impl.rs:14:13
+   |
+LL | impl Tr for Self {}
+   |             ^^^^
+   |
+   = note: replace `Self` with a different type
+
+error: `Self` is not valid in the self type of an impl block
+  --> $DIR/resolve-self-in-impl.rs:15:15
+   |
+LL | impl Tr for S<Self> {}
+   |               ^^^^
+   |
+   = note: replace `Self` with a different type
+
+error[E0391]: cycle detected when computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:19:1: 19:23>`
+  --> $DIR/resolve-self-in-impl.rs:19:1
+   |
+LL | impl Tr<Self::A> for S {}
+   | ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: ...which immediately requires computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:19:1: 19:23>` again
+note: cycle used when collecting item types in top-level module
+  --> $DIR/resolve-self-in-impl.rs:1:1
+   |
+LL | / #![feature(associated_type_defaults)]
+LL | |
+LL | | struct S<T = u8>(T);
+LL | | trait Tr<T = u8> {
+...  |
+LL | |
+LL | | fn main() {}
+   | |____________^
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/resolve/resolve-speculative-adjustment.rs b/tests/ui/resolve/resolve-speculative-adjustment.rs
new file mode 100644
index 00000000000..81f7578291b
--- /dev/null
+++ b/tests/ui/resolve/resolve-speculative-adjustment.rs
@@ -0,0 +1,30 @@
+// Make sure speculative path resolution works properly when resolution
+// adjustment happens and no extra errors is reported.
+
+struct S {
+    field: u8,
+}
+
+trait Tr {
+    fn method(&self);
+}
+
+impl Tr for S {
+    fn method(&self) {
+        fn g() {
+            // Speculative resolution of `Self` and `self` silently fails,
+            // "did you mean" messages are not printed.
+            field;
+            //~^ ERROR cannot find value `field`
+            method();
+            //~^ ERROR cannot find function `method`
+        }
+
+        field;
+        //~^ ERROR cannot find value `field`
+        method();
+        //~^ ERROR cannot find function `method`
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/resolve-speculative-adjustment.stderr b/tests/ui/resolve/resolve-speculative-adjustment.stderr
new file mode 100644
index 00000000000..be11a7ebeca
--- /dev/null
+++ b/tests/ui/resolve/resolve-speculative-adjustment.stderr
@@ -0,0 +1,27 @@
+error[E0425]: cannot find value `field` in this scope
+  --> $DIR/resolve-speculative-adjustment.rs:17:13
+   |
+LL |             field;
+   |             ^^^^^ not found in this scope
+
+error[E0425]: cannot find value `field` in this scope
+  --> $DIR/resolve-speculative-adjustment.rs:23:9
+   |
+LL |         field;
+   |         ^^^^^ help: you might have meant to use the available field: `self.field`
+
+error[E0425]: cannot find function `method` in this scope
+  --> $DIR/resolve-speculative-adjustment.rs:25:9
+   |
+LL |         method();
+   |         ^^^^^^ help: you might have meant to call the method: `self.method`
+
+error[E0425]: cannot find function `method` in this scope
+  --> $DIR/resolve-speculative-adjustment.rs:19:13
+   |
+LL |             method();
+   |             ^^^^^^ not found in this scope
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/resolve-type-param-in-item-in-trait.rs b/tests/ui/resolve/resolve-type-param-in-item-in-trait.rs
new file mode 100644
index 00000000000..c77a66524f7
--- /dev/null
+++ b/tests/ui/resolve/resolve-type-param-in-item-in-trait.rs
@@ -0,0 +1,35 @@
+// Issue #14603: Check for references to type parameters from the
+// outer scope (in this case, the trait) used on items in an inner
+// scope (in this case, the enum).
+
+trait TraitA<A> {
+    fn outer(&self) {
+        enum Foo<B> {
+            Variance(A)
+                //~^ ERROR can't use generic parameters from outer function
+        }
+    }
+}
+
+trait TraitB<A> {
+    fn outer(&self) {
+        struct Foo<B>(A);
+                //~^ ERROR can't use generic parameters from outer function
+    }
+}
+
+trait TraitC<A> {
+    fn outer(&self) {
+        struct Foo<B> { a: A }
+                //~^ ERROR can't use generic parameters from outer function
+    }
+}
+
+trait TraitD<A> {
+    fn outer(&self) {
+        fn foo<B>(a: A) { }
+                //~^ ERROR can't use generic parameters from outer function
+    }
+}
+
+fn main() { }
diff --git a/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr b/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr
new file mode 100644
index 00000000000..0a6d1cc3bcd
--- /dev/null
+++ b/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr
@@ -0,0 +1,47 @@
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/resolve-type-param-in-item-in-trait.rs:8:22
+   |
+LL | trait TraitA<A> {
+   |              - type parameter from outer function
+LL |     fn outer(&self) {
+LL |         enum Foo<B> {
+   |                  - help: try using a local generic parameter instead: `A,`
+LL |             Variance(A)
+   |                      ^ use of generic parameter from outer function
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/resolve-type-param-in-item-in-trait.rs:16:23
+   |
+LL | trait TraitB<A> {
+   |              - type parameter from outer function
+LL |     fn outer(&self) {
+LL |         struct Foo<B>(A);
+   |                    -  ^ use of generic parameter from outer function
+   |                    |
+   |                    help: try using a local generic parameter instead: `A,`
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/resolve-type-param-in-item-in-trait.rs:23:28
+   |
+LL | trait TraitC<A> {
+   |              - type parameter from outer function
+LL |     fn outer(&self) {
+LL |         struct Foo<B> { a: A }
+   |                    -       ^ use of generic parameter from outer function
+   |                    |
+   |                    help: try using a local generic parameter instead: `A,`
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/resolve-type-param-in-item-in-trait.rs:30:22
+   |
+LL | trait TraitD<A> {
+   |              - type parameter from outer function
+LL |     fn outer(&self) {
+LL |         fn foo<B>(a: A) { }
+   |                -     ^ use of generic parameter from outer function
+   |                |
+   |                help: try using a local generic parameter instead: `A,`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/resolve-unknown-trait.rs b/tests/ui/resolve/resolve-unknown-trait.rs
new file mode 100644
index 00000000000..290893bbbec
--- /dev/null
+++ b/tests/ui/resolve/resolve-unknown-trait.rs
@@ -0,0 +1,10 @@
+trait NewTrait : SomeNonExistentTrait {}
+//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope
+
+impl SomeNonExistentTrait for isize {}
+//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope
+
+fn f<T:SomeNonExistentTrait>() {}
+//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope
+
+fn main() {}
diff --git a/tests/ui/resolve/resolve-unknown-trait.stderr b/tests/ui/resolve/resolve-unknown-trait.stderr
new file mode 100644
index 00000000000..e19cfe617d4
--- /dev/null
+++ b/tests/ui/resolve/resolve-unknown-trait.stderr
@@ -0,0 +1,21 @@
+error[E0405]: cannot find trait `SomeNonExistentTrait` in this scope
+  --> $DIR/resolve-unknown-trait.rs:1:18
+   |
+LL | trait NewTrait : SomeNonExistentTrait {}
+   |                  ^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0405]: cannot find trait `SomeNonExistentTrait` in this scope
+  --> $DIR/resolve-unknown-trait.rs:4:6
+   |
+LL | impl SomeNonExistentTrait for isize {}
+   |      ^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0405]: cannot find trait `SomeNonExistentTrait` in this scope
+  --> $DIR/resolve-unknown-trait.rs:7:8
+   |
+LL | fn f<T:SomeNonExistentTrait>() {}
+   |        ^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0405`.
diff --git a/tests/ui/resolve/resolve-variant-assoc-item.rs b/tests/ui/resolve/resolve-variant-assoc-item.rs
new file mode 100644
index 00000000000..db4fedfb0bd
--- /dev/null
+++ b/tests/ui/resolve/resolve-variant-assoc-item.rs
@@ -0,0 +1,7 @@
+enum E { V }
+use E::V;
+
+fn main() {
+    E::V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module
+    V::associated_item; //~ ERROR failed to resolve: `V` is a variant, not a module
+}
diff --git a/tests/ui/resolve/resolve-variant-assoc-item.stderr b/tests/ui/resolve/resolve-variant-assoc-item.stderr
new file mode 100644
index 00000000000..4be1019968b
--- /dev/null
+++ b/tests/ui/resolve/resolve-variant-assoc-item.stderr
@@ -0,0 +1,15 @@
+error[E0433]: failed to resolve: `V` is a variant, not a module
+  --> $DIR/resolve-variant-assoc-item.rs:5:8
+   |
+LL |     E::V::associated_item;
+   |        ^ `V` is a variant, not a module
+
+error[E0433]: failed to resolve: `V` is a variant, not a module
+  --> $DIR/resolve-variant-assoc-item.rs:6:5
+   |
+LL |     V::associated_item;
+   |     ^ `V` is a variant, not a module
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/shadow-const-param.rs b/tests/ui/resolve/shadow-const-param.rs
new file mode 100644
index 00000000000..c435c16dc67
--- /dev/null
+++ b/tests/ui/resolve/shadow-const-param.rs
@@ -0,0 +1,20 @@
+// Checks that const parameters cannot be shadowed with fresh bindings
+// even in syntactically unambiguous contexts. See
+// https://github.com/rust-lang/rust/issues/33118#issuecomment-233962221
+
+fn foo<const N: i32>(i: i32) -> bool {
+    match i {
+        N @ _ => true,
+        //~^ ERROR: match bindings cannot shadow const parameters [E0530]
+    }
+}
+
+fn bar<const N: i32>(i: i32) -> bool {
+    let N @ _ = 0;
+    //~^ ERROR: let bindings cannot shadow const parameters [E0530]
+    match i {
+        N @ _ => true,
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/shadow-const-param.stderr b/tests/ui/resolve/shadow-const-param.stderr
new file mode 100644
index 00000000000..fbd0d811000
--- /dev/null
+++ b/tests/ui/resolve/shadow-const-param.stderr
@@ -0,0 +1,20 @@
+error[E0530]: match bindings cannot shadow const parameters
+  --> $DIR/shadow-const-param.rs:7:9
+   |
+LL | fn foo<const N: i32>(i: i32) -> bool {
+   |              - the const parameter `N` is defined here
+LL |     match i {
+LL |         N @ _ => true,
+   |         ^ cannot be named the same as a const parameter
+
+error[E0530]: let bindings cannot shadow const parameters
+  --> $DIR/shadow-const-param.rs:13:9
+   |
+LL | fn bar<const N: i32>(i: i32) -> bool {
+   |              - the const parameter `N` is defined here
+LL |     let N @ _ = 0;
+   |         ^ cannot be named the same as a const parameter
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0530`.
diff --git a/tests/ui/resolve/suggest-path-for-tuple-struct.rs b/tests/ui/resolve/suggest-path-for-tuple-struct.rs
new file mode 100644
index 00000000000..c8bc3e79fe2
--- /dev/null
+++ b/tests/ui/resolve/suggest-path-for-tuple-struct.rs
@@ -0,0 +1,26 @@
+mod module {
+    pub struct SomeTupleStruct(u8);
+    pub struct SomeRegularStruct {
+        foo: u8
+    }
+
+    impl SomeTupleStruct {
+        pub fn new() -> Self {
+            Self(0)
+        }
+    }
+    impl SomeRegularStruct {
+        pub fn new() -> Self {
+            Self { foo: 0 }
+        }
+    }
+}
+
+use module::{SomeTupleStruct, SomeRegularStruct};
+
+fn main() {
+    let _ = SomeTupleStruct.new();
+    //~^ ERROR expected value, found struct `SomeTupleStruct`
+    let _ = SomeRegularStruct.new();
+    //~^ ERROR expected value, found struct `SomeRegularStruct`
+}
diff --git a/tests/ui/resolve/suggest-path-for-tuple-struct.stderr b/tests/ui/resolve/suggest-path-for-tuple-struct.stderr
new file mode 100644
index 00000000000..4764cf2db20
--- /dev/null
+++ b/tests/ui/resolve/suggest-path-for-tuple-struct.stderr
@@ -0,0 +1,15 @@
+error[E0423]: expected value, found struct `SomeTupleStruct`
+  --> $DIR/suggest-path-for-tuple-struct.rs:22:13
+   |
+LL |     let _ = SomeTupleStruct.new();
+   |             ^^^^^^^^^^^^^^^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found struct `SomeRegularStruct`
+  --> $DIR/suggest-path-for-tuple-struct.rs:24:13
+   |
+LL |     let _ = SomeRegularStruct.new();
+   |             ^^^^^^^^^^^^^^^^^- help: use the path separator to refer to an item: `::`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/suggest-path-instead-of-mod-dot-item.rs b/tests/ui/resolve/suggest-path-instead-of-mod-dot-item.rs
new file mode 100644
index 00000000000..d5d6b13d62c
--- /dev/null
+++ b/tests/ui/resolve/suggest-path-instead-of-mod-dot-item.rs
@@ -0,0 +1,111 @@
+// Beginners write `mod.item` when they should write `mod::item`.
+// This tests that we suggest the latter when we encounter the former.
+
+pub mod a {
+    pub const I: i32 = 1;
+
+    pub fn f() -> i32 { 2 }
+
+    pub mod b {
+        pub const J: i32 = 3;
+
+        pub fn g() -> i32 { 4 }
+    }
+}
+
+fn h1() -> i32 {
+    a.I
+    //~^ ERROR expected value, found module `a`
+    //~| HELP use the path separator
+}
+
+fn h2() -> i32 {
+    a.g()
+    //~^ ERROR expected value, found module `a`
+    //~| HELP use the path separator
+}
+
+fn h3() -> i32 {
+    a.b.J
+    //~^ ERROR expected value, found module `a`
+    //~| HELP use the path separator
+}
+
+fn h4() -> i32 {
+    a::b.J
+    //~^ ERROR expected value, found module `a::b`
+    //~| HELP a constant with a similar name exists
+    //~| HELP use the path separator
+}
+
+fn h5() {
+    a.b.f();
+    //~^ ERROR expected value, found module `a`
+    //~| HELP use the path separator
+    let v = Vec::new();
+    v.push(a::b);
+    //~^ ERROR expected value, found module `a::b`
+    //~| HELP a constant with a similar name exists
+}
+
+fn h6() -> i32 {
+    a::b.f()
+    //~^ ERROR expected value, found module `a::b`
+    //~| HELP a constant with a similar name exists
+    //~| HELP use the path separator
+}
+
+fn h7() {
+    a::b
+    //~^ ERROR expected value, found module `a::b`
+    //~| HELP a constant with a similar name exists
+}
+
+fn h8() -> i32 {
+    a::b()
+    //~^ ERROR expected function, found module `a::b`
+    //~| HELP a constant with a similar name exists
+}
+
+macro_rules! module {
+    () => {
+        a
+        //~^ ERROR expected value, found module `a`
+        //~| ERROR expected value, found module `a`
+    };
+}
+
+macro_rules! create {
+    (method) => {
+        a.f()
+        //~^ ERROR expected value, found module `a`
+        //~| HELP use the path separator
+    };
+    (field) => {
+        a.f
+        //~^ ERROR expected value, found module `a`
+        //~| HELP use the path separator
+    };
+}
+
+fn h9() {
+    //
+    // Note that if the receiver is a macro call, we do not want to suggest to replace
+    // `.` with `::` as that would be a syntax error.
+    // Since the receiver is a module and not a type, we cannot suggest to surround
+    // it with angle brackets.
+    //
+
+    module!().g::<()>(); // no `help` here!
+
+    module!().g; // no `help` here!
+
+    //
+    // Ensure that the suggestion is shown for expressions inside of macro definitions.
+    //
+
+    let _ = create!(method);
+    let _ = create!(field);
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr b/tests/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr
new file mode 100644
index 00000000000..a4ce0deeb70
--- /dev/null
+++ b/tests/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr
@@ -0,0 +1,140 @@
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:17:5
+   |
+LL |     a.I
+   |     ^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:23:5
+   |
+LL |     a.g()
+   |     ^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:29:5
+   |
+LL |     a.b.J
+   |     ^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found module `a::b`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:35:5
+   |
+LL |     pub const I: i32 = 1;
+   |     --------------------- similarly named constant `I` defined here
+...
+LL |     a::b.J
+   |     ^^^^
+   |
+help: use the path separator to refer to an item
+   |
+LL |     a::b::J
+   |         ~~
+help: a constant with a similar name exists
+   |
+LL |     a::I.J
+   |        ~
+
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:42:5
+   |
+LL |     a.b.f();
+   |     ^- help: use the path separator to refer to an item: `::`
+
+error[E0423]: expected value, found module `a::b`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:46:12
+   |
+LL |     pub const I: i32 = 1;
+   |     --------------------- similarly named constant `I` defined here
+...
+LL |     v.push(a::b);
+   |            ^^^-
+   |               |
+   |               help: a constant with a similar name exists: `I`
+
+error[E0423]: expected value, found module `a::b`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:52:5
+   |
+LL |     pub const I: i32 = 1;
+   |     --------------------- similarly named constant `I` defined here
+...
+LL |     a::b.f()
+   |     ^^^^
+   |
+help: use the path separator to refer to an item
+   |
+LL |     a::b::f()
+   |         ~~
+help: a constant with a similar name exists
+   |
+LL |     a::I.f()
+   |        ~
+
+error[E0423]: expected value, found module `a::b`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:59:5
+   |
+LL |     pub const I: i32 = 1;
+   |     --------------------- similarly named constant `I` defined here
+...
+LL |     a::b
+   |     ^^^-
+   |        |
+   |        help: a constant with a similar name exists: `I`
+
+error[E0423]: expected function, found module `a::b`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:65:5
+   |
+LL |     pub const I: i32 = 1;
+   |     --------------------- similarly named constant `I` defined here
+...
+LL |     a::b()
+   |     ^^^-
+   |        |
+   |        help: a constant with a similar name exists: `I`
+
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:72:9
+   |
+LL |         a
+   |         ^ not a value
+...
+LL |     module!().g::<()>(); // no `help` here!
+   |     --------- in this macro invocation
+   |
+   = note: this error originates in the macro `module` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:72:9
+   |
+LL |         a
+   |         ^ not a value
+...
+LL |     module!().g; // no `help` here!
+   |     --------- in this macro invocation
+   |
+   = note: this error originates in the macro `module` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:80:9
+   |
+LL |         a.f()
+   |         ^- help: use the path separator to refer to an item: `::`
+...
+LL |     let _ = create!(method);
+   |             --------------- in this macro invocation
+   |
+   = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found module `a`
+  --> $DIR/suggest-path-instead-of-mod-dot-item.rs:85:9
+   |
+LL |         a.f
+   |         ^- help: use the path separator to refer to an item: `::`
+...
+LL |     let _ = create!(field);
+   |             -------------- in this macro invocation
+   |
+   = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 13 previous errors
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/token-error-correct-2.rs b/tests/ui/resolve/token-error-correct-2.rs
new file mode 100644
index 00000000000..f7c7d908c78
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct-2.rs
@@ -0,0 +1,7 @@
+// Test that we do some basic error correction in the tokeniser (and don't ICE).
+
+fn main() {
+    if foo {
+    //~^ ERROR: cannot find value `foo`
+    ) //~ ERROR: mismatched closing delimiter: `)`
+}
diff --git a/tests/ui/resolve/token-error-correct-2.stderr b/tests/ui/resolve/token-error-correct-2.stderr
new file mode 100644
index 00000000000..cca9f2dc88c
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct-2.stderr
@@ -0,0 +1,18 @@
+error: mismatched closing delimiter: `)`
+  --> $DIR/token-error-correct-2.rs:4:12
+   |
+LL |     if foo {
+   |            ^ unclosed delimiter
+LL |
+LL |     )
+   |     ^ mismatched closing delimiter
+
+error[E0425]: cannot find value `foo` in this scope
+  --> $DIR/token-error-correct-2.rs:4:8
+   |
+LL |     if foo {
+   |        ^^^ not found in this scope
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/token-error-correct-3.rs b/tests/ui/resolve/token-error-correct-3.rs
new file mode 100644
index 00000000000..52934085fa1
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct-3.rs
@@ -0,0 +1,25 @@
+// Test that we do some basic error correction in the tokeniser (and don't spew
+// too many bogus errors).
+
+pub mod raw {
+    use std::{io, fs};
+    use std::path::Path;
+
+    pub fn ensure_dir_exists<P: AsRef<Path>, F: FnOnce(&Path)>(path: P,
+                                                               callback: F)
+                                                               -> io::Result<bool> {
+        if !is_directory(path.as_ref()) {
+            //~^ ERROR cannot find function `is_directory`
+            callback(path.as_ref();
+            //~^ ERROR expected one of
+            fs::create_dir_all(path.as_ref()).map(|()| true)
+        } else {
+            //~^ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
+            Ok(false);
+        }
+
+        panic!();
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/token-error-correct-3.stderr b/tests/ui/resolve/token-error-correct-3.stderr
new file mode 100644
index 00000000000..77c87c78466
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct-3.stderr
@@ -0,0 +1,25 @@
+error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
+  --> $DIR/token-error-correct-3.rs:13:21
+   |
+LL |             callback(path.as_ref();
+   |                     ^             ^ help: `)` may belong here
+   |                     |
+   |                     unclosed delimiter
+
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
+  --> $DIR/token-error-correct-3.rs:16:9
+   |
+LL |             fs::create_dir_all(path.as_ref()).map(|()| true)
+   |                                                             - expected one of `.`, `;`, `?`, `}`, or an operator
+LL |         } else {
+   |         ^ unexpected token
+
+error[E0425]: cannot find function `is_directory` in this scope
+  --> $DIR/token-error-correct-3.rs:11:13
+   |
+LL |         if !is_directory(path.as_ref()) {
+   |             ^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/token-error-correct-4.fixed b/tests/ui/resolve/token-error-correct-4.fixed
new file mode 100644
index 00000000000..064b9e74e24
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct-4.fixed
@@ -0,0 +1,10 @@
+// run-rustfix
+// Test that we do some basic error correction in the tokeniser and apply suggestions.
+
+fn setsuna(_: ()) {}
+
+fn kazusa() {}
+
+fn main() {
+    setsuna(kazusa()); //~ ERROR: expected one of
+} //~ ERROR: expected expression
diff --git a/tests/ui/resolve/token-error-correct-4.rs b/tests/ui/resolve/token-error-correct-4.rs
new file mode 100644
index 00000000000..5e31d71e7bf
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct-4.rs
@@ -0,0 +1,10 @@
+// run-rustfix
+// Test that we do some basic error correction in the tokeniser and apply suggestions.
+
+fn setsuna(_: ()) {}
+
+fn kazusa() {}
+
+fn main() {
+    setsuna(kazusa(); //~ ERROR: expected one of
+} //~ ERROR: expected expression
diff --git a/tests/ui/resolve/token-error-correct-4.stderr b/tests/ui/resolve/token-error-correct-4.stderr
new file mode 100644
index 00000000000..81e5a133691
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct-4.stderr
@@ -0,0 +1,16 @@
+error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
+  --> $DIR/token-error-correct-4.rs:9:12
+   |
+LL |     setsuna(kazusa();
+   |            ^        ^ help: `)` may belong here
+   |            |
+   |            unclosed delimiter
+
+error: expected expression, found `)`
+  --> $DIR/token-error-correct-4.rs:10:1
+   |
+LL | }
+   | ^ expected expression
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/resolve/token-error-correct.rs b/tests/ui/resolve/token-error-correct.rs
new file mode 100644
index 00000000000..4f74df0bf1f
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct.rs
@@ -0,0 +1,9 @@
+// Test that we do some basic error correction in the tokeniser.
+
+fn main() {
+    foo(bar(;
+    //~^ ERROR cannot find function `bar` in this scope
+}
+//~^ ERROR: mismatched closing delimiter: `}`
+
+fn foo(_: usize) {}
diff --git a/tests/ui/resolve/token-error-correct.stderr b/tests/ui/resolve/token-error-correct.stderr
new file mode 100644
index 00000000000..ca0c4c18ad4
--- /dev/null
+++ b/tests/ui/resolve/token-error-correct.stderr
@@ -0,0 +1,20 @@
+error: mismatched closing delimiter: `}`
+  --> $DIR/token-error-correct.rs:4:12
+   |
+LL | fn main() {
+   |           - closing delimiter possibly meant for this
+LL |     foo(bar(;
+   |            ^ unclosed delimiter
+LL |
+LL | }
+   | ^ mismatched closing delimiter
+
+error[E0425]: cannot find function `bar` in this scope
+  --> $DIR/token-error-correct.rs:4:9
+   |
+LL |     foo(bar(;
+   |         ^^^ not found in this scope
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/tuple-struct-alias.rs b/tests/ui/resolve/tuple-struct-alias.rs
new file mode 100644
index 00000000000..298e7e47998
--- /dev/null
+++ b/tests/ui/resolve/tuple-struct-alias.rs
@@ -0,0 +1,9 @@
+struct S(u8, u16);
+type A = S;
+
+fn main() {
+    let s = A(0, 1); //~ ERROR expected function
+    match s {
+        A(..) => {} //~ ERROR expected tuple struct or tuple variant
+    }
+}
diff --git a/tests/ui/resolve/tuple-struct-alias.stderr b/tests/ui/resolve/tuple-struct-alias.stderr
new file mode 100644
index 00000000000..a739ea43eed
--- /dev/null
+++ b/tests/ui/resolve/tuple-struct-alias.stderr
@@ -0,0 +1,26 @@
+error[E0532]: expected tuple struct or tuple variant, found type alias `A`
+  --> $DIR/tuple-struct-alias.rs:7:9
+   |
+LL | struct S(u8, u16);
+   | ------------------ similarly named tuple struct `S` defined here
+...
+LL |         A(..) => {}
+   |         ^ help: a tuple struct with a similar name exists: `S`
+   |
+   = note: can't use a type alias as a constructor
+
+error[E0423]: expected function, tuple struct or tuple variant, found type alias `A`
+  --> $DIR/tuple-struct-alias.rs:5:13
+   |
+LL | struct S(u8, u16);
+   | ------------------ similarly named tuple struct `S` defined here
+...
+LL |     let s = A(0, 1);
+   |             ^ help: a tuple struct with a similar name exists: `S`
+   |
+   = note: can't use a type alias as a constructor
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0423, E0532.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs
new file mode 100644
index 00000000000..ecd3f588119
--- /dev/null
+++ b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs
@@ -0,0 +1,46 @@
+struct A {
+    config: String,
+}
+
+impl A {
+    fn new(cofig: String) -> Self {
+        Self { config } //~ Error cannot find value `config` in this scope
+    }
+
+    fn do_something(cofig: String) {
+        println!("{config}"); //~ Error cannot find value `config` in this scope
+    }
+
+    fn self_is_available(self, cofig: String) {
+        println!("{config}"); //~ Error cannot find value `config` in this scope
+    }
+}
+
+trait B {
+    const BAR: u32 = 3;
+    type Baz;
+    fn bar(&self);
+    fn baz(&self) {}
+    fn bah() {}
+}
+
+impl B for Box<isize> {
+    type Baz = String;
+    fn bar(&self) {
+        // let baz = 3;
+        baz();
+        //~^ ERROR cannot find function `baz`
+        bah;
+        //~^ ERROR cannot find value `bah`
+        BAR;
+        //~^ ERROR cannot find value `BAR` in this scope
+        let foo: Baz = "".to_string();
+        //~^ ERROR cannot find type `Baz` in this scope
+    }
+}
+
+fn ba() {}
+const BARR: u32 = 3;
+type Bar = String;
+
+fn main() {}
diff --git a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
new file mode 100644
index 00000000000..f32e0404e46
--- /dev/null
+++ b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
@@ -0,0 +1,109 @@
+error[E0425]: cannot find value `config` in this scope
+  --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:7:16
+   |
+LL |         Self { config }
+   |                ^^^^^^
+   |                |
+   |                a field by this name exists in `Self`
+   |                help: a local variable with a similar name exists: `cofig`
+
+error[E0425]: cannot find value `config` in this scope
+  --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:11:20
+   |
+LL |         println!("{config}");
+   |                    ^^^^^^
+   |                    |
+   |                    a field by this name exists in `Self`
+   |                    help: a local variable with a similar name exists: `cofig`
+
+error[E0425]: cannot find value `config` in this scope
+  --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20
+   |
+LL |         println!("{config}");
+   |                    ^^^^^^
+   |
+help: you might have meant to use the available field
+   |
+LL |         println!("{self.config}");
+   |                    ~~~~~~~~~~~
+help: a local variable with a similar name exists
+   |
+LL |         println!("{cofig}");
+   |                    ~~~~~
+
+error[E0425]: cannot find value `bah` in this scope
+  --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9
+   |
+LL |         bah;
+   |         ^^^
+...
+LL | fn ba() {}
+   | ------- similarly named function `ba` defined here
+   |
+help: you might have meant to refer to the associated function
+   |
+LL |         Self::bah;
+   |         ~~~~~~~~~
+help: a function with a similar name exists
+   |
+LL |         ba;
+   |         ~~
+
+error[E0425]: cannot find value `BAR` in this scope
+  --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:35:9
+   |
+LL |         BAR;
+   |         ^^^
+...
+LL | const BARR: u32 = 3;
+   | -------------------- similarly named constant `BARR` defined here
+   |
+help: you might have meant to use the associated `const`
+   |
+LL |         Self::BAR;
+   |         ~~~~~~~~~
+help: a constant with a similar name exists
+   |
+LL |         BARR;
+   |         ~~~~
+
+error[E0412]: cannot find type `Baz` in this scope
+  --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:37:18
+   |
+LL |         let foo: Baz = "".to_string();
+   |                  ^^^
+...
+LL | type Bar = String;
+   | ------------------ similarly named type alias `Bar` defined here
+   |
+help: you might have meant to use the associated type
+   |
+LL |         let foo: Self::Baz = "".to_string();
+   |                  ~~~~~~~~~
+help: a type alias with a similar name exists
+   |
+LL |         let foo: Bar = "".to_string();
+   |                  ~~~
+
+error[E0425]: cannot find function `baz` in this scope
+  --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:31:9
+   |
+LL |         baz();
+   |         ^^^
+...
+LL | fn ba() {}
+   | ------- similarly named function `ba` defined here
+   |
+help: you might have meant to call the method
+   |
+LL |         self.baz();
+   |         ~~~~~~~~
+help: a function with a similar name exists
+   |
+LL |         ba();
+   |         ~~
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0412, E0425.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/typo-suggestion-mistyped-in-path.rs b/tests/ui/resolve/typo-suggestion-mistyped-in-path.rs
new file mode 100644
index 00000000000..3ce17a14f14
--- /dev/null
+++ b/tests/ui/resolve/typo-suggestion-mistyped-in-path.rs
@@ -0,0 +1,42 @@
+struct Struct;
+//~^ NOTE function or associated item `fob` not found for this struct
+
+impl Struct {
+    fn foo() { }
+}
+
+mod module {
+    fn foo() { }
+
+    struct Struct;
+
+    impl Struct {
+        fn foo() { }
+    }
+}
+
+trait Trait {
+    fn foo();
+}
+
+fn main() {
+    Struct::fob();
+    //~^ ERROR no function or associated item named `fob` found for struct `Struct` in the current scope
+    //~| NOTE function or associated item not found in `Struct`
+
+    Struc::foo();
+    //~^ ERROR failed to resolve: use of undeclared type `Struc`
+    //~| NOTE use of undeclared type `Struc`
+
+    modul::foo();
+    //~^ ERROR failed to resolve: use of undeclared crate or module `modul`
+    //~| NOTE use of undeclared crate or module `modul`
+
+    module::Struc::foo();
+    //~^ ERROR failed to resolve: could not find `Struc` in `module`
+    //~| NOTE could not find `Struc` in `module`
+
+    Trai::foo();
+    //~^ ERROR failed to resolve: use of undeclared type `Trai`
+    //~| NOTE use of undeclared type `Trai`
+}
diff --git a/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr
new file mode 100644
index 00000000000..89b69e14099
--- /dev/null
+++ b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr
@@ -0,0 +1,54 @@
+error[E0433]: failed to resolve: could not find `Struc` in `module`
+  --> $DIR/typo-suggestion-mistyped-in-path.rs:35:13
+   |
+LL |     module::Struc::foo();
+   |             ^^^^^
+   |             |
+   |             could not find `Struc` in `module`
+   |             help: a struct with a similar name exists: `Struct`
+
+error[E0599]: no function or associated item named `fob` found for struct `Struct` in the current scope
+  --> $DIR/typo-suggestion-mistyped-in-path.rs:23:13
+   |
+LL | struct Struct;
+   | ------------- function or associated item `fob` not found for this struct
+...
+LL |     Struct::fob();
+   |             ^^^
+   |             |
+   |             function or associated item not found in `Struct`
+   |             help: there is an associated function with a similar name: `foo`
+
+error[E0433]: failed to resolve: use of undeclared type `Struc`
+  --> $DIR/typo-suggestion-mistyped-in-path.rs:27:5
+   |
+LL |     Struc::foo();
+   |     ^^^^^
+   |     |
+   |     use of undeclared type `Struc`
+   |     help: a struct with a similar name exists: `Struct`
+
+error[E0433]: failed to resolve: use of undeclared crate or module `modul`
+  --> $DIR/typo-suggestion-mistyped-in-path.rs:31:5
+   |
+LL |     modul::foo();
+   |     ^^^^^ use of undeclared crate or module `modul`
+   |
+help: there is a crate or module with a similar name
+   |
+LL |     module::foo();
+   |     ~~~~~~
+
+error[E0433]: failed to resolve: use of undeclared type `Trai`
+  --> $DIR/typo-suggestion-mistyped-in-path.rs:39:5
+   |
+LL |     Trai::foo();
+   |     ^^^^
+   |     |
+   |     use of undeclared type `Trai`
+   |     help: a trait with a similar name exists: `Trait`
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0433, E0599.
+For more information about an error, try `rustc --explain E0433`.
diff --git a/tests/ui/resolve/typo-suggestion-named-underscore.rs b/tests/ui/resolve/typo-suggestion-named-underscore.rs
new file mode 100644
index 00000000000..a2b05db0351
--- /dev/null
+++ b/tests/ui/resolve/typo-suggestion-named-underscore.rs
@@ -0,0 +1,14 @@
+const _: () = ();
+
+fn main() {
+    a // Shouldn't suggest underscore
+    //~^ ERROR: cannot find value `a` in this scope
+}
+
+trait Unknown {}
+
+#[allow(unused_imports)]
+use Unknown as _;
+
+fn foo<T: A>(x: T) {} // Shouldn't suggest underscore
+//~^ ERROR: cannot find trait `A` in this scope
diff --git a/tests/ui/resolve/typo-suggestion-named-underscore.stderr b/tests/ui/resolve/typo-suggestion-named-underscore.stderr
new file mode 100644
index 00000000000..65d1b084a3a
--- /dev/null
+++ b/tests/ui/resolve/typo-suggestion-named-underscore.stderr
@@ -0,0 +1,16 @@
+error[E0425]: cannot find value `a` in this scope
+  --> $DIR/typo-suggestion-named-underscore.rs:4:5
+   |
+LL |     a // Shouldn't suggest underscore
+   |     ^ not found in this scope
+
+error[E0405]: cannot find trait `A` in this scope
+  --> $DIR/typo-suggestion-named-underscore.rs:13:11
+   |
+LL | fn foo<T: A>(x: T) {} // Shouldn't suggest underscore
+   |           ^ not found in this scope
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0405, E0425.
+For more information about an error, try `rustc --explain E0405`.
diff --git a/tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs b/tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs
new file mode 100644
index 00000000000..87f9ce097c5
--- /dev/null
+++ b/tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs
@@ -0,0 +1,9 @@
+fn f<F:Nonexist(isize) -> isize>(x: F) {}
+//~^ ERROR cannot find trait `Nonexist`
+
+type Typedef = isize;
+
+fn g<F:Typedef(isize) -> isize>(x: F) {}
+//~^ ERROR expected trait, found type alias `Typedef`
+
+fn main() {}
diff --git a/tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr b/tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr
new file mode 100644
index 00000000000..8addc0303fb
--- /dev/null
+++ b/tests/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr
@@ -0,0 +1,21 @@
+error[E0405]: cannot find trait `Nonexist` in this scope
+  --> $DIR/unboxed-closure-sugar-nonexistent-trait.rs:1:8
+   |
+LL | fn f<F:Nonexist(isize) -> isize>(x: F) {}
+   |        ^^^^^^^^ not found in this scope
+
+error[E0404]: expected trait, found type alias `Typedef`
+  --> $DIR/unboxed-closure-sugar-nonexistent-trait.rs:6:8
+   |
+LL | fn g<F:Typedef(isize) -> isize>(x: F) {}
+   |        ^^^^^^^^^^^^^^^^^^^^^^^ type aliases cannot be used as traits
+   |
+help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias
+   |
+LL | trait Typedef = isize;
+   |
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0404, E0405.
+For more information about an error, try `rustc --explain E0404`.
diff --git a/tests/ui/resolve/unresolved_static_type_field.rs b/tests/ui/resolve/unresolved_static_type_field.rs
new file mode 100644
index 00000000000..494ad083f1a
--- /dev/null
+++ b/tests/ui/resolve/unresolved_static_type_field.rs
@@ -0,0 +1,14 @@
+fn f(_: bool) {}
+
+struct Foo {
+    cx: bool,
+}
+
+impl Foo {
+    fn bar() {
+        f(cx);
+        //~^ ERROR cannot find value `cx` in this scope
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/unresolved_static_type_field.stderr b/tests/ui/resolve/unresolved_static_type_field.stderr
new file mode 100644
index 00000000000..06926b53ddd
--- /dev/null
+++ b/tests/ui/resolve/unresolved_static_type_field.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `cx` in this scope
+  --> $DIR/unresolved_static_type_field.rs:9:11
+   |
+LL |         f(cx);
+   |           ^^ a field by this name exists in `Self`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/use-self-in-inner-fn.rs b/tests/ui/resolve/use-self-in-inner-fn.rs
new file mode 100644
index 00000000000..eccb315feb1
--- /dev/null
+++ b/tests/ui/resolve/use-self-in-inner-fn.rs
@@ -0,0 +1,14 @@
+struct A;
+
+impl A {
+//~^ NOTE `Self` type implicitly declared here, by this `impl`
+    fn banana(&mut self) {
+        fn peach(this: &Self) {
+        //~^ ERROR can't use generic parameters from outer function
+        //~| NOTE use of generic parameter from outer function
+        //~| NOTE use a type here instead
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/resolve/use-self-in-inner-fn.stderr b/tests/ui/resolve/use-self-in-inner-fn.stderr
new file mode 100644
index 00000000000..96609349924
--- /dev/null
+++ b/tests/ui/resolve/use-self-in-inner-fn.stderr
@@ -0,0 +1,15 @@
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/use-self-in-inner-fn.rs:6:25
+   |
+LL | impl A {
+   | ---- `Self` type implicitly declared here, by this `impl`
+...
+LL |         fn peach(this: &Self) {
+   |                         ^^^^
+   |                         |
+   |                         use of generic parameter from outer function
+   |                         use a type here instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/use_suggestion.rs b/tests/ui/resolve/use_suggestion.rs
new file mode 100644
index 00000000000..8c9bc6d76b8
--- /dev/null
+++ b/tests/ui/resolve/use_suggestion.rs
@@ -0,0 +1,7 @@
+fn main() {
+    let x1 = HashMap::new(); //~ ERROR failed to resolve
+    let x2 = GooMap::new(); //~ ERROR failed to resolve
+
+    let y1: HashMap; //~ ERROR cannot find type
+    let y2: GooMap; //~ ERROR cannot find type
+}
diff --git a/tests/ui/resolve/use_suggestion.stderr b/tests/ui/resolve/use_suggestion.stderr
new file mode 100644
index 00000000000..54ad853831f
--- /dev/null
+++ b/tests/ui/resolve/use_suggestion.stderr
@@ -0,0 +1,38 @@
+error[E0433]: failed to resolve: use of undeclared type `HashMap`
+  --> $DIR/use_suggestion.rs:2:14
+   |
+LL |     let x1 = HashMap::new();
+   |              ^^^^^^^ use of undeclared type `HashMap`
+   |
+help: consider importing this struct
+   |
+LL | use std::collections::HashMap;
+   |
+
+error[E0412]: cannot find type `HashMap` in this scope
+  --> $DIR/use_suggestion.rs:5:13
+   |
+LL |     let y1: HashMap;
+   |             ^^^^^^^ not found in this scope
+   |
+help: consider importing this struct
+   |
+LL | use std::collections::HashMap;
+   |
+
+error[E0412]: cannot find type `GooMap` in this scope
+  --> $DIR/use_suggestion.rs:6:13
+   |
+LL |     let y2: GooMap;
+   |             ^^^^^^ not found in this scope
+
+error[E0433]: failed to resolve: use of undeclared type `GooMap`
+  --> $DIR/use_suggestion.rs:3:14
+   |
+LL |     let x2 = GooMap::new();
+   |              ^^^^^^ use of undeclared type `GooMap`
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0412, E0433.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/use_suggestion_placement.fixed b/tests/ui/resolve/use_suggestion_placement.fixed
new file mode 100644
index 00000000000..d1686f7fd2b
--- /dev/null
+++ b/tests/ui/resolve/use_suggestion_placement.fixed
@@ -0,0 +1,35 @@
+// run-rustfix
+#![allow(dead_code)]
+
+use m::A;
+
+use std::collections::HashMap;
+
+macro_rules! y {
+    () => {}
+}
+
+mod m {
+    pub const A: i32 = 0;
+}
+
+mod foo {
+    use std::path::Path;
+
+#[derive(Debug)]
+    pub struct Foo;
+
+    // test whether the use suggestion isn't
+    // placed into the expansion of `#[derive(Debug)]
+    type Bar = Path; //~ ERROR cannot find
+}
+
+fn main() {
+    y!();
+    let _ = A; //~ ERROR cannot find
+    foo();
+}
+
+fn foo() {
+    type Dict<K, V> = HashMap<K, V>; //~ ERROR cannot find
+}
diff --git a/tests/ui/resolve/use_suggestion_placement.rs b/tests/ui/resolve/use_suggestion_placement.rs
new file mode 100644
index 00000000000..5be91f27092
--- /dev/null
+++ b/tests/ui/resolve/use_suggestion_placement.rs
@@ -0,0 +1,29 @@
+// run-rustfix
+#![allow(dead_code)]
+
+macro_rules! y {
+    () => {}
+}
+
+mod m {
+    pub const A: i32 = 0;
+}
+
+mod foo {
+    #[derive(Debug)]
+    pub struct Foo;
+
+    // test whether the use suggestion isn't
+    // placed into the expansion of `#[derive(Debug)]
+    type Bar = Path; //~ ERROR cannot find
+}
+
+fn main() {
+    y!();
+    let _ = A; //~ ERROR cannot find
+    foo();
+}
+
+fn foo() {
+    type Dict<K, V> = HashMap<K, V>; //~ ERROR cannot find
+}
diff --git a/tests/ui/resolve/use_suggestion_placement.stderr b/tests/ui/resolve/use_suggestion_placement.stderr
new file mode 100644
index 00000000000..0aadd82f6c2
--- /dev/null
+++ b/tests/ui/resolve/use_suggestion_placement.stderr
@@ -0,0 +1,37 @@
+error[E0412]: cannot find type `Path` in this scope
+  --> $DIR/use_suggestion_placement.rs:18:16
+   |
+LL |     type Bar = Path;
+   |                ^^^^ not found in this scope
+   |
+help: consider importing this struct
+   |
+LL |     use std::path::Path;
+   |
+
+error[E0425]: cannot find value `A` in this scope
+  --> $DIR/use_suggestion_placement.rs:23:13
+   |
+LL |     let _ = A;
+   |             ^ not found in this scope
+   |
+help: consider importing this constant
+   |
+LL | use m::A;
+   |
+
+error[E0412]: cannot find type `HashMap` in this scope
+  --> $DIR/use_suggestion_placement.rs:28:23
+   |
+LL |     type Dict<K, V> = HashMap<K, V>;
+   |                       ^^^^^^^ not found in this scope
+   |
+help: consider importing this struct
+   |
+LL | use std::collections::HashMap;
+   |
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0412, E0425.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/ui/resolve/visibility-indeterminate.rs b/tests/ui/resolve/visibility-indeterminate.rs
new file mode 100644
index 00000000000..0e1142db37d
--- /dev/null
+++ b/tests/ui/resolve/visibility-indeterminate.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+foo!(); //~ ERROR cannot find macro `foo` in this scope
+
+pub(in ::bar) struct Baz {} //~ ERROR cannot determine resolution for the visibility
+
+fn main() {}
diff --git a/tests/ui/resolve/visibility-indeterminate.stderr b/tests/ui/resolve/visibility-indeterminate.stderr
new file mode 100644
index 00000000000..84d82ce8522
--- /dev/null
+++ b/tests/ui/resolve/visibility-indeterminate.stderr
@@ -0,0 +1,15 @@
+error[E0578]: cannot determine resolution for the visibility
+  --> $DIR/visibility-indeterminate.rs:5:8
+   |
+LL | pub(in ::bar) struct Baz {}
+   |        ^^^^^
+
+error: cannot find macro `foo` in this scope
+  --> $DIR/visibility-indeterminate.rs:3:1
+   |
+LL | foo!();
+   | ^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0578`.