about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-09-30 22:25:16 +1000
committerGitHub <noreply@github.com>2025-09-30 22:25:16 +1000
commit5a6ac8c322a95e9607d7dc9f5760a60ff44d2c9a (patch)
treeef1b237962540cb823e369e8c0b3dbe8900f571e /compiler
parent1aa426b335ba4b7414deea34e6ecf628469fd98f (diff)
parent401857aaa1e21df49e0d013b9856ab6dbe34870b (diff)
downloadrust-5a6ac8c322a95e9607d7dc9f5760a60ff44d2c9a.tar.gz
rust-5a6ac8c322a95e9607d7dc9f5760a60ff44d2c9a.zip
Rollup merge of #146649 - folkertdev:cmse-call-erase-regions, r=lcnr
cmse: fix 'region variables should not be hashed'

tracking issue: https://github.com/rust-lang/rust/issues/81391
fixes https://github.com/rust-lang/rust/issues/131639

Some background: the `cmse-nonsecure-call` calling convention is used for a call from "secure" to "non-secure" code. To make sure that "non-secure" cannot read any secrets, restrictions are put on the signatures of functions with this calling convention: they can only use 4 arguments for passing arguments, and one register for passing a result. No arguments are passed via the stack, and all other registers are cleared before the call.

We check during `hir_ty_lowering` that the signature follows these rules. We do that by determining and then inspecting the layout of the type. That works well overall, but can run into asserts when the type itself is ill-formed. This PR fixes one such case.

I believe that the fix here, just erasing the regions, is the right shape, but there may be some nuance that I'm missing.

r? types
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
index 0458fa1204e..0a41659ec66 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
@@ -134,6 +134,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))?;