diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-06 22:45:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-06 22:45:42 +0100 |
| commit | af9994670011e826fa10848d9477e86caca5ae44 (patch) | |
| tree | 02b1241465c456fc3a82ceab64cc2c36d49f4539 /compiler/rustc_pattern_analysis/src | |
| parent | 59ba8024af9d216b2831b0b3e375084868fa5c23 (diff) | |
| parent | 5c414094ac8d41038819dd982403f4e3de05d93c (diff) | |
| download | rust-af9994670011e826fa10848d9477e86caca5ae44.tar.gz rust-af9994670011e826fa10848d9477e86caca5ae44.zip | |
Rollup merge of #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 {
| ++++++++++
```
Fix #108428.
Follow up to #120396, only last commit is relevant.
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions
