Skip to content

Commit 3750348

Browse files
committed
Auto merge of #59724 - oli-obk:const_arg_ice, r=eddyb
Function arguments should never get promoted fixes #59469
2 parents 474e7a6 + 01e8394 commit 3750348

7 files changed

+65
-4
lines changed

src/librustc_mir/transform/qualify_consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -639,15 +639,15 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
639639
per_local.insert(local);
640640
}
641641
}
642-
cx.per_local[IsNotPromotable].insert(local);
642+
cx.per_local[IsNotConst].insert(local);
643643
}
644644

645645
LocalKind::Var if mode == Mode::Fn => {
646646
cx.per_local[IsNotConst].insert(local);
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
_ => {}
@@ -817,15 +817,15 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
817817
}
818818
}
819819

820-
// Ensure the `IsNotPromotable` qualification is preserved.
820+
// Ensure the `IsNotConst` qualification is preserved.
821821
// NOTE(eddyb) this is actually unnecessary right now, as
822822
// we never replace the local's qualif, but we might in
823823
// the future, and so it serves to catch changes that unset
824824
// important bits (in which case, asserting `contains` could
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

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

0 commit comments

Comments
 (0)