rust/tests/ui/box
Esteban Küber 5c414094ac 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.
2024-01-30 19:26:13 +00:00
..
unit Account for non-overlapping unmet trait bounds in suggestion 2024-01-30 19:26:13 +00:00
alloc-unstable-fail.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
alloc-unstable-fail.stderr Bless tests 2024-01-13 12:46:58 -05:00
alloc-unstable.rs remove redundant imports 2023-12-10 10:56:22 +08:00
into-boxed-slice-fail.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
into-boxed-slice-fail.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
into-boxed-slice.rs remove redundant imports 2023-12-10 10:56:22 +08:00
issue-82446.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-82446.stderr recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05:00
issue-95036.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
large-allocator-ice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
leak-alloc.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
leak-alloc.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
new-box-syntax.rs remove redundant imports 2023-12-10 10:56:22 +08:00
new-box.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
new.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
thin_align.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
thin_drop.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
thin_new.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
thin_zst.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00