1
Fork 0

Rollup merge of #103276 - compiler-errors:default-on-uninit-ice, r=TaKO8Ki

Erase regions before checking for `Default` in uninitialized binding error

Fixes #103250
This commit is contained in:
Matthias Krüger 2022-10-20 07:58:58 +02:00 committed by GitHub
commit e29ecb70af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 2 deletions

View file

@ -492,10 +492,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let Some(default_trait) = tcx.get_diagnostic_item(sym::Default) else {
return false;
};
// Regions are already solved, so we must use a fresh InferCtxt,
// but the type has region variables, so erase those.
tcx.infer_ctxt()
.build()
.type_implements_trait(default_trait, ty, ty::List::empty(), param_env)
.may_apply()
.type_implements_trait(
default_trait,
tcx.erase_regions(ty),
ty::List::empty(),
param_env,
)
.must_apply_modulo_regions()
};
let assign_value = match ty.kind() {