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