Skip to content

Commit 401857a

Browse files
committed
cmse: fix 'region variables should not be hashed'
1 parent 8a1b399 commit 401857a

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ fn is_valid_cmse_inputs<'tcx>(
128128

129129
// this type is only used for layout computation, which does not rely on regions
130130
let fn_sig = tcx.instantiate_bound_regions_with_erased(fn_sig);
131+
let fn_sig = tcx.erase_and_anonymize_regions(fn_sig);
131132

132133
for (index, ty) in fn_sig.inputs().iter().enumerate() {
133134
let layout = tcx.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(*ty))?;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ add-core-stubs
2+
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib -Cincremental=true
3+
//@ needs-llvm-components: arm
4+
#![feature(abi_cmse_nonsecure_call, no_core)]
5+
#![no_core]
6+
7+
extern crate minicore;
8+
use minicore::*;
9+
10+
// A regression test for https://github.com/rust-lang/rust/issues/131639.
11+
// NOTE: -Cincremental=true was required for triggering the bug.
12+
13+
fn foo() {
14+
id::<extern "cmse-nonsecure-call" fn(&'a ())>(PhantomData);
15+
//~^ ERROR use of undeclared lifetime name `'a`
16+
}
17+
18+
fn id<T>(x: PhantomData<T>) -> PhantomData<T> {
19+
x
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0261]: use of undeclared lifetime name `'a`
2+
--> $DIR/undeclared-lifetime.rs:14:43
3+
|
4+
LL | id::<extern "cmse-nonsecure-call" fn(&'a ())>(PhantomData);
5+
| ^^ undeclared lifetime
6+
|
7+
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
8+
help: consider making the type lifetime-generic with a new `'a` lifetime
9+
|
10+
LL | id::<for<'a> extern "cmse-nonsecure-call" fn(&'a ())>(PhantomData);
11+
| +++++++
12+
help: consider introducing lifetime `'a` here
13+
|
14+
LL | fn foo<'a>() {
15+
| ++++
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)