1
Fork 0

Auto merge of #85596 - scottmcm:more-on-unimplemented, r=estebank

Extend `rustc_on_implemented` to improve more `?` error messages

`_Self` could match the generic definition; this adds that functionality for matching the generic definition of type parameters too.

Your advice welcome on the wording of all these messages, and which things belong in the message/label/note.

r? `@estebank`
This commit is contained in:
bors 2021-05-24 15:24:38 +00:00
commit ef0ec303fa
5 changed files with 47 additions and 15 deletions

View file

@ -186,6 +186,15 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
};
let name = param.name;
flags.push((name, Some(value)));
if let GenericParamDefKind::Type { .. } = param.kind {
let param_ty = trait_ref.substs[param.index as usize].expect_ty();
if let Some(def) = param_ty.ty_adt_def() {
// We also want to be able to select the parameter's
// original signature with no type arguments resolved
flags.push((name, Some(self.tcx.type_of(def.did).to_string())));
}
}
}
if let Some(true) = self_ty.ty_adt_def().map(|def| def.did.is_local()) {