1
Fork 0

Rollup merge of #100438 - compiler-errors:issue-100360, r=lcnr

Erase regions better in `promote_candidate`

Use `tcx.erase_regions` instead of manually walking through the substs.... this also makes the code slightly simpler 🙈

Fixes #100360
Fixes #89851
This commit is contained in:
Michael Goulet 2022-08-13 14:10:07 -07:00 committed by GitHub
commit 9ab54df8d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 7 deletions

View file

@ -839,17 +839,12 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
let mut promoted_operand = |ty, span| { let mut promoted_operand = |ty, span| {
promoted.span = span; promoted.span = span;
promoted.local_decls[RETURN_PLACE] = LocalDecl::new(ty, span); promoted.local_decls[RETURN_PLACE] = LocalDecl::new(ty, span);
let substs = tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def.did));
let _const = tcx.mk_const(ty::ConstS { let _const = tcx.mk_const(ty::ConstS {
ty, ty,
kind: ty::ConstKind::Unevaluated(ty::Unevaluated { kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
def, def,
substs: InternalSubsts::for_item(tcx, def.did, |param, _| { substs,
if let ty::GenericParamDefKind::Lifetime = param.kind {
tcx.lifetimes.re_erased.into()
} else {
tcx.mk_param_from_def(param)
}
}),
promoted: Some(promoted_id), promoted: Some(promoted_id),
}), }),
}); });

View file

@ -0,0 +1,13 @@
// check-pass
// (this requires debug assertions)
#![feature(adt_const_params)]
#![allow(incomplete_features)]
fn foo<const B: &'static bool>(arg: &'static bool) -> bool {
B == arg
}
fn main() {
foo::<{ &true }>(&false);
}

View file

@ -0,0 +1,12 @@
// check-pass
// (this requires debug assertions)
#![feature(adt_const_params)]
#![allow(incomplete_features)]
pub const BAR: () = ice::<"">();
pub const fn ice<const N: &'static str>() {
&10;
}
fn main() {}