summaryrefslogtreecommitdiffstats
path: root/tests/ui/resolve
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /tests/ui/resolve
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/resolve')
-rw-r--r--tests/ui/resolve/associated-fn-called-as-fn.stderr14
-rw-r--r--tests/ui/resolve/bad-expr-path.stderr4
-rw-r--r--tests/ui/resolve/bad-expr-path2.stderr4
-rw-r--r--tests/ui/resolve/bad-type-env-capture.stderr8
-rw-r--r--tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs18
-rw-r--r--tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr41
-rw-r--r--tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr28
-rw-r--r--tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr34
-rw-r--r--tests/ui/resolve/generic-params-from-outer-item-in-const-item.rs39
-rw-r--r--tests/ui/resolve/issue-103474.stderr2
-rw-r--r--tests/ui/resolve/issue-12796.rs2
-rw-r--r--tests/ui/resolve/issue-12796.stderr4
-rw-r--r--tests/ui/resolve/issue-14254.stderr98
-rw-r--r--tests/ui/resolve/issue-2356.stderr42
-rw-r--r--tests/ui/resolve/issue-3021-c.rs4
-rw-r--r--tests/ui/resolve/issue-3021-c.stderr16
-rw-r--r--tests/ui/resolve/issue-60057.stderr12
-rw-r--r--tests/ui/resolve/issue-65025-extern-static-parent-generics.rs2
-rw-r--r--tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr6
-rw-r--r--tests/ui/resolve/issue-65035-static-with-parent-generics.rs10
-rw-r--r--tests/ui/resolve/issue-65035-static-with-parent-generics.stderr30
-rw-r--r--tests/ui/resolve/issue-6642.rs9
-rw-r--r--tests/ui/resolve/issue-6642.stderr11
-rw-r--r--tests/ui/resolve/resolve-assoc-suggestions.stderr21
-rw-r--r--tests/ui/resolve/resolve-speculative-adjustment.stderr14
-rw-r--r--tests/ui/resolve/resolve-type-param-in-item-in-trait.rs8
-rw-r--r--tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr32
-rw-r--r--tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed16
-rw-r--r--tests/ui/resolve/suggest-import-without-clobbering-attrs.rs15
-rw-r--r--tests/ui/resolve/suggest-import-without-clobbering-attrs.stderr14
-rw-r--r--tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr26
-rw-r--r--tests/ui/resolve/unresolved_static_type_field.stderr5
-rw-r--r--tests/ui/resolve/use-self-in-inner-fn.rs6
-rw-r--r--tests/ui/resolve/use-self-in-inner-fn.stderr6
34 files changed, 479 insertions, 122 deletions
diff --git a/tests/ui/resolve/associated-fn-called-as-fn.stderr b/tests/ui/resolve/associated-fn-called-as-fn.stderr
index fbdea30d5..7d28b959a 100644
--- a/tests/ui/resolve/associated-fn-called-as-fn.stderr
+++ b/tests/ui/resolve/associated-fn-called-as-fn.stderr
@@ -2,13 +2,23 @@ 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`
+ | ^^^^^^^^^^^^^^^
+ |
+help: you might have meant to call the associated function
+ |
+LL | '0'..='9' => Self::collect_primary(&c),
+ | ++++++
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`
+ | ^^^^^^^^^^^^^^^
+ |
+help: you might have meant to call the associated function
+ |
+LL | '0'..='9' => Self::collect_primary(&c),
+ | ++++++
error: aborting due to 2 previous errors
diff --git a/tests/ui/resolve/bad-expr-path.stderr b/tests/ui/resolve/bad-expr-path.stderr
index 411130913..0392c1fa2 100644
--- a/tests/ui/resolve/bad-expr-path.stderr
+++ b/tests/ui/resolve/bad-expr-path.stderr
@@ -16,8 +16,8 @@ error[E0580]: `main` function has wrong type
LL | fn main(arguments: Vec<String>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
|
- = note: expected fn pointer `fn()`
- found fn pointer `fn(Vec<String>)`
+ = note: expected signature `fn()`
+ found signature `fn(Vec<String>)`
error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-expr-path.rs:4:5
diff --git a/tests/ui/resolve/bad-expr-path2.stderr b/tests/ui/resolve/bad-expr-path2.stderr
index af3ca99c5..9238b1f70 100644
--- a/tests/ui/resolve/bad-expr-path2.stderr
+++ b/tests/ui/resolve/bad-expr-path2.stderr
@@ -16,8 +16,8 @@ error[E0580]: `main` function has wrong type
LL | fn main(arguments: Vec<String>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
|
- = note: expected fn pointer `fn()`
- found fn pointer `fn(Vec<String>)`
+ = note: expected signature `fn()`
+ found signature `fn(Vec<String>)`
error[E0425]: cannot find function `log` in this scope
--> $DIR/bad-expr-path2.rs:6:5
diff --git a/tests/ui/resolve/bad-type-env-capture.stderr b/tests/ui/resolve/bad-type-env-capture.stderr
index b6282c2d0..941b6b7a6 100644
--- a/tests/ui/resolve/bad-type-env-capture.stderr
+++ b/tests/ui/resolve/bad-type-env-capture.stderr
@@ -1,12 +1,12 @@
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/bad-type-env-capture.rs:2:15
|
LL | fn foo<T>() {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | fn bar(b: T) { }
- | - ^ use of generic parameter from outer function
+ | - ^ use of generic parameter from outer item
| |
- | help: try using a local generic parameter instead: `<T>`
+ | help: try introducing a local generic parameter here: `<T>`
error: aborting due to previous error
diff --git a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs
new file mode 100644
index 000000000..b5f139590
--- /dev/null
+++ b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs
@@ -0,0 +1,18 @@
+struct Foo {
+ field: u32,
+}
+
+impl Foo {
+ fn field(&self) -> u32 {
+ self.field
+ }
+
+ fn new() -> Foo {
+ field; //~ ERROR cannot find value `field` in this scope
+ Foo { field } //~ ERROR cannot find value `field` in this scope
+ }
+ fn clone(&self) -> Foo {
+ Foo { field } //~ ERROR cannot find value `field` in this scope
+ }
+}
+fn main() {}
diff --git a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr
new file mode 100644
index 000000000..3c44c1c24
--- /dev/null
+++ b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr
@@ -0,0 +1,41 @@
+error[E0425]: cannot find value `field` in this scope
+ --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:11:9
+ |
+LL | field: u32,
+ | ---------- a field by that name exists in `Self`
+...
+LL | fn field(&self) -> u32 {
+ | ----- a method by that name is available on `Self` here
+...
+LL | field;
+ | ^^^^^
+
+error[E0425]: cannot find value `field` in this scope
+ --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:12:15
+ |
+LL | field: u32,
+ | ---------- a field by that name exists in `Self`
+...
+LL | fn field(&self) -> u32 {
+ | ----- a method by that name is available on `Self` here
+...
+LL | Foo { field }
+ | ^^^^^
+
+error[E0425]: cannot find value `field` in this scope
+ --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:15:15
+ |
+LL | fn field(&self) -> u32 {
+ | ----- a method by that name is available on `Self` here
+...
+LL | Foo { field }
+ | ^^^^^
+ |
+help: you might have meant to use the available field
+ |
+LL | Foo { field: self.field }
+ | ++++++++++++
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr
new file mode 100644
index 000000000..4f8538292
--- /dev/null
+++ b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr
@@ -0,0 +1,28 @@
+error[E0401]: can't use generic parameters from outer item
+ --> $DIR/generic-params-from-outer-item-in-const-item.rs:12:20
+ |
+LL | fn outer<T: Tr>() { // outer function
+ | - type parameter from outer item
+LL | const K: u32 = T::C;
+ | ^^^^ use of generic parameter from outer item
+
+error[E0401]: can't use generic parameters from outer item
+ --> $DIR/generic-params-from-outer-item-in-const-item.rs:19:24
+ |
+LL | impl<T> Tr for T { // outer impl block
+ | - type parameter from outer item
+LL | const C: u32 = {
+LL | const I: u32 = T::C;
+ | ^^^^ use of generic parameter from outer item
+
+error[E0401]: can't use generic parameters from outer item
+ --> $DIR/generic-params-from-outer-item-in-const-item.rs:27:20
+ |
+LL | struct S<T: Tr>(U32<{ // outer struct
+ | - type parameter from outer item
+LL | const _: u32 = T::C;
+ | ^^^^ use of generic parameter from outer item
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr
new file mode 100644
index 000000000..1cb55842b
--- /dev/null
+++ b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr
@@ -0,0 +1,34 @@
+error[E0401]: can't use generic parameters from outer item
+ --> $DIR/generic-params-from-outer-item-in-const-item.rs:12:20
+ |
+LL | fn outer<T: Tr>() { // outer function
+ | - type parameter from outer item
+LL | const K: u32 = T::C;
+ | - ^^^^ use of generic parameter from outer item
+ | |
+ | help: try introducing a local generic parameter here: `<T>`
+
+error[E0401]: can't use generic parameters from outer item
+ --> $DIR/generic-params-from-outer-item-in-const-item.rs:19:24
+ |
+LL | impl<T> Tr for T { // outer impl block
+ | - type parameter from outer item
+LL | const C: u32 = {
+LL | const I: u32 = T::C;
+ | - ^^^^ use of generic parameter from outer item
+ | |
+ | help: try introducing a local generic parameter here: `<T>`
+
+error[E0401]: can't use generic parameters from outer item
+ --> $DIR/generic-params-from-outer-item-in-const-item.rs:27:20
+ |
+LL | struct S<T: Tr>(U32<{ // outer struct
+ | - type parameter from outer item
+LL | const _: u32 = T::C;
+ | - ^^^^ use of generic parameter from outer item
+ | |
+ | help: try introducing a local generic parameter here: `<T>`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.rs b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.rs
new file mode 100644
index 000000000..e5647d72c
--- /dev/null
+++ b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.rs
@@ -0,0 +1,39 @@
+// Regression test for issue #115720.
+// If a const item contains generic params from an outer items, only suggest
+// turning the const item generic if the feature `generic_const_items` is enabled.
+
+// revisions: default generic_const_items
+
+#![cfg_attr(generic_const_items, feature(generic_const_items))]
+#![feature(generic_const_exprs)] // only used for the test case "outer struct"
+#![allow(incomplete_features)]
+
+fn outer<T: Tr>() { // outer function
+ const K: u32 = T::C;
+ //~^ ERROR can't use generic parameters from outer item
+ //[generic_const_items]~| HELP try introducing a local generic parameter here
+}
+
+impl<T> Tr for T { // outer impl block
+ const C: u32 = {
+ const I: u32 = T::C;
+ //~^ ERROR can't use generic parameters from outer item
+ //[generic_const_items]~| HELP try introducing a local generic parameter here
+ I
+ };
+}
+
+struct S<T: Tr>(U32<{ // outer struct
+ const _: u32 = T::C;
+ //~^ ERROR can't use generic parameters from outer item
+ //[generic_const_items]~| HELP try introducing a local generic parameter here
+ 0
+}>);
+
+trait Tr {
+ const C: u32;
+}
+
+struct U32<const N: u32>;
+
+fn main() {}
diff --git a/tests/ui/resolve/issue-103474.stderr b/tests/ui/resolve/issue-103474.stderr
index 415d23155..e48fb31ec 100644
--- a/tests/ui/resolve/issue-103474.stderr
+++ b/tests/ui/resolve/issue-103474.stderr
@@ -19,7 +19,7 @@ error[E0425]: cannot find function `first` in this scope
LL | first()
| ^^^^^ not found in this scope
|
-help: consider using the associated function
+help: consider using the method on `Self`
|
LL | self.first()
| +++++
diff --git a/tests/ui/resolve/issue-12796.rs b/tests/ui/resolve/issue-12796.rs
index 942d6b9a5..de3e73437 100644
--- a/tests/ui/resolve/issue-12796.rs
+++ b/tests/ui/resolve/issue-12796.rs
@@ -1,7 +1,7 @@
trait Trait {
fn outer(&self) {
fn inner(_: &Self) {
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
}
}
diff --git a/tests/ui/resolve/issue-12796.stderr b/tests/ui/resolve/issue-12796.stderr
index a01fd2d65..ef59d0036 100644
--- a/tests/ui/resolve/issue-12796.stderr
+++ b/tests/ui/resolve/issue-12796.stderr
@@ -1,10 +1,10 @@
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-12796.rs:3:22
|
LL | fn inner(_: &Self) {
| ^^^^
| |
- | use of generic parameter from outer function
+ | use of generic parameter from outer item
| can't use `Self` here
error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-14254.stderr b/tests/ui/resolve/issue-14254.stderr
index 690a40f7e..9284b4bab 100644
--- a/tests/ui/resolve/issue-14254.stderr
+++ b/tests/ui/resolve/issue-14254.stderr
@@ -8,13 +8,23 @@ 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`
+ | ^
+ |
+help: you might have meant to use the available field
+ |
+LL | 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`
+ | ^
+ |
+help: you might have meant to use the available field
+ |
+LL | self.y;
+ | +++++
error[E0425]: cannot find value `a` in this scope
--> $DIR/issue-14254.rs:34:9
@@ -31,7 +41,7 @@ LL | bah;
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find value `b` in this scope
--> $DIR/issue-14254.rs:38:9
@@ -43,13 +53,23 @@ 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`
+ | ^
+ |
+help: you might have meant to use the available field
+ |
+LL | 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`
+ | ^
+ |
+help: you might have meant to use the available field
+ |
+LL | self.y;
+ | +++++
error[E0425]: cannot find value `a` in this scope
--> $DIR/issue-14254.rs:51:9
@@ -66,7 +86,7 @@ LL | bah;
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find value `b` in this scope
--> $DIR/issue-14254.rs:55:9
@@ -83,7 +103,7 @@ LL | bah;
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:73:9
@@ -94,7 +114,7 @@ LL | bah;
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:82:9
@@ -105,7 +125,7 @@ LL | bah;
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:91:9
@@ -116,7 +136,7 @@ LL | bah;
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find value `bah` in this scope
--> $DIR/issue-14254.rs:100:9
@@ -127,55 +147,95 @@ LL | bah;
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:19:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:28:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:45:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:62:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:71:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:80:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:89:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/issue-14254.rs:98:9
|
LL | baz();
- | ^^^ help: you might have meant to call the method: `self.baz`
+ | ^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.baz();
+ | +++++
error: aborting due to 24 previous errors
diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr
index 30f5f0595..5f75ae988 100644
--- a/tests/ui/resolve/issue-2356.stderr
+++ b/tests/ui/resolve/issue-2356.stderr
@@ -1,8 +1,11 @@
error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:39:5
|
+LL | whiskers: isize,
+ | --------------- a field by that name exists in `Self`
+...
LL | whiskers -= other;
- | ^^^^^^^^ a field by this name exists in `Self`
+ | ^^^^^^^^
error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:65:8
@@ -21,13 +24,21 @@ 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`
+ | ^^^^^^^^
+ |
+help: you might have meant to use the available field
+ |
+LL | self.whiskers = 0;
+ | +++++
error[E0425]: cannot find value `whiskers` in this scope
--> $DIR/issue-2356.rs:84:5
|
+LL | whiskers: isize,
+ | --------------- a field by that name exists in `Self`
+...
LL | whiskers = 4;
- | ^^^^^^^^ a field by this name exists in `Self`
+ | ^^^^^^^^
error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:92:5
@@ -47,19 +58,34 @@ 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`
+ | ^^^^^
+ |
+help: you might have meant to call the method
+ |
+LL | 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: `Self::default`
+ | ^^^^^^^
+ |
+help: you might have meant to call the associated function
+ |
+LL | Self::default();
+ | ++++++
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`
+ | ^^^^^
+ |
+help: you might have meant to call the associated function
+ |
+LL | Self::shave(4);
+ | ++++++
error[E0425]: cannot find function `purr` in this scope
--> $DIR/issue-2356.rs:43:5
@@ -73,7 +99,7 @@ error[E0425]: cannot find function `static_method` in this scope
LL | static_method();
| ^^^^^^^^^^^^^ not found in this scope
|
-help: consider using the associated function
+help: consider using the associated function on `Self`
|
LL | Self::static_method();
| ++++++
@@ -102,7 +128,7 @@ error[E0425]: cannot find function `grow_older` in this scope
LL | grow_older();
| ^^^^^^^^^^ not found in this scope
|
-help: consider using the associated function
+help: consider using the associated function on `Self`
|
LL | Self::grow_older();
| ++++++
diff --git a/tests/ui/resolve/issue-3021-c.rs b/tests/ui/resolve/issue-3021-c.rs
index 94ed1fdf7..bd21d1244 100644
--- a/tests/ui/resolve/issue-3021-c.rs
+++ b/tests/ui/resolve/issue-3021-c.rs
@@ -1,8 +1,8 @@
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 g(&self, x: T) -> T; //~ ERROR can't use generic parameters from outer item
+ //~^ ERROR can't use generic parameters from outer item
}
}
diff --git a/tests/ui/resolve/issue-3021-c.stderr b/tests/ui/resolve/issue-3021-c.stderr
index 5176efc3a..537bbaf7b 100644
--- a/tests/ui/resolve/issue-3021-c.stderr
+++ b/tests/ui/resolve/issue-3021-c.stderr
@@ -1,24 +1,24 @@
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-3021-c.rs:4:24
|
LL | fn siphash<T>() {
- | - type parameter from outer function
+ | - type parameter from outer item
LL |
LL | trait U {
- | - help: try using a local generic parameter instead: `<T>`
+ | - help: try introducing a local generic parameter here: `<T>`
LL | fn g(&self, x: T) -> T;
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-3021-c.rs:4:30
|
LL | fn siphash<T>() {
- | - type parameter from outer function
+ | - type parameter from outer item
LL |
LL | trait U {
- | - help: try using a local generic parameter instead: `<T>`
+ | - help: try introducing a local generic parameter here: `<T>`
LL | fn g(&self, x: T) -> T;
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
error: aborting due to 2 previous errors
diff --git a/tests/ui/resolve/issue-60057.stderr b/tests/ui/resolve/issue-60057.stderr
index 4d915fcd9..a2ab86443 100644
--- a/tests/ui/resolve/issue-60057.stderr
+++ b/tests/ui/resolve/issue-60057.stderr
@@ -1,14 +1,22 @@
error[E0425]: cannot find value `banana` in this scope
--> $DIR/issue-60057.rs:8:21
|
+LL | banana: u8,
+ | ---------- a field by that name exists in `Self`
+...
LL | banana: banana
- | ^^^^^^ a field by this name exists in `Self`
+ | ^^^^^^
error[E0425]: cannot find value `banana` in this scope
--> $DIR/issue-60057.rs:14:21
|
LL | banana: banana
- | ^^^^^^ help: you might have meant to use the available field: `self.banana`
+ | ^^^^^^
+ |
+help: you might have meant to use the available field
+ |
+LL | banana: self.banana
+ | +++++
error: aborting due to 2 previous errors
diff --git a/tests/ui/resolve/issue-65025-extern-static-parent-generics.rs b/tests/ui/resolve/issue-65025-extern-static-parent-generics.rs
index ce45f630e..4fa3f12d0 100644
--- a/tests/ui/resolve/issue-65025-extern-static-parent-generics.rs
+++ b/tests/ui/resolve/issue-65025-extern-static-parent-generics.rs
@@ -1,7 +1,7 @@
unsafe fn foo<A>() {
extern "C" {
static baz: *const A;
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
let bar: *const u64 = core::mem::transmute(&baz);
diff --git a/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr b/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr
index 6bbf76dd1..3e9c3fd11 100644
--- a/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr
+++ b/tests/ui/resolve/issue-65025-extern-static-parent-generics.stderr
@@ -1,11 +1,11 @@
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-65025-extern-static-parent-generics.rs:3:28
|
LL | unsafe fn foo<A>() {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | extern "C" {
LL | static baz: *const A;
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
error: aborting due to previous error
diff --git a/tests/ui/resolve/issue-65035-static-with-parent-generics.rs b/tests/ui/resolve/issue-65035-static-with-parent-generics.rs
index f96c04841..bc99584a8 100644
--- a/tests/ui/resolve/issue-65035-static-with-parent-generics.rs
+++ b/tests/ui/resolve/issue-65035-static-with-parent-generics.rs
@@ -1,26 +1,26 @@
fn f<T>() {
extern "C" {
static a: *const T;
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
}
fn g<T: Default>() {
static a: *const T = Default::default();
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
fn h<const N: usize>() {
extern "C" {
static a: [u8; N];
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
}
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
+ //~^ ERROR can't use generic parameters from outer item
+ //~| ERROR can't use generic parameters from outer item
}
fn main() {}
diff --git a/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr b/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr
index 7ed572f80..f1fe1a600 100644
--- a/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr
+++ b/tests/ui/resolve/issue-65035-static-with-parent-generics.stderr
@@ -1,44 +1,44 @@
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-65035-static-with-parent-generics.rs:3:26
|
LL | fn f<T>() {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | extern "C" {
LL | static a: *const T;
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-65035-static-with-parent-generics.rs:9:22
|
LL | fn g<T: Default>() {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | static a: *const T = Default::default();
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-65035-static-with-parent-generics.rs:15:24
|
LL | fn h<const N: usize>() {
- | - const parameter from outer function
+ | - const parameter from outer item
LL | extern "C" {
LL | static a: [u8; N];
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-65035-static-with-parent-generics.rs:21:20
|
LL | fn i<const N: usize>() {
- | - const parameter from outer function
+ | - const parameter from outer item
LL | static a: [u8; N] = [0; N];
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-65035-static-with-parent-generics.rs:21:29
|
LL | fn i<const N: usize>() {
- | - const parameter from outer function
+ | - const parameter from outer item
LL | static a: [u8; N] = [0; N];
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
error: aborting due to 5 previous errors
diff --git a/tests/ui/resolve/issue-6642.rs b/tests/ui/resolve/issue-6642.rs
new file mode 100644
index 000000000..f80f6fffe
--- /dev/null
+++ b/tests/ui/resolve/issue-6642.rs
@@ -0,0 +1,9 @@
+struct A;
+impl A {
+ fn m(&self) {
+ fn x() {
+ self.m() //~ ERROR can't capture dynamic environment in a fn item
+ }
+ }
+}
+fn main() {}
diff --git a/tests/ui/resolve/issue-6642.stderr b/tests/ui/resolve/issue-6642.stderr
new file mode 100644
index 000000000..6668108d0
--- /dev/null
+++ b/tests/ui/resolve/issue-6642.stderr
@@ -0,0 +1,11 @@
+error[E0434]: can't capture dynamic environment in a fn item
+ --> $DIR/issue-6642.rs:5:13
+ |
+LL | self.m()
+ | ^^^^
+ |
+ = help: use the `|| { ... }` closure form instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0434`.
diff --git a/tests/ui/resolve/resolve-assoc-suggestions.stderr b/tests/ui/resolve/resolve-assoc-suggestions.stderr
index 8def9aa20..3d9d4ffaa 100644
--- a/tests/ui/resolve/resolve-assoc-suggestions.stderr
+++ b/tests/ui/resolve/resolve-assoc-suggestions.stderr
@@ -14,13 +14,23 @@ 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`
+ | ^^^^^
+ |
+help: you might have meant to use the available field
+ |
+LL | 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`
+ | ^^^^
+ |
+help: you might have meant to use the associated type
+ |
+LL | let _: Self::Type;
+ | ++++++
error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope
--> $DIR/resolve-assoc-suggestions.rs:25:13
@@ -50,7 +60,12 @@ error[E0425]: cannot find value `method` in this scope
--> $DIR/resolve-assoc-suggestions.rs:34:9
|
LL | method;
- | ^^^^^^ help: you might have meant to refer to the method: `self.method`
+ | ^^^^^^
+ |
+help: you might have meant to refer to the method
+ |
+LL | self.method;
+ | +++++
error: aborting due to 9 previous errors
diff --git a/tests/ui/resolve/resolve-speculative-adjustment.stderr b/tests/ui/resolve/resolve-speculative-adjustment.stderr
index be11a7ebe..fb15472bd 100644
--- a/tests/ui/resolve/resolve-speculative-adjustment.stderr
+++ b/tests/ui/resolve/resolve-speculative-adjustment.stderr
@@ -8,13 +8,23 @@ 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`
+ | ^^^^^
+ |
+help: you might have meant to use the available field
+ |
+LL | 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`
+ | ^^^^^^
+ |
+help: you might have meant to call the method
+ |
+LL | self.method();
+ | +++++
error[E0425]: cannot find function `method` in this scope
--> $DIR/resolve-speculative-adjustment.rs:19:13
diff --git a/tests/ui/resolve/resolve-type-param-in-item-in-trait.rs b/tests/ui/resolve/resolve-type-param-in-item-in-trait.rs
index c77a66524..2d5f34c62 100644
--- a/tests/ui/resolve/resolve-type-param-in-item-in-trait.rs
+++ b/tests/ui/resolve/resolve-type-param-in-item-in-trait.rs
@@ -6,7 +6,7 @@ trait TraitA<A> {
fn outer(&self) {
enum Foo<B> {
Variance(A)
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
}
}
@@ -14,21 +14,21 @@ trait TraitA<A> {
trait TraitB<A> {
fn outer(&self) {
struct Foo<B>(A);
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
}
trait TraitC<A> {
fn outer(&self) {
struct Foo<B> { a: A }
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
}
trait TraitD<A> {
fn outer(&self) {
fn foo<B>(a: A) { }
- //~^ ERROR can't use generic parameters from outer function
+ //~^ ERROR can't use generic parameters from outer item
}
}
diff --git a/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr b/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr
index 0a6d1cc3b..1ab56fdc5 100644
--- a/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr
+++ b/tests/ui/resolve/resolve-type-param-in-item-in-trait.stderr
@@ -1,46 +1,46 @@
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/resolve-type-param-in-item-in-trait.rs:8:22
|
LL | trait TraitA<A> {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | fn outer(&self) {
LL | enum Foo<B> {
- | - help: try using a local generic parameter instead: `A,`
+ | - help: try introducing a local generic parameter here: `A,`
LL | Variance(A)
- | ^ use of generic parameter from outer function
+ | ^ use of generic parameter from outer item
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/resolve-type-param-in-item-in-trait.rs:16:23
|
LL | trait TraitB<A> {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | fn outer(&self) {
LL | struct Foo<B>(A);
- | - ^ use of generic parameter from outer function
+ | - ^ use of generic parameter from outer item
| |
- | help: try using a local generic parameter instead: `A,`
+ | help: try introducing a local generic parameter here: `A,`
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/resolve-type-param-in-item-in-trait.rs:23:28
|
LL | trait TraitC<A> {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | fn outer(&self) {
LL | struct Foo<B> { a: A }
- | - ^ use of generic parameter from outer function
+ | - ^ use of generic parameter from outer item
| |
- | help: try using a local generic parameter instead: `A,`
+ | help: try introducing a local generic parameter here: `A,`
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/resolve-type-param-in-item-in-trait.rs:30:22
|
LL | trait TraitD<A> {
- | - type parameter from outer function
+ | - type parameter from outer item
LL | fn outer(&self) {
LL | fn foo<B>(a: A) { }
- | - ^ use of generic parameter from outer function
+ | - ^ use of generic parameter from outer item
| |
- | help: try using a local generic parameter instead: `A,`
+ | help: try introducing a local generic parameter here: `A,`
error: aborting due to 4 previous errors
diff --git a/tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed b/tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed
new file mode 100644
index 000000000..fc68884fe
--- /dev/null
+++ b/tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed
@@ -0,0 +1,16 @@
+// run-rustfix
+// compile-flags: --cfg=whatever -Aunused
+
+use y::z;
+#[cfg(whatever)]
+use y::Whatever;
+
+mod y {
+ pub(crate) fn z() {}
+ pub(crate) struct Whatever;
+}
+
+fn main() {
+ z();
+ //~^ ERROR cannot find function `z` in this scope
+}
diff --git a/tests/ui/resolve/suggest-import-without-clobbering-attrs.rs b/tests/ui/resolve/suggest-import-without-clobbering-attrs.rs
new file mode 100644
index 000000000..38a109570
--- /dev/null
+++ b/tests/ui/resolve/suggest-import-without-clobbering-attrs.rs
@@ -0,0 +1,15 @@
+// run-rustfix
+// compile-flags: --cfg=whatever -Aunused
+
+#[cfg(whatever)]
+use y::Whatever;
+
+mod y {
+ pub(crate) fn z() {}
+ pub(crate) struct Whatever;
+}
+
+fn main() {
+ z();
+ //~^ ERROR cannot find function `z` in this scope
+}
diff --git a/tests/ui/resolve/suggest-import-without-clobbering-attrs.stderr b/tests/ui/resolve/suggest-import-without-clobbering-attrs.stderr
new file mode 100644
index 000000000..d3574851d
--- /dev/null
+++ b/tests/ui/resolve/suggest-import-without-clobbering-attrs.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find function `z` in this scope
+ --> $DIR/suggest-import-without-clobbering-attrs.rs:13:5
+ |
+LL | z();
+ | ^ not found in this scope
+ |
+help: consider importing this function
+ |
+LL + use y::z;
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
index f32e0404e..0306c8af8 100644
--- a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
+++ b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
@@ -1,20 +1,20 @@
error[E0425]: cannot find value `config` in this scope
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:7:16
|
+LL | config: String,
+ | -------------- a field by that name exists in `Self`
+...
LL | Self { config }
- | ^^^^^^
- | |
- | a field by this name exists in `Self`
- | help: a local variable with a similar name exists: `cofig`
+ | ^^^^^^ 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 | config: String,
+ | -------------- a field by that name exists in `Self`
+...
LL | println!("{config}");
- | ^^^^^^
- | |
- | a field by this name exists in `Self`
- | help: a local variable with a similar name exists: `cofig`
+ | ^^^^^^ 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
@@ -25,7 +25,7 @@ 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}");
@@ -43,7 +43,7 @@ LL | fn ba() {}
help: you might have meant to refer to the associated function
|
LL | Self::bah;
- | ~~~~~~~~~
+ | ++++++
help: a function with a similar name exists
|
LL | ba;
@@ -61,7 +61,7 @@ LL | const BARR: u32 = 3;
help: you might have meant to use the associated `const`
|
LL | Self::BAR;
- | ~~~~~~~~~
+ | ++++++
help: a constant with a similar name exists
|
LL | BARR;
@@ -79,7 +79,7 @@ LL | type Bar = String;
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();
@@ -97,7 +97,7 @@ LL | fn ba() {}
help: you might have meant to call the method
|
LL | self.baz();
- | ~~~~~~~~
+ | +++++
help: a function with a similar name exists
|
LL | ba();
diff --git a/tests/ui/resolve/unresolved_static_type_field.stderr b/tests/ui/resolve/unresolved_static_type_field.stderr
index 06926b53d..035dc9b96 100644
--- a/tests/ui/resolve/unresolved_static_type_field.stderr
+++ b/tests/ui/resolve/unresolved_static_type_field.stderr
@@ -1,8 +1,11 @@
error[E0425]: cannot find value `cx` in this scope
--> $DIR/unresolved_static_type_field.rs:9:11
|
+LL | cx: bool,
+ | -------- a field by that name exists in `Self`
+...
LL | f(cx);
- | ^^ a field by this name exists in `Self`
+ | ^^
error: aborting due to previous error
diff --git a/tests/ui/resolve/use-self-in-inner-fn.rs b/tests/ui/resolve/use-self-in-inner-fn.rs
index eccb315fe..f4dfa4c40 100644
--- a/tests/ui/resolve/use-self-in-inner-fn.rs
+++ b/tests/ui/resolve/use-self-in-inner-fn.rs
@@ -4,9 +4,9 @@ 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
+ //~^ ERROR can't use generic parameters from outer item
+ //~| NOTE use of generic parameter from outer item
+ //~| NOTE refer to the type directly here instead
}
}
}
diff --git a/tests/ui/resolve/use-self-in-inner-fn.stderr b/tests/ui/resolve/use-self-in-inner-fn.stderr
index 966093499..832aaacaf 100644
--- a/tests/ui/resolve/use-self-in-inner-fn.stderr
+++ b/tests/ui/resolve/use-self-in-inner-fn.stderr
@@ -1,4 +1,4 @@
-error[E0401]: can't use generic parameters from outer function
+error[E0401]: can't use generic parameters from outer item
--> $DIR/use-self-in-inner-fn.rs:6:25
|
LL | impl A {
@@ -7,8 +7,8 @@ LL | impl A {
LL | fn peach(this: &Self) {
| ^^^^
| |
- | use of generic parameter from outer function
- | use a type here instead
+ | use of generic parameter from outer item
+ | refer to the type directly here instead
error: aborting due to previous error