mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 09:36:06 +00:00
af99946700
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. |
||
---|---|---|
.. | ||
auxiliary | ||
clone-debug-dead-code-in-the-same-struct.rs | ||
clone-debug-dead-code-in-the-same-struct.stderr | ||
clone-debug-dead-code.rs | ||
clone-debug-dead-code.stderr | ||
derive-assoc-type-not-impl.rs | ||
derive-assoc-type-not-impl.stderr | ||
derive-deadlock.rs | ||
derive-deadlock.stderr | ||
derive-Debug-use-ufcs-struct.rs | ||
derive-Debug-use-ufcs-tuple.rs | ||
derive-hygiene.rs | ||
derive-macro-const-default.rs | ||
derive-marker-tricky.rs | ||
derive-multiple-with-packed.rs | ||
derive-on-trait-item-or-impl-item.rs | ||
derive-on-trait-item-or-impl-item.stderr | ||
derive-partial-ord.rs | ||
derive-renamed.rs | ||
derives-span-Clone-enum-struct-variant.rs | ||
derives-span-Clone-enum-struct-variant.stderr | ||
derives-span-Clone-enum.rs | ||
derives-span-Clone-enum.stderr | ||
derives-span-Clone-struct.rs | ||
derives-span-Clone-struct.stderr | ||
derives-span-Clone-tuple-struct.rs | ||
derives-span-Clone-tuple-struct.stderr | ||
derives-span-Debug-enum-struct-variant.rs | ||
derives-span-Debug-enum-struct-variant.stderr | ||
derives-span-Debug-enum.rs | ||
derives-span-Debug-enum.stderr | ||
derives-span-Debug-struct.rs | ||
derives-span-Debug-struct.stderr | ||
derives-span-Debug-tuple-struct.rs | ||
derives-span-Debug-tuple-struct.stderr | ||
derives-span-Default-struct.rs | ||
derives-span-Default-struct.stderr | ||
derives-span-Default-tuple-struct.rs | ||
derives-span-Default-tuple-struct.stderr | ||
derives-span-Eq-enum-struct-variant.rs | ||
derives-span-Eq-enum-struct-variant.stderr | ||
derives-span-Eq-enum.rs | ||
derives-span-Eq-enum.stderr | ||
derives-span-Eq-struct.rs | ||
derives-span-Eq-struct.stderr | ||
derives-span-Eq-tuple-struct.rs | ||
derives-span-Eq-tuple-struct.stderr | ||
derives-span-Hash-enum-struct-variant.rs | ||
derives-span-Hash-enum-struct-variant.stderr | ||
derives-span-Hash-enum.rs | ||
derives-span-Hash-enum.stderr | ||
derives-span-Hash-struct.rs | ||
derives-span-Hash-struct.stderr | ||
derives-span-Hash-tuple-struct.rs | ||
derives-span-Hash-tuple-struct.stderr | ||
derives-span-Ord-enum-struct-variant.rs | ||
derives-span-Ord-enum-struct-variant.stderr | ||
derives-span-Ord-enum.rs | ||
derives-span-Ord-enum.stderr | ||
derives-span-Ord-struct.rs | ||
derives-span-Ord-struct.stderr | ||
derives-span-Ord-tuple-struct.rs | ||
derives-span-Ord-tuple-struct.stderr | ||
derives-span-PartialEq-enum-struct-variant.rs | ||
derives-span-PartialEq-enum-struct-variant.stderr | ||
derives-span-PartialEq-enum.rs | ||
derives-span-PartialEq-enum.stderr | ||
derives-span-PartialEq-struct.rs | ||
derives-span-PartialEq-struct.stderr | ||
derives-span-PartialEq-tuple-struct.rs | ||
derives-span-PartialEq-tuple-struct.stderr | ||
derives-span-PartialOrd-enum-struct-variant.rs | ||
derives-span-PartialOrd-enum-struct-variant.stderr | ||
derives-span-PartialOrd-enum.rs | ||
derives-span-PartialOrd-enum.stderr | ||
derives-span-PartialOrd-struct.rs | ||
derives-span-PartialOrd-struct.stderr | ||
derives-span-PartialOrd-tuple-struct.rs | ||
derives-span-PartialOrd-tuple-struct.stderr | ||
deriving-bounds.rs | ||
deriving-bounds.stderr | ||
deriving-copyclone.rs | ||
deriving-copyclone.stderr | ||
deriving-meta-empty-trait-list.rs | ||
deriving-meta-unknown-trait.rs | ||
deriving-meta-unknown-trait.stderr | ||
deriving-no-inner-impl-error-message.rs | ||
deriving-no-inner-impl-error-message.stderr | ||
deriving-non-type.rs | ||
deriving-non-type.stderr | ||
deriving-primitive.rs | ||
deriving-primitive.stderr | ||
deriving-with-repr-packed-2.rs | ||
deriving-with-repr-packed-2.stderr | ||
deriving-with-repr-packed-move-errors.rs | ||
deriving-with-repr-packed-move-errors.stderr | ||
deriving-with-repr-packed.rs | ||
deriving-with-repr-packed.stderr | ||
issue-36617.rs | ||
issue-36617.stderr | ||
issue-43023.rs | ||
issue-43023.stderr | ||
issue-91492.rs | ||
issue-91492.stderr | ||
issue-91550.rs | ||
issue-91550.stderr | ||
issue-97343.rs | ||
issue-97343.stderr |