You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid describing a method as 'not found' when bounds are unsatisfied
Fixes#76267
When there is a single applicable method candidate, but its trait bounds
are not satisfied, we avoid saying that the method is "not found".
Insted, we update the error message to directly mention which bounds are
not satisfied, rather than mentioning them in a note.
Copy file name to clipboardExpand all lines: src/test/ui/hrtb/issue-30786.migrate.stderr
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
error[E0599]: no method named `filterx` found for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` in the current scope
1
+
error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>`, but its trait bounds were not satisfied
2
2
--> $DIR/issue-30786.rs:128:22
3
3
|
4
4
LL | pub struct Map<S, F> {
@@ -8,17 +8,17 @@ LL | pub struct Map<S, F> {
8
8
| doesn't satisfy `_: StreamExt`
9
9
...
10
10
LL | let filter = map.filterx(|x: &_| true);
11
-
| ^^^^^^^ method not found in `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>`
11
+
| ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` due to unsatisfied trait bounds
12
12
|
13
-
= note: the method `filterx` exists but the following trait bounds were not satisfied:
13
+
= note: the following trait bounds were not satisfied:
which is required by `&mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
20
20
21
-
error[E0599]: no method named `countx` found for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` in the current scope
21
+
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`, but its trait bounds were not satisfied
22
22
--> $DIR/issue-30786.rs:141:24
23
23
|
24
24
LL | pub struct Filter<S, F> {
@@ -28,9 +28,9 @@ LL | pub struct Filter<S, F> {
28
28
| doesn't satisfy `_: StreamExt`
29
29
...
30
30
LL | let count = filter.countx();
31
-
| ^^^^^^ method not found in `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`
31
+
| ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` due to unsatisfied trait bounds
32
32
|
33
-
= note: the method `countx` exists but the following trait bounds were not satisfied:
33
+
= note: the following trait bounds were not satisfied:
Copy file name to clipboardExpand all lines: src/test/ui/hrtb/issue-30786.nll.stderr
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
error[E0599]: no method named `filterx` found for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` in the current scope
1
+
error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>`, but its trait bounds were not satisfied
2
2
--> $DIR/issue-30786.rs:128:22
3
3
|
4
4
LL | pub struct Map<S, F> {
@@ -8,17 +8,17 @@ LL | pub struct Map<S, F> {
8
8
| doesn't satisfy `_: StreamExt`
9
9
...
10
10
LL | let filter = map.filterx(|x: &_| true);
11
-
| ^^^^^^^ method not found in `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>`
11
+
| ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` due to unsatisfied trait bounds
12
12
|
13
-
= note: the method `filterx` exists but the following trait bounds were not satisfied:
13
+
= note: the following trait bounds were not satisfied:
which is required by `&mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
20
20
21
-
error[E0599]: no method named `countx` found for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` in the current scope
21
+
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`, but its trait bounds were not satisfied
22
22
--> $DIR/issue-30786.rs:141:24
23
23
|
24
24
LL | pub struct Filter<S, F> {
@@ -28,9 +28,9 @@ LL | pub struct Filter<S, F> {
28
28
| doesn't satisfy `_: StreamExt`
29
29
...
30
30
LL | let count = filter.countx();
31
-
| ^^^^^^ method not found in `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`
31
+
| ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` due to unsatisfied trait bounds
32
32
|
33
-
= note: the method `countx` exists but the following trait bounds were not satisfied:
33
+
= note: the following trait bounds were not satisfied:
Copy file name to clipboardExpand all lines: src/test/ui/issues/issue-21596.stderr
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
error[E0599]: no method named `to_string` found for raw pointer `*const u8` in the current scope
1
+
error[E0599]: the method `to_string` exists for raw pointer `*const u8`, but its trait bounds were not satisfied
2
2
--> $DIR/issue-21596.rs:4:22
3
3
|
4
4
LL | println!("{}", z.to_string());
5
-
| ^^^^^^^^^ method not found in `*const u8`
5
+
| ^^^^^^^^^ method cannot be called on `*const u8` due to unsatisfied trait bounds
6
6
|
7
7
= note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
8
8
= note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior
9
-
= note: the method `to_string` exists but the following trait bounds were not satisfied:
9
+
= note: the following trait bounds were not satisfied:
Copy file name to clipboardExpand all lines: src/test/ui/issues/issue-31173.stderr
+3-3
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,11 @@ LL | .cloned()
7
7
= note: expected type `u8`
8
8
found reference `&_`
9
9
10
-
error[E0599]: no method named `collect` found for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` in the current scope
10
+
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>`, but its trait bounds were not satisfied
11
11
--> $DIR/issue-31173.rs:14:10
12
12
|
13
13
LL | .collect();
14
-
| ^^^^^^^ method not found in `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>`
14
+
| ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` due to unsatisfied trait bounds
0 commit comments