Descriptive error when users try to combine RPITIT/AFIT with specialization
This commit is contained in:
parent
6290ae92b2
commit
ecac8fd5af
7 changed files with 83 additions and 65 deletions
|
@ -1307,25 +1307,8 @@ fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>(
|
|||
let _ = selcx.infcx.commit_if_ok(|_| {
|
||||
match selcx.select(&obligation.with(tcx, trait_predicate)) {
|
||||
Ok(Some(super::ImplSource::UserDefined(data))) => {
|
||||
let Ok(leaf_def) = specialization_graph::assoc_def(tcx, data.impl_def_id, trait_fn_def_id) else {
|
||||
return Err(());
|
||||
};
|
||||
// Only reveal a specializable default if we're past type-checking
|
||||
// and the obligation is monomorphic, otherwise passes such as
|
||||
// transmute checking and polymorphic MIR optimizations could
|
||||
// get a result which isn't correct for all monomorphizations.
|
||||
if leaf_def.is_final()
|
||||
|| (obligation.param_env.reveal() == Reveal::All
|
||||
&& !selcx
|
||||
.infcx
|
||||
.resolve_vars_if_possible(obligation.predicate.trait_ref(tcx))
|
||||
.still_further_specializable())
|
||||
{
|
||||
candidate_set.push_candidate(ProjectionCandidate::ImplTraitInTrait(data));
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
candidate_set.push_candidate(ProjectionCandidate::ImplTraitInTrait(data));
|
||||
Ok(())
|
||||
}
|
||||
Ok(None) => {
|
||||
candidate_set.mark_ambiguous();
|
||||
|
@ -2216,7 +2199,8 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
|
|||
Ok(assoc_ty) => assoc_ty,
|
||||
Err(guar) => return Progress::error(tcx, guar),
|
||||
};
|
||||
if !leaf_def.item.defaultness(tcx).has_value() {
|
||||
// We don't support specialization for RPITITs anyways... yet.
|
||||
if !leaf_def.is_final() {
|
||||
return Progress { term: tcx.ty_error_misc().into(), obligations };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue