Point at impl
and type defs introducing requirements on E0277
This commit is contained in:
parent
d326c218ef
commit
8bc5581978
55 changed files with 621 additions and 110 deletions
|
@ -2070,7 +2070,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
// Don't print the tuple of capture types
|
||||
if !is_upvar_tys_infer_tuple {
|
||||
err.note(&format!("required because it appears within the type `{}`", ty));
|
||||
let msg = format!("required because it appears within the type `{}`", ty);
|
||||
match ty.kind() {
|
||||
ty::Adt(def, _) => match self.tcx.item_name_from_hir(def.did) {
|
||||
Some(ident) => err.span_note(ident.span, &msg),
|
||||
None => err.note(&msg),
|
||||
},
|
||||
_ => err.note(&msg),
|
||||
};
|
||||
}
|
||||
|
||||
obligated_types.push(ty);
|
||||
|
@ -2092,11 +2099,36 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
ObligationCauseCode::ImplDerivedObligation(ref data) => {
|
||||
let mut parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_ref);
|
||||
let parent_def_id = parent_trait_ref.def_id();
|
||||
err.note(&format!(
|
||||
let msg = format!(
|
||||
"required because of the requirements on the impl of `{}` for `{}`",
|
||||
parent_trait_ref.print_only_trait_path(),
|
||||
parent_trait_ref.skip_binder().self_ty()
|
||||
));
|
||||
);
|
||||
let mut candidates = vec![];
|
||||
self.tcx.for_each_relevant_impl(
|
||||
parent_def_id,
|
||||
parent_trait_ref.self_ty().skip_binder(),
|
||||
|impl_def_id| {
|
||||
candidates.push(impl_def_id);
|
||||
},
|
||||
);
|
||||
match &candidates[..] {
|
||||
[def_id] => match self.tcx.hir().get_if_local(*def_id) {
|
||||
Some(Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Impl(hir::Impl { of_trait, self_ty, .. }),
|
||||
..
|
||||
})) => {
|
||||
let mut spans = Vec::with_capacity(2);
|
||||
if let Some(trait_ref) = of_trait {
|
||||
spans.push(trait_ref.path.span);
|
||||
}
|
||||
spans.push(self_ty.span);
|
||||
err.span_note(spans, &msg)
|
||||
}
|
||||
_ => err.note(&msg),
|
||||
},
|
||||
_ => err.note(&msg),
|
||||
};
|
||||
|
||||
let mut parent_predicate = parent_trait_ref.without_const().to_predicate(tcx);
|
||||
let mut data = data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue