mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 16:57:03 +00:00
5c414094ac
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.
27 lines
979 B
Plaintext
27 lines
979 B
Plaintext
error[E0599]: the method `clone` exists for struct `Bar<NotClone>`, but its trait bounds were not satisfied
|
|
--> $DIR/derive-assoc-type-not-impl.rs:18:30
|
|
|
|
|
LL | struct Bar<T: Foo> {
|
|
| ------------------ method `clone` not found for this struct because it doesn't satisfy `Bar<NotClone>: Clone`
|
|
...
|
|
LL | struct NotClone;
|
|
| --------------- doesn't satisfy `NotClone: Clone`
|
|
...
|
|
LL | Bar::<NotClone> { x: 1 }.clone();
|
|
| ^^^^^ method cannot be called on `Bar<NotClone>` due to unsatisfied trait bounds
|
|
|
|
|
note: trait bound `NotClone: Clone` was not satisfied
|
|
--> $DIR/derive-assoc-type-not-impl.rs:6:10
|
|
|
|
|
LL | #[derive(Clone)]
|
|
| ^^^^^ unsatisfied trait bound introduced in this `derive` macro
|
|
help: consider annotating `NotClone` with `#[derive(Clone)]`
|
|
|
|
|
LL + #[derive(Clone)]
|
|
LL | struct NotClone;
|
|
|
|
|
|
|
error: aborting due to 1 previous error
|
|
|
|
For more information about this error, try `rustc --explain E0599`.
|