diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index d91a118bc71a3..94a22d2893e10 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -240,13 +240,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if let OperandValueKind::Immediate(to_scalar) = cast_kind && from_scalar.size(self.cx) == to_scalar.size(self.cx) { - let from_backend_ty = bx.backend_type(operand.layout); let to_backend_ty = bx.backend_type(cast); Some(OperandValue::Immediate(self.transmute_immediate( bx, imm, from_scalar, - from_backend_ty, to_scalar, to_backend_ty, ))) @@ -262,13 +260,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { && in_a.size(self.cx) == out_a.size(self.cx) && in_b.size(self.cx) == out_b.size(self.cx) { - let in_a_ibty = bx.scalar_pair_element_backend_type(operand.layout, 0, false); - let in_b_ibty = bx.scalar_pair_element_backend_type(operand.layout, 1, false); let out_a_ibty = bx.scalar_pair_element_backend_type(cast, 0, false); let out_b_ibty = bx.scalar_pair_element_backend_type(cast, 1, false); Some(OperandValue::Pair( - self.transmute_immediate(bx, imm_a, in_a, in_a_ibty, out_a, out_a_ibty), - self.transmute_immediate(bx, imm_b, in_b, in_b_ibty, out_b, out_b_ibty), + self.transmute_immediate(bx, imm_a, in_a, out_a, out_a_ibty), + self.transmute_immediate(bx, imm_b, in_b, out_b, out_b_ibty), )) } else { None @@ -292,12 +288,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ) -> Option { use abi::Primitive::*; - // When scalars are passed by value, there's no metadata recording their - // valid ranges. For example, `char`s are passed as just `i32`, with no - // way for LLVM to know that they're 0x10FFFF at most. Thus we assume - // the range of the input value too, not just the output range. - self.assume_scalar_range(bx, imm, from_scalar, from_backend_ty); - imm = match (from_scalar.primitive(), to_scalar.primitive()) { (Int(_, is_signed), Int(..)) => bx.intcast(imm, to_backend_ty, is_signed), (Float(_), Float(_)) => { @@ -339,21 +329,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx: &mut Bx, mut imm: Bx::Value, from_scalar: abi::Scalar, - from_backend_ty: Bx::Type, to_scalar: abi::Scalar, to_backend_ty: Bx::Type, ) -> Bx::Value { + use abi::Primitive::*; + assert_eq!(from_scalar.size(self.cx), to_scalar.size(self.cx)); - use abi::Primitive::*; imm = bx.from_immediate(imm); - // When scalars are passed by value, there's no metadata recording their - // valid ranges. For example, `char`s are passed as just `i32`, with no - // way for LLVM to know that they're 0x10FFFF at most. Thus we assume - // the range of the input value too, not just the output range. - self.assume_scalar_range(bx, imm, from_scalar, from_backend_ty); - imm = match (from_scalar.primitive(), to_scalar.primitive()) { (Int(..) | Float(_), Int(..) | Float(_)) => bx.bitcast(imm, to_backend_ty), (Pointer(..), Pointer(..)) => bx.pointercast(imm, to_backend_ty), @@ -368,55 +352,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.bitcast(int_imm, to_backend_ty) } }; - self.assume_scalar_range(bx, imm, to_scalar, to_backend_ty); imm = bx.to_immediate_scalar(imm, to_scalar); imm } - fn assume_scalar_range( - &self, - bx: &mut Bx, - imm: Bx::Value, - scalar: abi::Scalar, - backend_ty: Bx::Type, - ) { - if matches!(self.cx.sess().opts.optimize, OptLevel::No | OptLevel::Less) - // For now, the critical niches are all over `Int`eger values. - // Should floating-point values or pointers ever get more complex - // niches, then this code will probably want to handle them too. - || !matches!(scalar.primitive(), abi::Primitive::Int(..)) - || scalar.is_always_valid(self.cx) - { - return; - } - - let abi::WrappingRange { start, end } = scalar.valid_range(self.cx); - - if start <= end { - if start > 0 { - let low = bx.const_uint_big(backend_ty, start); - let cmp = bx.icmp(IntPredicate::IntUGE, imm, low); - bx.assume(cmp); - } - - let type_max = scalar.size(self.cx).unsigned_int_max(); - if end < type_max { - let high = bx.const_uint_big(backend_ty, end); - let cmp = bx.icmp(IntPredicate::IntULE, imm, high); - bx.assume(cmp); - } - } else { - let low = bx.const_uint_big(backend_ty, start); - let cmp_low = bx.icmp(IntPredicate::IntUGE, imm, low); - - let high = bx.const_uint_big(backend_ty, end); - let cmp_high = bx.icmp(IntPredicate::IntULE, imm, high); - - let or = bx.or(cmp_low, cmp_high); - bx.assume(or); - } - } - pub fn codegen_rvalue_unsized( &mut self, bx: &mut Bx, diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 379d2140c09c5..32725ef375bf0 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -8,12 +8,11 @@ use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::*; use rustc_middle::thir::*; use rustc_middle::ty::cast::{mir_cast_kind, CastTy}; -use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, Ty, UpvarArgs}; use rustc_span::source_map::Spanned; use rustc_span::{Span, DUMMY_SP}; -use rustc_target::abi::{Abi, FieldIdx, Primitive}; +use rustc_target::abi::FieldIdx; use tracing::debug; use crate::build::expr::as_place::PlaceBase; @@ -201,7 +200,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { { let discr_ty = adt_def.repr().discr_type().to_ty(this.tcx); let temp = unpack!(block = this.as_temp(block, scope, source, Mutability::Not)); - let layout = this.tcx.layout_of(this.param_env.and(source_expr.ty)); let discr = this.temp(discr_ty, source_expr.span); this.cfg.push_assign( block, @@ -209,77 +207,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { discr, Rvalue::Discriminant(temp.into()), ); - let (op, ty) = (Operand::Move(discr), discr_ty); - - if let Abi::Scalar(scalar) = layout.unwrap().abi - && !scalar.is_always_valid(&this.tcx) - && let Primitive::Int(int_width, _signed) = scalar.primitive() - { - let unsigned_ty = int_width.to_ty(this.tcx, false); - let unsigned_place = this.temp(unsigned_ty, expr_span); - this.cfg.push_assign( - block, - source_info, - unsigned_place, - Rvalue::Cast(CastKind::IntToInt, Operand::Copy(discr), unsigned_ty), - ); - - let bool_ty = this.tcx.types.bool; - let range = scalar.valid_range(&this.tcx); - let merge_op = - if range.start <= range.end { BinOp::BitAnd } else { BinOp::BitOr }; - - let mut comparer = |range: u128, bin_op: BinOp| -> Place<'tcx> { - let range_val = Const::from_bits( - this.tcx, - range, - ty::ParamEnv::empty().and(unsigned_ty), - ); - let lit_op = this.literal_operand(expr.span, range_val); - let is_bin_op = this.temp(bool_ty, expr_span); - this.cfg.push_assign( - block, - source_info, - is_bin_op, - Rvalue::BinaryOp( - bin_op, - Box::new((Operand::Copy(unsigned_place), lit_op)), - ), - ); - is_bin_op - }; - let assert_place = if range.start == 0 { - comparer(range.end, BinOp::Le) - } else { - let start_place = comparer(range.start, BinOp::Ge); - let end_place = comparer(range.end, BinOp::Le); - let merge_place = this.temp(bool_ty, expr_span); - this.cfg.push_assign( - block, - source_info, - merge_place, - Rvalue::BinaryOp( - merge_op, - Box::new(( - Operand::Move(start_place), - Operand::Move(end_place), - )), - ), - ); - merge_place - }; - this.cfg.push( - block, - Statement { - source_info, - kind: StatementKind::Intrinsic(Box::new( - NonDivergingIntrinsic::Assume(Operand::Move(assert_place)), - )), - }, - ); - } - - (op, ty) + (Operand::Move(discr), discr_ty) } else { let ty = source_expr.ty; let source = unpack!( diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index 5731097770481..92840010250da 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -3628,7 +3628,6 @@ ui/regions/issue-56537-closure-uses-region-from-container.rs ui/regions/issue-6157.rs ui/regions/issue-72051-member-region-hang.rs ui/regions/issue-78262.rs -ui/repr/issue-83505-repr-simd.rs ui/resolve/auxiliary/issue-112831-aux.rs ui/resolve/auxiliary/issue-19452-aux.rs ui/resolve/auxiliary/issue-21221-3.rs diff --git a/tests/codegen/cast-optimized.rs b/tests/codegen/cast-optimized.rs index 59cf40935cd54..f5dddfd7b4dd0 100644 --- a/tests/codegen/cast-optimized.rs +++ b/tests/codegen/cast-optimized.rs @@ -1,4 +1,5 @@ //@ compile-flags: -O -Z merge-functions=disabled +//@ min-llvm-version: 19 #![crate_type = "lib"] // This tests that LLVM can optimize based on the niches in the source or diff --git a/tests/codegen/enum/enum-bounds-check-derived-idx.rs b/tests/codegen/enum/enum-bounds-check-derived-idx.rs index 15280cb2e6c87..b6e6411fedcd3 100644 --- a/tests/codegen/enum/enum-bounds-check-derived-idx.rs +++ b/tests/codegen/enum/enum-bounds-check-derived-idx.rs @@ -1,6 +1,7 @@ // This test checks an optimization that is not guaranteed to work. This test case should not block // a future LLVM update. //@ compile-flags: -O +//@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-bounds-check-issue-13926.rs b/tests/codegen/enum/enum-bounds-check-issue-13926.rs index b60ff38ce392c..9b2eaeff48cb4 100644 --- a/tests/codegen/enum/enum-bounds-check-issue-13926.rs +++ b/tests/codegen/enum/enum-bounds-check-issue-13926.rs @@ -1,6 +1,7 @@ // This test checks an optimization that is not guaranteed to work. This test case should not block // a future LLVM update. //@ compile-flags: -O +//@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-bounds-check.rs b/tests/codegen/enum/enum-bounds-check.rs index c44c007ed6a9f..013a5782851a7 100644 --- a/tests/codegen/enum/enum-bounds-check.rs +++ b/tests/codegen/enum/enum-bounds-check.rs @@ -1,4 +1,5 @@ //@ compile-flags: -O +//@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/transmute-niched.rs b/tests/codegen/intrinsics/transmute-niched.rs index f5b7bd2efea8e..46b013a2919c8 100644 --- a/tests/codegen/intrinsics/transmute-niched.rs +++ b/tests/codegen/intrinsics/transmute-niched.rs @@ -1,7 +1,5 @@ -//@ revisions: OPT DBG -//@ [OPT] compile-flags: -C opt-level=3 -C no-prepopulate-passes -//@ [DBG] compile-flags: -C opt-level=0 -C no-prepopulate-passes -//@ only-64bit (so I don't need to worry about usize) +//@ compile-flags: -C opt-level=3 -C no-prepopulate-passes +//@ min-llvm-version: 19 #![crate_type = "lib"] use std::mem::transmute; @@ -14,59 +12,27 @@ pub enum SmallEnum { C = 12, } -// CHECK-LABEL: @check_to_enum( +// CHECK: noundef range(i8 10, 13) i8 @check_to_enum( #[no_mangle] pub unsafe fn check_to_enum(x: i8) -> SmallEnum { - // OPT: %0 = icmp uge i8 %x, 10 - // OPT: call void @llvm.assume(i1 %0) - // OPT: %1 = icmp ule i8 %x, 12 - // OPT: call void @llvm.assume(i1 %1) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: ret i8 %x - transmute(x) } -// CHECK-LABEL: @check_from_enum( +// CHECK: @check_from_enum(i8 noundef range(i8 10, 13) %x) #[no_mangle] pub unsafe fn check_from_enum(x: SmallEnum) -> i8 { - // OPT: %0 = icmp uge i8 %x, 10 - // OPT: call void @llvm.assume(i1 %0) - // OPT: %1 = icmp ule i8 %x, 12 - // OPT: call void @llvm.assume(i1 %1) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: ret i8 %x - transmute(x) } -// CHECK-LABEL: @check_to_ordering( +// CHECK: noundef range(i8 -1, 2) i8 @check_to_ordering( #[no_mangle] pub unsafe fn check_to_ordering(x: u8) -> std::cmp::Ordering { - // OPT: %0 = icmp uge i8 %x, -1 - // OPT: %1 = icmp ule i8 %x, 1 - // OPT: %2 = or i1 %0, %1 - // OPT: call void @llvm.assume(i1 %2) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: ret i8 %x - transmute(x) } -// CHECK-LABEL: @check_from_ordering( +// CHECK: @check_from_ordering(i8 noundef range(i8 -1, 2) %x) #[no_mangle] pub unsafe fn check_from_ordering(x: std::cmp::Ordering) -> u8 { - // OPT: %0 = icmp uge i8 %x, -1 - // OPT: %1 = icmp ule i8 %x, 1 - // OPT: %2 = or i1 %0, %1 - // OPT: call void @llvm.assume(i1 %2) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: ret i8 %x - transmute(x) } @@ -95,88 +61,32 @@ pub enum Minus100ToPlus100 { U = 100, } -// CHECK-LABEL: @check_enum_from_char( +// CHECK: noundef range(i32 -100, 101) i32 @check_enum_from_char(i32 noundef range(i32 0, 1114112) %x) #[no_mangle] pub unsafe fn check_enum_from_char(x: char) -> Minus100ToPlus100 { - // OPT: %0 = icmp ule i32 %x, 1114111 - // OPT: call void @llvm.assume(i1 %0) - // OPT: %1 = icmp uge i32 %x, -100 - // OPT: %2 = icmp ule i32 %x, 100 - // OPT: %3 = or i1 %1, %2 - // OPT: call void @llvm.assume(i1 %3) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: ret i32 %x - transmute(x) } -// CHECK-LABEL: @check_enum_to_char( +// CHECK: noundef range(i32 0, 1114112) i32 @check_enum_to_char(i32 noundef range(i32 -100, 101) %x) #[no_mangle] pub unsafe fn check_enum_to_char(x: Minus100ToPlus100) -> char { - // OPT: %0 = icmp uge i32 %x, -100 - // OPT: %1 = icmp ule i32 %x, 100 - // OPT: %2 = or i1 %0, %1 - // OPT: call void @llvm.assume(i1 %2) - // OPT: %3 = icmp ule i32 %x, 1114111 - // OPT: call void @llvm.assume(i1 %3) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: ret i32 %x - transmute(x) } -// CHECK-LABEL: @check_swap_pair( +// CHECK: @check_swap_pair(i32 noundef range(i32 0, 1114112) %x.0, i32 noundef range(i32 1, 0) %x.1) #[no_mangle] pub unsafe fn check_swap_pair(x: (char, NonZero)) -> (NonZero, char) { - // OPT: %0 = icmp ule i32 %x.0, 1114111 - // OPT: call void @llvm.assume(i1 %0) - // OPT: %1 = icmp uge i32 %x.0, 1 - // OPT: call void @llvm.assume(i1 %1) - // OPT: %2 = icmp uge i32 %x.1, 1 - // OPT: call void @llvm.assume(i1 %2) - // OPT: %3 = icmp ule i32 %x.1, 1114111 - // OPT: call void @llvm.assume(i1 %3) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: %[[P1:.+]] = insertvalue { i32, i32 } poison, i32 %x.0, 0 - // CHECK: %[[P2:.+]] = insertvalue { i32, i32 } %[[P1]], i32 %x.1, 1 - // CHECK: ret { i32, i32 } %[[P2]] - transmute(x) } -// CHECK-LABEL: @check_bool_from_ordering( +// CHECK: @check_bool_from_ordering(i8 noundef range(i8 -1, 2) %x) #[no_mangle] pub unsafe fn check_bool_from_ordering(x: std::cmp::Ordering) -> bool { - // OPT: %0 = icmp uge i8 %x, -1 - // OPT: %1 = icmp ule i8 %x, 1 - // OPT: %2 = or i1 %0, %1 - // OPT: call void @llvm.assume(i1 %2) - // OPT: %3 = icmp ule i8 %x, 1 - // OPT: call void @llvm.assume(i1 %3) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: %[[R:.+]] = trunc i8 %x to i1 - // CHECK: ret i1 %[[R]] - transmute(x) } -// CHECK-LABEL: @check_bool_to_ordering( +// CHECK: noundef range(i8 -1, 2) i8 @check_bool_to_ordering( #[no_mangle] pub unsafe fn check_bool_to_ordering(x: bool) -> std::cmp::Ordering { - // CHECK: %_0 = zext i1 %x to i8 - // OPT: %0 = icmp ule i8 %_0, 1 - // OPT: call void @llvm.assume(i1 %0) - // OPT: %1 = icmp uge i8 %_0, -1 - // OPT: %2 = icmp ule i8 %_0, 1 - // OPT: %3 = or i1 %1, %2 - // OPT: call void @llvm.assume(i1 %3) - // DBG-NOT: icmp - // DBG-NOT: assume - // CHECK: ret i8 %_0 - transmute(x) } diff --git a/tests/codegen/issues/issue-119422.rs b/tests/codegen/issues/issue-119422.rs index 682430a79f4a9..44402fd94d363 100644 --- a/tests/codegen/issues/issue-119422.rs +++ b/tests/codegen/issues/issue-119422.rs @@ -3,6 +3,7 @@ //! //@ compile-flags: -O --edition=2021 -Zmerge-functions=disabled //@ only-64bit (because the LLVM type of i64 for usize shows up) +//@ min-llvm-version: 19 #![crate_type = "lib"] use core::num::NonZero; diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs index 11bd0523788a1..ed55f95661d4e 100644 --- a/tests/codegen/transmute-optimized.rs +++ b/tests/codegen/transmute-optimized.rs @@ -1,4 +1,5 @@ //@ compile-flags: -O -Z merge-functions=disabled +//@ min-llvm-version: 19 #![crate_type = "lib"] // This tests that LLVM can optimize based on the niches in the source or @@ -92,14 +93,14 @@ pub enum OneTwoThree { // CHECK-LABEL: i8 @ordering_transmute_onetwothree(i8 #[no_mangle] pub unsafe fn ordering_transmute_onetwothree(x: std::cmp::Ordering) -> OneTwoThree { - // CHECK: ret i8 1 + // CHECK: ret i8 %x std::mem::transmute(x) } // CHECK-LABEL: i8 @onetwothree_transmute_ordering(i8 #[no_mangle] pub unsafe fn onetwothree_transmute_ordering(x: OneTwoThree) -> std::cmp::Ordering { - // CHECK: ret i8 1 + // CHECK: ret i8 %x std::mem::transmute(x) } diff --git a/tests/crashes/121097.rs b/tests/crashes/121097.rs deleted file mode 100644 index 65c6028e03e36..0000000000000 --- a/tests/crashes/121097.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: #121097 -#[repr(simd)] -enum Aligned { - Zero = 0, - One = 1, -} - -fn tou8(al: Aligned) -> u8 { - al as u8 -} diff --git a/tests/mir-opt/building/enum_cast.bar.built.after.mir b/tests/mir-opt/building/enum_cast.bar.built.after.mir index 512c73216198e..0dc6448ffad01 100644 --- a/tests/mir-opt/building/enum_cast.bar.built.after.mir +++ b/tests/mir-opt/building/enum_cast.bar.built.after.mir @@ -5,16 +5,11 @@ fn bar(_1: Bar) -> usize { let mut _0: usize; let _2: Bar; let mut _3: isize; - let mut _4: u8; - let mut _5: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = _3 as u8 (IntToInt); - _5 = Le(_4, const 1_u8); - assume(move _5); _0 = move _3 as usize (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.boo.built.after.mir b/tests/mir-opt/building/enum_cast.boo.built.after.mir index ad0adf14e4ac8..3540a2b1e2e47 100644 --- a/tests/mir-opt/building/enum_cast.boo.built.after.mir +++ b/tests/mir-opt/building/enum_cast.boo.built.after.mir @@ -5,16 +5,11 @@ fn boo(_1: Boo) -> usize { let mut _0: usize; let _2: Boo; let mut _3: u8; - let mut _4: u8; - let mut _5: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = _3 as u8 (IntToInt); - _5 = Le(_4, const 1_u8); - assume(move _5); _0 = move _3 as usize (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.droppy.built.after.mir b/tests/mir-opt/building/enum_cast.droppy.built.after.mir index ea0edb610f5cc..65390605f740d 100644 --- a/tests/mir-opt/building/enum_cast.droppy.built.after.mir +++ b/tests/mir-opt/building/enum_cast.droppy.built.after.mir @@ -6,9 +6,7 @@ fn droppy() -> () { let _2: Droppy; let _4: Droppy; let mut _5: isize; - let mut _6: u8; - let mut _7: bool; - let _8: Droppy; + let _6: Droppy; scope 1 { debug x => _2; scope 2 { @@ -19,7 +17,7 @@ fn droppy() -> () { } } scope 4 { - debug z => _8; + debug z => _6; } bb0: { @@ -31,9 +29,6 @@ fn droppy() -> () { StorageLive(_4); _4 = move _2; _5 = discriminant(_4); - _6 = _5 as u8 (IntToInt); - _7 = Le(_6, const 2_u8); - assume(move _7); _3 = move _5 as usize (IntToInt); drop(_4) -> [return: bb1, unwind: bb4]; } @@ -49,15 +44,15 @@ fn droppy() -> () { bb2: { StorageDead(_2); StorageDead(_1); - StorageLive(_8); - _8 = Droppy::B; - FakeRead(ForLet(None), _8); + StorageLive(_6); + _6 = Droppy::B; + FakeRead(ForLet(None), _6); _0 = const (); - drop(_8) -> [return: bb3, unwind: bb5]; + drop(_6) -> [return: bb3, unwind: bb5]; } bb3: { - StorageDead(_8); + StorageDead(_6); return; } diff --git a/tests/mir-opt/building/enum_cast.far.built.after.mir b/tests/mir-opt/building/enum_cast.far.built.after.mir index e75803c706daf..da34b7ba6c28a 100644 --- a/tests/mir-opt/building/enum_cast.far.built.after.mir +++ b/tests/mir-opt/building/enum_cast.far.built.after.mir @@ -5,16 +5,11 @@ fn far(_1: Far) -> isize { let mut _0: isize; let _2: Far; let mut _3: i16; - let mut _4: u16; - let mut _5: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = _3 as u16 (IntToInt); - _5 = Le(_4, const 1_u16); - assume(move _5); _0 = move _3 as isize (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.offsetty.built.after.mir b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir index 282859d7cd014..b84ce0de9a0a7 100644 --- a/tests/mir-opt/building/enum_cast.offsetty.built.after.mir +++ b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir @@ -5,20 +5,11 @@ fn offsetty(_1: NotStartingAtZero) -> u32 { let mut _0: u32; let _2: NotStartingAtZero; let mut _3: isize; - let mut _4: u8; - let mut _5: bool; - let mut _6: bool; - let mut _7: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = _3 as u8 (IntToInt); - _5 = Ge(_4, const 4_u8); - _6 = Le(_4, const 8_u8); - _7 = BitAnd(move _5, move _6); - assume(move _7); _0 = move _3 as u32 (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.signy.built.after.mir b/tests/mir-opt/building/enum_cast.signy.built.after.mir index a9f7d6c78007a..503c506748ff9 100644 --- a/tests/mir-opt/building/enum_cast.signy.built.after.mir +++ b/tests/mir-opt/building/enum_cast.signy.built.after.mir @@ -5,20 +5,11 @@ fn signy(_1: SignedAroundZero) -> i16 { let mut _0: i16; let _2: SignedAroundZero; let mut _3: i16; - let mut _4: u16; - let mut _5: bool; - let mut _6: bool; - let mut _7: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = _3 as u16 (IntToInt); - _5 = Ge(_4, const 65534_u16); - _6 = Le(_4, const 2_u16); - _7 = BitOr(move _5, move _6); - assume(move _7); _0 = move _3 as i16 (IntToInt); StorageDead(_2); return; diff --git a/tests/ui/repr/issue-83505-repr-simd.rs b/tests/ui/repr/invalid-repr-simd.rs similarity index 50% rename from tests/ui/repr/issue-83505-repr-simd.rs rename to tests/ui/repr/invalid-repr-simd.rs index 280b771d01539..6d8f6ab7de633 100644 --- a/tests/ui/repr/issue-83505-repr-simd.rs +++ b/tests/ui/repr/invalid-repr-simd.rs @@ -1,4 +1,4 @@ -// Regression test for the ICE described in #83505. +// Regression test for the ICEs described in #83505 & #121097. #![crate_type="lib"] @@ -8,3 +8,14 @@ enum Es {} static CLs: Es; //~^ ERROR: free static item without body + +#[repr(simd)] +//~^ ERROR: attribute should be applied to a struct [E0517] +enum Aligned { + Zero = 0, + One = 1, +} + +pub fn tou8(al: Aligned) -> u8 { + al as u8 +} diff --git a/tests/ui/repr/issue-83505-repr-simd.stderr b/tests/ui/repr/invalid-repr-simd.stderr similarity index 61% rename from tests/ui/repr/issue-83505-repr-simd.stderr rename to tests/ui/repr/invalid-repr-simd.stderr index df99baaf52293..67ba5d0131200 100644 --- a/tests/ui/repr/issue-83505-repr-simd.stderr +++ b/tests/ui/repr/invalid-repr-simd.stderr @@ -1,5 +1,5 @@ error: free static item without body - --> $DIR/issue-83505-repr-simd.rs:9:1 + --> $DIR/invalid-repr-simd.rs:9:1 | LL | static CLs: Es; | ^^^^^^^^^^^^^^- @@ -7,7 +7,7 @@ LL | static CLs: Es; | help: provide a definition for the static: `= ;` error[E0517]: attribute should be applied to a struct - --> $DIR/issue-83505-repr-simd.rs:5:8 + --> $DIR/invalid-repr-simd.rs:5:8 | LL | #[repr(simd)] | ^^^^ @@ -15,8 +15,20 @@ LL | #[repr(simd)] LL | enum Es {} | ---------- not a struct +error[E0517]: attribute should be applied to a struct + --> $DIR/invalid-repr-simd.rs:12:8 + | +LL | #[repr(simd)] + | ^^^^ +LL | +LL | / enum Aligned { +LL | | Zero = 0, +LL | | One = 1, +LL | | } + | |_- not a struct + error[E0084]: unsupported representation for zero-variant enum - --> $DIR/issue-83505-repr-simd.rs:5:1 + --> $DIR/invalid-repr-simd.rs:5:1 | LL | #[repr(simd)] | ^^^^^^^^^^^^^ @@ -24,7 +36,7 @@ LL | #[repr(simd)] LL | enum Es {} | ------- zero-variant enum -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0084, E0517. For more information about an error, try `rustc --explain E0084`. diff --git a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr index 084008d8b2a42..13ae6dfcaa354 100644 --- a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr +++ b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr @@ -7,36 +7,6 @@ LL | V3 = Self::V1 {} as u8 + 2, note: ...which requires const-evaluating + checking `Alpha::V3::{constant#0}`... --> $DIR/self-in-enum-definition.rs:5:10 | -LL | V3 = Self::V1 {} as u8 + 2, - | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires caching mir of `Alpha::V3::{constant#0}` for CTFE... - --> $DIR/self-in-enum-definition.rs:5:10 - | -LL | V3 = Self::V1 {} as u8 + 2, - | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires elaborating drops for `Alpha::V3::{constant#0}`... - --> $DIR/self-in-enum-definition.rs:5:10 - | -LL | V3 = Self::V1 {} as u8 + 2, - | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires borrow-checking `Alpha::V3::{constant#0}`... - --> $DIR/self-in-enum-definition.rs:5:10 - | -LL | V3 = Self::V1 {} as u8 + 2, - | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires promoting constants in MIR for `Alpha::V3::{constant#0}`... - --> $DIR/self-in-enum-definition.rs:5:10 - | -LL | V3 = Self::V1 {} as u8 + 2, - | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `Alpha::V3::{constant#0}`... - --> $DIR/self-in-enum-definition.rs:5:10 - | -LL | V3 = Self::V1 {} as u8 + 2, - | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building MIR for `Alpha::V3::{constant#0}`... - --> $DIR/self-in-enum-definition.rs:5:10 - | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `Alpha`...