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 `?`.
This commit is contained in:
parent
6a9080b25e
commit
3aac307ca6
115 changed files with 690 additions and 183 deletions
|
@ -41,7 +41,7 @@ use rustc_hir::Node;
|
|||
use rustc_macros::HashStable;
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
use rustc_session::cstore::CrateStoreDyn;
|
||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::Align;
|
||||
|
||||
|
@ -2206,7 +2206,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.impl_trait_ref(def_id).map(|tr| tr.def_id)
|
||||
}
|
||||
|
||||
/// If the given defid describes a method belonging to an impl, returns the
|
||||
/// If the given `DefId` describes a method belonging to an impl, returns the
|
||||
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
|
||||
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
|
||||
self.opt_associated_item(def_id).and_then(|trait_item| match trait_item.container {
|
||||
|
@ -2215,6 +2215,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
/// If the given `DefId` belongs to a trait that was automatically derived, returns `true`.
|
||||
pub fn is_builtin_derive(self, def_id: DefId) -> bool {
|
||||
self.has_attr(def_id, sym::automatically_derived)
|
||||
}
|
||||
|
||||
/// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
|
||||
/// with the name of the crate containing the impl.
|
||||
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue