Auto merge of #59724 - oli-obk:const_arg_ice, r=eddyb
Function arguments should never get promoted fixes https://github.com/rust-lang/rust/issues/59469
This commit is contained in:
commit
3750348daf
7 changed files with 65 additions and 4 deletions
|
@ -639,7 +639,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
||||||
per_local.insert(local);
|
per_local.insert(local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cx.per_local[IsNotPromotable].insert(local);
|
cx.per_local[IsNotConst].insert(local);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalKind::Var if mode == Mode::Fn => {
|
LocalKind::Var if mode == Mode::Fn => {
|
||||||
|
@ -647,7 +647,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalKind::Temp if !temps[local].is_promotable() => {
|
LocalKind::Temp if !temps[local].is_promotable() => {
|
||||||
cx.per_local[IsNotPromotable].insert(local);
|
cx.per_local[IsNotConst].insert(local);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -817,7 +817,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the `IsNotPromotable` qualification is preserved.
|
// Ensure the `IsNotConst` qualification is preserved.
|
||||||
// NOTE(eddyb) this is actually unnecessary right now, as
|
// NOTE(eddyb) this is actually unnecessary right now, as
|
||||||
// we never replace the local's qualif, but we might in
|
// we never replace the local's qualif, but we might in
|
||||||
// the future, and so it serves to catch changes that unset
|
// the future, and so it serves to catch changes that unset
|
||||||
|
@ -825,7 +825,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
||||||
// be replaced with calling `insert` to re-set the bit).
|
// be replaced with calling `insert` to re-set the bit).
|
||||||
if kind == LocalKind::Temp {
|
if kind == LocalKind::Temp {
|
||||||
if !self.temp_promotion_state[index].is_promotable() {
|
if !self.temp_promotion_state[index].is_promotable() {
|
||||||
assert!(self.cx.per_local[IsNotPromotable].contains(index));
|
assert!(self.cx.per_local[IsNotConst].contains(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
src/test/ui/consts/const_arg_local.rs
Normal file
13
src/test/ui/consts/const_arg_local.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// only-x86_64
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86")]
|
||||||
|
use std::arch::x86::*;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use std::arch::x86_64::*;
|
||||||
|
|
||||||
|
unsafe fn pclmul(a: __m128i, b: __m128i) -> __m128i {
|
||||||
|
let imm8 = 3;
|
||||||
|
_mm_clmulepi64_si128(a, b, imm8) //~ ERROR argument 3 is required to be a constant
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
8
src/test/ui/consts/const_arg_local.stderr
Normal file
8
src/test/ui/consts/const_arg_local.stderr
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
error: argument 3 is required to be a constant
|
||||||
|
--> $DIR/const_arg_local.rs:10:5
|
||||||
|
|
|
||||||
|
LL | _mm_clmulepi64_si128(a, b, imm8)
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
12
src/test/ui/consts/const_arg_promotable.rs
Normal file
12
src/test/ui/consts/const_arg_promotable.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// only-x86_64
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86")]
|
||||||
|
use std::arch::x86::*;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use std::arch::x86_64::*;
|
||||||
|
|
||||||
|
unsafe fn pclmul(a: __m128i, b: __m128i) -> __m128i {
|
||||||
|
_mm_clmulepi64_si128(a, b, *&mut 42) //~ ERROR argument 3 is required to be a constant
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
8
src/test/ui/consts/const_arg_promotable.stderr
Normal file
8
src/test/ui/consts/const_arg_promotable.stderr
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
error: argument 3 is required to be a constant
|
||||||
|
--> $DIR/const_arg_promotable.rs:9:5
|
||||||
|
|
|
||||||
|
LL | _mm_clmulepi64_si128(a, b, *&mut 42)
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
12
src/test/ui/consts/const_arg_wrapper.rs
Normal file
12
src/test/ui/consts/const_arg_wrapper.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// only-x86_64
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86")]
|
||||||
|
use std::arch::x86::*;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use std::arch::x86_64::*;
|
||||||
|
|
||||||
|
unsafe fn pclmul(a: __m128i, b: __m128i, imm8: i32) -> __m128i {
|
||||||
|
_mm_clmulepi64_si128(a, b, imm8) //~ ERROR argument 3 is required to be a constant
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
8
src/test/ui/consts/const_arg_wrapper.stderr
Normal file
8
src/test/ui/consts/const_arg_wrapper.stderr
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
error: argument 3 is required to be a constant
|
||||||
|
--> $DIR/const_arg_wrapper.rs:9:5
|
||||||
|
|
|
||||||
|
LL | _mm_clmulepi64_si128(a, b, imm8)
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Add table
Reference in a new issue