Skip to content

Commit 65a45dd

Browse files
committed
Add more regression tests for accidental promotion
1 parent 1f40580 commit 65a45dd

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

src/librustc_mir/transform/qualify_consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
647647
}
648648

649649
LocalKind::Temp if !temps[local].is_promotable() => {
650-
cx.per_local[IsNotPromotable].insert(local);
650+
cx.per_local[IsNotConst].insert(local);
651651
}
652652

653653
_ => {}
@@ -825,7 +825,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
825825
// be replaced with calling `insert` to re-set the bit).
826826
if kind == LocalKind::Temp {
827827
if !self.temp_promotion_state[index].is_promotable() {
828-
assert!(self.cx.per_local[IsNotPromotable].contains(index));
828+
assert!(self.cx.per_local[IsNotConst].contains(index));
829829
}
830830
}
831831
}

src/test/ui/consts/const_arg_local.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[cfg(target_arch = "x86")]
2+
use std::arch::x86::*;
3+
#[cfg(target_arch = "x86_64")]
4+
use std::arch::x86_64::*;
5+
6+
unsafe fn pclmul(a: __m128i, b: __m128i) -> __m128i {
7+
let imm8 = 3;
8+
_mm_clmulepi64_si128(a, b, imm8) //~ ERROR argument 3 is required to be a constant
9+
}
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: argument 3 is required to be a constant
2+
--> $DIR/const_arg_local.rs:8:5
3+
|
4+
LL | _mm_clmulepi64_si128(a, b, imm8)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[cfg(target_arch = "x86")]
2+
use std::arch::x86::*;
3+
#[cfg(target_arch = "x86_64")]
4+
use std::arch::x86_64::*;
5+
6+
unsafe fn pclmul(a: __m128i, b: __m128i) -> __m128i {
7+
_mm_clmulepi64_si128(a, b, *&mut 42) //~ ERROR argument 3 is required to be a constant
8+
}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: argument 3 is required to be a constant
2+
--> $DIR/const_arg_promotable.rs:7:5
3+
|
4+
LL | _mm_clmulepi64_si128(a, b, *&mut 42)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)