Skip to content

Commit 9ee38f2

Browse files
committed
Auto merge of #152923 - ShoyuVanilla:builtin-object-proj-wf, r=<try>
WF check normalized assoc types when considerting builtin object boun…
2 parents 59fd4ef + a44de55 commit 9ee38f2

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
2626
use crate::traits::util::{self, closure_trait_ref_and_return_type};
2727
use crate::traits::{
2828
ImplSource, ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause,
29-
PolyTraitObligation, PredicateObligation, Selection, SelectionError, TraitObligation,
29+
PolyTraitObligation, PredicateObligation, Selection, SelectionError, TraitObligation, wf,
3030
};
3131

3232
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
@@ -587,6 +587,29 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
587587
);
588588
nested.push(obligation.with(tcx, normalized_bound));
589589
}
590+
591+
// The above only ensures that the normalized assoc type meets the bounds.
592+
// Check well-formedness of itself as well.
593+
let normalized_assoc_type = normalize_with_depth_to(
594+
self,
595+
obligation.param_env,
596+
obligation.cause.clone(),
597+
obligation.recursion_depth + 1,
598+
Ty::new_projection(tcx, assoc_type, trait_predicate.trait_ref.args),
599+
&mut nested,
600+
);
601+
nested.extend(
602+
wf::obligations(
603+
self.infcx,
604+
obligation.param_env,
605+
obligation.cause.body_id,
606+
obligation.recursion_depth + 1,
607+
normalized_assoc_type.into(),
608+
obligation.cause.span,
609+
)
610+
.into_iter()
611+
.flatten(),
612+
);
590613
}
591614

592615
debug!(?nested, "object nested obligations");

0 commit comments

Comments
 (0)