Skip to content

Commit 6146073

Browse files
committed
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 following other types implement trait `Foo`: Option<T> i32 str 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` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
1 parent 56eecd5 commit 6146073

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)