diff options
Diffstat (limited to 'tests')
10 files changed, 82 insertions, 40 deletions
diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff index 543ddcfc44c..8a8cd896e85 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff @@ -34,7 +34,7 @@ - // + literal: Const { ty: unsafe fn(Option<T>) -> T {Option::<T>::unwrap_unchecked}, val: Value(<ZST>) } + StorageLive(_3); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 + _4 = discriminant(_2); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _4) -> [1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL } bb1: { diff --git a/tests/mir-opt/instcombine_duplicate_switch_targets_e2e.rs b/tests/mir-opt/instcombine_duplicate_switch_targets_e2e.rs new file mode 100644 index 00000000000..09779d789e5 --- /dev/null +++ b/tests/mir-opt/instcombine_duplicate_switch_targets_e2e.rs @@ -0,0 +1,16 @@ +// compile-flags: -Zmir-opt-level=2 -Zinline-mir +// ignore-debug: standard library debug assertions add a panic that breaks this optimization +#![crate_type = "lib"] + +pub enum Thing { + A, + B, +} + +// EMIT_MIR instcombine_duplicate_switch_targets_e2e.ub_if_b.PreCodegen.after.mir +pub unsafe fn ub_if_b(t: Thing) -> Thing { + match t { + Thing::A => t, + Thing::B => std::hint::unreachable_unchecked(), + } +} diff --git a/tests/mir-opt/instcombine_duplicate_switch_targets_e2e.ub_if_b.PreCodegen.after.mir b/tests/mir-opt/instcombine_duplicate_switch_targets_e2e.ub_if_b.PreCodegen.after.mir new file mode 100644 index 00000000000..acb7297310f --- /dev/null +++ b/tests/mir-opt/instcombine_duplicate_switch_targets_e2e.ub_if_b.PreCodegen.after.mir @@ -0,0 +1,27 @@ +// MIR for `ub_if_b` after PreCodegen + +fn ub_if_b(_1: Thing) -> Thing { + debug t => _1; // in scope 0 at $DIR/instcombine_duplicate_switch_targets_e2e.rs:+0:23: +0:24 + let mut _0: Thing; // return place in scope 0 at $DIR/instcombine_duplicate_switch_targets_e2e.rs:+0:36: +0:41 + let mut _2: isize; // in scope 0 at $DIR/instcombine_duplicate_switch_targets_e2e.rs:+2:9: +2:17 + scope 1 (inlined unreachable_unchecked) { // at $DIR/instcombine_duplicate_switch_targets_e2e.rs:14:21: 14:55 + scope 2 { + scope 3 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + + bb0: { + _2 = discriminant(_1); // scope 0 at $DIR/instcombine_duplicate_switch_targets_e2e.rs:+1:11: +1:12 + switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/instcombine_duplicate_switch_targets_e2e.rs:+1:5: +1:12 + } + + bb1: { + unreachable; // scope 2 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + + bb2: { + _0 = move _1; // scope 0 at $DIR/instcombine_duplicate_switch_targets_e2e.rs:+2:21: +2:22 + return; // scope 0 at $DIR/instcombine_duplicate_switch_targets_e2e.rs:+5:2: +5:2 + } +} diff --git a/tests/run-make/const-prop-lint/Makefile b/tests/run-make/const-prop-lint/Makefile new file mode 100644 index 00000000000..f29f282f787 --- /dev/null +++ b/tests/run-make/const-prop-lint/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +# Test that emitting an error because of arithmetic +# overflow lint does not leave .o files around +# because of interrupted codegen. + +all: + $(RUSTC) input.rs; test $$? -eq 1 + ls *.o; test $$? -ne 0 diff --git a/tests/run-make/const-prop-lint/input.rs b/tests/run-make/const-prop-lint/input.rs new file mode 100644 index 00000000000..ccbdfb8d50b --- /dev/null +++ b/tests/run-make/const-prop-lint/input.rs @@ -0,0 +1,5 @@ +#![deny(arithmetic_overflow)] + +fn main() { + let x = 255u8 + 1; +} diff --git a/tests/ui/consts/const-eval/issue-100878.rs b/tests/ui/consts/const-eval/issue-100878.rs index 353ce505035..bd56f854c8b 100644 --- a/tests/ui/consts/const-eval/issue-100878.rs +++ b/tests/ui/consts/const-eval/issue-100878.rs @@ -1,6 +1,8 @@ // This checks that the const-eval ICE in issue #100878 does not recur. // // build-pass + +#[allow(arithmetic_overflow)] pub fn bitshift_data(data: [u8; 1]) -> u8 { data[0] << 8 } diff --git a/tests/ui/issues/issue-33287.rs b/tests/ui/issues/issue-33287.rs index 770eb7c02bb..b3f87305781 100644 --- a/tests/ui/issues/issue-33287.rs +++ b/tests/ui/issues/issue-33287.rs @@ -1,6 +1,7 @@ // build-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(unconditional_panic)] const A: [u32; 1] = [0]; fn test() { diff --git a/tests/ui/polymorphization/generators.stderr b/tests/ui/polymorphization/generators.stderr index 84888f6fb2f..32d49d25f02 100644 --- a/tests/ui/polymorphization/generators.stderr +++ b/tests/ui/polymorphization/generators.stderr @@ -15,12 +15,6 @@ LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + LL | || { | ^^ -note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:35:5: 35:7], u32, u32>` - --> $DIR/generators.rs:86:5 - | -LL | finish(unused_type::<u32>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: item has unused generic parameters --> $DIR/generators.rs:60:5 | @@ -29,11 +23,5 @@ LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Retu LL | || { | ^^ -note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:60:5: 60:7], u32, u32>` - --> $DIR/generators.rs:89:5 - | -LL | finish(unused_const::<1u32>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/polymorphization/predicates.stderr b/tests/ui/polymorphization/predicates.stderr index 80bb2af25cc..a3b2f75b12d 100644 --- a/tests/ui/polymorphization/predicates.stderr +++ b/tests/ui/polymorphization/predicates.stderr @@ -1,4 +1,10 @@ error: item has unused generic parameters + --> $DIR/predicates.rs:10:4 + | +LL | fn bar<I>() { + | ^^^ - generic parameter `I` is unused + +error: item has unused generic parameters --> $DIR/predicates.rs:15:4 | LL | fn foo<I, T>(_: I) @@ -35,17 +41,5 @@ error: item has unused generic parameters LL | fn foobar<F, G>() -> usize | ^^^^^^ - generic parameter `F` is unused -error: item has unused generic parameters - --> $DIR/predicates.rs:10:4 - | -LL | fn bar<I>() { - | ^^^ - generic parameter `I` is unused - -note: the above error was encountered while instantiating `fn foo::<std::slice::Iter<'_, u32>, T>` - --> $DIR/predicates.rs:86:5 - | -LL | foo(x.iter()); - | ^^^^^^^^^^^^^ - error: aborting due to 6 previous errors diff --git a/tests/ui/polymorphization/type_parameters/closures.stderr b/tests/ui/polymorphization/type_parameters/closures.stderr index 94a4a08bd2f..5c3b46c6041 100644 --- a/tests/ui/polymorphization/type_parameters/closures.stderr +++ b/tests/ui/polymorphization/type_parameters/closures.stderr @@ -44,21 +44,6 @@ LL | pub fn unused_all<G: Default>() -> u32 { | ^^^^^^^^^^ - generic parameter `G` is unused error: item has unused generic parameters - --> $DIR/closures.rs:128:23 - | -LL | pub fn used_impl<G: Default>() -> u32 { - | - generic parameter `G` is unused -LL | -LL | let add_one = |x: u32| { - | ^^^^^^^^ - -error: item has unused generic parameters - --> $DIR/closures.rs:126:12 - | -LL | pub fn used_impl<G: Default>() -> u32 { - | ^^^^^^^^^ - generic parameter `G` is unused - -error: item has unused generic parameters --> $DIR/closures.rs:115:23 | LL | impl<F: Default> Foo<F> { @@ -76,5 +61,20 @@ LL | impl<F: Default> Foo<F> { LL | pub fn used_fn<G: Default>() -> u32 { | ^^^^^^^ +error: item has unused generic parameters + --> $DIR/closures.rs:128:23 + | +LL | pub fn used_impl<G: Default>() -> u32 { + | - generic parameter `G` is unused +LL | +LL | let add_one = |x: u32| { + | ^^^^^^^^ + +error: item has unused generic parameters + --> $DIR/closures.rs:126:12 + | +LL | pub fn used_impl<G: Default>() -> u32 { + | ^^^^^^^^^ - generic parameter `G` is unused + error: aborting due to 9 previous errors |
