1
Fork 0

Rollup merge of #124809 - lcnr:prepopulate-opaques, r=compiler-errors

borrowck: prepopulate opaque storage more eagerly

otherwise we ICE due to ambiguity when normalizing while computing implied bounds.

r? ``@compiler-errors``
This commit is contained in:
Matthias Krüger 2024-05-06 21:46:06 +02:00 committed by GitHub
commit 284b5530b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 115 additions and 165 deletions

View file

@ -236,7 +236,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
normalization_nested_goals,
} = external_constraints.deref();
self.register_region_constraints(region_constraints);
self.register_new_opaque_types(param_env, opaque_types);
self.register_new_opaque_types(opaque_types);
(normalization_nested_goals.clone(), certainty)
}
@ -368,13 +368,10 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
assert!(region_constraints.member_constraints.is_empty());
}
fn register_new_opaque_types(
&mut self,
param_env: ty::ParamEnv<'tcx>,
opaque_types: &[(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)],
) {
fn register_new_opaque_types(&mut self, opaque_types: &[(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)]) {
for &(key, ty) in opaque_types {
self.insert_hidden_type(key, param_env, ty).unwrap();
let hidden_ty = ty::OpaqueHiddenType { ty, span: DUMMY_SP };
self.infcx.inject_new_hidden_type_unchecked(key, hidden_ty);
}
}
}

View file

@ -248,8 +248,8 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
};
for &(key, ty) in &input.predefined_opaques_in_body.opaque_types {
ecx.insert_hidden_type(key, input.goal.param_env, ty)
.expect("failed to prepopulate opaque types");
let hidden_ty = ty::OpaqueHiddenType { ty, span: DUMMY_SP };
ecx.infcx.inject_new_hidden_type_unchecked(key, hidden_ty);
}
if !ecx.nested_goals.is_empty() {