summaryrefslogtreecommitdiffstats
path: root/src/test/ui/resolve
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/resolve
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/resolve')
-rw-r--r--src/test/ui/resolve/associated-fn-called-as-fn.rs32
-rw-r--r--src/test/ui/resolve/associated-fn-called-as-fn.stderr15
-rw-r--r--src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs3
-rw-r--r--src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs3
-rw-r--r--src/test/ui/resolve/auxiliary/extern-prelude-vec.rs3
-rw-r--r--src/test/ui/resolve/auxiliary/extern-prelude.rs5
-rw-r--r--src/test/ui/resolve/auxiliary/issue-19452-aux.rs3
-rw-r--r--src/test/ui/resolve/auxiliary/issue-21221-3.rs19
-rw-r--r--src/test/ui/resolve/auxiliary/issue-21221-4.rs12
-rw-r--r--src/test/ui/resolve/auxiliary/issue-3907.rs3
-rw-r--r--src/test/ui/resolve/auxiliary/issue-80079.rs18
-rw-r--r--src/test/ui/resolve/auxiliary/namespaced_enums.rs10
-rw-r--r--src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs9
-rw-r--r--src/test/ui/resolve/bad-env-capture.rs6
-rw-r--r--src/test/ui/resolve/bad-env-capture.stderr24
-rw-r--r--src/test/ui/resolve/bad-env-capture2.rs5
-rw-r--r--src/test/ui/resolve/bad-env-capture2.stderr24
-rw-r--r--src/test/ui/resolve/bad-env-capture3.rs8
-rw-r--r--src/test/ui/resolve/bad-env-capture3.stderr24
-rw-r--r--src/test/ui/resolve/bad-expr-path.rs8
-rw-r--r--src/test/ui/resolve/bad-expr-path.stderr31
-rw-r--r--src/test/ui/resolve/bad-expr-path2.rs10
-rw-r--r--src/test/ui/resolve/bad-expr-path2.stderr31
-rw-r--r--src/test/ui/resolve/bad-module.rs7
-rw-r--r--src/test/ui/resolve/bad-module.stderr15
-rw-r--r--src/test/ui/resolve/bad-type-env-capture.rs4
-rw-r--r--src/test/ui/resolve/bad-type-env-capture.stderr13
-rw-r--r--src/test/ui/resolve/blind-item-mixed-crate-use-item.rs26
-rw-r--r--src/test/ui/resolve/blind-item-mixed-use-item.rs20
-rw-r--r--src/test/ui/resolve/block-with-trait-parent.rs14
-rw-r--r--src/test/ui/resolve/crate-called-as-function.rs3
-rw-r--r--src/test/ui/resolve/crate-called-as-function.stderr9
-rw-r--r--src/test/ui/resolve/crate-in-paths.rs10
-rw-r--r--src/test/ui/resolve/crate-in-paths.stderr14
-rw-r--r--src/test/ui/resolve/editions-crate-root-2015.rs21
-rw-r--r--src/test/ui/resolve/editions-crate-root-2015.stderr32
-rw-r--r--src/test/ui/resolve/editions-crate-root-2018.rs21
-rw-r--r--src/test/ui/resolve/editions-crate-root-2018.stderr28
-rw-r--r--src/test/ui/resolve/enums-are-namespaced-xc.rs11
-rw-r--r--src/test/ui/resolve/enums-are-namespaced-xc.stderr52
-rw-r--r--src/test/ui/resolve/enums-pats-not-idents.rs3
-rw-r--r--src/test/ui/resolve/enums-pats-not-idents.stderr9
-rw-r--r--src/test/ui/resolve/export-fully-qualified.rs11
-rw-r--r--src/test/ui/resolve/export-fully-qualified.stderr9
-rw-r--r--src/test/ui/resolve/extern-prelude-fail.rs9
-rw-r--r--src/test/ui/resolve/extern-prelude-fail.stderr20
-rw-r--r--src/test/ui/resolve/extern-prelude.rs31
-rw-r--r--src/test/ui/resolve/filter-intrinsics.rs10
-rw-r--r--src/test/ui/resolve/filter-intrinsics.stderr25
-rw-r--r--src/test/ui/resolve/impl-items-vis-unresolved.rs26
-rw-r--r--src/test/ui/resolve/impl-items-vis-unresolved.stderr9
-rw-r--r--src/test/ui/resolve/issue-10200.rs9
-rw-r--r--src/test/ui/resolve/issue-10200.stderr12
-rw-r--r--src/test/ui/resolve/issue-12796.rs9
-rw-r--r--src/test/ui/resolve/issue-12796.stderr12
-rw-r--r--src/test/ui/resolve/issue-14254.rs105
-rw-r--r--src/test/ui/resolve/issue-14254.stderr147
-rw-r--r--src/test/ui/resolve/issue-16058.rs18
-rw-r--r--src/test/ui/resolve/issue-16058.stderr18
-rw-r--r--src/test/ui/resolve/issue-17518.rs7
-rw-r--r--src/test/ui/resolve/issue-17518.stderr14
-rw-r--r--src/test/ui/resolve/issue-18252.rs8
-rw-r--r--src/test/ui/resolve/issue-18252.stderr12
-rw-r--r--src/test/ui/resolve/issue-19452.rs15
-rw-r--r--src/test/ui/resolve/issue-19452.stderr23
-rw-r--r--src/test/ui/resolve/issue-21221-1.rs75
-rw-r--r--src/test/ui/resolve/issue-21221-1.stderr51
-rw-r--r--src/test/ui/resolve/issue-21221-2.rs21
-rw-r--r--src/test/ui/resolve/issue-21221-2.stderr16
-rw-r--r--src/test/ui/resolve/issue-21221-3.rs19
-rw-r--r--src/test/ui/resolve/issue-21221-3.stderr14
-rw-r--r--src/test/ui/resolve/issue-21221-4.rs15
-rw-r--r--src/test/ui/resolve/issue-21221-4.stderr14
-rw-r--r--src/test/ui/resolve/issue-22692.rs3
-rw-r--r--src/test/ui/resolve/issue-22692.stderr11
-rw-r--r--src/test/ui/resolve/issue-2330.rs13
-rw-r--r--src/test/ui/resolve/issue-2330.stderr9
-rw-r--r--src/test/ui/resolve/issue-23305.rs8
-rw-r--r--src/test/ui/resolve/issue-23305.stderr22
-rw-r--r--src/test/ui/resolve/issue-2356.rs94
-rw-r--r--src/test/ui/resolve/issue-2356.stderr134
-rw-r--r--src/test/ui/resolve/issue-23716.rs17
-rw-r--r--src/test/ui/resolve/issue-23716.stderr21
-rw-r--r--src/test/ui/resolve/issue-24968.rs30
-rw-r--r--src/test/ui/resolve/issue-24968.stderr57
-rw-r--r--src/test/ui/resolve/issue-26545.rs12
-rw-r--r--src/test/ui/resolve/issue-26545.stderr14
-rw-r--r--src/test/ui/resolve/issue-3021-c.rs9
-rw-r--r--src/test/ui/resolve/issue-3021-c.stderr25
-rw-r--r--src/test/ui/resolve/issue-3021.rs18
-rw-r--r--src/test/ui/resolve/issue-3021.stderr11
-rw-r--r--src/test/ui/resolve/issue-31845.rs12
-rw-r--r--src/test/ui/resolve/issue-31845.stderr9
-rw-r--r--src/test/ui/resolve/issue-33876.rs12
-rw-r--r--src/test/ui/resolve/issue-33876.stderr9
-rw-r--r--src/test/ui/resolve/issue-3907-2.rs14
-rw-r--r--src/test/ui/resolve/issue-3907-2.stderr15
-rw-r--r--src/test/ui/resolve/issue-3907.rs20
-rw-r--r--src/test/ui/resolve/issue-3907.stderr18
-rw-r--r--src/test/ui/resolve/issue-39226.rs14
-rw-r--r--src/test/ui/resolve/issue-39226.stderr21
-rw-r--r--src/test/ui/resolve/issue-42944.rs21
-rw-r--r--src/test/ui/resolve/issue-42944.stderr28
-rw-r--r--src/test/ui/resolve/issue-49074.rs13
-rw-r--r--src/test/ui/resolve/issue-49074.stderr16
-rw-r--r--src/test/ui/resolve/issue-5035-2.rs7
-rw-r--r--src/test/ui/resolve/issue-5035-2.stderr16
-rw-r--r--src/test/ui/resolve/issue-5035.rs9
-rw-r--r--src/test/ui/resolve/issue-5035.stderr28
-rw-r--r--src/test/ui/resolve/issue-50599.rs6
-rw-r--r--src/test/ui/resolve/issue-50599.stderr28
-rw-r--r--src/test/ui/resolve/issue-5099.rs13
-rw-r--r--src/test/ui/resolve/issue-5099.stderr48
-rw-r--r--src/test/ui/resolve/issue-54379.rs14
-rw-r--r--src/test/ui/resolve/issue-54379.stderr19
-rw-r--r--src/test/ui/resolve/issue-55673.rs12
-rw-r--r--src/test/ui/resolve/issue-55673.stderr9
-rw-r--r--src/test/ui/resolve/issue-57523.rs21
-rw-r--r--src/test/ui/resolve/issue-65025-extern-static-parent-generics.rs10
-rw-r--r--src/test/ui/resolve/issue-65025-extern-static-parent-generics.stderr12
-rw-r--r--src/test/ui/resolve/issue-65035-static-with-parent-generics.rs26
-rw-r--r--src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr45
-rw-r--r--src/test/ui/resolve/issue-6702.rs9
-rw-r--r--src/test/ui/resolve/issue-6702.stderr14
-rw-r--r--src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs6
-rw-r--r--src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.stderr9
-rw-r--r--src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs20
-rw-r--r--src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr68
-rw-r--r--src/test/ui/resolve/issue-73427.rs44
-rw-r--r--src/test/ui/resolve/issue-73427.stderr156
-rw-r--r--src/test/ui/resolve/issue-80079.rs12
-rw-r--r--src/test/ui/resolve/issue-80079.stderr9
-rw-r--r--src/test/ui/resolve/issue-81508.rs22
-rw-r--r--src/test/ui/resolve/issue-81508.stderr21
-rw-r--r--src/test/ui/resolve/issue-82156.rs3
-rw-r--r--src/test/ui/resolve/issue-82156.stderr9
-rw-r--r--src/test/ui/resolve/issue-82865.rs13
-rw-r--r--src/test/ui/resolve/issue-82865.stderr23
-rw-r--r--src/test/ui/resolve/issue-85348.rs12
-rw-r--r--src/test/ui/resolve/issue-85348.stderr30
-rw-r--r--src/test/ui/resolve/issue-85671.rs37
-rw-r--r--src/test/ui/resolve/issue-88472.rs38
-rw-r--r--src/test/ui/resolve/issue-88472.stderr42
-rw-r--r--src/test/ui/resolve/issue-90113.rs21
-rw-r--r--src/test/ui/resolve/issue-90113.stderr14
-rw-r--r--src/test/ui/resolve/levenshtein.rs31
-rw-r--r--src/test/ui/resolve/levenshtein.stderr72
-rw-r--r--src/test/ui/resolve/macro-determinacy-non-module.rs7
-rw-r--r--src/test/ui/resolve/missing-in-namespace.rs4
-rw-r--r--src/test/ui/resolve/missing-in-namespace.stderr19
-rw-r--r--src/test/ui/resolve/name-clash-nullary.rs3
-rw-r--r--src/test/ui/resolve/name-clash-nullary.stderr14
-rw-r--r--src/test/ui/resolve/no-implicit-prelude-nested.rs54
-rw-r--r--src/test/ui/resolve/no-implicit-prelude-nested.stderr187
-rw-r--r--src/test/ui/resolve/no-implicit-prelude.rs18
-rw-r--r--src/test/ui/resolve/no-implicit-prelude.stderr65
-rw-r--r--src/test/ui/resolve/no-std-1.rs10
-rw-r--r--src/test/ui/resolve/no-std-2.rs10
-rw-r--r--src/test/ui/resolve/no-std-3.rs17
-rw-r--r--src/test/ui/resolve/pathless-extern-ok.rs9
-rw-r--r--src/test/ui/resolve/privacy-enum-ctor.rs71
-rw-r--r--src/test/ui/resolve/privacy-enum-ctor.stderr425
-rw-r--r--src/test/ui/resolve/privacy-struct-ctor.rs47
-rw-r--r--src/test/ui/resolve/privacy-struct-ctor.stderr139
-rw-r--r--src/test/ui/resolve/raw-ident-in-path.rs5
-rw-r--r--src/test/ui/resolve/raw-ident-in-path.stderr9
-rw-r--r--src/test/ui/resolve/resolve-assoc-suggestions.rs39
-rw-r--r--src/test/ui/resolve/resolve-assoc-suggestions.stderr58
-rw-r--r--src/test/ui/resolve/resolve-bad-import-prefix.rs14
-rw-r--r--src/test/ui/resolve/resolve-bad-import-prefix.stderr9
-rw-r--r--src/test/ui/resolve/resolve-bad-visibility.rs15
-rw-r--r--src/test/ui/resolve/resolve-bad-visibility.stderr38
-rw-r--r--src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.rs4
-rw-r--r--src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr11
-rw-r--r--src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.rs4
-rw-r--r--src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr15
-rw-r--r--src/test/ui/resolve/resolve-conflict-import-vs-import.fixed9
-rw-r--r--src/test/ui/resolve/resolve-conflict-import-vs-import.rs9
-rw-r--r--src/test/ui/resolve/resolve-conflict-import-vs-import.stderr13
-rw-r--r--src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.rs5
-rw-r--r--src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr11
-rw-r--r--src/test/ui/resolve/resolve-conflict-item-vs-import.rs8
-rw-r--r--src/test/ui/resolve/resolve-conflict-item-vs-import.stderr18
-rw-r--r--src/test/ui/resolve/resolve-conflict-type-vs-import.rs7
-rw-r--r--src/test/ui/resolve/resolve-conflict-type-vs-import.stderr18
-rw-r--r--src/test/ui/resolve/resolve-hint-macro.fixed11
-rw-r--r--src/test/ui/resolve/resolve-hint-macro.rs11
-rw-r--r--src/test/ui/resolve/resolve-hint-macro.stderr53
-rw-r--r--src/test/ui/resolve/resolve-inconsistent-binding-mode.rs41
-rw-r--r--src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr64
-rw-r--r--src/test/ui/resolve/resolve-inconsistent-names.rs35
-rw-r--r--src/test/ui/resolve/resolve-inconsistent-names.stderr99
-rw-r--r--src/test/ui/resolve/resolve-issue-2428.rs8
-rw-r--r--src/test/ui/resolve/resolve-label.rs13
-rw-r--r--src/test/ui/resolve/resolve-label.stderr14
-rw-r--r--src/test/ui/resolve/resolve-primitive-fallback.rs10
-rw-r--r--src/test/ui/resolve/resolve-primitive-fallback.stderr42
-rw-r--r--src/test/ui/resolve/resolve-pseudo-shadowing.rs11
-rw-r--r--src/test/ui/resolve/resolve-self-in-impl-2.rs7
-rw-r--r--src/test/ui/resolve/resolve-self-in-impl-2.stderr16
-rw-r--r--src/test/ui/resolve/resolve-self-in-impl.rs20
-rw-r--r--src/test/ui/resolve/resolve-self-in-impl.stderr98
-rw-r--r--src/test/ui/resolve/resolve-speculative-adjustment.rs30
-rw-r--r--src/test/ui/resolve/resolve-speculative-adjustment.stderr27
-rw-r--r--src/test/ui/resolve/resolve-type-param-in-item-in-trait.rs35
-rw-r--r--src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr45
-rw-r--r--src/test/ui/resolve/resolve-unknown-trait.rs10
-rw-r--r--src/test/ui/resolve/resolve-unknown-trait.stderr21
-rw-r--r--src/test/ui/resolve/resolve-variant-assoc-item.rs7
-rw-r--r--src/test/ui/resolve/resolve-variant-assoc-item.stderr15
-rw-r--r--src/test/ui/resolve/shadow-const-param.rs20
-rw-r--r--src/test/ui/resolve/shadow-const-param.stderr20
-rw-r--r--src/test/ui/resolve/suggest-path-for-tuple-struct.rs26
-rw-r--r--src/test/ui/resolve/suggest-path-for-tuple-struct.stderr19
-rw-r--r--src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs59
-rw-r--r--src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr104
-rw-r--r--src/test/ui/resolve/token-error-correct-2.rs7
-rw-r--r--src/test/ui/resolve/token-error-correct-2.stderr18
-rw-r--r--src/test/ui/resolve/token-error-correct-3.rs25
-rw-r--r--src/test/ui/resolve/token-error-correct-3.stderr25
-rw-r--r--src/test/ui/resolve/token-error-correct-4.fixed10
-rw-r--r--src/test/ui/resolve/token-error-correct-4.rs10
-rw-r--r--src/test/ui/resolve/token-error-correct-4.stderr16
-rw-r--r--src/test/ui/resolve/token-error-correct.rs9
-rw-r--r--src/test/ui/resolve/token-error-correct.stderr20
-rw-r--r--src/test/ui/resolve/tuple-struct-alias.rs9
-rw-r--r--src/test/ui/resolve/tuple-struct-alias.stderr26
-rw-r--r--src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs46
-rw-r--r--src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr109
-rw-r--r--src/test/ui/resolve/typo-suggestion-named-underscore.rs14
-rw-r--r--src/test/ui/resolve/typo-suggestion-named-underscore.stderr16
-rw-r--r--src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs9
-rw-r--r--src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr21
-rw-r--r--src/test/ui/resolve/unresolved_static_type_field.rs14
-rw-r--r--src/test/ui/resolve/unresolved_static_type_field.stderr9
-rw-r--r--src/test/ui/resolve/use-self-in-inner-fn.rs14
-rw-r--r--src/test/ui/resolve/use-self-in-inner-fn.stderr15
-rw-r--r--src/test/ui/resolve/use_suggestion.rs7
-rw-r--r--src/test/ui/resolve/use_suggestion.stderr38
-rw-r--r--src/test/ui/resolve/use_suggestion_placement.fixed35
-rw-r--r--src/test/ui/resolve/use_suggestion_placement.rs29
-rw-r--r--src/test/ui/resolve/use_suggestion_placement.stderr37
-rw-r--r--src/test/ui/resolve/visibility-indeterminate.rs7
-rw-r--r--src/test/ui/resolve/visibility-indeterminate.stderr15
244 files changed, 6209 insertions, 0 deletions
diff --git a/src/test/ui/resolve/associated-fn-called-as-fn.rs b/src/test/ui/resolve/associated-fn-called-as-fn.rs
new file mode 100644
index 000000000..f31f3d67b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/associated-fn-called-as-fn.stderr b/src/test/ui/resolve/associated-fn-called-as-fn.stderr
new file mode 100644
index 000000000..fbdea30d5
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs b/src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs
new file mode 100644
index 000000000..cf769f31b
--- /dev/null
+++ b/src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo.rs
@@ -0,0 +1,3 @@
+#![crate_type="lib"]
+
+pub const X: () = ();
diff --git a/src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs b/src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs
new file mode 100644
index 000000000..81c16ede9
--- /dev/null
+++ b/src/test/ui/resolve/auxiliary/blind-item-mixed-crate-use-item-foo2.rs
@@ -0,0 +1,3 @@
+#![crate_type="lib"]
+
+pub const Y: () = ();
diff --git a/src/test/ui/resolve/auxiliary/extern-prelude-vec.rs b/src/test/ui/resolve/auxiliary/extern-prelude-vec.rs
new file mode 100644
index 000000000..a643c8889
--- /dev/null
+++ b/src/test/ui/resolve/auxiliary/extern-prelude-vec.rs
@@ -0,0 +1,3 @@
+#![crate_name = "Vec"]
+
+pub fn new(arg1: f32, arg2: ()) {}
diff --git a/src/test/ui/resolve/auxiliary/extern-prelude.rs b/src/test/ui/resolve/auxiliary/extern-prelude.rs
new file mode 100644
index 000000000..2fdfd85a1
--- /dev/null
+++ b/src/test/ui/resolve/auxiliary/extern-prelude.rs
@@ -0,0 +1,5 @@
+pub struct S;
+
+impl S {
+ pub fn external(&self) {}
+}
diff --git a/src/test/ui/resolve/auxiliary/issue-19452-aux.rs b/src/test/ui/resolve/auxiliary/issue-19452-aux.rs
new file mode 100644
index 000000000..9c7bcec51
--- /dev/null
+++ b/src/test/ui/resolve/auxiliary/issue-19452-aux.rs
@@ -0,0 +1,3 @@
+pub enum Homura {
+ Madoka { age: u32 }
+}
diff --git a/src/test/ui/resolve/auxiliary/issue-21221-3.rs b/src/test/ui/resolve/auxiliary/issue-21221-3.rs
new file mode 100644
index 000000000..176c23180
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/auxiliary/issue-21221-4.rs b/src/test/ui/resolve/auxiliary/issue-21221-4.rs
new file mode 100644
index 000000000..5e0d6cbdf
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/auxiliary/issue-3907.rs b/src/test/ui/resolve/auxiliary/issue-3907.rs
new file mode 100644
index 000000000..5dc502930
--- /dev/null
+++ b/src/test/ui/resolve/auxiliary/issue-3907.rs
@@ -0,0 +1,3 @@
+pub trait Foo {
+ fn bar();
+}
diff --git a/src/test/ui/resolve/auxiliary/issue-80079.rs b/src/test/ui/resolve/auxiliary/issue-80079.rs
new file mode 100644
index 000000000..190ca75ab
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/auxiliary/namespaced_enums.rs b/src/test/ui/resolve/auxiliary/namespaced_enums.rs
new file mode 100644
index 000000000..d3548c76c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs b/src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs
new file mode 100644
index 000000000..6d0bc7285
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-env-capture.rs b/src/test/ui/resolve/bad-env-capture.rs
new file mode 100644
index 000000000..83fd2544f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-env-capture.stderr b/src/test/ui/resolve/bad-env-capture.stderr
new file mode 100644
index 000000000..f78a38a3d
--- /dev/null
+++ b/src/test/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 function `log` in this scope
+ --> $DIR/bad-env-capture.rs:4:16
+ |
+LL | fn bar() { log(debug, x); }
+ | ^^^ not found in this scope
+
+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: 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/src/test/ui/resolve/bad-env-capture2.rs b/src/test/ui/resolve/bad-env-capture2.rs
new file mode 100644
index 000000000..b04569c9d
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-env-capture2.stderr b/src/test/ui/resolve/bad-env-capture2.stderr
new file mode 100644
index 000000000..57c807fd7
--- /dev/null
+++ b/src/test/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 function `log` in this scope
+ --> $DIR/bad-env-capture2.rs:3:16
+ |
+LL | fn bar() { log(debug, x); }
+ | ^^^ not found in this scope
+
+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: 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/src/test/ui/resolve/bad-env-capture3.rs b/src/test/ui/resolve/bad-env-capture3.rs
new file mode 100644
index 000000000..62f12fd1a
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-env-capture3.stderr b/src/test/ui/resolve/bad-env-capture3.stderr
new file mode 100644
index 000000000..d6eb4f86e
--- /dev/null
+++ b/src/test/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 function `log` in this scope
+ --> $DIR/bad-env-capture3.rs:4:20
+ |
+LL | fn bar() { log(debug, x); }
+ | ^^^ not found in this scope
+
+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: 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/src/test/ui/resolve/bad-expr-path.rs b/src/test/ui/resolve/bad-expr-path.rs
new file mode 100644
index 000000000..31fc9cf2c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-expr-path.stderr b/src/test/ui/resolve/bad-expr-path.stderr
new file mode 100644
index 000000000..77c48c951
--- /dev/null
+++ b/src/test/ui/resolve/bad-expr-path.stderr
@@ -0,0 +1,31 @@
+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[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[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/src/test/ui/resolve/bad-expr-path2.rs b/src/test/ui/resolve/bad-expr-path2.rs
new file mode 100644
index 000000000..eb88edb90
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-expr-path2.stderr b/src/test/ui/resolve/bad-expr-path2.stderr
new file mode 100644
index 000000000..d06e10271
--- /dev/null
+++ b/src/test/ui/resolve/bad-expr-path2.stderr
@@ -0,0 +1,31 @@
+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[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[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/src/test/ui/resolve/bad-module.rs b/src/test/ui/resolve/bad-module.rs
new file mode 100644
index 000000000..b23e97c2c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-module.stderr b/src/test/ui/resolve/bad-module.stderr
new file mode 100644
index 000000000..581a66198
--- /dev/null
+++ b/src/test/ui/resolve/bad-module.stderr
@@ -0,0 +1,15 @@
+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[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: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/src/test/ui/resolve/bad-type-env-capture.rs b/src/test/ui/resolve/bad-type-env-capture.rs
new file mode 100644
index 000000000..53dfb1313
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/bad-type-env-capture.stderr b/src/test/ui/resolve/bad-type-env-capture.stderr
new file mode 100644
index 000000000..6f24c0d86
--- /dev/null
+++ b/src/test/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: `bar<T>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/src/test/ui/resolve/blind-item-mixed-crate-use-item.rs b/src/test/ui/resolve/blind-item-mixed-crate-use-item.rs
new file mode 100644
index 000000000..36d8ab151
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/blind-item-mixed-use-item.rs b/src/test/ui/resolve/blind-item-mixed-use-item.rs
new file mode 100644
index 000000000..4a3905496
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/block-with-trait-parent.rs b/src/test/ui/resolve/block-with-trait-parent.rs
new file mode 100644
index 000000000..bc86f94e9
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/crate-called-as-function.rs b/src/test/ui/resolve/crate-called-as-function.rs
new file mode 100644
index 000000000..e8f52c0c0
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/crate-called-as-function.stderr b/src/test/ui/resolve/crate-called-as-function.stderr
new file mode 100644
index 000000000..eb42349af
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/crate-in-paths.rs b/src/test/ui/resolve/crate-in-paths.rs
new file mode 100644
index 000000000..7ebd25918
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/crate-in-paths.stderr b/src/test/ui/resolve/crate-in-paths.stderr
new file mode 100644
index 000000000..b7cf49507
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/editions-crate-root-2015.rs b/src/test/ui/resolve/editions-crate-root-2015.rs
new file mode 100644
index 000000000..4c890e3ae
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/editions-crate-root-2015.stderr b/src/test/ui/resolve/editions-crate-root-2015.stderr
new file mode 100644
index 000000000..00cdd0c58
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/editions-crate-root-2018.rs b/src/test/ui/resolve/editions-crate-root-2018.rs
new file mode 100644
index 000000000..61e4329bb
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/editions-crate-root-2018.stderr b/src/test/ui/resolve/editions-crate-root-2018.stderr
new file mode 100644
index 000000000..967a5a2fc
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/enums-are-namespaced-xc.rs b/src/test/ui/resolve/enums-are-namespaced-xc.rs
new file mode 100644
index 000000000..dfc16d6ce
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/enums-are-namespaced-xc.stderr b/src/test/ui/resolve/enums-are-namespaced-xc.stderr
new file mode 100644
index 000000000..6448e596d
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/enums-pats-not-idents.rs b/src/test/ui/resolve/enums-pats-not-idents.rs
new file mode 100644
index 000000000..5b918eef6
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/enums-pats-not-idents.stderr b/src/test/ui/resolve/enums-pats-not-idents.stderr
new file mode 100644
index 000000000..072b88716
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/export-fully-qualified.rs b/src/test/ui/resolve/export-fully-qualified.rs
new file mode 100644
index 000000000..4e73a2c54
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/export-fully-qualified.stderr b/src/test/ui/resolve/export-fully-qualified.stderr
new file mode 100644
index 000000000..7ee352e12
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/extern-prelude-fail.rs b/src/test/ui/resolve/extern-prelude-fail.rs
new file mode 100644
index 000000000..7d387025a
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/extern-prelude-fail.stderr b/src/test/ui/resolve/extern-prelude-fail.stderr
new file mode 100644
index 000000000..a1591914b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/extern-prelude.rs b/src/test/ui/resolve/extern-prelude.rs
new file mode 100644
index 000000000..50fed6034
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/filter-intrinsics.rs b/src/test/ui/resolve/filter-intrinsics.rs
new file mode 100644
index 000000000..c0956ef85
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/filter-intrinsics.stderr b/src/test/ui/resolve/filter-intrinsics.stderr
new file mode 100644
index 000000000..955070891
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/impl-items-vis-unresolved.rs b/src/test/ui/resolve/impl-items-vis-unresolved.rs
new file mode 100644
index 000000000..1494c1cf9
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/impl-items-vis-unresolved.stderr b/src/test/ui/resolve/impl-items-vis-unresolved.stderr
new file mode 100644
index 000000000..f2293d28e
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-10200.rs b/src/test/ui/resolve/issue-10200.rs
new file mode 100644
index 000000000..fe36a7e00
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-10200.stderr b/src/test/ui/resolve/issue-10200.stderr
new file mode 100644
index 000000000..e60489f5b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-12796.rs b/src/test/ui/resolve/issue-12796.rs
new file mode 100644
index 000000000..942d6b9a5
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-12796.stderr b/src/test/ui/resolve/issue-12796.stderr
new file mode 100644
index 000000000..a01fd2d65
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-14254.rs b/src/test/ui/resolve/issue-14254.rs
new file mode 100644
index 000000000..78add29ca
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-14254.stderr b/src/test/ui/resolve/issue-14254.stderr
new file mode 100644
index 000000000..b1f45adb8
--- /dev/null
+++ b/src/test/ui/resolve/issue-14254.stderr
@@ -0,0 +1,147 @@
+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 value `a` in this scope
+ --> $DIR/issue-14254.rs:21:9
+ |
+LL | a;
+ | ^ not found in this scope
+
+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 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 call the associated function: `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 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 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 call the associated function: `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 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 value `bah` in this scope
+ --> $DIR/issue-14254.rs:64:9
+ |
+LL | bah;
+ | ^^^ help: you might have meant to call the associated function: `Self::bah`
+
+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 value `bah` in this scope
+ --> $DIR/issue-14254.rs:73:9
+ |
+LL | bah;
+ | ^^^ help: you might have meant to call the associated function: `Self::bah`
+
+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 value `bah` in this scope
+ --> $DIR/issue-14254.rs:82:9
+ |
+LL | bah;
+ | ^^^ help: you might have meant to call the associated function: `Self::bah`
+
+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 value `bah` in this scope
+ --> $DIR/issue-14254.rs:91:9
+ |
+LL | bah;
+ | ^^^ help: you might have meant to call the associated function: `Self::bah`
+
+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[E0425]: cannot find value `bah` in this scope
+ --> $DIR/issue-14254.rs:100:9
+ |
+LL | bah;
+ | ^^^ help: you might have meant to call the associated function: `Self::bah`
+
+error: aborting due to 24 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/resolve/issue-16058.rs b/src/test/ui/resolve/issue-16058.rs
new file mode 100644
index 000000000..048aaf65f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-16058.stderr b/src/test/ui/resolve/issue-16058.stderr
new file mode 100644
index 000000000..c47d22cef
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-17518.rs b/src/test/ui/resolve/issue-17518.rs
new file mode 100644
index 000000000..edaebc812
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-17518.stderr b/src/test/ui/resolve/issue-17518.stderr
new file mode 100644
index 000000000..034d0d01b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-18252.rs b/src/test/ui/resolve/issue-18252.rs
new file mode 100644
index 000000000..af0a3cbcb
--- /dev/null
+++ b/src/test/ui/resolve/issue-18252.rs
@@ -0,0 +1,8 @@
+enum Foo {
+ Variant { x: usize }
+}
+
+fn main() {
+ let f = Foo::Variant(42);
+ //~^ ERROR expected function, tuple struct or tuple variant, found struct variant `Foo::Variant`
+}
diff --git a/src/test/ui/resolve/issue-18252.stderr b/src/test/ui/resolve/issue-18252.stderr
new file mode 100644
index 000000000..13e7a5973
--- /dev/null
+++ b/src/test/ui/resolve/issue-18252.stderr
@@ -0,0 +1,12 @@
+error[E0423]: expected function, tuple struct or tuple variant, found struct variant `Foo::Variant`
+ --> $DIR/issue-18252.rs:6:13
+ |
+LL | Variant { x: usize }
+ | -------------------- `Foo::Variant` defined here
+...
+LL | let f = Foo::Variant(42);
+ | ^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `Foo::Variant { x: val }`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/src/test/ui/resolve/issue-19452.rs b/src/test/ui/resolve/issue-19452.rs
new file mode 100644
index 000000000..1d3aa49ea
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-19452.stderr b/src/test/ui/resolve/issue-19452.stderr
new file mode 100644
index 000000000..8df84067e
--- /dev/null
+++ b/src/test/ui/resolve/issue-19452.stderr
@@ -0,0 +1,23 @@
+error[E0423]: expected value, found struct variant `Homura::Madoka`
+ --> $DIR/issue-19452.rs:10:18
+ |
+LL | Madoka { age: u32 }
+ | ------------------- `Homura::Madoka` defined here
+...
+LL | let homura = Homura::Madoka;
+ | ^^^^^^^^^^^^^^ help: use struct literal syntax instead: `Homura::Madoka { age: val }`
+
+error[E0423]: expected value, found struct variant `issue_19452_aux::Homura::Madoka`
+ --> $DIR/issue-19452.rs:13:18
+ |
+LL | let homura = issue_19452_aux::Homura::Madoka;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `issue_19452_aux::Homura::Madoka { /* fields */ }`
+ |
+ ::: $DIR/auxiliary/issue-19452-aux.rs:2:5
+ |
+LL | Madoka { age: u32 }
+ | ------ `issue_19452_aux::Homura::Madoka` defined here
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/src/test/ui/resolve/issue-21221-1.rs b/src/test/ui/resolve/issue-21221-1.rs
new file mode 100644
index 000000000..b180624d2
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-21221-1.stderr b/src/test/ui/resolve/issue-21221-1.stderr
new file mode 100644
index 000000000..538eeead9
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-21221-2.rs b/src/test/ui/resolve/issue-21221-2.rs
new file mode 100644
index 000000000..dc13e46cb
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-21221-2.stderr b/src/test/ui/resolve/issue-21221-2.stderr
new file mode 100644
index 000000000..d4fd7cb12
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-21221-3.rs b/src/test/ui/resolve/issue-21221-3.rs
new file mode 100644
index 000000000..f0c0a9fd6
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-21221-3.stderr b/src/test/ui/resolve/issue-21221-3.stderr
new file mode 100644
index 000000000..f12e5b09b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-21221-4.rs b/src/test/ui/resolve/issue-21221-4.rs
new file mode 100644
index 000000000..88d5bd06c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-21221-4.stderr b/src/test/ui/resolve/issue-21221-4.stderr
new file mode 100644
index 000000000..fc15444d0
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-22692.rs b/src/test/ui/resolve/issue-22692.rs
new file mode 100644
index 000000000..1d8f44222
--- /dev/null
+++ b/src/test/ui/resolve/issue-22692.rs
@@ -0,0 +1,3 @@
+fn main() {
+ let _ = String.new(); //~ ERROR expected value, found struct `String`
+}
diff --git a/src/test/ui/resolve/issue-22692.stderr b/src/test/ui/resolve/issue-22692.stderr
new file mode 100644
index 000000000..e076419f6
--- /dev/null
+++ b/src/test/ui/resolve/issue-22692.stderr
@@ -0,0 +1,11 @@
+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: `String::new`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/src/test/ui/resolve/issue-2330.rs b/src/test/ui/resolve/issue-2330.rs
new file mode 100644
index 000000000..4560caba0
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-2330.stderr b/src/test/ui/resolve/issue-2330.stderr
new file mode 100644
index 000000000..877cf68b5
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-23305.rs b/src/test/ui/resolve/issue-23305.rs
new file mode 100644
index 000000000..95635e12a
--- /dev/null
+++ b/src/test/ui/resolve/issue-23305.rs
@@ -0,0 +1,8 @@
+pub trait ToNbt<T> {
+ fn new(val: T) -> Self;
+}
+
+impl dyn ToNbt<Self> {}
+//~^ ERROR cycle detected
+
+fn main() {}
diff --git a/src/test/ui/resolve/issue-23305.stderr b/src/test/ui/resolve/issue-23305.stderr
new file mode 100644
index 000000000..20aeb7b99
--- /dev/null
+++ b/src/test/ui/resolve/issue-23305.stderr
@@ -0,0 +1,22 @@
+error[E0391]: cycle detected when computing type of `<impl at $DIR/issue-23305.rs:5:1: 5:21>`
+ --> $DIR/issue-23305.rs:5:16
+ |
+LL | impl dyn ToNbt<Self> {}
+ | ^^^^
+ |
+ = note: ...which immediately requires computing type of `<impl at $DIR/issue-23305.rs:5:1: 5:21>` again
+note: cycle used when collecting item types in top-level module
+ --> $DIR/issue-23305.rs:1:1
+ |
+LL | / pub trait ToNbt<T> {
+LL | | fn new(val: T) -> Self;
+LL | | }
+LL | |
+... |
+LL | |
+LL | | fn main() {}
+ | |____________^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/resolve/issue-2356.rs b/src/test/ui/resolve/issue-2356.rs
new file mode 100644
index 000000000..fe9bf4d44
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-2356.stderr b/src/test/ui/resolve/issue-2356.stderr
new file mode 100644
index 000000000..b8d528efc
--- /dev/null
+++ b/src/test/ui/resolve/issue-2356.stderr
@@ -0,0 +1,134 @@
+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 `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[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[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 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 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[E0425]: cannot find function `purr_louder` in this scope
+ --> $DIR/issue-2356.rs:86:5
+ |
+LL | purr_louder();
+ | ^^^^^^^^^^^ not found in this scope
+
+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: 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/src/test/ui/resolve/issue-23716.rs b/src/test/ui/resolve/issue-23716.rs
new file mode 100644
index 000000000..e9139c0aa
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-23716.stderr b/src/test/ui/resolve/issue-23716.stderr
new file mode 100644
index 000000000..8b89c350c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-24968.rs b/src/test/ui/resolve/issue-24968.rs
new file mode 100644
index 000000000..19e16abce
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-24968.stderr b/src/test/ui/resolve/issue-24968.stderr
new file mode 100644
index 000000000..7e539d258
--- /dev/null
+++ b/src/test/ui/resolve/issue-24968.stderr
@@ -0,0 +1,57 @@
+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[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: 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/src/test/ui/resolve/issue-26545.rs b/src/test/ui/resolve/issue-26545.rs
new file mode 100644
index 000000000..5652ee747
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-26545.stderr b/src/test/ui/resolve/issue-26545.stderr
new file mode 100644
index 000000000..d3c866925
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-3021-c.rs b/src/test/ui/resolve/issue-3021-c.rs
new file mode 100644
index 000000000..94ed1fdf7
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-3021-c.stderr b/src/test/ui/resolve/issue-3021-c.stderr
new file mode 100644
index 000000000..8764ac8a8
--- /dev/null
+++ b/src/test/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 | fn g(&self, x: T) -> T;
+ | - ^ use of generic parameter from outer function
+ | |
+ | help: try using a local generic parameter instead: `g<T>`
+
+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 | fn g(&self, x: T) -> T;
+ | - ^ use of generic parameter from outer function
+ | |
+ | help: try using a local generic parameter instead: `g<T>`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/src/test/ui/resolve/issue-3021.rs b/src/test/ui/resolve/issue-3021.rs
new file mode 100644
index 000000000..a672261f8
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-3021.stderr b/src/test/ui/resolve/issue-3021.stderr
new file mode 100644
index 000000000..d5b015eec
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-31845.rs b/src/test/ui/resolve/issue-31845.rs
new file mode 100644
index 000000000..f6dc11502
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-31845.stderr b/src/test/ui/resolve/issue-31845.stderr
new file mode 100644
index 000000000..562819385
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-33876.rs b/src/test/ui/resolve/issue-33876.rs
new file mode 100644
index 000000000..e233ec631
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-33876.stderr b/src/test/ui/resolve/issue-33876.stderr
new file mode 100644
index 000000000..52308f2a7
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-3907-2.rs b/src/test/ui/resolve/issue-3907-2.rs
new file mode 100644
index 000000000..46f145e63
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-3907-2.stderr b/src/test/ui/resolve/issue-3907-2.stderr
new file mode 100644
index 000000000..782cfeec4
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-3907.rs b/src/test/ui/resolve/issue-3907.rs
new file mode 100644
index 000000000..6211de427
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-3907.stderr b/src/test/ui/resolve/issue-3907.stderr
new file mode 100644
index 000000000..6fc61cae8
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-39226.rs b/src/test/ui/resolve/issue-39226.rs
new file mode 100644
index 000000000..0f784f02b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-39226.stderr b/src/test/ui/resolve/issue-39226.stderr
new file mode 100644
index 000000000..5045ec6c3
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-42944.rs b/src/test/ui/resolve/issue-42944.rs
new file mode 100644
index 000000000..a4404857a
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-42944.stderr b/src/test/ui/resolve/issue-42944.stderr
new file mode 100644
index 000000000..cad3ccc4a
--- /dev/null
+++ b/src/test/ui/resolve/issue-42944.stderr
@@ -0,0 +1,28 @@
+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[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: 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/src/test/ui/resolve/issue-49074.rs b/src/test/ui/resolve/issue-49074.rs
new file mode 100644
index 000000000..752bb345b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-49074.stderr b/src/test/ui/resolve/issue-49074.stderr
new file mode 100644
index 000000000..bbfeb4ea9
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-5035-2.rs b/src/test/ui/resolve/issue-5035-2.rs
new file mode 100644
index 000000000..b831bb4be
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr
new file mode 100644
index 000000000..939392733
--- /dev/null
+++ b/src/test/ui/resolve/issue-5035-2.stderr
@@ -0,0 +1,16 @@
+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: 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/src/test/ui/resolve/issue-5035.rs b/src/test/ui/resolve/issue-5035.rs
new file mode 100644
index 000000000..49fa312f9
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-5035.stderr b/src/test/ui/resolve/issue-5035.stderr
new file mode 100644
index 000000000..32b972b21
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-50599.rs b/src/test/ui/resolve/issue-50599.rs
new file mode 100644
index 000000000..78a20cf8e
--- /dev/null
+++ b/src/test/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];
+ //~^ ERROR evaluation of constant value failed
+}
diff --git a/src/test/ui/resolve/issue-50599.stderr b/src/test/ui/resolve/issue-50599.stderr
new file mode 100644
index 000000000..910deddd8
--- /dev/null
+++ b/src/test/ui/resolve/issue-50599.stderr
@@ -0,0 +1,28 @@
+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;
+ |
+
+error[E0080]: evaluation of constant value failed
+ --> $DIR/issue-50599.rs:4:29
+ |
+LL | let mut digits = [0u32; M];
+ | ^ referenced constant has errors
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0080, E0425.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/src/test/ui/resolve/issue-5099.rs b/src/test/ui/resolve/issue-5099.rs
new file mode 100644
index 000000000..b5abccb4b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-5099.stderr b/src/test/ui/resolve/issue-5099.stderr
new file mode 100644
index 000000000..e9b2a9c4d
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-54379.rs b/src/test/ui/resolve/issue-54379.rs
new file mode 100644
index 000000000..807c54393
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-54379.stderr b/src/test/ui/resolve/issue-54379.stderr
new file mode 100644
index 000000000..750727273
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-55673.rs b/src/test/ui/resolve/issue-55673.rs
new file mode 100644
index 000000000..0436bd397
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-55673.stderr b/src/test/ui/resolve/issue-55673.stderr
new file mode 100644
index 000000000..39318f959
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-57523.rs b/src/test/ui/resolve/issue-57523.rs
new file mode 100644
index 000000000..976238cc3
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-65025-extern-static-parent-generics.rs b/src/test/ui/resolve/issue-65025-extern-static-parent-generics.rs
new file mode 100644
index 000000000..ce45f630e
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-65025-extern-static-parent-generics.stderr b/src/test/ui/resolve/issue-65025-extern-static-parent-generics.stderr
new file mode 100644
index 000000000..6bbf76dd1
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-65035-static-with-parent-generics.rs b/src/test/ui/resolve/issue-65035-static-with-parent-generics.rs
new file mode 100644
index 000000000..f96c04841
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr b/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr
new file mode 100644
index 000000000..7ed572f80
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-6702.rs b/src/test/ui/resolve/issue-6702.rs
new file mode 100644
index 000000000..954dc36f3
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-6702.stderr b/src/test/ui/resolve/issue-6702.stderr
new file mode 100644
index 000000000..a118f9419
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs b/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs
new file mode 100644
index 000000000..c377ecea9
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.stderr b/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.stderr
new file mode 100644
index 000000000..109409d27
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs
new file mode 100644
index 000000000..aaf0f7eae
--- /dev/null
+++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs
@@ -0,0 +1,20 @@
+// 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`
+ //~| ERROR has an incompatible type for trait
+}
+
+fn main() {}
diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr
new file mode 100644
index 000000000..d3214458e
--- /dev/null
+++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr
@@ -0,0 +1,68 @@
+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[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
+
+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: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
+
+error[E0053]: method `associated` has an incompatible type for trait
+ --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:26
+ |
+LL | async fn associated();
+ | ^
+ | |
+ | checked the `Output` of this `async fn`, found opaque type
+ | expected `()`, found opaque type
+ |
+ = note: while checking the return type of the `async fn`
+note: type in trait
+ --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:26
+ |
+LL | async fn associated();
+ | ^
+ = note: expected fn pointer `fn()`
+ found fn pointer `fn() -> impl Future<Output = ()>`
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0053, E0706.
+For more information about an error, try `rustc --explain E0053`.
diff --git a/src/test/ui/resolve/issue-73427.rs b/src/test/ui/resolve/issue-73427.rs
new file mode 100644
index 000000000..3c62782a8
--- /dev/null
+++ b/src/test/ui/resolve/issue-73427.rs
@@ -0,0 +1,44 @@
+enum A {
+ StructWithFields { x: () },
+ TupleWithFields(()),
+ Struct {},
+ Tuple(),
+ Unit,
+}
+
+enum B {
+ StructWithFields { x: () },
+ TupleWithFields(()),
+}
+
+enum C {
+ StructWithFields { x: () },
+ TupleWithFields(()),
+ Unit,
+}
+
+enum D {
+ TupleWithFields(()),
+ Unit,
+}
+
+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`
+
+ // 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/src/test/ui/resolve/issue-73427.stderr b/src/test/ui/resolve/issue-73427.stderr
new file mode 100644
index 000000000..59bb98a34
--- /dev/null
+++ b/src/test/ui/resolve/issue-73427.stderr
@@ -0,0 +1,156 @@
+error[E0423]: expected value, found enum `A`
+ --> $DIR/issue-73427.rs:29: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::Struct {}).foo();
+ | ~~~~~~~~~~~~~~
+LL | (A::Tuple()).foo();
+ | ~~~~~~~~~~~~
+LL | A::Unit.foo();
+ | ~~~~~~~
+help: the following enum variants are available
+ |
+LL | (A::StructWithFields { /* fields */ }).foo();
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LL | (A::TupleWithFields(/* fields */)).foo();
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `B`
+ --> $DIR/issue-73427.rs:31:5
+ |
+LL | B.foo();
+ | ^
+ |
+note: the enum is defined here
+ --> $DIR/issue-73427.rs:9:1
+ |
+LL | / enum B {
+LL | | StructWithFields { x: () },
+LL | | TupleWithFields(()),
+LL | | }
+ | |_^
+help: the following enum variants are available
+ |
+LL | (B::StructWithFields { /* fields */ }).foo();
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LL | (B::TupleWithFields(/* fields */)).foo();
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `C`
+ --> $DIR/issue-73427.rs:33: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: the following enum variants are available
+ |
+LL | (C::StructWithFields { /* fields */ }).foo();
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LL | (C::TupleWithFields(/* fields */)).foo();
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found enum `D`
+ --> $DIR/issue-73427.rs:35: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: the following enum variant is available
+ |
+LL | (D::TupleWithFields(/* fields */)).foo();
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected function, tuple struct or tuple variant, found enum `A`
+ --> $DIR/issue-73427.rs:40:13
+ |
+LL | let x = A(3);
+ | ^
+ |
+ = help: you might have meant to construct one of the enum's non-tuple variants
+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[E0532]: expected tuple struct or tuple variant, found enum `A`
+ --> $DIR/issue-73427.rs:42:12
+ |
+LL | if let A(3) = x { }
+ | ^
+ |
+ = help: you might have meant to match against one of the enum's non-tuple variants
+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: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0423, E0532.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/src/test/ui/resolve/issue-80079.rs b/src/test/ui/resolve/issue-80079.rs
new file mode 100644
index 000000000..4795ed062
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-80079.stderr b/src/test/ui/resolve/issue-80079.stderr
new file mode 100644
index 000000000..93e8c0341
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-81508.rs b/src/test/ui/resolve/issue-81508.rs
new file mode 100644
index 000000000..23605cd2f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-81508.stderr b/src/test/ui/resolve/issue-81508.stderr
new file mode 100644
index 000000000..7258174ba
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-82156.rs b/src/test/ui/resolve/issue-82156.rs
new file mode 100644
index 000000000..6215259e4
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-82156.stderr b/src/test/ui/resolve/issue-82156.stderr
new file mode 100644
index 000000000..d53599dcc
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-82865.rs b/src/test/ui/resolve/issue-82865.rs
new file mode 100644
index 000000000..07d88c413
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-82865.stderr b/src/test/ui/resolve/issue-82865.stderr
new file mode 100644
index 000000000..730fd6d60
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-85348.rs b/src/test/ui/resolve/issue-85348.rs
new file mode 100644
index 000000000..3a33c1934
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-85348.stderr b/src/test/ui/resolve/issue-85348.stderr
new file mode 100644
index 000000000..f839dd927
--- /dev/null
+++ b/src/test/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: _;
+ | +++
+
+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/src/test/ui/resolve/issue-85671.rs b/src/test/ui/resolve/issue-85671.rs
new file mode 100644
index 000000000..337ec307e
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-88472.rs b/src/test/ui/resolve/issue-88472.rs
new file mode 100644
index 000000000..6bf7caedd
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-88472.stderr b/src/test/ui/resolve/issue-88472.stderr
new file mode 100644
index 000000000..8431fc977
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-90113.rs b/src/test/ui/resolve/issue-90113.rs
new file mode 100644
index 000000000..f6658b45e
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/issue-90113.stderr b/src/test/ui/resolve/issue-90113.stderr
new file mode 100644
index 000000000..1b7872057
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/levenshtein.rs b/src/test/ui/resolve/levenshtein.rs
new file mode 100644
index 000000000..a6f471625
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/levenshtein.stderr b/src/test/ui/resolve/levenshtein.stderr
new file mode 100644
index 000000000..249a7e53d
--- /dev/null
+++ b/src/test/ui/resolve/levenshtein.stderr
@@ -0,0 +1,72 @@
+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
+ |
+LL | pub enum Option<T> {
+ | ------------------ 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[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[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: 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/src/test/ui/resolve/macro-determinacy-non-module.rs b/src/test/ui/resolve/macro-determinacy-non-module.rs
new file mode 100644
index 000000000..3215e0cd3
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/missing-in-namespace.rs b/src/test/ui/resolve/missing-in-namespace.rs
new file mode 100644
index 000000000..e1dedb072
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/missing-in-namespace.stderr b/src/test/ui/resolve/missing-in-namespace.stderr
new file mode 100644
index 000000000..3d49b2e5d
--- /dev/null
+++ b/src/test/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:29
+ |
+LL | let _map = std::hahmap::HashMap::new();
+ | ^^^^^^^ not found in `std::hahmap`
+ |
+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/src/test/ui/resolve/name-clash-nullary.rs b/src/test/ui/resolve/name-clash-nullary.rs
new file mode 100644
index 000000000..b5f5e1214
--- /dev/null
+++ b/src/test/ui/resolve/name-clash-nullary.rs
@@ -0,0 +1,3 @@
+fn main() {
+ let None: isize = 42; //~ ERROR mismatched types
+}
diff --git a/src/test/ui/resolve/name-clash-nullary.stderr b/src/test/ui/resolve/name-clash-nullary.stderr
new file mode 100644
index 000000000..76c4b5914
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/no-implicit-prelude-nested.rs b/src/test/ui/resolve/no-implicit-prelude-nested.rs
new file mode 100644
index 000000000..c314967da
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/no-implicit-prelude-nested.stderr b/src/test/ui/resolve/no-implicit-prelude-nested.stderr
new file mode 100644
index 000000000..198b630c5
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/no-implicit-prelude.rs b/src/test/ui/resolve/no-implicit-prelude.rs
new file mode 100644
index 000000000..4b0ca4d52
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/no-implicit-prelude.stderr b/src/test/ui/resolve/no-implicit-prelude.stderr
new file mode 100644
index 000000000..36a9b65b7
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/no-std-1.rs b/src/test/ui/resolve/no-std-1.rs
new file mode 100644
index 000000000..5b59e9b4e
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/no-std-2.rs b/src/test/ui/resolve/no-std-2.rs
new file mode 100644
index 000000000..487d41649
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/no-std-3.rs b/src/test/ui/resolve/no-std-3.rs
new file mode 100644
index 000000000..f6c4ed579
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/pathless-extern-ok.rs b/src/test/ui/resolve/pathless-extern-ok.rs
new file mode 100644
index 000000000..0ffa5eb89
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/privacy-enum-ctor.rs b/src/test/ui/resolve/privacy-enum-ctor.rs
new file mode 100644
index 000000000..f0d2cf8c0
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr
new file mode 100644
index 000000000..f885ac215
--- /dev/null
+++ b/src/test/ui/resolve/privacy-enum-ctor.stderr
@@ -0,0 +1,425 @@
+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: the following enum variants are available
+ |
+LL | (m::Z::Fn(/* fields */));
+ | ~~~~~~~~~~~~~~~~~~~~~~~~
+LL | (m::Z::Struct { /* 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: the following enum variants are available
+ |
+LL | (m::Z::Fn(/* fields */));
+ | ~~~~~~~~~~~~~~~~~~~~~~~~
+LL | (m::Z::Struct { /* fields */ });
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0423]: expected value, found struct variant `Z::Struct`
+ --> $DIR/privacy-enum-ctor.rs:29:20
+ |
+LL | / Struct {
+LL | | s: u8,
+LL | | },
+ | |_____________- `Z::Struct` defined here
+...
+LL | let _: Z = Z::Struct;
+ | ^^^^^^^^^ help: use struct literal syntax instead: `Z::Struct { s: val }`
+
+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: the following enum variants are available
+ |
+LL | let _: E = (E::Fn(/* fields */));
+ | ~~~~~~~~~~~~~~~~~~~~~
+LL | let _: E = (E::Struct { /* 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 struct variant `m::E::Struct`
+ --> $DIR/privacy-enum-ctor.rs:45:16
+ |
+LL | / Struct {
+LL | | s: u8,
+LL | | },
+ | |_________- `m::E::Struct` defined here
+...
+LL | let _: E = m::E::Struct;
+ | ^^^^^^^^^^^^ help: use struct literal syntax instead: `m::E::Struct { s: val }`
+
+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: the following enum variants are available
+ |
+LL | let _: E = (E::Fn(/* fields */));
+ | ~~~~~~~~~~~~~~~~~~~~~
+LL | let _: E = (E::Struct { /* fields */ });
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+help: consider importing one of these items instead
+ |
+LL | use std::f32::consts::E;
+ |
+LL | use std::f64::consts::E;
+ |
+
+error[E0423]: expected value, found struct variant `E::Struct`
+ --> $DIR/privacy-enum-ctor.rs:53:16
+ |
+LL | / Struct {
+LL | | s: u8,
+LL | | },
+ | |_________- `E::Struct` defined here
+...
+LL | let _: E = E::Struct;
+ | ^^^^^^^^^ help: use struct literal syntax instead: `E::Struct { s: val }`
+
+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: the following enum variants are available
+ |
+LL | let _: Z = (m::Z::Fn(/* fields */));
+ | ~~~~~~~~~~~~~~~~~~~~~~~~
+LL | let _: Z = (m::Z::Struct { /* 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[E0423]: expected value, found struct variant `m::n::Z::Struct`
+ --> $DIR/privacy-enum-ctor.rs:64:16
+ |
+LL | / Struct {
+LL | | s: u8,
+LL | | },
+ | |_____________- `m::n::Z::Struct` defined here
+...
+LL | let _: Z = m::n::Z::Struct;
+ | ^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `m::n::Z::Struct { s: val }`
+
+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 instantiate this tuple variant
+ |
+LL | let _: Z = Z::Fn(_);
+ | +++
+
+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 instantiate this tuple variant
+ |
+LL | let _: E = m::E::Fn(_);
+ | +++
+
+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 instantiate this tuple variant
+ |
+LL | let _: E = E::Fn(_);
+ | +++
+
+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: aborting due to 23 previous errors
+
+Some errors have detailed explanations: E0308, E0412, E0423, E0603, E0618.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/resolve/privacy-struct-ctor.rs b/src/test/ui/resolve/privacy-struct-ctor.rs
new file mode 100644
index 000000000..0eecc7f8c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/privacy-struct-ctor.stderr b/src/test/ui/resolve/privacy-struct-ctor.stderr
new file mode 100644
index 000000000..17a666a40
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/raw-ident-in-path.rs b/src/test/ui/resolve/raw-ident-in-path.rs
new file mode 100644
index 000000000..7f1163beb
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/raw-ident-in-path.stderr b/src/test/ui/resolve/raw-ident-in-path.stderr
new file mode 100644
index 000000000..771dacbbb
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-assoc-suggestions.rs b/src/test/ui/resolve/resolve-assoc-suggestions.rs
new file mode 100644
index 000000000..ee9bce60c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-assoc-suggestions.stderr b/src/test/ui/resolve/resolve-assoc-suggestions.stderr
new file mode 100644
index 000000000..b6acaeb8c
--- /dev/null
+++ b/src/test/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 call 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/src/test/ui/resolve/resolve-bad-import-prefix.rs b/src/test/ui/resolve/resolve-bad-import-prefix.rs
new file mode 100644
index 000000000..325c69b43
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-bad-import-prefix.stderr b/src/test/ui/resolve/resolve-bad-import-prefix.stderr
new file mode 100644
index 000000000..852b9c6af
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-bad-visibility.rs b/src/test/ui/resolve/resolve-bad-visibility.rs
new file mode 100644
index 000000000..7d48bb97b
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-bad-visibility.stderr b/src/test/ui/resolve/resolve-bad-visibility.stderr
new file mode 100644
index 000000000..2ac41b875
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.rs b/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.rs
new file mode 100644
index 000000000..3cb6ab52e
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr b/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr
new file mode 100644
index 000000000..ea6cb9eb0
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.rs b/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.rs
new file mode 100644
index 000000000..10772e7a4
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr b/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr
new file mode 100644
index 000000000..abf068a1f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-import-vs-import.fixed b/src/test/ui/resolve/resolve-conflict-import-vs-import.fixed
new file mode 100644
index 000000000..e429513b5
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-import-vs-import.rs b/src/test/ui/resolve/resolve-conflict-import-vs-import.rs
new file mode 100644
index 000000000..43853117a
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr
new file mode 100644
index 000000000..632be50f4
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.rs b/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.rs
new file mode 100644
index 000000000..122606249
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr b/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr
new file mode 100644
index 000000000..7b9fb6c63
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-item-vs-import.rs b/src/test/ui/resolve/resolve-conflict-item-vs-import.rs
new file mode 100644
index 000000000..4308c7a27
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-item-vs-import.stderr b/src/test/ui/resolve/resolve-conflict-item-vs-import.stderr
new file mode 100644
index 000000000..5e5c9f6b3
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-type-vs-import.rs b/src/test/ui/resolve/resolve-conflict-type-vs-import.rs
new file mode 100644
index 000000000..3abce8396
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-conflict-type-vs-import.stderr b/src/test/ui/resolve/resolve-conflict-type-vs-import.stderr
new file mode 100644
index 000000000..198ef1031
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-hint-macro.fixed b/src/test/ui/resolve/resolve-hint-macro.fixed
new file mode 100644
index 000000000..54e016084
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-hint-macro.rs b/src/test/ui/resolve/resolve-hint-macro.rs
new file mode 100644
index 000000000..f16e8c075
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-hint-macro.stderr b/src/test/ui/resolve/resolve-hint-macro.stderr
new file mode 100644
index 000000000..bc69ddd8f
--- /dev/null
+++ b/src/test/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[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[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: 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/src/test/ui/resolve/resolve-inconsistent-binding-mode.rs b/src/test/ui/resolve/resolve-inconsistent-binding-mode.rs
new file mode 100644
index 000000000..43e9378b7
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr b/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr
new file mode 100644
index 000000000..96c1869b4
--- /dev/null
+++ b/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr
@@ -0,0 +1,64 @@
+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
+
+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
+
+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/src/test/ui/resolve/resolve-inconsistent-names.rs b/src/test/ui/resolve/resolve-inconsistent-names.rs
new file mode 100644
index 000000000..989d2d452
--- /dev/null
+++ b/src/test/ui/resolve/resolve-inconsistent-names.rs
@@ -0,0 +1,35 @@
+#![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
+ }
+
+ 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/src/test/ui/resolve/resolve-inconsistent-names.stderr b/src/test/ui/resolve/resolve-inconsistent-names.stderr
new file mode 100644
index 000000000..9de191f7d
--- /dev/null
+++ b/src/test/ui/resolve/resolve-inconsistent-names.stderr
@@ -0,0 +1,99 @@
+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:30: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:30: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
+
+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/src/test/ui/resolve/resolve-issue-2428.rs b/src/test/ui/resolve/resolve-issue-2428.rs
new file mode 100644
index 000000000..5f3473e9f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-label.rs b/src/test/ui/resolve/resolve-label.rs
new file mode 100644
index 000000000..ac5410cd3
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-label.stderr b/src/test/ui/resolve/resolve-label.stderr
new file mode 100644
index 000000000..5729348ef
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-primitive-fallback.rs b/src/test/ui/resolve/resolve-primitive-fallback.rs
new file mode 100644
index 000000000..992bcd797
--- /dev/null
+++ b/src/test/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 this 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/src/test/ui/resolve/resolve-primitive-fallback.stderr b/src/test/ui/resolve/resolve-primitive-fallback.stderr
new file mode 100644
index 000000000..f0eb1a4f4
--- /dev/null
+++ b/src/test/ui/resolve/resolve-primitive-fallback.stderr
@@ -0,0 +1,42 @@
+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
+ |
+LL | pub const fn size_of<T>() -> usize {
+ | ^^^^^^^
+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/src/test/ui/resolve/resolve-pseudo-shadowing.rs b/src/test/ui/resolve/resolve-pseudo-shadowing.rs
new file mode 100644
index 000000000..85c684ca0
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-self-in-impl-2.rs b/src/test/ui/resolve/resolve-self-in-impl-2.rs
new file mode 100644
index 000000000..f586760c8
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-self-in-impl-2.stderr b/src/test/ui/resolve/resolve-self-in-impl-2.stderr
new file mode 100644
index 000000000..3791fe90a
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-self-in-impl.rs b/src/test/ui/resolve/resolve-self-in-impl.rs
new file mode 100644
index 000000000..024fdc51e
--- /dev/null
+++ b/src/test/ui/resolve/resolve-self-in-impl.rs
@@ -0,0 +1,20 @@
+#![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 cycle detected
+impl Tr for S<Self> {} //~ ERROR cycle detected
+impl Self {} //~ ERROR cycle detected
+impl S<Self> {} //~ ERROR cycle detected
+impl Tr<Self::A> for S {} //~ ERROR cycle detected
+
+fn main() {}
diff --git a/src/test/ui/resolve/resolve-self-in-impl.stderr b/src/test/ui/resolve/resolve-self-in-impl.stderr
new file mode 100644
index 000000000..aa99c1a33
--- /dev/null
+++ b/src/test/ui/resolve/resolve-self-in-impl.stderr
@@ -0,0 +1,98 @@
+error[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-in-impl.rs:14:1: 14:17>`
+ --> $DIR/resolve-self-in-impl.rs:14:13
+ |
+LL | impl Tr for Self {}
+ | ^^^^
+ |
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:14:1: 14:17>` 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[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-in-impl.rs:15:1: 15:20>`
+ --> $DIR/resolve-self-in-impl.rs:15:15
+ |
+LL | impl Tr for S<Self> {}
+ | ^^^^
+ |
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:15:1: 15:20>` 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[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-in-impl.rs:16:1: 16:10>`
+ --> $DIR/resolve-self-in-impl.rs:16:6
+ |
+LL | impl Self {}
+ | ^^^^
+ |
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:16:1: 16:10>` 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[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-in-impl.rs:17:1: 17:13>`
+ --> $DIR/resolve-self-in-impl.rs:17:8
+ |
+LL | impl S<Self> {}
+ | ^^^^
+ |
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:17:1: 17:13>` 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[E0391]: cycle detected when computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:18:1: 18:23>`
+ --> $DIR/resolve-self-in-impl.rs:18:1
+ |
+LL | impl Tr<Self::A> for S {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: ...which immediately requires computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:18:1: 18: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 5 previous errors
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/resolve/resolve-speculative-adjustment.rs b/src/test/ui/resolve/resolve-speculative-adjustment.rs
new file mode 100644
index 000000000..81f757829
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-speculative-adjustment.stderr b/src/test/ui/resolve/resolve-speculative-adjustment.stderr
new file mode 100644
index 000000000..1c34af6d0
--- /dev/null
+++ b/src/test/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 function `method` in this scope
+ --> $DIR/resolve-speculative-adjustment.rs:19:13
+ |
+LL | method();
+ | ^^^^^^ 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: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/resolve/resolve-type-param-in-item-in-trait.rs b/src/test/ui/resolve/resolve-type-param-in-item-in-trait.rs
new file mode 100644
index 000000000..c77a66524
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr b/src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr
new file mode 100644
index 000000000..10a703ee0
--- /dev/null
+++ b/src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr
@@ -0,0 +1,45 @@
+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) {
+ | ----- try adding a local generic parameter in this method instead
+LL | enum Foo<B> {
+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) {
+ | ----- try adding a local generic parameter in this method instead
+LL | struct Foo<B>(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:23:28
+ |
+LL | trait TraitC<A> {
+ | - type parameter from outer function
+LL | fn outer(&self) {
+ | ----- try adding a local generic parameter in this method instead
+LL | struct Foo<B> { a: 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: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: `foo<B, A>`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/src/test/ui/resolve/resolve-unknown-trait.rs b/src/test/ui/resolve/resolve-unknown-trait.rs
new file mode 100644
index 000000000..290893bbb
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-unknown-trait.stderr b/src/test/ui/resolve/resolve-unknown-trait.stderr
new file mode 100644
index 000000000..e19cfe617
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-variant-assoc-item.rs b/src/test/ui/resolve/resolve-variant-assoc-item.rs
new file mode 100644
index 000000000..db4fedfb0
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/resolve-variant-assoc-item.stderr b/src/test/ui/resolve/resolve-variant-assoc-item.stderr
new file mode 100644
index 000000000..4be101996
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/shadow-const-param.rs b/src/test/ui/resolve/shadow-const-param.rs
new file mode 100644
index 000000000..c435c16dc
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/shadow-const-param.stderr b/src/test/ui/resolve/shadow-const-param.stderr
new file mode 100644
index 000000000..fbd0d8110
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/suggest-path-for-tuple-struct.rs b/src/test/ui/resolve/suggest-path-for-tuple-struct.rs
new file mode 100644
index 000000000..c8bc3e79f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/suggest-path-for-tuple-struct.stderr b/src/test/ui/resolve/suggest-path-for-tuple-struct.stderr
new file mode 100644
index 000000000..957045ca7
--- /dev/null
+++ b/src/test/ui/resolve/suggest-path-for-tuple-struct.stderr
@@ -0,0 +1,19 @@
+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: `SomeTupleStruct::new`
+
+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: `SomeRegularStruct::new`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs
new file mode 100644
index 000000000..204a27240
--- /dev/null
+++ b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs
@@ -0,0 +1,59 @@
+// 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`
+}
+
+fn h2() -> i32 {
+ a.g()
+ //~^ ERROR expected value, found module `a`
+}
+
+fn h3() -> i32 {
+ a.b.J
+ //~^ ERROR expected value, found module `a`
+}
+
+fn h4() -> i32 {
+ a::b.J
+ //~^ ERROR expected value, found module `a::b`
+}
+
+fn h5() {
+ a.b.f();
+ //~^ ERROR expected value, found module `a`
+ let v = Vec::new();
+ v.push(a::b);
+ //~^ ERROR expected value, found module `a::b`
+}
+
+fn h6() -> i32 {
+ a::b.f()
+ //~^ ERROR expected value, found module `a::b`
+}
+
+fn h7() {
+ a::b
+ //~^ ERROR expected value, found module `a::b`
+}
+
+fn h8() -> i32 {
+ a::b()
+ //~^ ERROR expected function, found module `a::b`
+}
+
+fn main() {}
diff --git a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr
new file mode 100644
index 000000000..54b242123
--- /dev/null
+++ b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr
@@ -0,0 +1,104 @@
+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: `a::I`
+
+error[E0423]: expected value, found module `a`
+ --> $DIR/suggest-path-instead-of-mod-dot-item.rs:22:5
+ |
+LL | a.g()
+ | ^--
+ | |
+ | help: use the path separator to refer to an item: `a::g`
+
+error[E0423]: expected value, found module `a`
+ --> $DIR/suggest-path-instead-of-mod-dot-item.rs:27:5
+ |
+LL | a.b.J
+ | ^--
+ | |
+ | help: use the path separator to refer to an item: `a::b`
+
+error[E0423]: expected value, found module `a::b`
+ --> $DIR/suggest-path-instead-of-mod-dot-item.rs:32: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:37:5
+ |
+LL | a.b.f();
+ | ^--
+ | |
+ | help: use the path separator to refer to an item: `a::b`
+
+error[E0423]: expected value, found module `a::b`
+ --> $DIR/suggest-path-instead-of-mod-dot-item.rs:40: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:45: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:50: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:55: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: aborting due to 9 previous errors
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/src/test/ui/resolve/token-error-correct-2.rs b/src/test/ui/resolve/token-error-correct-2.rs
new file mode 100644
index 000000000..f7c7d908c
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct-2.stderr b/src/test/ui/resolve/token-error-correct-2.stderr
new file mode 100644
index 000000000..cca9f2dc8
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct-3.rs b/src/test/ui/resolve/token-error-correct-3.rs
new file mode 100644
index 000000000..52934085f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr
new file mode 100644
index 000000000..77c87c784
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct-4.fixed b/src/test/ui/resolve/token-error-correct-4.fixed
new file mode 100644
index 000000000..064b9e74e
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct-4.rs b/src/test/ui/resolve/token-error-correct-4.rs
new file mode 100644
index 000000000..5e31d71e7
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct-4.stderr b/src/test/ui/resolve/token-error-correct-4.stderr
new file mode 100644
index 000000000..81e5a1336
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct.rs b/src/test/ui/resolve/token-error-correct.rs
new file mode 100644
index 000000000..4f74df0bf
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/token-error-correct.stderr b/src/test/ui/resolve/token-error-correct.stderr
new file mode 100644
index 000000000..ca0c4c18a
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/tuple-struct-alias.rs b/src/test/ui/resolve/tuple-struct-alias.rs
new file mode 100644
index 000000000..298e7e479
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/tuple-struct-alias.stderr b/src/test/ui/resolve/tuple-struct-alias.stderr
new file mode 100644
index 000000000..5a7873301
--- /dev/null
+++ b/src/test/ui/resolve/tuple-struct-alias.stderr
@@ -0,0 +1,26 @@
+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[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: 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/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs b/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs
new file mode 100644
index 000000000..ecd3f5881
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
new file mode 100644
index 000000000..0b0a37f24
--- /dev/null
+++ b/src/test/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 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[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 call 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: 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/src/test/ui/resolve/typo-suggestion-named-underscore.rs b/src/test/ui/resolve/typo-suggestion-named-underscore.rs
new file mode 100644
index 000000000..a2b05db03
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/typo-suggestion-named-underscore.stderr b/src/test/ui/resolve/typo-suggestion-named-underscore.stderr
new file mode 100644
index 000000000..65d1b084a
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs b/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs
new file mode 100644
index 000000000..87f9ce097
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr b/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr
new file mode 100644
index 000000000..8addc0303
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/unresolved_static_type_field.rs b/src/test/ui/resolve/unresolved_static_type_field.rs
new file mode 100644
index 000000000..494ad083f
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/unresolved_static_type_field.stderr b/src/test/ui/resolve/unresolved_static_type_field.stderr
new file mode 100644
index 000000000..06926b53d
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/use-self-in-inner-fn.rs b/src/test/ui/resolve/use-self-in-inner-fn.rs
new file mode 100644
index 000000000..eccb315fe
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/use-self-in-inner-fn.stderr b/src/test/ui/resolve/use-self-in-inner-fn.stderr
new file mode 100644
index 000000000..966093499
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/use_suggestion.rs b/src/test/ui/resolve/use_suggestion.rs
new file mode 100644
index 000000000..8c9bc6d76
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/use_suggestion.stderr b/src/test/ui/resolve/use_suggestion.stderr
new file mode 100644
index 000000000..4fff179b1
--- /dev/null
+++ b/src/test/ui/resolve/use_suggestion.stderr
@@ -0,0 +1,38 @@
+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[E0433]: failed to resolve: use of undeclared type `HashMap`
+ --> $DIR/use_suggestion.rs:2:14
+ |
+LL | let x1 = HashMap::new();
+ | ^^^^^^^ not found in this scope
+ |
+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: 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/src/test/ui/resolve/use_suggestion_placement.fixed b/src/test/ui/resolve/use_suggestion_placement.fixed
new file mode 100644
index 000000000..d1686f7fd
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/use_suggestion_placement.rs b/src/test/ui/resolve/use_suggestion_placement.rs
new file mode 100644
index 000000000..5be91f270
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/use_suggestion_placement.stderr b/src/test/ui/resolve/use_suggestion_placement.stderr
new file mode 100644
index 000000000..0aadd82f6
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/visibility-indeterminate.rs b/src/test/ui/resolve/visibility-indeterminate.rs
new file mode 100644
index 000000000..0e1142db3
--- /dev/null
+++ b/src/test/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/src/test/ui/resolve/visibility-indeterminate.stderr b/src/test/ui/resolve/visibility-indeterminate.stderr
new file mode 100644
index 000000000..84d82ce85
--- /dev/null
+++ b/src/test/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`.