Skip to content

Commit b945b2c

Browse files
authored
Rollup merge of rust-lang#91873 - estebank:mention-impls-for-unsatisfied-trait, r=davidtwco
Mention implementers of unsatisfied trait When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the trait `Foo` is implemented for `i32` note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` ``` error[E0277]: the trait bound `u32: Foo` is not satisfied --> $DIR/associated-types-path-2.rs:29:5 | LL | f1(2u32, 4u32); | ^^ the trait `Foo` is not implemented for `u32` | = help: the trait `Foo` is implemented for `i32` note: required by a bound in `f1` --> $DIR/associated-types-path-2.rs:13:14 | LL | pub fn f1<T: Foo>(a: T, x: T::A) {} | ^^^ required by this bound in `f1` ``` Suggest dereferencing in more cases. Fix rust-lang#87437, fix rust-lang#90970.
2 parents 2382259 + 6146073 commit b945b2c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

core/src/ops/function.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
/// ```
5454
#[lang = "fn"]
5555
#[stable(feature = "rust1", since = "1.0.0")]
56+
#[rustc_diagnostic_item = "Fn"]
5657
#[rustc_paren_sugar]
5758
#[rustc_on_unimplemented(
5859
on(
@@ -133,6 +134,7 @@ pub trait Fn<Args>: FnMut<Args> {
133134
/// ```
134135
#[lang = "fn_mut"]
135136
#[stable(feature = "rust1", since = "1.0.0")]
137+
#[rustc_diagnostic_item = "FnMut"]
136138
#[rustc_paren_sugar]
137139
#[rustc_on_unimplemented(
138140
on(
@@ -205,6 +207,7 @@ pub trait FnMut<Args>: FnOnce<Args> {
205207
/// ```
206208
#[lang = "fn_once"]
207209
#[stable(feature = "rust1", since = "1.0.0")]
210+
#[rustc_diagnostic_item = "FnOnce"]
208211
#[rustc_paren_sugar]
209212
#[rustc_on_unimplemented(
210213
on(

core/src/slice/index.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ mod private_slice_index {
140140
/// Implementations of this trait have to promise that if the argument
141141
/// to `get_(mut_)unchecked` is a safe reference, then so is the result.
142142
#[stable(feature = "slice_get_slice", since = "1.28.0")]
143+
#[rustc_diagnostic_item = "SliceIndex"]
143144
#[rustc_on_unimplemented(
144145
on(T = "str", label = "string indices are ranges of `usize`",),
145146
on(

0 commit comments

Comments
 (0)