Consider lifetimes when comparing assoc types in method chain

Do not say "Type changed to X here" when the only difference is caused
by lifetimes.
This commit is contained in:
Esteban Küber 2022-12-13 18:00:24 -08:00
parent 3b938f73f3
commit 2492235c32
3 changed files with 44 additions and 14 deletions

View file

@ -3333,7 +3333,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let ty_str = with_forced_trimmed_paths!(self.ty_to_string(ty));
let assoc = with_forced_trimmed_paths!(self.tcx.def_path_str(assoc));
if ty != *prev_ty {
if self.can_eq(param_env, ty, *prev_ty).is_err() {
if type_diffs.iter().any(|diff| {
let Sorts(expected_found) = diff else { return false; };
self.can_eq(param_env, expected_found.found, ty).is_ok()