diff options
| author | Michael Goulet <michael@errs.io> | 2023-02-28 02:03:26 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-02-28 02:03:43 +0000 |
| commit | ecac8fd5afbb4ca8a98f8b0d3b547608e04cfc44 (patch) | |
| tree | 43e93cb3e088c8affc4a5763a4168fe31556317f /compiler/rustc_trait_selection/src | |
| parent | 6290ae92b2df2bfff09abdcb80a3aa483692bab6 (diff) | |
| download | rust-ecac8fd5afbb4ca8a98f8b0d3b547608e04cfc44.tar.gz rust-ecac8fd5afbb4ca8a98f8b0d3b547608e04cfc44.zip | |
Descriptive error when users try to combine RPITIT/AFIT with specialization
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/project.rs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index d542240be9b..013db2edb39 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -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 }; } |
