1
Fork 0

Auto merge of #104179 - Manishearth:rollup-yvsx5hh, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #100508 (avoid making substs of type aliases late bound when used as fn args)
 - #101381 (Test that target feature mix up with homogeneous floats is sound)
 - #103353 (Fix Access Violation when using lld & ThinLTO on windows-msvc)
 - #103521 (Avoid possible infinite  loop when next_point reaching the end of file)
 - #103559 (first move on a nested span_label)
 - #103778 (Update several crates for improved support of the new targets)
 - #103827 (Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-11-09 04:43:43 +00:00
commit 91385d5776
32 changed files with 759 additions and 84 deletions

View file

@ -2187,7 +2187,7 @@ fn confirm_impl_candidate<'cx, 'tcx>(
// Verify that the trait item and its implementation have compatible substs lists
fn check_substs_compatible<'tcx>(
tcx: TyCtxt<'tcx>,
assoc_ty: &ty::AssocItem,
assoc_item: &ty::AssocItem,
substs: ty::SubstsRef<'tcx>,
) -> bool {
fn check_substs_compatible_inner<'tcx>(
@ -2219,7 +2219,10 @@ fn check_substs_compatible<'tcx>(
true
}
check_substs_compatible_inner(tcx, tcx.generics_of(assoc_ty.def_id), substs.as_slice())
let generics = tcx.generics_of(assoc_item.def_id);
// Chop off any additional substs (RPITIT) substs
let substs = &substs[0..generics.count().min(substs.len())];
check_substs_compatible_inner(tcx, generics, substs)
}
fn confirm_impl_trait_in_trait_candidate<'tcx>(
@ -2248,11 +2251,27 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
};
}
let impl_fn_def_id = leaf_def.item.def_id;
// Rebase from {trait}::{fn}::{opaque} to {impl}::{fn}::{opaque},
// since `data.substs` are the impl substs.
let impl_fn_substs =
obligation.predicate.substs.rebase_onto(tcx, tcx.parent(trait_fn_def_id), data.substs);
let impl_fn_substs = translate_substs(
selcx.infcx(),
obligation.param_env,
data.impl_def_id,
impl_fn_substs,
leaf_def.defining_node,
);
if !check_substs_compatible(tcx, &leaf_def.item, impl_fn_substs) {
let err = tcx.ty_error_with_message(
obligation.cause.span,
"impl method and trait method have different parameters",
);
return Progress { term: err.into(), obligations };
}
let impl_fn_def_id = leaf_def.item.def_id;
let cause = ObligationCause::new(
obligation.cause.span,