Skip to content
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
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ fn is_valid_cmse_inputs<'tcx>(

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

for (index, ty) in fn_sig.inputs().iter().enumerate() {
let layout = tcx.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(*ty))?;
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-call/undeclared-lifetime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ add-core-stubs
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib -Cincremental=true
//@ needs-llvm-components: arm
#![feature(abi_cmse_nonsecure_call, no_core)]
#![no_core]

extern crate minicore;
use minicore::*;

// A regression test for https://github.com/rust-lang/rust/issues/131639.
// NOTE: -Cincremental=true was required for triggering the bug.

fn foo() {
id::<extern "cmse-nonsecure-call" fn(&'a ())>(PhantomData);
//~^ ERROR use of undeclared lifetime name `'a`
}

fn id<T>(x: PhantomData<T>) -> PhantomData<T> {
x
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/undeclared-lifetime.rs:14:43
|
LL | id::<extern "cmse-nonsecure-call" fn(&'a ())>(PhantomData);
| ^^ undeclared lifetime
|
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the type lifetime-generic with a new `'a` lifetime
|
LL | id::<for<'a> extern "cmse-nonsecure-call" fn(&'a ())>(PhantomData);
| +++++++
help: consider introducing lifetime `'a` here
|
LL | fn foo<'a>() {
| ++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0261`.
Loading