rust/tests/ui/box/unit
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
..
expr-block-generic-unique1.rs
expr-block-generic-unique2.rs
expr-if-unique.rs
unique-assign-copy.rs
unique-assign-drop.rs
unique-assign-generic.rs
unique-assign.rs
unique-autoderef-field.rs
unique-autoderef-index.rs
unique-cmp.rs
unique-containing-tag.rs
unique-create.rs
unique-decl-init-copy.rs
unique-decl-init.rs
unique-decl-move.rs
unique-decl.rs
unique-deref.rs
unique-destructure.rs
unique-drop-complex.rs
unique-ffi-symbols.rs
unique-fn-arg-move.rs
unique-fn-arg-mut.rs
unique-fn-arg.rs
unique-fn-ret.rs
unique-generic-assign.rs
unique-in-tag.rs
unique-in-vec-copy.rs
unique-in-vec.rs
unique-init.rs
unique-kinds.rs remove redundant imports 2023-12-10 10:56:22 +08:00
unique-log.rs
unique-match-discrim.rs
unique-move-drop.rs
unique-move-temp.rs
unique-move.rs
unique-mutable.rs
unique-object-move.rs
unique-object-noncopyable.rs
unique-object-noncopyable.stderr Account for non-overlapping unmet trait bounds in suggestion 2024-01-30 19:26:13 +00:00
unique-pat-2.rs
unique-pat-3.rs
unique-pat.rs
unique-pinned-nocopy.rs
unique-pinned-nocopy.stderr Account for non-overlapping unmet trait bounds in suggestion 2024-01-30 19:26:13 +00:00
unique-rec.rs
unique-send-2.rs
unique-send.rs
unique-swap.rs
unwind-unique.rs