Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erase regions better in promote_candidate #100438

Merged
merged 1 commit into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions compiler/rustc_const_eval/src/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,17 +839,12 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
let mut promoted_operand = |ty, span| {
promoted.span = 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 {
ty,
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
def,
substs: InternalSubsts::for_item(tcx, def.did, |param, _| {
if let ty::GenericParamDefKind::Lifetime = param.kind {
tcx.lifetimes.re_erased.into()
} else {
tcx.mk_param_from_def(param)
}
}),
substs,
promoted: Some(promoted_id),
}),
});
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/const-generics/generic_const_exprs/issue-100360.rs
Original file line number Diff line number Diff line change
@@ -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);
}
12 changes: 12 additions & 0 deletions src/test/ui/const-generics/generic_const_exprs/issue-89851.rs
Original file line number Diff line number Diff line change
@@ -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() {}