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
Rollup merge of rust-lang#120507 - estebank:issue-108428, r=davidtwco
Account for non-overlapping unmet trait bounds in suggestion
When a method not found on a type parameter could have been provided by any
of multiple traits, suggest each trait individually, instead of a single
suggestion to restrict the type parameter with *all* of them.
Before:
```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
--> $DIR/method-on-unbounded-type-param.rs:5:10
|
LL | (&a).cmp(&b)
| ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`T: Ord`
which is required by `&T: Ord`
`&T: Iterator`
which is required by `&mut &T: Iterator`
`T: Iterator`
which is required by `&mut T: Iterator`
help: consider restricting the type parameters to satisfy the trait bounds
|
LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord {
| +++++++++++++++++++++++++
```
After:
```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
--> $DIR/method-on-unbounded-type-param.rs:5:10
|
LL | (&a).cmp(&b)
| ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`T: Ord`
which is required by `&T: Ord`
`&T: Iterator`
which is required by `&mut &T: Iterator`
`T: Iterator`
which is required by `&mut T: Iterator`
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
|
LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
| +++++
LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
| ++++++++++
```
Fixrust-lang#108428.
Follow up to rust-lang#120396, only last commit is relevant.
Copy file name to clipboardExpand all lines: tests/ui/higher-ranked/trait-bounds/issue-30786.stderr
+12
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,12 @@ note: the following trait bounds were not satisfied:
15
15
|
16
16
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
17
17
| --------- - ^^^^^^ unsatisfied trait bound introduced here
18
+
= help: items from traits can only be used if the trait is implemented and in scope
19
+
note: `StreamExt` defines an item `filterx`, perhaps you need to implement it
20
+
--> $DIR/issue-30786.rs:66:1
21
+
|
22
+
LL | pub trait StreamExt
23
+
| ^^^^^^^^^^^^^^^^^^^
18
24
19
25
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, {closure@issue-30786.rs:131:30}>`, but its trait bounds were not satisfied
20
26
--> $DIR/issue-30786.rs:132:24
@@ -33,6 +39,12 @@ note: the following trait bounds were not satisfied:
33
39
|
34
40
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
35
41
| --------- - ^^^^^^ unsatisfied trait bound introduced here
42
+
= help: items from traits can only be used if the trait is implemented and in scope
43
+
note: `StreamExt` defines an item `countx`, perhaps you need to implement it
0 commit comments