diff options
Diffstat (limited to 'tests')
494 files changed, 6158 insertions, 3258 deletions
diff --git a/tests/assembly/x86_64-windows-float-abi.rs b/tests/assembly/x86_64-windows-float-abi.rs new file mode 100644 index 00000000000..1381d492fa5 --- /dev/null +++ b/tests/assembly/x86_64-windows-float-abi.rs @@ -0,0 +1,39 @@ +//@ assembly-output: emit-asm +//@ compile-flags: -O +//@ only-windows +//@ only-x86_64 + +#![feature(f16, f128)] +#![crate_type = "lib"] + +// CHECK-LABEL: second_f16 +// CHECK: movaps %xmm1, %xmm0 +// CHECK-NEXT: retq +#[no_mangle] +pub extern "C" fn second_f16(_: f16, x: f16) -> f16 { + x +} + +// CHECK-LABEL: second_f32 +// CHECK: movaps %xmm1, %xmm0 +// CHECK-NEXT: retq +#[no_mangle] +pub extern "C" fn second_f32(_: f32, x: f32) -> f32 { + x +} + +// CHECK-LABEL: second_f64 +// CHECK: movaps %xmm1, %xmm0 +// CHECK-NEXT: retq +#[no_mangle] +pub extern "C" fn second_f64(_: f64, x: f64) -> f64 { + x +} + +// CHECK-LABEL: second_f128 +// CHECK: movaps %xmm1, %xmm0 +// CHECK-NEXT: retq +#[no_mangle] +pub extern "C" fn second_f128(_: f128, x: f128) -> f128 { + x +} diff --git a/tests/codegen-units/item-collection/generic-impl.rs b/tests/codegen-units/item-collection/generic-impl.rs index b4cd99272b1..23d09e0d8af 100644 --- a/tests/codegen-units/item-collection/generic-impl.rs +++ b/tests/codegen-units/item-collection/generic-impl.rs @@ -22,16 +22,16 @@ impl<T> Struct<T> { } } -pub struct _LifeTimeOnly<'a> { +pub struct LifeTimeOnly<'a> { _a: &'a u32, } -impl<'a> _LifeTimeOnly<'a> { - //~ MONO_ITEM fn _LifeTimeOnly::<'_>::foo +impl<'a> LifeTimeOnly<'a> { + //~ MONO_ITEM fn LifeTimeOnly::<'_>::foo pub fn foo(&self) {} - //~ MONO_ITEM fn _LifeTimeOnly::<'_>::bar + //~ MONO_ITEM fn LifeTimeOnly::<'_>::bar pub fn bar(&'a self) {} - //~ MONO_ITEM fn _LifeTimeOnly::<'_>::baz + //~ MONO_ITEM fn LifeTimeOnly::<'_>::baz pub fn baz<'b>(&'b self) {} pub fn non_instantiated<T>(&self) {} diff --git a/tests/codegen-units/item-collection/overloaded-operators.rs b/tests/codegen-units/item-collection/overloaded-operators.rs index e00e22dbab9..69b55695d3d 100644 --- a/tests/codegen-units/item-collection/overloaded-operators.rs +++ b/tests/codegen-units/item-collection/overloaded-operators.rs @@ -5,44 +5,44 @@ use std::ops::{Add, Deref, Index, IndexMut}; -pub struct _Indexable { +pub struct Indexable { data: [u8; 3], } -impl Index<usize> for _Indexable { +impl Index<usize> for Indexable { type Output = u8; - //~ MONO_ITEM fn <_Indexable as std::ops::Index<usize>>::index + //~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index fn index(&self, index: usize) -> &Self::Output { if index >= 3 { &self.data[0] } else { &self.data[index] } } } -impl IndexMut<usize> for _Indexable { - //~ MONO_ITEM fn <_Indexable as std::ops::IndexMut<usize>>::index_mut +impl IndexMut<usize> for Indexable { + //~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut fn index_mut(&mut self, index: usize) -> &mut Self::Output { if index >= 3 { &mut self.data[0] } else { &mut self.data[index] } } } -//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::eq -//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::ne +//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq +//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne #[derive(PartialEq)] -pub struct _Equatable(u32); +pub struct Equatable(u32); -impl Add<u32> for _Equatable { +impl Add<u32> for Equatable { type Output = u32; - //~ MONO_ITEM fn <_Equatable as std::ops::Add<u32>>::add + //~ MONO_ITEM fn <Equatable as std::ops::Add<u32>>::add fn add(self, rhs: u32) -> u32 { self.0 + rhs } } -impl Deref for _Equatable { +impl Deref for Equatable { type Target = u32; - //~ MONO_ITEM fn <_Equatable as std::ops::Deref>::deref + //~ MONO_ITEM fn <Equatable as std::ops::Deref>::deref fn deref(&self) -> &Self::Target { &self.0 } diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 31020b77984..7de224b92d8 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -1,8 +1,9 @@ -//@ compile-flags: -O +//@ compile-flags: -C opt-level=3 //@ only-x86_64 #![crate_type = "lib"] #![feature(iter_repeat_n)] +#![feature(array_repeat)] #[derive(Clone)] pub struct NotCopy(u16); @@ -54,3 +55,15 @@ pub fn vec_extend_via_iter_repeat_n() -> Vec<u8> { v.extend(std::iter::repeat_n(42_u8, n)); v } + +// Array repeat uses `RepeatN::next_unchecked` internally, +// so also check that the distinction disappears there. + +#[no_mangle] +// CHECK-LABEL: @array_repeat_not_copy +pub unsafe fn array_repeat_not_copy(item: NotCopy) -> [NotCopy; 8] { + // CHECK: insertelement {{.+}} i16 %item + // CHECK: shufflevector <8 x i16> {{.+}} zeroinitializer + // CHECK: store <8 x i16> + std::array::repeat(item) +} diff --git a/tests/codegen/simd/issue-120720-reduce-nan.rs b/tests/codegen/simd/issue-120720-reduce-nan.rs deleted file mode 100644 index 13af0bb076e..00000000000 --- a/tests/codegen/simd/issue-120720-reduce-nan.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ compile-flags: -C opt-level=3 -C target-cpu=cannonlake -//@ only-x86_64 - -// In a previous implementation, _mm512_reduce_add_pd did the reduction with all fast-math flags -// enabled, making it UB to reduce a vector containing a NaN. - -#![crate_type = "lib"] -#![feature(stdarch_x86_avx512, avx512_target_feature)] -use std::arch::x86_64::*; - -// CHECK-LABEL: @demo( -#[no_mangle] -#[target_feature(enable = "avx512f")] // Function-level target feature mismatches inhibit inlining -pub unsafe fn demo() -> bool { - // CHECK: %0 = tail call reassoc double @llvm.vector.reduce.fadd.v8f64( - // CHECK: %_0.i = fcmp uno double %0, 0.000000e+00 - // CHECK: ret i1 %_0.i - let res = - unsafe { _mm512_reduce_add_pd(_mm512_set_pd(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, f64::NAN)) }; - res.is_nan() -} diff --git a/tests/coverage/mcdc/condition-limit.cov-map b/tests/coverage/mcdc/condition-limit.cov-map index b4447a33691..b565353572a 100644 --- a/tests/coverage/mcdc/condition-limit.cov-map +++ b/tests/coverage/mcdc/condition-limit.cov-map @@ -1,5 +1,5 @@ Function name: condition_limit::bad -Raw bytes (204): 0x[01, 01, 2c, 01, 05, 05, 1d, 05, 1d, 7a, 19, 05, 1d, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 21, 9b, 01, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 11, 01, 14, 01, 03, 09, 20, 05, 02, 03, 08, 00, 09, 05, 00, 0d, 00, 0e, 20, 7a, 1d, 00, 0d, 00, 0e, 7a, 00, 12, 00, 13, 20, 76, 19, 00, 12, 00, 13, 76, 00, 17, 00, 18, 20, 72, 15, 00, 17, 00, 18, 72, 00, 1c, 00, 1d, 20, 6e, 11, 00, 1c, 00, 1d, 6e, 00, 21, 00, 22, 20, 6a, 0d, 00, 21, 00, 22, 6a, 00, 26, 00, 27, 20, 21, 09, 00, 26, 00, 27, 21, 00, 28, 02, 06, 9b, 01, 02, 06, 00, 07, 97, 01, 01, 01, 00, 02] +Raw bytes (204): 0x[01, 01, 2c, 01, 05, 05, 1d, 05, 1d, 7a, 19, 05, 1d, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 21, 9b, 01, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 11, 01, 15, 01, 03, 09, 20, 05, 02, 03, 08, 00, 09, 05, 00, 0d, 00, 0e, 20, 7a, 1d, 00, 0d, 00, 0e, 7a, 00, 12, 00, 13, 20, 76, 19, 00, 12, 00, 13, 76, 00, 17, 00, 18, 20, 72, 15, 00, 17, 00, 18, 72, 00, 1c, 00, 1d, 20, 6e, 11, 00, 1c, 00, 1d, 6e, 00, 21, 00, 22, 20, 6a, 0d, 00, 21, 00, 22, 6a, 00, 26, 00, 27, 20, 21, 09, 00, 26, 00, 27, 21, 00, 28, 02, 06, 9b, 01, 02, 06, 00, 07, 97, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 44 @@ -48,7 +48,7 @@ Number of expressions: 44 - expression 42 operands: lhs = Expression(43, Add), rhs = Counter(4) - expression 43 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 17 -- Code(Counter(0)) at (prev + 20, 1) to (start + 3, 9) +- Code(Counter(0)) at (prev + 21, 1) to (start + 3, 9) - Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 3, 8) to (start + 0, 9) true = c1 false = (c0 - c1) @@ -88,7 +88,7 @@ Number of file 0 mappings: 17 = (c8 + ((((((c2 + c3) + c4) + c5) + c6) + c7) + (c0 - c1))) Function name: condition_limit::good -Raw bytes (180): 0x[01, 01, 20, 01, 05, 05, 19, 05, 19, 52, 15, 05, 19, 52, 15, 05, 19, 4e, 11, 52, 15, 05, 19, 4e, 11, 52, 15, 05, 19, 4a, 0d, 4e, 11, 52, 15, 05, 19, 4a, 0d, 4e, 11, 52, 15, 05, 19, 73, 02, 77, 19, 7b, 15, 7f, 11, 09, 0d, 1d, 6f, 73, 02, 77, 19, 7b, 15, 7f, 11, 09, 0d, 10, 01, 0c, 01, 03, 09, 28, 00, 06, 03, 08, 00, 22, 30, 05, 02, 01, 06, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 52, 19, 06, 05, 00, 00, 0d, 00, 0e, 52, 00, 12, 00, 13, 30, 4e, 15, 05, 04, 00, 00, 12, 00, 13, 4e, 00, 17, 00, 18, 30, 4a, 11, 04, 03, 00, 00, 17, 00, 18, 4a, 00, 1c, 00, 1d, 30, 46, 0d, 03, 02, 00, 00, 1c, 00, 1d, 46, 00, 21, 00, 22, 30, 1d, 09, 02, 00, 00, 00, 21, 00, 22, 1d, 00, 23, 02, 06, 6f, 02, 06, 00, 07, 6b, 01, 01, 00, 02] +Raw bytes (180): 0x[01, 01, 20, 01, 05, 05, 19, 05, 19, 52, 15, 05, 19, 52, 15, 05, 19, 4e, 11, 52, 15, 05, 19, 4e, 11, 52, 15, 05, 19, 4a, 0d, 4e, 11, 52, 15, 05, 19, 4a, 0d, 4e, 11, 52, 15, 05, 19, 73, 02, 77, 19, 7b, 15, 7f, 11, 09, 0d, 1d, 6f, 73, 02, 77, 19, 7b, 15, 7f, 11, 09, 0d, 10, 01, 0d, 01, 03, 09, 28, 00, 06, 03, 08, 00, 22, 30, 05, 02, 01, 06, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 52, 19, 06, 05, 00, 00, 0d, 00, 0e, 52, 00, 12, 00, 13, 30, 4e, 15, 05, 04, 00, 00, 12, 00, 13, 4e, 00, 17, 00, 18, 30, 4a, 11, 04, 03, 00, 00, 17, 00, 18, 4a, 00, 1c, 00, 1d, 30, 46, 0d, 03, 02, 00, 00, 1c, 00, 1d, 46, 00, 21, 00, 22, 30, 1d, 09, 02, 00, 00, 00, 21, 00, 22, 1d, 00, 23, 02, 06, 6f, 02, 06, 00, 07, 6b, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 32 @@ -125,7 +125,7 @@ Number of expressions: 32 - expression 30 operands: lhs = Expression(31, Add), rhs = Counter(4) - expression 31 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 16 -- Code(Counter(0)) at (prev + 12, 1) to (start + 3, 9) +- Code(Counter(0)) at (prev + 13, 1) to (start + 3, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 6 } at (prev + 3, 8) to (start + 0, 34) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 6, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 diff --git a/tests/coverage/mcdc/condition-limit.coverage b/tests/coverage/mcdc/condition-limit.coverage index 4eb87432fab..81e832d6a49 100644 --- a/tests/coverage/mcdc/condition-limit.coverage +++ b/tests/coverage/mcdc/condition-limit.coverage @@ -1,6 +1,7 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 LL| |//@ min-llvm-version: 18 + LL| |//@ ignore-llvm-version: 19 - 99 LL| |//@ compile-flags: -Zcoverage-options=mcdc LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc LL| | diff --git a/tests/coverage/mcdc/condition-limit.rs b/tests/coverage/mcdc/condition-limit.rs index 571c600ebd0..2ff46b11a16 100644 --- a/tests/coverage/mcdc/condition-limit.rs +++ b/tests/coverage/mcdc/condition-limit.rs @@ -1,6 +1,7 @@ #![feature(coverage_attribute)] //@ edition: 2021 //@ min-llvm-version: 18 +//@ ignore-llvm-version: 19 - 99 //@ compile-flags: -Zcoverage-options=mcdc //@ llvm-cov-flags: --show-branches=count --show-mcdc diff --git a/tests/coverage/mcdc/if.cov-map b/tests/coverage/mcdc/if.cov-map index 9a7d15f700d..ea8dedb0ac3 100644 --- a/tests/coverage/mcdc/if.cov-map +++ b/tests/coverage/mcdc/if.cov-map @@ -1,5 +1,5 @@ Function name: if::mcdc_check_a -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 0f, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 10, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 @@ -8,7 +8,7 @@ Number of expressions: 4 - expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) - expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 8 -- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 16, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -24,7 +24,7 @@ Number of file 0 mappings: 8 = (c3 + (c2 + (c0 - c1))) Function name: if::mcdc_check_b -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 17, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 18, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 @@ -33,7 +33,7 @@ Number of expressions: 4 - expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) - expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 8 -- Code(Counter(0)) at (prev + 23, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 24, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -49,7 +49,7 @@ Number of file 0 mappings: 8 = (c3 + (c2 + (c0 - c1))) Function name: if::mcdc_check_both -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 1f, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 20, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 @@ -58,7 +58,7 @@ Number of expressions: 4 - expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) - expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 8 -- Code(Counter(0)) at (prev + 31, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 32, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -74,7 +74,7 @@ Number of file 0 mappings: 8 = (c3 + (c2 + (c0 - c1))) Function name: if::mcdc_check_neither -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 07, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 08, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 @@ -83,7 +83,7 @@ Number of expressions: 4 - expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) - expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 8 -- Code(Counter(0)) at (prev + 7, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -99,7 +99,7 @@ Number of file 0 mappings: 8 = (c3 + (c2 + (c0 - c1))) Function name: if::mcdc_check_not_tree_decision -Raw bytes (87): 0x[01, 01, 08, 01, 05, 02, 09, 05, 09, 0d, 1e, 02, 09, 11, 1b, 0d, 1e, 02, 09, 0a, 01, 31, 01, 03, 0a, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 1e, 03, 02, 00, 00, 0e, 00, 0f, 0b, 00, 14, 00, 15, 30, 11, 0d, 02, 00, 00, 00, 14, 00, 15, 11, 00, 16, 02, 06, 1b, 02, 0c, 02, 06, 17, 03, 01, 00, 02] +Raw bytes (87): 0x[01, 01, 08, 01, 05, 02, 09, 05, 09, 0d, 1e, 02, 09, 11, 1b, 0d, 1e, 02, 09, 0a, 01, 32, 01, 03, 0a, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 1e, 03, 02, 00, 00, 0e, 00, 0f, 0b, 00, 14, 00, 15, 30, 11, 0d, 02, 00, 00, 00, 14, 00, 15, 11, 00, 16, 02, 06, 1b, 02, 0c, 02, 06, 17, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 8 @@ -112,7 +112,7 @@ Number of expressions: 8 - expression 6 operands: lhs = Counter(3), rhs = Expression(7, Sub) - expression 7 operands: lhs = Expression(0, Sub), rhs = Counter(2) Number of file 0 mappings: 10 -- Code(Counter(0)) at (prev + 49, 1) to (start + 3, 10) +- Code(Counter(0)) at (prev + 50, 1) to (start + 3, 10) - MCDCDecision { bitmap_idx: 0, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 3 } at (prev + 0, 9) to (start + 0, 10) true = c1 @@ -134,7 +134,7 @@ Number of file 0 mappings: 10 = (c4 + (c3 + ((c0 - c1) - c2))) Function name: if::mcdc_check_tree_decision -Raw bytes (87): 0x[01, 01, 08, 01, 05, 05, 0d, 05, 0d, 0d, 11, 09, 02, 1b, 1f, 0d, 11, 09, 02, 0a, 01, 27, 01, 03, 09, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 0d, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 11, 09, 03, 00, 00, 00, 13, 00, 14, 1b, 00, 16, 02, 06, 1f, 02, 0c, 02, 06, 17, 03, 01, 00, 02] +Raw bytes (87): 0x[01, 01, 08, 01, 05, 05, 0d, 05, 0d, 0d, 11, 09, 02, 1b, 1f, 0d, 11, 09, 02, 0a, 01, 28, 01, 03, 09, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 0d, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 11, 09, 03, 00, 00, 00, 13, 00, 14, 1b, 00, 16, 02, 06, 1f, 02, 0c, 02, 06, 17, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 8 @@ -147,7 +147,7 @@ Number of expressions: 8 - expression 6 operands: lhs = Counter(3), rhs = Counter(4) - expression 7 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 10 -- Code(Counter(0)) at (prev + 39, 1) to (start + 3, 9) +- Code(Counter(0)) at (prev + 40, 1) to (start + 3, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -169,7 +169,7 @@ Number of file 0 mappings: 10 = ((c3 + c4) + (c2 + (c0 - c1))) Function name: if::mcdc_nested_if -Raw bytes (124): 0x[01, 01, 0d, 01, 05, 02, 09, 05, 09, 1b, 15, 05, 09, 1b, 15, 05, 09, 11, 15, 02, 09, 2b, 32, 0d, 2f, 11, 15, 02, 09, 0e, 01, 3b, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 32, 02, 00, 00, 00, 0d, 00, 0e, 1b, 01, 09, 01, 0d, 28, 01, 02, 01, 0c, 00, 12, 30, 16, 15, 01, 02, 00, 00, 0c, 00, 0d, 16, 00, 11, 00, 12, 30, 0d, 11, 02, 00, 00, 00, 11, 00, 12, 0d, 00, 13, 02, 0a, 2f, 02, 0a, 00, 0b, 32, 01, 0c, 02, 06, 27, 03, 01, 00, 02] +Raw bytes (124): 0x[01, 01, 0d, 01, 05, 02, 09, 05, 09, 1b, 15, 05, 09, 1b, 15, 05, 09, 11, 15, 02, 09, 2b, 32, 0d, 2f, 11, 15, 02, 09, 0e, 01, 3c, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 32, 02, 00, 00, 00, 0d, 00, 0e, 1b, 01, 09, 01, 0d, 28, 01, 02, 01, 0c, 00, 12, 30, 16, 15, 01, 02, 00, 00, 0c, 00, 0d, 16, 00, 11, 00, 12, 30, 0d, 11, 02, 00, 00, 00, 11, 00, 12, 0d, 00, 13, 02, 0a, 2f, 02, 0a, 00, 0b, 32, 01, 0c, 02, 06, 27, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 13 @@ -187,7 +187,7 @@ Number of expressions: 13 - expression 11 operands: lhs = Counter(4), rhs = Counter(5) - expression 12 operands: lhs = Expression(0, Sub), rhs = Counter(2) Number of file 0 mappings: 14 -- Code(Counter(0)) at (prev + 59, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 60, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 8) to (start + 0, 9) true = c1 diff --git a/tests/coverage/mcdc/if.coverage b/tests/coverage/mcdc/if.coverage index 91fff073d0c..dc93319950b 100644 --- a/tests/coverage/mcdc/if.coverage +++ b/tests/coverage/mcdc/if.coverage @@ -1,6 +1,7 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 LL| |//@ min-llvm-version: 18 + LL| |//@ ignore-llvm-version: 19 - 99 LL| |//@ compile-flags: -Zcoverage-options=mcdc LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc LL| | diff --git a/tests/coverage/mcdc/if.rs b/tests/coverage/mcdc/if.rs index d8e6b61a9d5..6f589659a3d 100644 --- a/tests/coverage/mcdc/if.rs +++ b/tests/coverage/mcdc/if.rs @@ -1,6 +1,7 @@ #![feature(coverage_attribute)] //@ edition: 2021 //@ min-llvm-version: 18 +//@ ignore-llvm-version: 19 - 99 //@ compile-flags: -Zcoverage-options=mcdc //@ llvm-cov-flags: --show-branches=count --show-mcdc diff --git a/tests/coverage/mcdc/inlined_expressions.cov-map b/tests/coverage/mcdc/inlined_expressions.cov-map index 09b7291c964..8bb488c0dc0 100644 --- a/tests/coverage/mcdc/inlined_expressions.cov-map +++ b/tests/coverage/mcdc/inlined_expressions.cov-map @@ -1,5 +1,5 @@ Function name: inlined_expressions::inlined_instance -Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 08, 01, 01, 06, 28, 00, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 07, 01, 01, 00, 02] +Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 09, 01, 01, 06, 28, 00, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 07, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 3 @@ -7,7 +7,7 @@ Number of expressions: 3 - expression 1 operands: lhs = Expression(2, Add), rhs = Expression(0, Sub) - expression 2 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 6 -- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 6) +- Code(Counter(0)) at (prev + 9, 1) to (start + 1, 6) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 5) to (start + 0, 11) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 5) to (start + 0, 6) true = c1 diff --git a/tests/coverage/mcdc/inlined_expressions.coverage b/tests/coverage/mcdc/inlined_expressions.coverage index 5b083d62186..4e4800310c9 100644 --- a/tests/coverage/mcdc/inlined_expressions.coverage +++ b/tests/coverage/mcdc/inlined_expressions.coverage @@ -1,6 +1,7 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 LL| |//@ min-llvm-version: 18 + LL| |//@ ignore-llvm-version: 19 - 99 LL| |//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0 LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc LL| | diff --git a/tests/coverage/mcdc/inlined_expressions.rs b/tests/coverage/mcdc/inlined_expressions.rs index 65f7ee66f39..fc1e4dae37c 100644 --- a/tests/coverage/mcdc/inlined_expressions.rs +++ b/tests/coverage/mcdc/inlined_expressions.rs @@ -1,6 +1,7 @@ #![feature(coverage_attribute)] //@ edition: 2021 //@ min-llvm-version: 18 +//@ ignore-llvm-version: 19 - 99 //@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0 //@ llvm-cov-flags: --show-branches=count --show-mcdc diff --git a/tests/coverage/mcdc/nested_if.cov-map b/tests/coverage/mcdc/nested_if.cov-map index adeb6cbc1fb..0bd2aef814c 100644 --- a/tests/coverage/mcdc/nested_if.cov-map +++ b/tests/coverage/mcdc/nested_if.cov-map @@ -1,5 +1,5 @@ Function name: nested_if::doubly_nested_if_in_condition -Raw bytes (168): 0x[01, 01, 0e, 01, 05, 05, 11, 05, 11, 26, 19, 05, 11, 19, 1d, 19, 1d, 1d, 22, 26, 19, 05, 11, 11, 15, 09, 02, 0d, 37, 09, 02, 14, 01, 0f, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 01, 02, 00, 10, 00, 36, 30, 11, 26, 01, 00, 02, 00, 10, 00, 11, 30, 15, 21, 02, 00, 00, 00, 15, 00, 36, 26, 00, 18, 00, 19, 28, 00, 02, 00, 18, 00, 1e, 30, 19, 22, 01, 02, 00, 00, 18, 00, 19, 19, 00, 1d, 00, 1e, 30, 1a, 1d, 02, 00, 00, 00, 1d, 00, 1e, 1a, 00, 21, 00, 25, 1f, 00, 2f, 00, 34, 2b, 00, 39, 00, 3e, 21, 00, 48, 00, 4c, 0d, 00, 4f, 02, 06, 37, 02, 0c, 02, 06, 33, 03, 01, 00, 02] +Raw bytes (168): 0x[01, 01, 0e, 01, 05, 05, 11, 05, 11, 26, 19, 05, 11, 19, 1d, 19, 1d, 1d, 22, 26, 19, 05, 11, 11, 15, 09, 02, 0d, 37, 09, 02, 14, 01, 10, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 01, 02, 00, 10, 00, 36, 30, 11, 26, 01, 00, 02, 00, 10, 00, 11, 30, 15, 21, 02, 00, 00, 00, 15, 00, 36, 26, 00, 18, 00, 19, 28, 00, 02, 00, 18, 00, 1e, 30, 19, 22, 01, 02, 00, 00, 18, 00, 19, 19, 00, 1d, 00, 1e, 30, 1a, 1d, 02, 00, 00, 00, 1d, 00, 1e, 1a, 00, 21, 00, 25, 1f, 00, 2f, 00, 34, 2b, 00, 39, 00, 3e, 21, 00, 48, 00, 4c, 0d, 00, 4f, 02, 06, 37, 02, 0c, 02, 06, 33, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 14 @@ -18,7 +18,7 @@ Number of expressions: 14 - expression 12 operands: lhs = Counter(3), rhs = Expression(13, Add) - expression 13 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 20 -- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 16, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 2, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 78) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -58,7 +58,7 @@ Number of file 0 mappings: 20 = (c3 + (c2 + (c0 - c1))) Function name: nested_if::nested_if_in_condition -Raw bytes (120): 0x[01, 01, 0b, 01, 05, 05, 11, 05, 11, 1e, 15, 05, 11, 11, 15, 1e, 15, 05, 11, 09, 02, 0d, 2b, 09, 02, 0e, 01, 07, 01, 01, 09, 28, 01, 02, 01, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 1e, 01, 00, 02, 00, 10, 00, 11, 1e, 00, 15, 00, 16, 30, 15, 1a, 02, 00, 00, 00, 15, 00, 16, 17, 00, 19, 00, 1d, 1a, 00, 27, 00, 2c, 0d, 00, 2f, 02, 06, 2b, 02, 0c, 02, 06, 27, 03, 01, 00, 02] +Raw bytes (120): 0x[01, 01, 0b, 01, 05, 05, 11, 05, 11, 1e, 15, 05, 11, 11, 15, 1e, 15, 05, 11, 09, 02, 0d, 2b, 09, 02, 0e, 01, 08, 01, 01, 09, 28, 01, 02, 01, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 1e, 01, 00, 02, 00, 10, 00, 11, 1e, 00, 15, 00, 16, 30, 15, 1a, 02, 00, 00, 00, 15, 00, 16, 17, 00, 19, 00, 1d, 1a, 00, 27, 00, 2c, 0d, 00, 2f, 02, 06, 2b, 02, 0c, 02, 06, 27, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 11 @@ -74,7 +74,7 @@ Number of expressions: 11 - expression 9 operands: lhs = Counter(3), rhs = Expression(10, Add) - expression 10 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 14 -- Code(Counter(0)) at (prev + 7, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 1, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 46) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -103,7 +103,7 @@ Number of file 0 mappings: 14 = (c3 + (c2 + (c0 - c1))) Function name: nested_if::nested_in_then_block_in_condition -Raw bytes (176): 0x[01, 01, 12, 01, 05, 05, 11, 05, 11, 3a, 15, 05, 11, 11, 15, 33, 19, 11, 15, 19, 1d, 19, 1d, 1d, 2e, 33, 19, 11, 15, 3a, 15, 05, 11, 09, 02, 0d, 47, 09, 02, 14, 01, 22, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 3a, 01, 00, 02, 00, 10, 00, 11, 3a, 00, 15, 00, 16, 30, 15, 36, 02, 00, 00, 00, 15, 00, 16, 33, 00, 1c, 00, 1d, 28, 01, 02, 00, 1c, 00, 22, 30, 19, 2e, 01, 02, 00, 00, 1c, 00, 1d, 19, 00, 21, 00, 22, 30, 26, 1d, 02, 00, 00, 00, 21, 00, 22, 26, 00, 25, 00, 29, 2b, 00, 33, 00, 38, 36, 00, 44, 00, 49, 0d, 00, 4c, 02, 06, 47, 02, 0c, 02, 06, 43, 03, 01, 00, 02] +Raw bytes (176): 0x[01, 01, 12, 01, 05, 05, 11, 05, 11, 3a, 15, 05, 11, 11, 15, 33, 19, 11, 15, 19, 1d, 19, 1d, 1d, 2e, 33, 19, 11, 15, 3a, 15, 05, 11, 09, 02, 0d, 47, 09, 02, 14, 01, 23, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 3a, 01, 00, 02, 00, 10, 00, 11, 3a, 00, 15, 00, 16, 30, 15, 36, 02, 00, 00, 00, 15, 00, 16, 33, 00, 1c, 00, 1d, 28, 01, 02, 00, 1c, 00, 22, 30, 19, 2e, 01, 02, 00, 00, 1c, 00, 1d, 19, 00, 21, 00, 22, 30, 26, 1d, 02, 00, 00, 00, 21, 00, 22, 26, 00, 25, 00, 29, 2b, 00, 33, 00, 38, 36, 00, 44, 00, 49, 0d, 00, 4c, 02, 06, 47, 02, 0c, 02, 06, 43, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 18 @@ -126,7 +126,7 @@ Number of expressions: 18 - expression 16 operands: lhs = Counter(3), rhs = Expression(17, Add) - expression 17 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 20 -- Code(Counter(0)) at (prev + 34, 1) to (start + 1, 9) +- Code(Counter(0)) at (prev + 35, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 2, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 75) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 @@ -167,7 +167,7 @@ Number of file 0 mappings: 20 = (c3 + (c2 + (c0 - c1))) Function name: nested_if::nested_single_condition_decision -Raw bytes (85): 0x[01, 01, 06, 01, 05, 05, 11, 05, 11, 09, 02, 0d, 17, 09, 02, 0b, 01, 17, 01, 04, 09, 28, 00, 02, 04, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 11, 0a, 00, 10, 00, 11, 11, 00, 14, 00, 19, 0a, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 17, 02, 0c, 02, 06, 13, 03, 01, 00, 02] +Raw bytes (85): 0x[01, 01, 06, 01, 05, 05, 11, 05, 11, 09, 02, 0d, 17, 09, 02, 0b, 01, 18, 01, 04, 09, 28, 00, 02, 04, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 11, 0a, 00, 10, 00, 11, 11, 00, 14, 00, 19, 0a, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 17, 02, 0c, 02, 06, 13, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 6 @@ -178,7 +178,7 @@ Number of expressions: 6 - expression 4 operands: lhs = Counter(3), rhs = Expression(5, Add) - expression 5 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 11 -- Code(Counter(0)) at (prev + 23, 1) to (start + 4, 9) +- Code(Counter(0)) at (prev + 24, 1) to (start + 4, 9) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 4, 8) to (start + 0, 41) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 diff --git a/tests/coverage/mcdc/nested_if.coverage b/tests/coverage/mcdc/nested_if.coverage index a273a713a8a..916bb94745d 100644 --- a/tests/coverage/mcdc/nested_if.coverage +++ b/tests/coverage/mcdc/nested_if.coverage @@ -1,6 +1,7 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 LL| |//@ min-llvm-version: 18 + LL| |//@ ignore-llvm-version: 19 - 99 LL| |//@ compile-flags: -Zcoverage-options=mcdc LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc LL| | diff --git a/tests/coverage/mcdc/nested_if.rs b/tests/coverage/mcdc/nested_if.rs index f5068b5dcc2..f9ce7a0bc25 100644 --- a/tests/coverage/mcdc/nested_if.rs +++ b/tests/coverage/mcdc/nested_if.rs @@ -1,6 +1,7 @@ #![feature(coverage_attribute)] //@ edition: 2021 //@ min-llvm-version: 18 +//@ ignore-llvm-version: 19 - 99 //@ compile-flags: -Zcoverage-options=mcdc //@ llvm-cov-flags: --show-branches=count --show-mcdc diff --git a/tests/coverage/mcdc/non_control_flow.cov-map b/tests/coverage/mcdc/non_control_flow.cov-map index f8576831e75..0c6928b684d 100644 --- a/tests/coverage/mcdc/non_control_flow.cov-map +++ b/tests/coverage/mcdc/non_control_flow.cov-map @@ -1,5 +1,5 @@ Function name: non_control_flow::assign_3 -Raw bytes (89): 0x[01, 01, 09, 05, 07, 0b, 11, 09, 0d, 01, 05, 01, 05, 22, 11, 01, 05, 22, 11, 01, 05, 0a, 01, 16, 01, 00, 28, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 03, 00, 0d, 00, 18, 30, 05, 22, 01, 00, 02, 00, 0d, 00, 0e, 22, 00, 12, 00, 13, 30, 1e, 11, 02, 03, 00, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 30, 09, 0d, 03, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] +Raw bytes (89): 0x[01, 01, 09, 05, 07, 0b, 11, 09, 0d, 01, 05, 01, 05, 22, 11, 01, 05, 22, 11, 01, 05, 0a, 01, 17, 01, 00, 28, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 03, 00, 0d, 00, 18, 30, 05, 22, 01, 00, 02, 00, 0d, 00, 0e, 22, 00, 12, 00, 13, 30, 1e, 11, 02, 03, 00, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 30, 09, 0d, 03, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 9 @@ -13,7 +13,7 @@ Number of expressions: 9 - expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(4) - expression 8 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 10 -- Code(Counter(0)) at (prev + 22, 1) to (start + 0, 40) +- Code(Counter(0)) at (prev + 23, 1) to (start + 0, 40) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) = (c1 + ((c2 + c3) + c4)) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) @@ -35,7 +35,7 @@ Number of file 0 mappings: 10 = (c1 + ((c2 + c3) + c4)) Function name: non_control_flow::assign_3_bis -Raw bytes (85): 0x[01, 01, 07, 07, 11, 09, 0d, 01, 05, 05, 09, 16, 1a, 05, 09, 01, 05, 0a, 01, 1b, 01, 00, 2c, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 03, 00, 0d, 00, 18, 30, 05, 1a, 01, 03, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 16, 03, 00, 02, 00, 12, 00, 13, 13, 00, 17, 00, 18, 30, 0d, 11, 02, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] +Raw bytes (85): 0x[01, 01, 07, 07, 11, 09, 0d, 01, 05, 05, 09, 16, 1a, 05, 09, 01, 05, 0a, 01, 1c, 01, 00, 2c, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 03, 00, 0d, 00, 18, 30, 05, 1a, 01, 03, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 16, 03, 00, 02, 00, 12, 00, 13, 13, 00, 17, 00, 18, 30, 0d, 11, 02, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 7 @@ -47,7 +47,7 @@ Number of expressions: 7 - expression 5 operands: lhs = Counter(1), rhs = Counter(2) - expression 6 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 10 -- Code(Counter(0)) at (prev + 27, 1) to (start + 0, 44) +- Code(Counter(0)) at (prev + 28, 1) to (start + 0, 44) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) = ((c2 + c3) + c4) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) @@ -68,7 +68,7 @@ Number of file 0 mappings: 10 = ((c2 + c3) + c4) Function name: non_control_flow::assign_and -Raw bytes (64): 0x[01, 01, 04, 07, 0e, 09, 0d, 01, 05, 01, 05, 08, 01, 0c, 01, 00, 21, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02] +Raw bytes (64): 0x[01, 01, 04, 07, 0e, 09, 0d, 01, 05, 01, 05, 08, 01, 0d, 01, 00, 21, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 @@ -77,7 +77,7 @@ Number of expressions: 4 - expression 2 operands: lhs = Counter(0), rhs = Counter(1) - expression 3 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 8 -- Code(Counter(0)) at (prev + 12, 1) to (start + 0, 33) +- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 33) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) = ((c2 + c3) + (c0 - c1)) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) @@ -93,7 +93,7 @@ Number of file 0 mappings: 8 = ((c2 + c3) + (c0 - c1)) Function name: non_control_flow::assign_or -Raw bytes (64): 0x[01, 01, 04, 07, 0d, 05, 09, 01, 05, 01, 05, 08, 01, 11, 01, 00, 20, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 00, 02, 00, 0d, 00, 0e, 0e, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02] +Raw bytes (64): 0x[01, 01, 04, 07, 0d, 05, 09, 01, 05, 01, 05, 08, 01, 12, 01, 00, 20, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 00, 02, 00, 0d, 00, 0e, 0e, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 @@ -102,7 +102,7 @@ Number of expressions: 4 - expression 2 operands: lhs = Counter(0), rhs = Counter(1) - expression 3 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 8 -- Code(Counter(0)) at (prev + 17, 1) to (start + 0, 32) +- Code(Counter(0)) at (prev + 18, 1) to (start + 0, 32) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) = ((c1 + c2) + c3) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) @@ -119,15 +119,15 @@ Number of file 0 mappings: 8 = ((c1 + c2) + c3) Function name: non_control_flow::foo -Raw bytes (9): 0x[01, 01, 00, 01, 01, 25, 01, 02, 02] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 26, 01, 02, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 37, 1) to (start + 2, 2) +- Code(Counter(0)) at (prev + 38, 1) to (start + 2, 2) Function name: non_control_flow::func_call -Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 29, 01, 01, 0a, 28, 00, 02, 01, 09, 00, 0f, 30, 05, 02, 01, 02, 00, 00, 09, 00, 0a, 05, 00, 0e, 00, 0f, 30, 09, 0d, 02, 00, 00, 00, 0e, 00, 0f, 07, 01, 01, 00, 02] +Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 2a, 01, 01, 0a, 28, 00, 02, 01, 09, 00, 0f, 30, 05, 02, 01, 02, 00, 00, 09, 00, 0a, 05, 00, 0e, 00, 0f, 30, 09, 0d, 02, 00, 00, 00, 0e, 00, 0f, 07, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 3 @@ -135,7 +135,7 @@ Number of expressions: 3 - expression 1 operands: lhs = Expression(2, Add), rhs = Expression(0, Sub) - expression 2 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 6 -- Code(Counter(0)) at (prev + 41, 1) to (start + 1, 10) +- Code(Counter(0)) at (prev + 42, 1) to (start + 1, 10) - MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 9) to (start + 0, 15) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 9) to (start + 0, 10) true = c1 @@ -148,7 +148,7 @@ Number of file 0 mappings: 6 = ((c2 + c3) + (c0 - c1)) Function name: non_control_flow::right_comb_tree -Raw bytes (139): 0x[01, 01, 13, 07, 1a, 0b, 19, 0f, 15, 13, 11, 09, 0d, 01, 05, 01, 05, 05, 19, 05, 19, 4a, 15, 05, 19, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 0e, 01, 20, 01, 00, 41, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 05, 00, 0d, 00, 2a, 30, 05, 1a, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 13, 00, 14, 30, 4a, 19, 02, 03, 00, 00, 13, 00, 14, 4a, 00, 19, 00, 1a, 30, 46, 15, 03, 04, 00, 00, 19, 00, 1a, 46, 00, 1f, 00, 20, 30, 42, 11, 04, 05, 00, 00, 1f, 00, 20, 42, 00, 24, 00, 27, 30, 09, 0d, 05, 00, 00, 00, 24, 00, 27, 03, 01, 05, 01, 02] +Raw bytes (139): 0x[01, 01, 13, 07, 1a, 0b, 19, 0f, 15, 13, 11, 09, 0d, 01, 05, 01, 05, 05, 19, 05, 19, 4a, 15, 05, 19, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 0e, 01, 21, 01, 00, 41, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 05, 00, 0d, 00, 2a, 30, 05, 1a, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 13, 00, 14, 30, 4a, 19, 02, 03, 00, 00, 13, 00, 14, 4a, 00, 19, 00, 1a, 30, 46, 15, 03, 04, 00, 00, 19, 00, 1a, 46, 00, 1f, 00, 20, 30, 42, 11, 04, 05, 00, 00, 1f, 00, 20, 42, 00, 24, 00, 27, 30, 09, 0d, 05, 00, 00, 00, 24, 00, 27, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 19 @@ -172,7 +172,7 @@ Number of expressions: 19 - expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(5) - expression 18 operands: lhs = Counter(1), rhs = Counter(6) Number of file 0 mappings: 14 -- Code(Counter(0)) at (prev + 32, 1) to (start + 0, 65) +- Code(Counter(0)) at (prev + 33, 1) to (start + 0, 65) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) = (((((c2 + c3) + c4) + c5) + c6) + (c0 - c1)) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) diff --git a/tests/coverage/mcdc/non_control_flow.coverage b/tests/coverage/mcdc/non_control_flow.coverage index 6ae796e8ed2..c64f61a153c 100644 --- a/tests/coverage/mcdc/non_control_flow.coverage +++ b/tests/coverage/mcdc/non_control_flow.coverage @@ -1,6 +1,7 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 LL| |//@ min-llvm-version: 18 + LL| |//@ ignore-llvm-version: 19 - 99 LL| |//@ compile-flags: -Zcoverage-options=mcdc LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc LL| | diff --git a/tests/coverage/mcdc/non_control_flow.rs b/tests/coverage/mcdc/non_control_flow.rs index 77e64e6625b..633d381a1aa 100644 --- a/tests/coverage/mcdc/non_control_flow.rs +++ b/tests/coverage/mcdc/non_control_flow.rs @@ -1,6 +1,7 @@ #![feature(coverage_attribute)] //@ edition: 2021 //@ min-llvm-version: 18 +//@ ignore-llvm-version: 19 - 99 //@ compile-flags: -Zcoverage-options=mcdc //@ llvm-cov-flags: --show-branches=count --show-mcdc diff --git a/tests/crashes/119716-2.rs b/tests/crashes/119716-2.rs index 9cdc4417f5b..47bffb5c1de 100644 --- a/tests/crashes/119716-2.rs +++ b/tests/crashes/119716-2.rs @@ -1,4 +1,4 @@ //@ known-bug: #119716 #![feature(non_lifetime_binders)] trait Trait<T> {} -fn f<T>() -> impl for<T> Trait<impl Trait<T>> {} +fn f() -> impl for<T> Trait<impl Trait<T>> {} diff --git a/tests/crashes/123809.rs b/tests/crashes/123809.rs index c7a633aed01..75abe6dc0cd 100644 --- a/tests/crashes/123809.rs +++ b/tests/crashes/123809.rs @@ -1,4 +1,4 @@ //@ known-bug: #123809 -type Positive = std::pat::pattern_type!(std::pat:: is 0..); +type Positive = std::pat::pattern_type!(std::pat is 0..); pub fn main() {} diff --git a/tests/incremental/hashes/for_loops.rs b/tests/incremental/hashes/for_loops.rs index 9cd99bf76b7..b827ad9cc6f 100644 --- a/tests/incremental/hashes/for_loops.rs +++ b/tests/incremental/hashes/for_loops.rs @@ -103,9 +103,9 @@ pub fn change_iterable() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, promoted_mir, optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, promoted_mir")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, promoted_mir, optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, promoted_mir")] #[rustc_clean(cfg="cfail6")] pub fn change_iterable() { let mut _x = 0; diff --git a/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir index 9ebfff18f48..a93743edfac 100644 --- a/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir +++ b/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir @@ -37,11 +37,11 @@ fn full_tested_match() -> () { } bb2: { - falseEdge -> [real: bb7, imaginary: bb3]; + falseEdge -> [real: bb8, imaginary: bb3]; } bb3: { - falseEdge -> [real: bb12, imaginary: bb5]; + falseEdge -> [real: bb7, imaginary: bb5]; } bb4: { @@ -50,7 +50,7 @@ fn full_tested_match() -> () { bb5: { _1 = (const 3_i32, const 3_i32); - goto -> bb13; + goto -> bb14; } bb6: { @@ -58,18 +58,33 @@ fn full_tested_match() -> () { } bb7: { + StorageLive(_9); + _9 = ((_2 as Some).0: i32); + StorageLive(_10); + _10 = _9; + _1 = (const 2_i32, move _10); + StorageDead(_10); + StorageDead(_9); + goto -> bb14; + } + + bb8: { StorageLive(_6); _6 = &((_2 as Some).0: i32); _3 = &fake shallow _2; StorageLive(_7); - _7 = guard() -> [return: bb8, unwind: bb15]; + _7 = guard() -> [return: bb10, unwind: bb16]; } - bb8: { - switchInt(move _7) -> [0: bb10, otherwise: bb9]; + bb9: { + goto -> bb3; } - bb9: { + bb10: { + switchInt(move _7) -> [0: bb12, otherwise: bb11]; + } + + bb11: { StorageDead(_7); FakeRead(ForMatchGuard, _3); FakeRead(ForGuardBinding, _6); @@ -81,31 +96,20 @@ fn full_tested_match() -> () { StorageDead(_8); StorageDead(_5); StorageDead(_6); - goto -> bb13; + goto -> bb14; } - bb10: { - goto -> bb11; + bb12: { + goto -> bb13; } - bb11: { + bb13: { StorageDead(_7); StorageDead(_6); - goto -> bb3; - } - - bb12: { - StorageLive(_9); - _9 = ((_2 as Some).0: i32); - StorageLive(_10); - _10 = _9; - _1 = (const 2_i32, move _10); - StorageDead(_10); - StorageDead(_9); - goto -> bb13; + goto -> bb9; } - bb13: { + bb14: { PlaceMention(_1); StorageDead(_2); StorageDead(_1); @@ -113,12 +117,12 @@ fn full_tested_match() -> () { return; } - bb14: { + bb15: { FakeRead(ForMatchedPlace(None), _1); unreachable; } - bb15 (cleanup): { + bb16 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir index 4d2989ea93e..0d0ea2be1b0 100644 --- a/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir +++ b/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir @@ -37,7 +37,7 @@ fn full_tested_match2() -> () { } bb2: { - falseEdge -> [real: bb7, imaginary: bb5]; + falseEdge -> [real: bb8, imaginary: bb5]; } bb3: { @@ -48,7 +48,7 @@ fn full_tested_match2() -> () { _1 = (const 2_i32, move _10); StorageDead(_10); StorageDead(_9); - goto -> bb13; + goto -> bb14; } bb4: { @@ -56,7 +56,7 @@ fn full_tested_match2() -> () { } bb5: { - falseEdge -> [real: bb12, imaginary: bb3]; + falseEdge -> [real: bb7, imaginary: bb3]; } bb6: { @@ -64,18 +64,27 @@ fn full_tested_match2() -> () { } bb7: { + _1 = (const 3_i32, const 3_i32); + goto -> bb14; + } + + bb8: { StorageLive(_6); _6 = &((_2 as Some).0: i32); _3 = &fake shallow _2; StorageLive(_7); - _7 = guard() -> [return: bb8, unwind: bb15]; + _7 = guard() -> [return: bb10, unwind: bb16]; } - bb8: { - switchInt(move _7) -> [0: bb10, otherwise: bb9]; + bb9: { + falseEdge -> [real: bb3, imaginary: bb5]; } - bb9: { + bb10: { + switchInt(move _7) -> [0: bb12, otherwise: bb11]; + } + + bb11: { StorageDead(_7); FakeRead(ForMatchGuard, _3); FakeRead(ForGuardBinding, _6); @@ -87,25 +96,20 @@ fn full_tested_match2() -> () { StorageDead(_8); StorageDead(_5); StorageDead(_6); - goto -> bb13; + goto -> bb14; } - bb10: { - goto -> bb11; + bb12: { + goto -> bb13; } - bb11: { + bb13: { StorageDead(_7); StorageDead(_6); - falseEdge -> [real: bb3, imaginary: bb5]; - } - - bb12: { - _1 = (const 3_i32, const 3_i32); - goto -> bb13; + goto -> bb9; } - bb13: { + bb14: { PlaceMention(_1); StorageDead(_2); StorageDead(_1); @@ -113,12 +117,12 @@ fn full_tested_match2() -> () { return; } - bb14: { + bb15: { FakeRead(ForMatchedPlace(None), _1); unreachable; } - bb15 (cleanup): { + bb16 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match/match_false_edges.main.built.after.mir index 4ed93610706..87b7e29848f 100644 --- a/tests/mir-opt/building/match/match_false_edges.main.built.after.mir +++ b/tests/mir-opt/building/match/match_false_edges.main.built.after.mir @@ -43,11 +43,11 @@ fn main() -> () { } bb1: { - falseEdge -> [real: bb14, imaginary: bb4]; + falseEdge -> [real: bb11, imaginary: bb4]; } bb2: { - falseEdge -> [real: bb9, imaginary: bb1]; + falseEdge -> [real: bb12, imaginary: bb1]; } bb3: { @@ -64,11 +64,11 @@ fn main() -> () { _14 = _2; _1 = const 4_i32; StorageDead(_14); - goto -> bb20; + goto -> bb22; } bb6: { - falseEdge -> [real: bb15, imaginary: bb5]; + falseEdge -> [real: bb9, imaginary: bb5]; } bb7: { @@ -81,62 +81,70 @@ fn main() -> () { } bb9: { - StorageLive(_7); - _7 = &((_2 as Some).0: i32); + StorageLive(_11); + _11 = &((_2 as Some).0: i32); _3 = &fake shallow _2; - StorageLive(_8); - _8 = guard() -> [return: bb10, unwind: bb22]; + StorageLive(_12); + StorageLive(_13); + _13 = (*_11); + _12 = guard2(move _13) -> [return: bb18, unwind: bb24]; } bb10: { - switchInt(move _8) -> [0: bb12, otherwise: bb11]; + falseEdge -> [real: bb7, imaginary: bb5]; } bb11: { - StorageDead(_8); - FakeRead(ForMatchGuard, _3); - FakeRead(ForGuardBinding, _7); - StorageLive(_6); - _6 = ((_2 as Some).0: i32); - _1 = const 1_i32; - StorageDead(_6); - StorageDead(_7); - goto -> bb20; + StorageLive(_9); + _9 = _2; + _1 = const 2_i32; + StorageDead(_9); + goto -> bb22; } bb12: { - goto -> bb13; + StorageLive(_7); + _7 = &((_2 as Some).0: i32); + _3 = &fake shallow _2; + StorageLive(_8); + _8 = guard() -> [return: bb14, unwind: bb24]; } bb13: { - StorageDead(_8); - StorageDead(_7); falseEdge -> [real: bb3, imaginary: bb1]; } bb14: { - StorageLive(_9); - _9 = _2; - _1 = const 2_i32; - StorageDead(_9); - goto -> bb20; + switchInt(move _8) -> [0: bb16, otherwise: bb15]; } bb15: { - StorageLive(_11); - _11 = &((_2 as Some).0: i32); - _3 = &fake shallow _2; - StorageLive(_12); - StorageLive(_13); - _13 = (*_11); - _12 = guard2(move _13) -> [return: bb16, unwind: bb22]; + StorageDead(_8); + FakeRead(ForMatchGuard, _3); + FakeRead(ForGuardBinding, _7); + StorageLive(_6); + _6 = ((_2 as Some).0: i32); + _1 = const 1_i32; + StorageDead(_6); + StorageDead(_7); + goto -> bb22; } bb16: { - switchInt(move _12) -> [0: bb18, otherwise: bb17]; + goto -> bb17; } bb17: { + StorageDead(_8); + StorageDead(_7); + goto -> bb13; + } + + bb18: { + switchInt(move _12) -> [0: bb20, otherwise: bb19]; + } + + bb19: { StorageDead(_13); StorageDead(_12); FakeRead(ForMatchGuard, _3); @@ -146,21 +154,21 @@ fn main() -> () { _1 = const 3_i32; StorageDead(_10); StorageDead(_11); - goto -> bb20; + goto -> bb22; } - bb18: { - goto -> bb19; + bb20: { + goto -> bb21; } - bb19: { + bb21: { StorageDead(_13); StorageDead(_12); StorageDead(_11); - falseEdge -> [real: bb7, imaginary: bb5]; + goto -> bb10; } - bb20: { + bb22: { PlaceMention(_1); StorageDead(_2); StorageDead(_1); @@ -168,12 +176,12 @@ fn main() -> () { return; } - bb21: { + bb23: { FakeRead(ForMatchedPlace(None), _1); unreachable; } - bb22 (cleanup): { + bb24 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir index 2b5dbacc2d9..2bce79a3ae7 100644 --- a/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir @@ -31,7 +31,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { } bb2: { - falseEdge -> [real: bb12, imaginary: bb5]; + falseEdge -> [real: bb15, imaginary: bb5]; } bb3: { @@ -39,7 +39,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { } bb4: { - falseEdge -> [real: bb16, imaginary: bb1]; + falseEdge -> [real: bb13, imaginary: bb1]; } bb5: { @@ -51,7 +51,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { } bb7: { - falseEdge -> [real: bb15, imaginary: bb3]; + falseEdge -> [real: bb14, imaginary: bb3]; } bb8: { @@ -68,43 +68,43 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { } bb11: { - falseEdge -> [real: bb17, imaginary: bb10]; + falseEdge -> [real: bb12, imaginary: bb10]; } bb12: { - _6 = &fake shallow (_3.0: &str); - _7 = &fake shallow (_3.1: bool); - StorageLive(_10); - _10 = const true; - switchInt(move _10) -> [0: bb14, otherwise: bb13]; + _0 = const 4_u32; + goto -> bb18; } bb13: { - StorageDead(_10); - FakeRead(ForMatchGuard, _6); - FakeRead(ForMatchGuard, _7); - _0 = const 1_u32; + _0 = const 3_u32; goto -> bb18; } bb14: { - StorageDead(_10); - falseEdge -> [real: bb3, imaginary: bb5]; + _0 = const 2_u32; + goto -> bb18; } bb15: { - _0 = const 2_u32; - goto -> bb18; + _6 = &fake shallow (_3.0: &str); + _7 = &fake shallow (_3.1: bool); + StorageLive(_10); + _10 = const true; + switchInt(move _10) -> [0: bb17, otherwise: bb16]; } bb16: { - _0 = const 3_u32; + StorageDead(_10); + FakeRead(ForMatchGuard, _6); + FakeRead(ForMatchGuard, _7); + _0 = const 1_u32; goto -> bb18; } bb17: { - _0 = const 4_u32; - goto -> bb18; + StorageDead(_10); + falseEdge -> [real: bb3, imaginary: bb5]; } bb18: { diff --git a/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir index 07daa3eddfa..e521fb4509a 100644 --- a/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir @@ -23,7 +23,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 { } bb2: { - falseEdge -> [real: bb9, imaginary: bb3]; + falseEdge -> [real: bb11, imaginary: bb3]; } bb3: { @@ -32,7 +32,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 { } bb4: { - falseEdge -> [real: bb12, imaginary: bb5]; + falseEdge -> [real: bb10, imaginary: bb5]; } bb5: { @@ -40,7 +40,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 { } bb6: { - falseEdge -> [real: bb13, imaginary: bb1]; + falseEdge -> [real: bb9, imaginary: bb1]; } bb7: { @@ -54,32 +54,32 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 { } bb9: { - _3 = &fake shallow _1; - StorageLive(_8); - _8 = _2; - switchInt(move _8) -> [0: bb11, otherwise: bb10]; + _0 = const 2_u32; + goto -> bb14; } bb10: { - StorageDead(_8); - FakeRead(ForMatchGuard, _3); - _0 = const 0_u32; + _0 = const 1_u32; goto -> bb14; } bb11: { - StorageDead(_8); - falseEdge -> [real: bb1, imaginary: bb3]; + _3 = &fake shallow _1; + StorageLive(_8); + _8 = _2; + switchInt(move _8) -> [0: bb13, otherwise: bb12]; } bb12: { - _0 = const 1_u32; + StorageDead(_8); + FakeRead(ForMatchGuard, _3); + _0 = const 0_u32; goto -> bb14; } bb13: { - _0 = const 2_u32; - goto -> bb14; + StorageDead(_8); + falseEdge -> [real: bb1, imaginary: bb3]; } bb14: { diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff index 8415789de6e..21d91d0320a 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff @@ -22,12 +22,11 @@ StorageLive(_3); StorageLive(_4); _9 = const main::promoted[0]; -- _4 = _9; + _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); -+ _4 = const {ALLOC0<imm>: &[u32; 3]}; -+ _3 = const {ALLOC0<imm>: &[u32; 3]}; -+ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); ++ _3 = _9; ++ _2 = _9 as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; @@ -50,6 +49,4 @@ return; } } -+ -+ ALLOC0 (size: 12, align: 4) { .. } diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff index fea7caac3cd..889114c9862 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff @@ -22,12 +22,11 @@ StorageLive(_3); StorageLive(_4); _9 = const main::promoted[0]; -- _4 = _9; + _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); -+ _4 = const {ALLOC0<imm>: &[u32; 3]}; -+ _3 = const {ALLOC0<imm>: &[u32; 3]}; -+ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); ++ _3 = _9; ++ _2 = _9 as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; @@ -50,6 +49,4 @@ return; } } -+ -+ ALLOC0 (size: 12, align: 4) { .. } diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff index 8415789de6e..21d91d0320a 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff @@ -22,12 +22,11 @@ StorageLive(_3); StorageLive(_4); _9 = const main::promoted[0]; -- _4 = _9; + _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); -+ _4 = const {ALLOC0<imm>: &[u32; 3]}; -+ _3 = const {ALLOC0<imm>: &[u32; 3]}; -+ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); ++ _3 = _9; ++ _2 = _9 as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; @@ -50,6 +49,4 @@ return; } } -+ -+ ALLOC0 (size: 12, align: 4) { .. } diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff index fea7caac3cd..889114c9862 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff @@ -22,12 +22,11 @@ StorageLive(_3); StorageLive(_4); _9 = const main::promoted[0]; -- _4 = _9; + _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); -+ _4 = const {ALLOC0<imm>: &[u32; 3]}; -+ _3 = const {ALLOC0<imm>: &[u32; 3]}; -+ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); ++ _3 = _9; ++ _2 = _9 as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; @@ -50,6 +49,4 @@ return; } } -+ -+ ALLOC0 (size: 12, align: 4) { .. } diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 221fb18f92c..3d1b58965ac 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -7,7 +7,7 @@ fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: [[slice:_.*]] = const {{.*}} as &[u32] (PointerCoercion(Unsize)); + // CHECK: [[slice:_.*]] = {{.*}} as &[u32] (PointerCoercion(Unsize)); // CHECK: assert(const true, // CHECK: [[a]] = const 2_u32; let a = (&[1u32, 2, 3] as &[u32])[1]; diff --git a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff index e60f71f47b1..3d791734f46 100644 --- a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff @@ -55,17 +55,17 @@ bb2: { + Coverage::CounterIncrement(3); - falseEdge -> [real: bb6, imaginary: bb3]; + falseEdge -> [real: bb8, imaginary: bb3]; } bb3: { + Coverage::CounterIncrement(2); - falseEdge -> [real: bb8, imaginary: bb4]; + falseEdge -> [real: bb7, imaginary: bb4]; } bb4: { + Coverage::CounterIncrement(1); - falseEdge -> [real: bb10, imaginary: bb5]; + falseEdge -> [real: bb6, imaginary: bb5]; } bb5: { @@ -78,39 +78,39 @@ } bb6: { - StorageLive(_3); - _3 = ((_1 as D).0: u32); - StorageLive(_4); - _4 = _3; - _0 = consume(move _4) -> [return: bb7, unwind: bb14]; + StorageLive(_7); + _7 = ((_1 as B).0: u32); + StorageLive(_8); + _8 = _7; + _0 = consume(move _8) -> [return: bb11, unwind: bb14]; } bb7: { - StorageDead(_4); - StorageDead(_3); - goto -> bb13; - } - - bb8: { StorageLive(_5); _5 = ((_1 as C).0: u32); StorageLive(_6); _6 = _5; - _0 = consume(move _6) -> [return: bb9, unwind: bb14]; + _0 = consume(move _6) -> [return: bb10, unwind: bb14]; + } + + bb8: { + StorageLive(_3); + _3 = ((_1 as D).0: u32); + StorageLive(_4); + _4 = _3; + _0 = consume(move _4) -> [return: bb9, unwind: bb14]; } bb9: { - StorageDead(_6); - StorageDead(_5); + StorageDead(_4); + StorageDead(_3); goto -> bb13; } bb10: { - StorageLive(_7); - _7 = ((_1 as B).0: u32); - StorageLive(_8); - _8 = _7; - _0 = consume(move _8) -> [return: bb11, unwind: bb14]; + StorageDead(_6); + StorageDead(_5); + goto -> bb13; } bb11: { diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff index 3a5762e4f3d..efb28ba344b 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff @@ -33,7 +33,7 @@ _8 = const 3_usize; _9 = Ge(move _7, move _8); - switchInt(move _9) -> [0: bb7, otherwise: bb8]; -+ switchInt(move _9) -> [0: bb10, otherwise: bb7]; ++ switchInt(move _9) -> [0: bb11, otherwise: bb7]; } bb3: { @@ -49,48 +49,48 @@ } bb6: { -- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; -+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; +- switchInt((*_2)[3 of 4]) -> [47: bb13, otherwise: bb2]; ++ switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; } bb7: { - _0 = const false; - goto -> bb14; -+ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; ++ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb11]; } bb8: { - switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7]; -+ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; ++ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb11]; } bb9: { - switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7]; -+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; ++ switchInt((*_2)[2 of 3]) -> [47: bb10, 33: bb10, otherwise: bb11]; } bb10: { -- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7]; +- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb11, otherwise: bb7]; - } - - bb11: { - _0 = const false; + _0 = const true; - goto -> bb14; + goto -> bb12; } - bb12: { +- _0 = const true; +- goto -> bb14; +- } +- +- bb13: { + bb11: { - _0 = const true; + _0 = const false; - goto -> bb14; + goto -> bb12; } -- bb13: { -- _0 = const true; -- goto -> bb14; -- } -- - bb14: { + bb12: { StorageDead(_2); diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff index 21b197d2f27..c6e2d3a5512 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff @@ -33,7 +33,7 @@ _8 = const 3_usize; _9 = Ge(move _7, move _8); - switchInt(move _9) -> [0: bb7, otherwise: bb8]; -+ switchInt(move _9) -> [0: bb10, otherwise: bb7]; ++ switchInt(move _9) -> [0: bb11, otherwise: bb7]; } bb3: { @@ -49,48 +49,48 @@ } bb6: { -- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; -+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; +- switchInt((*_2)[3 of 4]) -> [47: bb13, otherwise: bb2]; ++ switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; } bb7: { - _0 = const false; - goto -> bb14; -+ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; ++ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb11]; } bb8: { - switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7]; -+ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; ++ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb11]; } bb9: { - switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7]; -+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; ++ switchInt((*_2)[2 of 3]) -> [47: bb10, 33: bb10, otherwise: bb11]; } bb10: { -- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7]; +- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb11, otherwise: bb7]; - } - - bb11: { - _0 = const false; + _0 = const true; - goto -> bb14; + goto -> bb12; } - bb12: { +- _0 = const true; +- goto -> bb14; +- } +- +- bb13: { + bb11: { - _0 = const true; + _0 = const false; - goto -> bb14; + goto -> bb12; } -- bb13: { -- _0 = const true; -- goto -> bb14; -- } -- - bb14: { + bb12: { StorageDead(_2); diff --git a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff index 7776ff0fde7..41ae2fd3af3 100644 --- a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff @@ -38,15 +38,20 @@ bb2: { _6 = discriminant((_3.1: std::option::Option<u32>)); - switchInt(move _6) -> [1: bb4, 0: bb1, otherwise: bb7]; + switchInt(move _6) -> [1: bb5, 0: bb1, otherwise: bb7]; } bb3: { _7 = discriminant((_3.1: std::option::Option<u32>)); - switchInt(move _7) -> [0: bb5, 1: bb1, otherwise: bb7]; + switchInt(move _7) -> [0: bb4, 1: bb1, otherwise: bb7]; } bb4: { + _0 = const 2_u32; + goto -> bb6; + } + + bb5: { StorageLive(_9); _9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); StorageLive(_10); @@ -57,11 +62,6 @@ goto -> bb6; } - bb5: { - _0 = const 2_u32; - goto -> bb6; - } - bb6: { StorageDead(_3); return; diff --git a/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff index b41e952d80f..302fd0bfded 100644 --- a/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff @@ -49,7 +49,7 @@ bb2: { - _6 = discriminant((_3.1: Option2<bool>)); -- switchInt(move _6) -> [0: bb5, otherwise: bb1]; +- switchInt(move _6) -> [0: bb7, otherwise: bb1]; - } - - bb3: { @@ -59,17 +59,11 @@ - - bb4: { - _8 = discriminant((_3.1: Option2<bool>)); -- switchInt(move _8) -> [2: bb7, otherwise: bb1]; +- switchInt(move _8) -> [2: bb5, otherwise: bb1]; - } - - bb5: { - StorageLive(_10); - _10 = (((_3.0: Option2<u32>) as Some).0: u32); - StorageLive(_11); - _11 = (((_3.1: Option2<bool>) as Some).0: bool); - _0 = const 0_u32; - StorageDead(_11); - StorageDead(_10); + _0 = const 3_u32; - goto -> bb8; + goto -> bb5; } @@ -83,7 +77,13 @@ - bb7: { + bb4: { - _0 = const 3_u32; + StorageLive(_10); + _10 = (((_3.0: Option2<u32>) as Some).0: u32); + StorageLive(_11); + _11 = (((_3.1: Option2<bool>) as Some).0: bool); + _0 = const 0_u32; + StorageDead(_11); + StorageDead(_10); - goto -> bb8; + goto -> bb5; } @@ -101,7 +101,7 @@ + + bb7: { + StorageDead(_13); -+ switchInt(_9) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb6]; ++ switchInt(_9) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb6]; } } diff --git a/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff index 18dea56f430..eef4fb3278c 100644 --- a/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff @@ -49,7 +49,7 @@ bb2: { - _6 = discriminant((_3.1: Option2<u32>)); -- switchInt(move _6) -> [0: bb5, otherwise: bb1]; +- switchInt(move _6) -> [0: bb7, otherwise: bb1]; - } - - bb3: { @@ -59,17 +59,11 @@ - - bb4: { - _8 = discriminant((_3.1: Option2<u32>)); -- switchInt(move _8) -> [2: bb7, otherwise: bb1]; +- switchInt(move _8) -> [2: bb5, otherwise: bb1]; - } - - bb5: { - StorageLive(_10); - _10 = (((_3.0: Option2<u32>) as Some).0: u32); - StorageLive(_11); - _11 = (((_3.1: Option2<u32>) as Some).0: u32); - _0 = const 0_u32; - StorageDead(_11); - StorageDead(_10); + _0 = const 3_u32; - goto -> bb8; + goto -> bb5; } @@ -83,7 +77,13 @@ - bb7: { + bb4: { - _0 = const 3_u32; + StorageLive(_10); + _10 = (((_3.0: Option2<u32>) as Some).0: u32); + StorageLive(_11); + _11 = (((_3.1: Option2<u32>) as Some).0: u32); + _0 = const 0_u32; + StorageDead(_11); + StorageDead(_10); - goto -> bb8; + goto -> bb5; } @@ -101,7 +101,7 @@ + + bb7: { + StorageDead(_13); -+ switchInt(_9) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb6]; ++ switchInt(_9) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb6]; } } diff --git a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff index 4c3c717b522..cb03e2697cc 100644 --- a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff @@ -52,7 +52,7 @@ bb3: { _8 = discriminant((_4.2: std::option::Option<u32>)); - switchInt(move _8) -> [1: bb6, 0: bb1, otherwise: bb9]; + switchInt(move _8) -> [1: bb7, 0: bb1, otherwise: bb9]; } bb4: { @@ -62,10 +62,15 @@ bb5: { _10 = discriminant((_4.2: std::option::Option<u32>)); - switchInt(move _10) -> [0: bb7, 1: bb1, otherwise: bb9]; + switchInt(move _10) -> [0: bb6, 1: bb1, otherwise: bb9]; } bb6: { + _0 = const 2_u32; + goto -> bb8; + } + + bb7: { StorageLive(_13); _13 = (((_4.0: std::option::Option<u32>) as Some).0: u32); StorageLive(_14); @@ -79,11 +84,6 @@ goto -> bb8; } - bb7: { - _0 = const 2_u32; - goto -> bb8; - } - bb8: { StorageDead(_4); return; diff --git a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff index 0ea7a10baaa..5634df253a5 100644 --- a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff @@ -64,8 +64,8 @@ - - bb3: { _8 = discriminant((_4.2: Option2<u32>)); -- switchInt(move _8) -> [0: bb8, otherwise: bb1]; -+ switchInt(move _8) -> [0: bb5, otherwise: bb1]; +- switchInt(move _8) -> [0: bb10, otherwise: bb1]; ++ switchInt(move _8) -> [0: bb7, otherwise: bb1]; } - bb4: { @@ -88,22 +88,13 @@ - bb7: { + bb4: { _12 = discriminant((_4.2: Option2<u32>)); -- switchInt(move _12) -> [2: bb10, otherwise: bb1]; -+ switchInt(move _12) -> [2: bb7, otherwise: bb1]; +- switchInt(move _12) -> [2: bb8, otherwise: bb1]; ++ switchInt(move _12) -> [2: bb5, otherwise: bb1]; } - bb8: { + bb5: { - StorageLive(_15); - _15 = (((_4.0: Option2<u32>) as Some).0: u32); - StorageLive(_16); - _16 = (((_4.1: Option2<u32>) as Some).0: u32); - StorageLive(_17); - _17 = (((_4.2: Option2<u32>) as Some).0: u32); - _0 = const 0_u32; - StorageDead(_17); - StorageDead(_16); - StorageDead(_15); + _0 = const 3_u32; - goto -> bb11; + goto -> bb8; } @@ -117,7 +108,16 @@ - bb10: { + bb7: { - _0 = const 3_u32; + StorageLive(_15); + _15 = (((_4.0: Option2<u32>) as Some).0: u32); + StorageLive(_16); + _16 = (((_4.1: Option2<u32>) as Some).0: u32); + StorageLive(_17); + _17 = (((_4.2: Option2<u32>) as Some).0: u32); + _0 = const 0_u32; + StorageDead(_17); + StorageDead(_16); + StorageDead(_15); - goto -> bb11; + goto -> bb8; } diff --git a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index de12fe8f120..8179d9dd115 100644 --- a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -94,78 +94,56 @@ bb2: { _35 = deref_copy (_4.1: &ViewportPercentageLength); _7 = discriminant((*_35)); - switchInt(move _7) -> [0: bb6, otherwise: bb1]; + switchInt(move _7) -> [0: bb9, otherwise: bb1]; } bb3: { _36 = deref_copy (_4.1: &ViewportPercentageLength); _8 = discriminant((*_36)); - switchInt(move _8) -> [1: bb7, otherwise: bb1]; + switchInt(move _8) -> [1: bb8, otherwise: bb1]; } bb4: { _37 = deref_copy (_4.1: &ViewportPercentageLength); _9 = discriminant((*_37)); - switchInt(move _9) -> [2: bb8, otherwise: bb1]; + switchInt(move _9) -> [2: bb7, otherwise: bb1]; } bb5: { _38 = deref_copy (_4.1: &ViewportPercentageLength); _10 = discriminant((*_38)); - switchInt(move _10) -> [3: bb9, otherwise: bb1]; + switchInt(move _10) -> [3: bb6, otherwise: bb1]; } bb6: { - StorageLive(_12); + StorageLive(_27); _39 = deref_copy (_4.0: &ViewportPercentageLength); - _12 = (((*_39) as Vw).0: f32); - StorageLive(_13); + _27 = (((*_39) as Vmax).0: f32); + StorageLive(_28); _40 = deref_copy (_4.1: &ViewportPercentageLength); - _13 = (((*_40) as Vw).0: f32); - StorageLive(_14); - StorageLive(_15); - _15 = _12; - StorageLive(_16); - _16 = _13; - _14 = Add(move _15, move _16); - StorageDead(_16); - StorageDead(_15); - _3 = ViewportPercentageLength::Vw(move _14); - StorageDead(_14); - StorageDead(_13); - StorageDead(_12); + _28 = (((*_40) as Vmax).0: f32); + StorageLive(_29); + StorageLive(_30); + _30 = _27; + StorageLive(_31); + _31 = _28; + _29 = Add(move _30, move _31); + StorageDead(_31); + StorageDead(_30); + _3 = ViewportPercentageLength::Vmax(move _29); + StorageDead(_29); + StorageDead(_28); + StorageDead(_27); goto -> bb10; } bb7: { - StorageLive(_17); - _41 = deref_copy (_4.0: &ViewportPercentageLength); - _17 = (((*_41) as Vh).0: f32); - StorageLive(_18); - _42 = deref_copy (_4.1: &ViewportPercentageLength); - _18 = (((*_42) as Vh).0: f32); - StorageLive(_19); - StorageLive(_20); - _20 = _17; - StorageLive(_21); - _21 = _18; - _19 = Add(move _20, move _21); - StorageDead(_21); - StorageDead(_20); - _3 = ViewportPercentageLength::Vh(move _19); - StorageDead(_19); - StorageDead(_18); - StorageDead(_17); - goto -> bb10; - } - - bb8: { StorageLive(_22); - _43 = deref_copy (_4.0: &ViewportPercentageLength); - _22 = (((*_43) as Vmin).0: f32); + _41 = deref_copy (_4.0: &ViewportPercentageLength); + _22 = (((*_41) as Vmin).0: f32); StorageLive(_23); - _44 = deref_copy (_4.1: &ViewportPercentageLength); - _23 = (((*_44) as Vmin).0: f32); + _42 = deref_copy (_4.1: &ViewportPercentageLength); + _23 = (((*_42) as Vmin).0: f32); StorageLive(_24); StorageLive(_25); _25 = _22; @@ -181,25 +159,47 @@ goto -> bb10; } + bb8: { + StorageLive(_17); + _43 = deref_copy (_4.0: &ViewportPercentageLength); + _17 = (((*_43) as Vh).0: f32); + StorageLive(_18); + _44 = deref_copy (_4.1: &ViewportPercentageLength); + _18 = (((*_44) as Vh).0: f32); + StorageLive(_19); + StorageLive(_20); + _20 = _17; + StorageLive(_21); + _21 = _18; + _19 = Add(move _20, move _21); + StorageDead(_21); + StorageDead(_20); + _3 = ViewportPercentageLength::Vh(move _19); + StorageDead(_19); + StorageDead(_18); + StorageDead(_17); + goto -> bb10; + } + bb9: { - StorageLive(_27); + StorageLive(_12); _45 = deref_copy (_4.0: &ViewportPercentageLength); - _27 = (((*_45) as Vmax).0: f32); - StorageLive(_28); + _12 = (((*_45) as Vw).0: f32); + StorageLive(_13); _46 = deref_copy (_4.1: &ViewportPercentageLength); - _28 = (((*_46) as Vmax).0: f32); - StorageLive(_29); - StorageLive(_30); - _30 = _27; - StorageLive(_31); - _31 = _28; - _29 = Add(move _30, move _31); - StorageDead(_31); - StorageDead(_30); - _3 = ViewportPercentageLength::Vmax(move _29); - StorageDead(_29); - StorageDead(_28); - StorageDead(_27); + _13 = (((*_46) as Vw).0: f32); + StorageLive(_14); + StorageLive(_15); + _15 = _12; + StorageLive(_16); + _16 = _13; + _14 = Add(move _15, move _16); + StorageDead(_16); + StorageDead(_15); + _3 = ViewportPercentageLength::Vw(move _14); + StorageDead(_14); + StorageDead(_13); + StorageDead(_12); goto -> bb10; } diff --git a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff index 350e5fe6db5..651b1de4ddd 100644 --- a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff @@ -45,12 +45,12 @@ bb2: { _6 = discriminant((_3.1: std::option::Option<u32>)); - switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb1]; + switchInt(move _6) -> [0: bb6, 1: bb7, otherwise: bb1]; } bb3: { _7 = discriminant((_3.1: std::option::Option<u32>)); - switchInt(move _7) -> [0: bb4, 1: bb7, otherwise: bb1]; + switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb1]; } bb4: { @@ -59,13 +59,10 @@ } bb5: { - StorageLive(_9); - _9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); - StorageLive(_10); - _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); - _0 = const 0_u32; - StorageDead(_10); - StorageDead(_9); + StorageLive(_12); + _12 = (((_3.1: std::option::Option<u32>) as Some).0: u32); + _0 = const 2_u32; + StorageDead(_12); goto -> bb8; } @@ -78,10 +75,13 @@ } bb7: { - StorageLive(_12); - _12 = (((_3.1: std::option::Option<u32>) as Some).0: u32); - _0 = const 2_u32; - StorageDead(_12); + StorageLive(_9); + _9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); + StorageLive(_10); + _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); + _0 = const 0_u32; + StorageDead(_10); + StorageDead(_9); goto -> bb8; } diff --git a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff index bbbfe90691f..8009721fa5c 100644 --- a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff @@ -24,7 +24,7 @@ bb1: { _4 = discriminant(_1); - switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; + switchInt(move _4) -> [0: bb6, 1: bb5, 2: bb4, 3: bb3, otherwise: bb2]; } bb2: { @@ -39,11 +39,11 @@ } bb4: { - StorageLive(_5); - _5 = DFA::B; - _1 = move _5; + StorageLive(_7); + _7 = DFA::D; + _1 = move _7; _3 = const (); - StorageDead(_5); + StorageDead(_7); goto -> bb1; } @@ -57,11 +57,11 @@ } bb6: { - StorageLive(_7); - _7 = DFA::D; - _1 = move _7; + StorageLive(_5); + _5 = DFA::B; + _1 = move _5; _3 = const (); - StorageDead(_7); + StorageDead(_5); goto -> bb1; } } diff --git a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff index bbbfe90691f..8009721fa5c 100644 --- a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff @@ -24,7 +24,7 @@ bb1: { _4 = discriminant(_1); - switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; + switchInt(move _4) -> [0: bb6, 1: bb5, 2: bb4, 3: bb3, otherwise: bb2]; } bb2: { @@ -39,11 +39,11 @@ } bb4: { - StorageLive(_5); - _5 = DFA::B; - _1 = move _5; + StorageLive(_7); + _7 = DFA::D; + _1 = move _7; _3 = const (); - StorageDead(_5); + StorageDead(_7); goto -> bb1; } @@ -57,11 +57,11 @@ } bb6: { - StorageLive(_7); - _7 = DFA::D; - _1 = move _7; + StorageLive(_5); + _5 = DFA::B; + _1 = move _5; _3 = const (); - StorageDead(_7); + StorageDead(_5); goto -> bb1; } } diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index e5d8525dcac..6486a321e69 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -93,19 +93,19 @@ fn dfa() { // CHECK: {{_.*}} = DFA::A; // CHECK: goto -> bb1; // CHECK: bb1: { - // CHECK: switchInt({{.*}}) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; + // CHECK: switchInt({{.*}}) -> [0: bb6, 1: bb5, 2: bb4, 3: bb3, otherwise: bb2]; // CHECK: bb2: { // CHECK: unreachable; // CHECK: bb3: { // CHECK: return; // CHECK: bb4: { - // CHECK: {{_.*}} = DFA::B; + // CHECK: {{_.*}} = DFA::D; // CHECK: goto -> bb1; // CHECK: bb5: { // CHECK: {{_.*}} = DFA::C; // CHECK: goto -> bb1; // CHECK: bb6: { - // CHECK: {{_.*}} = DFA::D; + // CHECK: {{_.*}} = DFA::B; // CHECK: goto -> bb1; let mut state = DFA::A; loop { diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 4f29e5244d7..3c4a84bc243 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -33,17 +33,17 @@ bb0: { PlaceMention(_2); - switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1]; -+ switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; ++ switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1]; } bb1: { - switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3]; -+ switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; ++ switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2]; } bb2: { -- falseEdge -> [real: bb8, imaginary: bb1]; -+ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; +- falseEdge -> [real: bb9, imaginary: bb1]; ++ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb4]; } bb3: { @@ -51,11 +51,11 @@ - } - - bb4: { -- falseEdge -> [real: bb13, imaginary: bb3]; +- falseEdge -> [real: bb8, imaginary: bb3]; - } - - bb5: { -- falseEdge -> [real: bb20, imaginary: bb6]; +- falseEdge -> [real: bb7, imaginary: bb6]; - } - - bb6: { @@ -63,20 +63,38 @@ _15 = (_2.1: bool); StorageLive(_16); _16 = move (_2.2: std::string::String); -- goto -> bb19; -+ goto -> bb16; +- goto -> bb20; ++ goto -> bb17; } - bb7: { + bb4: { - _0 = const 1_i32; -- drop(_7) -> [return: bb18, unwind: bb25]; -+ drop(_7) -> [return: bb15, unwind: bb22]; + StorageLive(_15); + _15 = (_2.1: bool); + StorageLive(_16); + _16 = move (_2.2: std::string::String); +- goto -> bb20; ++ goto -> bb17; } - bb8: { + bb5: { StorageLive(_6); + _6 = &(_2.0: bool); + StorageLive(_8); + _8 = &(_2.2: std::string::String); +- _3 = &fake shallow (_2.0: bool); +- _4 = &fake shallow (_2.1: bool); + StorageLive(_12); + StorageLive(_13); + _13 = _1; +- switchInt(move _13) -> [0: bb16, otherwise: bb15]; ++ switchInt(move _13) -> [0: bb13, otherwise: bb12]; + } + +- bb9: { ++ bb6: { + StorageLive(_6); _6 = &(_2.1: bool); StorageLive(_8); _8 = &(_2.2: std::string::String); @@ -85,12 +103,19 @@ StorageLive(_9); StorageLive(_10); _10 = _1; -- switchInt(move _10) -> [0: bb10, otherwise: bb9]; -+ switchInt(move _10) -> [0: bb7, otherwise: bb6]; +- switchInt(move _10) -> [0: bb12, otherwise: bb11]; ++ switchInt(move _10) -> [0: bb9, otherwise: bb8]; } -- bb9: { -+ bb6: { +- bb10: { ++ bb7: { + _0 = const 1_i32; +- drop(_7) -> [return: bb19, unwind: bb25]; ++ drop(_7) -> [return: bb16, unwind: bb22]; + } + +- bb11: { ++ bb8: { _0 = const 3_i32; StorageDead(_10); StorageDead(_9); @@ -98,15 +123,15 @@ + goto -> bb20; } -- bb10: { -+ bb7: { +- bb12: { ++ bb9: { _9 = (*_6); -- switchInt(move _9) -> [0: bb12, otherwise: bb11]; -+ switchInt(move _9) -> [0: bb9, otherwise: bb8]; +- switchInt(move _9) -> [0: bb14, otherwise: bb13]; ++ switchInt(move _9) -> [0: bb11, otherwise: bb10]; } -- bb11: { -+ bb8: { +- bb13: { ++ bb10: { StorageDead(_10); StorageDead(_9); - FakeRead(ForMatchGuard, _3); @@ -117,12 +142,12 @@ _5 = (_2.1: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); -- goto -> bb7; -+ goto -> bb4; +- goto -> bb10; ++ goto -> bb7; } -- bb12: { -+ bb9: { +- bb14: { ++ bb11: { StorageDead(_10); StorageDead(_9); StorageDead(_8); @@ -131,23 +156,8 @@ + goto -> bb1; } -- bb13: { -+ bb10: { - StorageLive(_6); - _6 = &(_2.0: bool); - StorageLive(_8); - _8 = &(_2.2: std::string::String); -- _3 = &fake shallow (_2.0: bool); -- _4 = &fake shallow (_2.1: bool); - StorageLive(_12); - StorageLive(_13); - _13 = _1; -- switchInt(move _13) -> [0: bb15, otherwise: bb14]; -+ switchInt(move _13) -> [0: bb12, otherwise: bb11]; - } - -- bb14: { -+ bb11: { +- bb15: { ++ bb12: { _0 = const 3_i32; StorageDead(_13); StorageDead(_12); @@ -155,15 +165,15 @@ + goto -> bb20; } -- bb15: { -+ bb12: { +- bb16: { ++ bb13: { _12 = (*_6); -- switchInt(move _12) -> [0: bb17, otherwise: bb16]; -+ switchInt(move _12) -> [0: bb14, otherwise: bb13]; +- switchInt(move _12) -> [0: bb18, otherwise: bb17]; ++ switchInt(move _12) -> [0: bb15, otherwise: bb14]; } -- bb16: { -+ bb13: { +- bb17: { ++ bb14: { StorageDead(_13); StorageDead(_12); - FakeRead(ForMatchGuard, _3); @@ -174,12 +184,12 @@ _5 = (_2.0: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); -- goto -> bb7; -+ goto -> bb4; +- goto -> bb10; ++ goto -> bb7; } -- bb17: { -+ bb14: { +- bb18: { ++ bb15: { StorageDead(_13); StorageDead(_12); StorageDead(_8); @@ -188,8 +198,8 @@ + goto -> bb2; } -- bb18: { -+ bb15: { +- bb19: { ++ bb16: { StorageDead(_7); StorageDead(_5); StorageDead(_8); @@ -198,23 +208,13 @@ + goto -> bb19; } -- bb19: { -+ bb16: { +- bb20: { ++ bb17: { _0 = const 2_i32; - drop(_16) -> [return: bb21, unwind: bb25]; + drop(_16) -> [return: bb18, unwind: bb22]; } -- bb20: { -+ bb17: { - StorageLive(_15); - _15 = (_2.1: bool); - StorageLive(_16); - _16 = move (_2.2: std::string::String); -- goto -> bb19; -+ goto -> bb16; - } - - bb21: { + bb18: { StorageDead(_16); diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 4f29e5244d7..3c4a84bc243 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -33,17 +33,17 @@ bb0: { PlaceMention(_2); - switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1]; -+ switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; ++ switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1]; } bb1: { - switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3]; -+ switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; ++ switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2]; } bb2: { -- falseEdge -> [real: bb8, imaginary: bb1]; -+ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; +- falseEdge -> [real: bb9, imaginary: bb1]; ++ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb4]; } bb3: { @@ -51,11 +51,11 @@ - } - - bb4: { -- falseEdge -> [real: bb13, imaginary: bb3]; +- falseEdge -> [real: bb8, imaginary: bb3]; - } - - bb5: { -- falseEdge -> [real: bb20, imaginary: bb6]; +- falseEdge -> [real: bb7, imaginary: bb6]; - } - - bb6: { @@ -63,20 +63,38 @@ _15 = (_2.1: bool); StorageLive(_16); _16 = move (_2.2: std::string::String); -- goto -> bb19; -+ goto -> bb16; +- goto -> bb20; ++ goto -> bb17; } - bb7: { + bb4: { - _0 = const 1_i32; -- drop(_7) -> [return: bb18, unwind: bb25]; -+ drop(_7) -> [return: bb15, unwind: bb22]; + StorageLive(_15); + _15 = (_2.1: bool); + StorageLive(_16); + _16 = move (_2.2: std::string::String); +- goto -> bb20; ++ goto -> bb17; } - bb8: { + bb5: { StorageLive(_6); + _6 = &(_2.0: bool); + StorageLive(_8); + _8 = &(_2.2: std::string::String); +- _3 = &fake shallow (_2.0: bool); +- _4 = &fake shallow (_2.1: bool); + StorageLive(_12); + StorageLive(_13); + _13 = _1; +- switchInt(move _13) -> [0: bb16, otherwise: bb15]; ++ switchInt(move _13) -> [0: bb13, otherwise: bb12]; + } + +- bb9: { ++ bb6: { + StorageLive(_6); _6 = &(_2.1: bool); StorageLive(_8); _8 = &(_2.2: std::string::String); @@ -85,12 +103,19 @@ StorageLive(_9); StorageLive(_10); _10 = _1; -- switchInt(move _10) -> [0: bb10, otherwise: bb9]; -+ switchInt(move _10) -> [0: bb7, otherwise: bb6]; +- switchInt(move _10) -> [0: bb12, otherwise: bb11]; ++ switchInt(move _10) -> [0: bb9, otherwise: bb8]; } -- bb9: { -+ bb6: { +- bb10: { ++ bb7: { + _0 = const 1_i32; +- drop(_7) -> [return: bb19, unwind: bb25]; ++ drop(_7) -> [return: bb16, unwind: bb22]; + } + +- bb11: { ++ bb8: { _0 = const 3_i32; StorageDead(_10); StorageDead(_9); @@ -98,15 +123,15 @@ + goto -> bb20; } -- bb10: { -+ bb7: { +- bb12: { ++ bb9: { _9 = (*_6); -- switchInt(move _9) -> [0: bb12, otherwise: bb11]; -+ switchInt(move _9) -> [0: bb9, otherwise: bb8]; +- switchInt(move _9) -> [0: bb14, otherwise: bb13]; ++ switchInt(move _9) -> [0: bb11, otherwise: bb10]; } -- bb11: { -+ bb8: { +- bb13: { ++ bb10: { StorageDead(_10); StorageDead(_9); - FakeRead(ForMatchGuard, _3); @@ -117,12 +142,12 @@ _5 = (_2.1: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); -- goto -> bb7; -+ goto -> bb4; +- goto -> bb10; ++ goto -> bb7; } -- bb12: { -+ bb9: { +- bb14: { ++ bb11: { StorageDead(_10); StorageDead(_9); StorageDead(_8); @@ -131,23 +156,8 @@ + goto -> bb1; } -- bb13: { -+ bb10: { - StorageLive(_6); - _6 = &(_2.0: bool); - StorageLive(_8); - _8 = &(_2.2: std::string::String); -- _3 = &fake shallow (_2.0: bool); -- _4 = &fake shallow (_2.1: bool); - StorageLive(_12); - StorageLive(_13); - _13 = _1; -- switchInt(move _13) -> [0: bb15, otherwise: bb14]; -+ switchInt(move _13) -> [0: bb12, otherwise: bb11]; - } - -- bb14: { -+ bb11: { +- bb15: { ++ bb12: { _0 = const 3_i32; StorageDead(_13); StorageDead(_12); @@ -155,15 +165,15 @@ + goto -> bb20; } -- bb15: { -+ bb12: { +- bb16: { ++ bb13: { _12 = (*_6); -- switchInt(move _12) -> [0: bb17, otherwise: bb16]; -+ switchInt(move _12) -> [0: bb14, otherwise: bb13]; +- switchInt(move _12) -> [0: bb18, otherwise: bb17]; ++ switchInt(move _12) -> [0: bb15, otherwise: bb14]; } -- bb16: { -+ bb13: { +- bb17: { ++ bb14: { StorageDead(_13); StorageDead(_12); - FakeRead(ForMatchGuard, _3); @@ -174,12 +184,12 @@ _5 = (_2.0: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); -- goto -> bb7; -+ goto -> bb4; +- goto -> bb10; ++ goto -> bb7; } -- bb17: { -+ bb14: { +- bb18: { ++ bb15: { StorageDead(_13); StorageDead(_12); StorageDead(_8); @@ -188,8 +198,8 @@ + goto -> bb2; } -- bb18: { -+ bb15: { +- bb19: { ++ bb16: { StorageDead(_7); StorageDead(_5); StorageDead(_8); @@ -198,23 +208,13 @@ + goto -> bb19; } -- bb19: { -+ bb16: { +- bb20: { ++ bb17: { _0 = const 2_i32; - drop(_16) -> [return: bb21, unwind: bb25]; + drop(_16) -> [return: bb18, unwind: bb22]; } -- bb20: { -+ bb17: { - StorageLive(_15); - _15 = (_2.1: bool); - StorageLive(_16); - _16 = move (_2.2: std::string::String); -- goto -> bb19; -+ goto -> bb16; - } - - bb21: { + bb18: { StorageDead(_16); diff --git a/tests/mir-opt/matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff index 1f20349fdec..fc34ce7125e 100644 --- a/tests/mir-opt/matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff @@ -5,37 +5,42 @@ debug i => _1; let mut _0: u128; let mut _2: i128; ++ let mut _3: i128; bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [1: bb3, 2: bb4, 3: bb5, 340282366920938463463374607431768211455: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const core::num::<impl u128>::MAX; - goto -> bb6; - } - - bb3: { - _0 = const 1_u128; - goto -> bb6; - } - - bb4: { - _0 = const 2_u128; - goto -> bb6; - } - - bb5: { - _0 = const 3_u128; - goto -> bb6; - } - - bb6: { +- switchInt(move _2) -> [1: bb5, 2: bb4, 3: bb3, 340282366920938463463374607431768211455: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const core::num::<impl u128>::MAX; +- goto -> bb6; +- } +- +- bb3: { +- _0 = const 3_u128; +- goto -> bb6; +- } +- +- bb4: { +- _0 = const 2_u128; +- goto -> bb6; +- } +- +- bb5: { +- _0 = const 1_u128; +- goto -> bb6; +- } +- +- bb6: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as u128 (IntToInt); ++ StorageDead(_3); return; } } diff --git a/tests/mir-opt/matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff deleted file mode 100644 index 4b435310916..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `match_i16_i8` before MatchBranchSimplification -+ // MIR for `match_i16_i8` after MatchBranchSimplification - - fn match_i16_i8(_1: EnumAi16) -> i8 { - debug i => _1; - let mut _0: i8; - let mut _2: i16; - - bb0: { - _2 = discriminant(_1); - switchInt(move _2) -> [65535: bb3, 2: bb4, 65533: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const -3_i8; - goto -> bb5; - } - - bb3: { - _0 = const -1_i8; - goto -> bb5; - } - - bb4: { - _0 = const 2_i8; - goto -> bb5; - } - - bb5: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_i8_i16.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_i8_i16.MatchBranchSimplification.diff deleted file mode 100644 index 8a390736add..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_i8_i16.MatchBranchSimplification.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `match_i8_i16` before MatchBranchSimplification -+ // MIR for `match_i8_i16` after MatchBranchSimplification - - fn match_i8_i16(_1: EnumAi8) -> i16 { - debug i => _1; - let mut _0: i16; - let mut _2: i8; - - bb0: { - _2 = discriminant(_1); - switchInt(move _2) -> [255: bb3, 2: bb4, 253: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const -3_i16; - goto -> bb5; - } - - bb3: { - _0 = const -1_i16; - goto -> bb5; - } - - bb4: { - _0 = const 2_i16; - goto -> bb5; - } - - bb5: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_i8_i16_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_i8_i16_failed.MatchBranchSimplification.diff deleted file mode 100644 index b0217792294..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_i8_i16_failed.MatchBranchSimplification.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `match_i8_i16_failed` before MatchBranchSimplification -+ // MIR for `match_i8_i16_failed` after MatchBranchSimplification - - fn match_i8_i16_failed(_1: EnumAi8) -> i16 { - debug i => _1; - let mut _0: i16; - let mut _2: i8; - - bb0: { - _2 = discriminant(_1); - switchInt(move _2) -> [255: bb3, 2: bb4, 253: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const 3_i16; - goto -> bb5; - } - - bb3: { - _0 = const -1_i16; - goto -> bb5; - } - - bb4: { - _0 = const 2_i16; - goto -> bb5; - } - - bb5: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_sext_i8_i16.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_sext_i8_i16.MatchBranchSimplification.diff new file mode 100644 index 00000000000..7f8c2ab8d37 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_sext_i8_i16.MatchBranchSimplification.diff @@ -0,0 +1,52 @@ +- // MIR for `match_sext_i8_i16` before MatchBranchSimplification ++ // MIR for `match_sext_i8_i16` after MatchBranchSimplification + + fn match_sext_i8_i16(_1: EnumAi8) -> i16 { + debug i => _1; + let mut _0: i16; + let mut _2: i8; ++ let mut _3: i8; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [128: bb6, 255: bb5, 0: bb4, 1: bb3, 127: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const 127_i16; +- goto -> bb7; +- } +- +- bb3: { +- _0 = const 1_i16; +- goto -> bb7; +- } +- +- bb4: { +- _0 = const 0_i16; +- goto -> bb7; +- } +- +- bb5: { +- _0 = const -1_i16; +- goto -> bb7; +- } +- +- bb6: { +- _0 = const -128_i16; +- goto -> bb7; +- } +- +- bb7: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as i16 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_sext_i8_i16_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_sext_i8_i16_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..94ec2293222 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_sext_i8_i16_failed.MatchBranchSimplification.diff @@ -0,0 +1,47 @@ +- // MIR for `match_sext_i8_i16_failed` before MatchBranchSimplification ++ // MIR for `match_sext_i8_i16_failed` after MatchBranchSimplification + + fn match_sext_i8_i16_failed(_1: EnumAi8) -> i16 { + debug i => _1; + let mut _0: i16; + let mut _2: i8; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [128: bb6, 255: bb5, 0: bb4, 1: bb3, 127: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const 127_i16; + goto -> bb7; + } + + bb3: { + _0 = const 1_i16; + goto -> bb7; + } + + bb4: { + _0 = const 0_i16; + goto -> bb7; + } + + bb5: { + _0 = const 255_i16; + goto -> bb7; + } + + bb6: { + _0 = const -128_i16; + goto -> bb7; + } + + bb7: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_sext_i8_u16.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_sext_i8_u16.MatchBranchSimplification.diff new file mode 100644 index 00000000000..86d0d0ba6cf --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_sext_i8_u16.MatchBranchSimplification.diff @@ -0,0 +1,52 @@ +- // MIR for `match_sext_i8_u16` before MatchBranchSimplification ++ // MIR for `match_sext_i8_u16` after MatchBranchSimplification + + fn match_sext_i8_u16(_1: EnumAi8) -> u16 { + debug i => _1; + let mut _0: u16; + let mut _2: i8; ++ let mut _3: i8; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [128: bb6, 255: bb5, 0: bb4, 1: bb3, 127: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const 127_u16; +- goto -> bb7; +- } +- +- bb3: { +- _0 = const 1_u16; +- goto -> bb7; +- } +- +- bb4: { +- _0 = const 0_u16; +- goto -> bb7; +- } +- +- bb5: { +- _0 = const u16::MAX; +- goto -> bb7; +- } +- +- bb6: { +- _0 = const 65408_u16; +- goto -> bb7; +- } +- +- bb7: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as u16 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_sext_i8_u16_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_sext_i8_u16_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..281f373bf87 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_sext_i8_u16_failed.MatchBranchSimplification.diff @@ -0,0 +1,47 @@ +- // MIR for `match_sext_i8_u16_failed` before MatchBranchSimplification ++ // MIR for `match_sext_i8_u16_failed` after MatchBranchSimplification + + fn match_sext_i8_u16_failed(_1: EnumAi8) -> u16 { + debug i => _1; + let mut _0: u16; + let mut _2: i8; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [128: bb6, 255: bb5, 0: bb4, 1: bb3, 127: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const 127_u16; + goto -> bb7; + } + + bb3: { + _0 = const 1_u16; + goto -> bb7; + } + + bb4: { + _0 = const 0_u16; + goto -> bb7; + } + + bb5: { + _0 = const 255_u16; + goto -> bb7; + } + + bb6: { + _0 = const 65408_u16; + goto -> bb7; + } + + bb7: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_i16_i8.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_i8.MatchBranchSimplification.diff new file mode 100644 index 00000000000..d3d27be2070 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_i8.MatchBranchSimplification.diff @@ -0,0 +1,77 @@ +- // MIR for `match_trunc_i16_i8` before MatchBranchSimplification ++ // MIR for `match_trunc_i16_i8` after MatchBranchSimplification + + fn match_trunc_i16_i8(_1: EnumAi16) -> i8 { + debug i => _1; + let mut _0: i8; + let mut _2: i16; ++ let mut _3: i16; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [128: bb11, 255: bb10, 0: bb9, 1: bb8, 127: bb7, 65408: bb6, 65535: bb5, 65280: bb4, 65281: bb3, 65407: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const i8::MAX; +- goto -> bb12; +- } +- +- bb3: { +- _0 = const 1_i8; +- goto -> bb12; +- } +- +- bb4: { +- _0 = const 0_i8; +- goto -> bb12; +- } +- +- bb5: { +- _0 = const -1_i8; +- goto -> bb12; +- } +- +- bb6: { +- _0 = const i8::MIN; +- goto -> bb12; +- } +- +- bb7: { +- _0 = const i8::MAX; +- goto -> bb12; +- } +- +- bb8: { +- _0 = const 1_i8; +- goto -> bb12; +- } +- +- bb9: { +- _0 = const 0_i8; +- goto -> bb12; +- } +- +- bb10: { +- _0 = const -1_i8; +- goto -> bb12; +- } +- +- bb11: { +- _0 = const i8::MIN; +- goto -> bb12; +- } +- +- bb12: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as i8 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_i16_i8_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_i8_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..7f663baefba --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_i8_failed.MatchBranchSimplification.diff @@ -0,0 +1,72 @@ +- // MIR for `match_trunc_i16_i8_failed` before MatchBranchSimplification ++ // MIR for `match_trunc_i16_i8_failed` after MatchBranchSimplification + + fn match_trunc_i16_i8_failed(_1: EnumAi16) -> i8 { + debug i => _1; + let mut _0: i8; + let mut _2: i16; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [128: bb11, 255: bb10, 0: bb9, 1: bb8, 127: bb7, 65408: bb6, 65535: bb5, 65280: bb4, 65281: bb3, 65407: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const -127_i8; + goto -> bb12; + } + + bb3: { + _0 = const 1_i8; + goto -> bb12; + } + + bb4: { + _0 = const 0_i8; + goto -> bb12; + } + + bb5: { + _0 = const -1_i8; + goto -> bb12; + } + + bb6: { + _0 = const i8::MIN; + goto -> bb12; + } + + bb7: { + _0 = const i8::MAX; + goto -> bb12; + } + + bb8: { + _0 = const 1_i8; + goto -> bb12; + } + + bb9: { + _0 = const 0_i8; + goto -> bb12; + } + + bb10: { + _0 = const -1_i8; + goto -> bb12; + } + + bb11: { + _0 = const i8::MIN; + goto -> bb12; + } + + bb12: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_i16_u8.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_u8.MatchBranchSimplification.diff new file mode 100644 index 00000000000..5fe899148eb --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_u8.MatchBranchSimplification.diff @@ -0,0 +1,77 @@ +- // MIR for `match_trunc_i16_u8` before MatchBranchSimplification ++ // MIR for `match_trunc_i16_u8` after MatchBranchSimplification + + fn match_trunc_i16_u8(_1: EnumAi16) -> u8 { + debug i => _1; + let mut _0: u8; + let mut _2: i16; ++ let mut _3: i16; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [128: bb11, 255: bb10, 0: bb9, 1: bb8, 127: bb7, 65408: bb6, 65535: bb5, 65280: bb4, 65281: bb3, 65407: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const 127_u8; +- goto -> bb12; +- } +- +- bb3: { +- _0 = const 1_u8; +- goto -> bb12; +- } +- +- bb4: { +- _0 = const 0_u8; +- goto -> bb12; +- } +- +- bb5: { +- _0 = const u8::MAX; +- goto -> bb12; +- } +- +- bb6: { +- _0 = const 128_u8; +- goto -> bb12; +- } +- +- bb7: { +- _0 = const 127_u8; +- goto -> bb12; +- } +- +- bb8: { +- _0 = const 1_u8; +- goto -> bb12; +- } +- +- bb9: { +- _0 = const 0_u8; +- goto -> bb12; +- } +- +- bb10: { +- _0 = const u8::MAX; +- goto -> bb12; +- } +- +- bb11: { +- _0 = const 128_u8; +- goto -> bb12; +- } +- +- bb12: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as u8 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_i16_u8_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_u8_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..1c0ffb30c5b --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_i16_u8_failed.MatchBranchSimplification.diff @@ -0,0 +1,72 @@ +- // MIR for `match_trunc_i16_u8_failed` before MatchBranchSimplification ++ // MIR for `match_trunc_i16_u8_failed` after MatchBranchSimplification + + fn match_trunc_i16_u8_failed(_1: EnumAi16) -> u8 { + debug i => _1; + let mut _0: u8; + let mut _2: i16; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [128: bb11, 255: bb10, 0: bb9, 1: bb8, 127: bb7, 65408: bb6, 65535: bb5, 65280: bb4, 65281: bb3, 65407: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const -127_i8 as u8 (IntToInt); + goto -> bb12; + } + + bb3: { + _0 = const 1_u8; + goto -> bb12; + } + + bb4: { + _0 = const 0_u8; + goto -> bb12; + } + + bb5: { + _0 = const u8::MAX; + goto -> bb12; + } + + bb6: { + _0 = const 128_u8; + goto -> bb12; + } + + bb7: { + _0 = const 127_u8; + goto -> bb12; + } + + bb8: { + _0 = const 1_u8; + goto -> bb12; + } + + bb9: { + _0 = const 0_u8; + goto -> bb12; + } + + bb10: { + _0 = const u8::MAX; + goto -> bb12; + } + + bb11: { + _0 = const 128_u8; + goto -> bb12; + } + + bb12: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_u16_i8.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_i8.MatchBranchSimplification.diff new file mode 100644 index 00000000000..85f97a13cac --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_i8.MatchBranchSimplification.diff @@ -0,0 +1,67 @@ +- // MIR for `match_trunc_u16_i8` before MatchBranchSimplification ++ // MIR for `match_trunc_u16_i8` after MatchBranchSimplification + + fn match_trunc_u16_i8(_1: EnumAu16) -> i8 { + debug i => _1; + let mut _0: i8; + let mut _2: u16; ++ let mut _3: u16; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [0: bb9, 127: bb8, 128: bb7, 255: bb6, 65280: bb5, 65407: bb4, 65408: bb3, 65535: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const -1_i8; +- goto -> bb10; +- } +- +- bb3: { +- _0 = const i8::MIN; +- goto -> bb10; +- } +- +- bb4: { +- _0 = const i8::MAX; +- goto -> bb10; +- } +- +- bb5: { +- _0 = const 0_i8; +- goto -> bb10; +- } +- +- bb6: { +- _0 = const -1_i8; +- goto -> bb10; +- } +- +- bb7: { +- _0 = const i8::MIN; +- goto -> bb10; +- } +- +- bb8: { +- _0 = const i8::MAX; +- goto -> bb10; +- } +- +- bb9: { +- _0 = const 0_i8; +- goto -> bb10; +- } +- +- bb10: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as i8 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_u16_i8_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_i8_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..cf6c86a71ad --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_i8_failed.MatchBranchSimplification.diff @@ -0,0 +1,62 @@ +- // MIR for `match_trunc_u16_i8_failed` before MatchBranchSimplification ++ // MIR for `match_trunc_u16_i8_failed` after MatchBranchSimplification + + fn match_trunc_u16_i8_failed(_1: EnumAu16) -> i8 { + debug i => _1; + let mut _0: i8; + let mut _2: u16; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb9, 127: bb8, 128: bb7, 255: bb6, 65280: bb5, 65407: bb4, 65408: bb3, 65535: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const 1_i8; + goto -> bb10; + } + + bb3: { + _0 = const i8::MIN; + goto -> bb10; + } + + bb4: { + _0 = const i8::MAX; + goto -> bb10; + } + + bb5: { + _0 = const 0_i8; + goto -> bb10; + } + + bb6: { + _0 = const -1_i8; + goto -> bb10; + } + + bb7: { + _0 = const i8::MIN; + goto -> bb10; + } + + bb8: { + _0 = const i8::MAX; + goto -> bb10; + } + + bb9: { + _0 = const 0_i8; + goto -> bb10; + } + + bb10: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_u16_u8.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_u8.MatchBranchSimplification.diff new file mode 100644 index 00000000000..768d838eaa6 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_u8.MatchBranchSimplification.diff @@ -0,0 +1,67 @@ +- // MIR for `match_trunc_u16_u8` before MatchBranchSimplification ++ // MIR for `match_trunc_u16_u8` after MatchBranchSimplification + + fn match_trunc_u16_u8(_1: EnumAu16) -> u8 { + debug i => _1; + let mut _0: u8; + let mut _2: u16; ++ let mut _3: u16; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [0: bb9, 127: bb8, 128: bb7, 255: bb6, 65280: bb5, 65407: bb4, 65408: bb3, 65535: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const u8::MAX; +- goto -> bb10; +- } +- +- bb3: { +- _0 = const 128_u8; +- goto -> bb10; +- } +- +- bb4: { +- _0 = const 127_u8; +- goto -> bb10; +- } +- +- bb5: { +- _0 = const 0_u8; +- goto -> bb10; +- } +- +- bb6: { +- _0 = const u8::MAX; +- goto -> bb10; +- } +- +- bb7: { +- _0 = const 128_u8; +- goto -> bb10; +- } +- +- bb8: { +- _0 = const 127_u8; +- goto -> bb10; +- } +- +- bb9: { +- _0 = const 0_u8; +- goto -> bb10; +- } +- +- bb10: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as u8 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_trunc_u16_u8_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_u8_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..109e97bb578 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_trunc_u16_u8_failed.MatchBranchSimplification.diff @@ -0,0 +1,62 @@ +- // MIR for `match_trunc_u16_u8_failed` before MatchBranchSimplification ++ // MIR for `match_trunc_u16_u8_failed` after MatchBranchSimplification + + fn match_trunc_u16_u8_failed(_1: EnumAu16) -> u8 { + debug i => _1; + let mut _0: u8; + let mut _2: u16; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb9, 127: bb8, 128: bb7, 255: bb6, 65280: bb5, 65407: bb4, 65408: bb3, 65535: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const 127_u8; + goto -> bb10; + } + + bb3: { + _0 = const 128_u8; + goto -> bb10; + } + + bb4: { + _0 = const 127_u8; + goto -> bb10; + } + + bb5: { + _0 = const 0_u8; + goto -> bb10; + } + + bb6: { + _0 = const u8::MAX; + goto -> bb10; + } + + bb7: { + _0 = const 128_u8; + goto -> bb10; + } + + bb8: { + _0 = const 127_u8; + goto -> bb10; + } + + bb9: { + _0 = const 0_u8; + goto -> bb10; + } + + bb10: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff deleted file mode 100644 index 72ad60956ab..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff +++ /dev/null @@ -1,32 +0,0 @@ -- // MIR for `match_u8_i16` before MatchBranchSimplification -+ // MIR for `match_u8_i16` after MatchBranchSimplification - - fn match_u8_i16(_1: EnumAu8) -> i16 { - debug i => _1; - let mut _0: i16; - let mut _2: u8; - - bb0: { - _2 = discriminant(_1); - switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const 2_i16; - goto -> bb4; - } - - bb3: { - _0 = const 1_i16; - goto -> bb4; - } - - bb4: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i16_2.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i16_2.MatchBranchSimplification.diff deleted file mode 100644 index 3333cd765a8..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_u8_i16_2.MatchBranchSimplification.diff +++ /dev/null @@ -1,26 +0,0 @@ -- // MIR for `match_u8_i16_2` before MatchBranchSimplification -+ // MIR for `match_u8_i16_2` after MatchBranchSimplification - - fn match_u8_i16_2(_1: EnumAu8) -> i16 { - let mut _0: i16; - let mut _2: u8; - - bb0: { - _2 = discriminant(_1); - switchInt(_2) -> [1: bb3, 2: bb1, otherwise: bb2]; - } - - bb1: { - _0 = const 2_i16; - goto -> bb3; - } - - bb2: { - unreachable; - } - - bb3: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i16_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i16_failed.MatchBranchSimplification.diff deleted file mode 100644 index 6da19e46dab..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_u8_i16_failed.MatchBranchSimplification.diff +++ /dev/null @@ -1,32 +0,0 @@ -- // MIR for `match_u8_i16_failed` before MatchBranchSimplification -+ // MIR for `match_u8_i16_failed` after MatchBranchSimplification - - fn match_u8_i16_failed(_1: EnumAu8) -> i16 { - debug i => _1; - let mut _0: i16; - let mut _2: u8; - - bb0: { - _2 = discriminant(_1); - switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const 3_i16; - goto -> bb4; - } - - bb3: { - _0 = const 1_i16; - goto -> bb4; - } - - bb4: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i16_fallback.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i16_fallback.MatchBranchSimplification.diff deleted file mode 100644 index 8fa497fe890..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_u8_i16_fallback.MatchBranchSimplification.diff +++ /dev/null @@ -1,31 +0,0 @@ -- // MIR for `match_u8_i16_fallback` before MatchBranchSimplification -+ // MIR for `match_u8_i16_fallback` after MatchBranchSimplification - - fn match_u8_i16_fallback(_1: u8) -> i16 { - debug i => _1; - let mut _0: i16; - - bb0: { - switchInt(_1) -> [1: bb2, 2: bb3, otherwise: bb1]; - } - - bb1: { - _0 = const 3_i16; - goto -> bb4; - } - - bb2: { - _0 = const 1_i16; - goto -> bb4; - } - - bb3: { - _0 = const 2_i16; - goto -> bb4; - } - - bb4: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i8.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i8.MatchBranchSimplification.diff new file mode 100644 index 00000000000..d63eed7c019 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_u8_i8.MatchBranchSimplification.diff @@ -0,0 +1,47 @@ +- // MIR for `match_u8_i8` before MatchBranchSimplification ++ // MIR for `match_u8_i8` after MatchBranchSimplification + + fn match_u8_i8(_1: EnumAu8) -> i8 { + debug i => _1; + let mut _0: i8; + let mut _2: u8; ++ let mut _3: u8; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const -1_i8; +- goto -> bb6; +- } +- +- bb3: { +- _0 = const i8::MIN; +- goto -> bb6; +- } +- +- bb4: { +- _0 = const i8::MAX; +- goto -> bb6; +- } +- +- bb5: { +- _0 = const 0_i8; +- goto -> bb6; +- } +- +- bb6: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as i8 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i8_2.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i8_2.MatchBranchSimplification.diff new file mode 100644 index 00000000000..98dee1835a8 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_u8_i8_2.MatchBranchSimplification.diff @@ -0,0 +1,80 @@ +- // MIR for `match_u8_i8_2` before MatchBranchSimplification ++ // MIR for `match_u8_i8_2` after MatchBranchSimplification + + fn match_u8_i8_2(_1: EnumAu8) -> (i8, i8) { + debug i => _1; + let mut _0: (i8, i8); + let _2: i8; + let _4: (); + let mut _5: u8; + let mut _6: i8; + let mut _7: i8; ++ let mut _8: u8; + scope 1 { + debug a => _2; + let _3: i8; + scope 2 { + debug b => _3; + } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _5 = discriminant(_1); +- switchInt(move _5) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _2 = const -1_i8; +- _3 = const -1_i8; ++ StorageLive(_8); ++ _8 = move _5; ++ _2 = _8 as i8 (IntToInt); ++ _3 = _8 as i8 (IntToInt); + _4 = (); +- goto -> bb6; +- } +- +- bb3: { +- _2 = const i8::MIN; +- _3 = const i8::MIN; +- _4 = (); +- goto -> bb6; +- } +- +- bb4: { +- _2 = const i8::MAX; +- _3 = const i8::MAX; +- _4 = (); +- goto -> bb6; +- } +- +- bb5: { +- _2 = const 0_i8; +- _3 = const 0_i8; +- _4 = (); +- goto -> bb6; +- } +- +- bb6: { ++ StorageDead(_8); + StorageDead(_4); + StorageLive(_6); + _6 = _2; + StorageLive(_7); + _7 = _3; + _0 = (move _6, move _7); + StorageDead(_7); + StorageDead(_6); + StorageDead(_3); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i8_2_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i8_2_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..901dda58617 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_u8_i8_2_failed.MatchBranchSimplification.diff @@ -0,0 +1,74 @@ +- // MIR for `match_u8_i8_2_failed` before MatchBranchSimplification ++ // MIR for `match_u8_i8_2_failed` after MatchBranchSimplification + + fn match_u8_i8_2_failed(_1: EnumAu8) -> (i8, i8) { + debug i => _1; + let mut _0: (i8, i8); + let _2: i8; + let _4: (); + let mut _5: u8; + let mut _6: i8; + let mut _7: i8; + scope 1 { + debug a => _2; + let _3: i8; + scope 2 { + debug b => _3; + } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _5 = discriminant(_1); + switchInt(move _5) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _2 = const -1_i8; + _3 = const 1_i8; + _4 = (); + goto -> bb6; + } + + bb3: { + _2 = const i8::MIN; + _3 = const i8::MIN; + _4 = (); + goto -> bb6; + } + + bb4: { + _2 = const i8::MAX; + _3 = const i8::MAX; + _4 = (); + goto -> bb6; + } + + bb5: { + _2 = const 0_i8; + _3 = const 0_i8; + _4 = (); + goto -> bb6; + } + + bb6: { + StorageDead(_4); + StorageLive(_6); + _6 = _2; + StorageLive(_7); + _7 = _3; + _0 = (move _6, move _7); + StorageDead(_7); + StorageDead(_6); + StorageDead(_3); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..ac96be55312 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed.MatchBranchSimplification.diff @@ -0,0 +1,42 @@ +- // MIR for `match_u8_i8_failed` before MatchBranchSimplification ++ // MIR for `match_u8_i8_failed` after MatchBranchSimplification + + fn match_u8_i8_failed(_1: EnumAu8) -> i8 { + debug i => _1; + let mut _0: i8; + let mut _2: u8; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const 1_i8; + goto -> bb6; + } + + bb3: { + _0 = const i8::MIN; + goto -> bb6; + } + + bb4: { + _0 = const i8::MAX; + goto -> bb6; + } + + bb5: { + _0 = const 0_i8; + goto -> bb6; + } + + bb6: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed_len_1.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed_len_1.MatchBranchSimplification.diff new file mode 100644 index 00000000000..9ebf2cf27cb --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed_len_1.MatchBranchSimplification.diff @@ -0,0 +1,42 @@ +- // MIR for `match_u8_i8_failed_len_1` before MatchBranchSimplification ++ // MIR for `match_u8_i8_failed_len_1` after MatchBranchSimplification + + fn match_u8_i8_failed_len_1(_1: EnumAu8) -> i8 { + let mut _0: i8; + let mut _2: u8; + + bb0: { + _2 = discriminant(_1); + switchInt(_2) -> [0: bb1, 127: bb2, 128: bb3, 255: bb4, otherwise: bb5]; + } + + bb1: { + _0 = const 0_i8; + goto -> bb6; + } + + bb2: { + _0 = const i8::MAX; + _0 = const i8::MAX; + goto -> bb6; + } + + bb3: { + _0 = const i8::MIN; + goto -> bb6; + } + + bb4: { + _0 = const -1_i8; + goto -> bb6; + } + + bb5: { + unreachable; + } + + bb6: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed_len_2.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed_len_2.MatchBranchSimplification.diff new file mode 100644 index 00000000000..554856777eb --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_u8_i8_failed_len_2.MatchBranchSimplification.diff @@ -0,0 +1,42 @@ +- // MIR for `match_u8_i8_failed_len_2` before MatchBranchSimplification ++ // MIR for `match_u8_i8_failed_len_2` after MatchBranchSimplification + + fn match_u8_i8_failed_len_2(_1: EnumAu8) -> i8 { + let mut _0: i8; + let mut _2: u8; + + bb0: { + _2 = discriminant(_1); + switchInt(_2) -> [0: bb1, 127: bb2, 128: bb3, 255: bb4, otherwise: bb5]; + } + + bb1: { + _0 = const 0_i8; + goto -> bb6; + } + + bb2: { + _0 = const i8::MAX; + goto -> bb6; + } + + bb3: { + _0 = const i8::MIN; + goto -> bb6; + } + + bb4: { + _0 = const -1_i8; + _0 = const -1_i8; + goto -> bb6; + } + + bb5: { + unreachable; + } + + bb6: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_i8_fallback.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_i8_fallback.MatchBranchSimplification.diff new file mode 100644 index 00000000000..356655021f7 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_u8_i8_fallback.MatchBranchSimplification.diff @@ -0,0 +1,38 @@ +- // MIR for `match_u8_i8_fallback` before MatchBranchSimplification ++ // MIR for `match_u8_i8_fallback` after MatchBranchSimplification + + fn match_u8_i8_fallback(_1: EnumAu8) -> i8 { + debug i => _1; + let mut _0: i8; + let mut _2: u8; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb4, 127: bb3, 128: bb2, otherwise: bb1]; + } + + bb1: { + _0 = const -1_i8; + goto -> bb5; + } + + bb2: { + _0 = const i8::MIN; + goto -> bb5; + } + + bb3: { + _0 = const i8::MAX; + goto -> bb5; + } + + bb4: { + _0 = const 0_i8; + goto -> bb5; + } + + bb5: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff deleted file mode 100644 index 043fdb197a3..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `match_u8_u16` before MatchBranchSimplification -+ // MIR for `match_u8_u16` after MatchBranchSimplification - - fn match_u8_u16(_1: EnumBu8) -> u16 { - debug i => _1; - let mut _0: u16; - let mut _2: u8; - - bb0: { - _2 = discriminant(_1); - switchInt(move _2) -> [1: bb3, 2: bb4, 5: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const 5_u16; - goto -> bb5; - } - - bb3: { - _0 = const 1_u16; - goto -> bb5; - } - - bb4: { - _0 = const 2_u16; - goto -> bb5; - } - - bb5: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_u8_u16_2.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_u8_u16_2.MatchBranchSimplification.diff deleted file mode 100644 index b47de6a52b7..00000000000 --- a/tests/mir-opt/matches_reduce_branches.match_u8_u16_2.MatchBranchSimplification.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `match_u8_u16_2` before MatchBranchSimplification -+ // MIR for `match_u8_u16_2` after MatchBranchSimplification - - fn match_u8_u16_2(_1: EnumBu8) -> i16 { - let mut _0: i16; - let mut _2: u8; - - bb0: { - _2 = discriminant(_1); - switchInt(_2) -> [1: bb1, 2: bb2, 5: bb3, otherwise: bb4]; - } - - bb1: { - _0 = const 1_i16; - goto -> bb5; - } - - bb2: { - _0 = const 2_i16; - goto -> bb5; - } - - bb3: { - _0 = const 5_i16; - _0 = const 5_i16; - goto -> bb5; - } - - bb4: { - unreachable; - } - - bb5: { - return; - } - } - diff --git a/tests/mir-opt/matches_reduce_branches.match_zext_u8_i16.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_zext_u8_i16.MatchBranchSimplification.diff new file mode 100644 index 00000000000..e00a604fe25 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_zext_u8_i16.MatchBranchSimplification.diff @@ -0,0 +1,47 @@ +- // MIR for `match_zext_u8_i16` before MatchBranchSimplification ++ // MIR for `match_zext_u8_i16` after MatchBranchSimplification + + fn match_zext_u8_i16(_1: EnumAu8) -> i16 { + debug i => _1; + let mut _0: i16; + let mut _2: u8; ++ let mut _3: u8; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const 255_i16; +- goto -> bb6; +- } +- +- bb3: { +- _0 = const 128_i16; +- goto -> bb6; +- } +- +- bb4: { +- _0 = const 127_i16; +- goto -> bb6; +- } +- +- bb5: { +- _0 = const 0_i16; +- goto -> bb6; +- } +- +- bb6: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as i16 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_zext_u8_i16_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_zext_u8_i16_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..a19cd796c27 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_zext_u8_i16_failed.MatchBranchSimplification.diff @@ -0,0 +1,42 @@ +- // MIR for `match_zext_u8_i16_failed` before MatchBranchSimplification ++ // MIR for `match_zext_u8_i16_failed` after MatchBranchSimplification + + fn match_zext_u8_i16_failed(_1: EnumAu8) -> i16 { + debug i => _1; + let mut _0: i16; + let mut _2: u8; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const 255_i16; + goto -> bb6; + } + + bb3: { + _0 = const 128_i16; + goto -> bb6; + } + + bb4: { + _0 = const -127_i16; + goto -> bb6; + } + + bb5: { + _0 = const 0_i16; + goto -> bb6; + } + + bb6: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_zext_u8_u16.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_zext_u8_u16.MatchBranchSimplification.diff new file mode 100644 index 00000000000..befb9118907 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_zext_u8_u16.MatchBranchSimplification.diff @@ -0,0 +1,47 @@ +- // MIR for `match_zext_u8_u16` before MatchBranchSimplification ++ // MIR for `match_zext_u8_u16` after MatchBranchSimplification + + fn match_zext_u8_u16(_1: EnumAu8) -> u16 { + debug i => _1; + let mut _0: u16; + let mut _2: u8; ++ let mut _3: u8; + + bb0: { + _2 = discriminant(_1); +- switchInt(move _2) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const 255_u16; +- goto -> bb6; +- } +- +- bb3: { +- _0 = const 128_u16; +- goto -> bb6; +- } +- +- bb4: { +- _0 = const 127_u16; +- goto -> bb6; +- } +- +- bb5: { +- _0 = const 0_u16; +- goto -> bb6; +- } +- +- bb6: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as u16 (IntToInt); ++ StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_zext_u8_u16_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_zext_u8_u16_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..f781f88449d --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_zext_u8_u16_failed.MatchBranchSimplification.diff @@ -0,0 +1,42 @@ +- // MIR for `match_zext_u8_u16_failed` before MatchBranchSimplification ++ // MIR for `match_zext_u8_u16_failed` after MatchBranchSimplification + + fn match_zext_u8_u16_failed(_1: EnumAu8) -> u16 { + debug i => _1; + let mut _0: u16; + let mut _2: u8; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb5, 127: bb4, 128: bb3, 255: bb2, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const 255_u16; + goto -> bb6; + } + + bb3: { + _0 = const 128_u16; + goto -> bb6; + } + + bb4: { + _0 = const 65407_u16; + goto -> bb6; + } + + bb5: { + _0 = const 0_u16; + goto -> bb6; + } + + bb6: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.rs b/tests/mir-opt/matches_reduce_branches.rs index 176d68bcd40..6787e5816a3 100644 --- a/tests/mir-opt/matches_reduce_branches.rs +++ b/tests/mir-opt/matches_reduce_branches.rs @@ -3,6 +3,7 @@ #![feature(repr128)] #![feature(core_intrinsics)] #![feature(custom_mir)] +#![allow(non_camel_case_types)] use std::intrinsics::mir::*; @@ -12,6 +13,7 @@ fn foo(bar: Option<()>) { // CHECK: = Eq( // CHECK: switchInt // CHECK-NOT: switchInt + // CHECK: return if matches!(bar, None) { () } @@ -23,6 +25,7 @@ fn bar(i: i32) -> (bool, bool, bool, bool) { // CHECK: = Ne( // CHECK: = Eq( // CHECK-NOT: switchInt + // CHECK: return let a; let b; let c; @@ -52,6 +55,7 @@ fn bar(i: i32) -> (bool, bool, bool, bool) { fn match_nested_if() -> bool { // CHECK-LABEL: fn match_nested_if( // CHECK-NOT: switchInt + // CHECK: return let val = match () { () if if if if true { true } else { false } { true } else { false } { true @@ -66,42 +70,170 @@ fn match_nested_if() -> bool { val } +// # Fold switchInt into IntToInt. +// To simplify writing and checking these test cases, I use the first character of +// each case to distinguish the sign of the number: +// 'u' for unsigned, '_' for negative, and 'o' for non-negative. +// Followed by a decimal number, and add the corresponding radix representation. +// For example, o127_0x7f represents 127i8, and _1_0xff represents -1i8. + +// ## Cast but without numeric conversion. + #[repr(u8)] enum EnumAu8 { - A = 1, - B = 2, + u0_0x00 = 0, + u127_0x7f = 127, + u128_0x80 = 128, + u255_0xff = 255, +} + +#[repr(i8)] +enum EnumAi8 { + _128_0x80 = -128, + _1_0xff = -1, + o0_0x00 = 0, + o1_0x01 = 1, + o127_0x7f = 127, } -// EMIT_MIR matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff -fn match_u8_i16(i: EnumAu8) -> i16 { - // CHECK-LABEL: fn match_u8_i16( +// EMIT_MIR matches_reduce_branches.match_u8_i8.MatchBranchSimplification.diff +fn match_u8_i8(i: EnumAu8) -> i8 { + // CHECK-LABEL: fn match_u8_i8( + // CHECK-NOT: switchInt + // CHECK: return + match i { + EnumAu8::u0_0x00 => 0, + EnumAu8::u127_0x7f => 127, + EnumAu8::u128_0x80 => -128, + EnumAu8::u255_0xff => -1, + } +} + +// EMIT_MIR matches_reduce_branches.match_u8_i8_failed.MatchBranchSimplification.diff +fn match_u8_i8_failed(i: EnumAu8) -> i8 { + // CHECK-LABEL: fn match_u8_i8_failed( // CHECK: switchInt + // CHECK: return match i { - EnumAu8::A => 1, - EnumAu8::B => 2, + EnumAu8::u0_0x00 => 0, + EnumAu8::u127_0x7f => 127, + EnumAu8::u128_0x80 => -128, + EnumAu8::u255_0xff => 1, // failed } } -// EMIT_MIR matches_reduce_branches.match_u8_i16_2.MatchBranchSimplification.diff +// EMIT_MIR matches_reduce_branches.match_u8_i8_2.MatchBranchSimplification.diff +fn match_u8_i8_2(i: EnumAu8) -> (i8, i8) { + // CHECK-LABEL: fn match_u8_i8_2( + // CHECK-NOT: switchInt + // CHECK: IntToInt + // CHECK: IntToInt + // CHECK: return + let a: i8; + let b: i8; + match i { + EnumAu8::u0_0x00 => { + a = 0; + b = 0; + () + } + EnumAu8::u127_0x7f => { + a = 127; + b = 127; + () + } + EnumAu8::u128_0x80 => { + a = -128; + b = -128; + () + } + EnumAu8::u255_0xff => { + a = -1; + b = -1; + () + } + }; + (a, b) +} + +// EMIT_MIR matches_reduce_branches.match_u8_i8_2_failed.MatchBranchSimplification.diff +fn match_u8_i8_2_failed(i: EnumAu8) -> (i8, i8) { + // CHECK-LABEL: fn match_u8_i8_2_failed( + // CHECK: switchInt + // CHECK: return + let a: i8; + let b: i8; + match i { + EnumAu8::u0_0x00 => { + a = 0; + b = 0; + () + } + EnumAu8::u127_0x7f => { + a = 127; + b = 127; + () + } + EnumAu8::u128_0x80 => { + a = -128; + b = -128; + () + } + EnumAu8::u255_0xff => { + a = -1; + b = 1; // failed + () + } + }; + (a, b) +} + +// EMIT_MIR matches_reduce_branches.match_u8_i8_fallback.MatchBranchSimplification.diff +fn match_u8_i8_fallback(i: EnumAu8) -> i8 { + // CHECK-LABEL: fn match_u8_i8_fallback( + // CHECK: switchInt + // CHECK: return + match i { + EnumAu8::u0_0x00 => 0, + EnumAu8::u127_0x7f => 127, + EnumAu8::u128_0x80 => -128, + _ => -1, + } +} + +// EMIT_MIR matches_reduce_branches.match_u8_i8_failed_len_1.MatchBranchSimplification.diff // Check for different instruction lengths #[custom_mir(dialect = "built")] -fn match_u8_i16_2(i: EnumAu8) -> i16 { - // CHECK-LABEL: fn match_u8_i16_2( +fn match_u8_i8_failed_len_1(i: EnumAu8) -> i8 { + // CHECK-LABEL: fn match_u8_i8_failed_len_1( // CHECK: switchInt + // CHECK: return mir! { { let a = Discriminant(i); match a { - 1 => bb1, - 2 => bb2, + 0 => bb1, + 127 => bb2, + 128 => bb3, + 255 => bb4, _ => unreachable_bb, } } bb1 = { + RET = 0; Goto(ret) } bb2 = { - RET = 2; + RET = 127; + RET = 127; + Goto(ret) + } + bb3 = { + RET = -128; + Goto(ret) + } + bb4 = { + RET = -1; Goto(ret) } unreachable_bb = { @@ -113,72 +245,39 @@ fn match_u8_i16_2(i: EnumAu8) -> i16 { } } -// EMIT_MIR matches_reduce_branches.match_u8_i16_failed.MatchBranchSimplification.diff -fn match_u8_i16_failed(i: EnumAu8) -> i16 { - // CHECK-LABEL: fn match_u8_i16_failed( - // CHECK: switchInt - match i { - EnumAu8::A => 1, - EnumAu8::B => 3, - } -} - -// EMIT_MIR matches_reduce_branches.match_u8_i16_fallback.MatchBranchSimplification.diff -fn match_u8_i16_fallback(i: u8) -> i16 { - // CHECK-LABEL: fn match_u8_i16_fallback( - // CHECK: switchInt - match i { - 1 => 1, - 2 => 2, - _ => 3, - } -} - -#[repr(u8)] -enum EnumBu8 { - A = 1, - B = 2, - C = 5, -} - -// EMIT_MIR matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff -fn match_u8_u16(i: EnumBu8) -> u16 { - // CHECK-LABEL: fn match_u8_u16( - // CHECK: switchInt - match i { - EnumBu8::A => 1, - EnumBu8::B => 2, - EnumBu8::C => 5, - } -} - -// EMIT_MIR matches_reduce_branches.match_u8_u16_2.MatchBranchSimplification.diff +// EMIT_MIR matches_reduce_branches.match_u8_i8_failed_len_2.MatchBranchSimplification.diff // Check for different instruction lengths #[custom_mir(dialect = "built")] -fn match_u8_u16_2(i: EnumBu8) -> i16 { - // CHECK-LABEL: fn match_u8_u16_2( +fn match_u8_i8_failed_len_2(i: EnumAu8) -> i8 { + // CHECK-LABEL: fn match_u8_i8_failed_len_2( // CHECK: switchInt + // CHECK: return mir! { { let a = Discriminant(i); match a { - 1 => bb1, - 2 => bb2, - 5 => bb5, + 0 => bb1, + 127 => bb2, + 128 => bb3, + 255 => bb4, _ => unreachable_bb, } } bb1 = { - RET = 1; + RET = 0; Goto(ret) } bb2 = { - RET = 2; + RET = 127; Goto(ret) } - bb5 = { - RET = 5; - RET = 5; + bb3 = { + RET = -128; + Goto(ret) + } + bb4 = { + RET = -1; + RET = -1; Goto(ret) } unreachable_bb = { @@ -190,50 +289,309 @@ fn match_u8_u16_2(i: EnumBu8) -> i16 { } } -#[repr(i8)] -enum EnumAi8 { - A = -1, - B = 2, - C = -3, +// ## Cast with sext. + +// EMIT_MIR matches_reduce_branches.match_sext_i8_i16.MatchBranchSimplification.diff +fn match_sext_i8_i16(i: EnumAi8) -> i16 { + // CHECK-LABEL: fn match_sext_i8_i16( + // CHECK-NOT: switchInt + // CHECK: return + match i { + EnumAi8::_128_0x80 => -128, + EnumAi8::_1_0xff => -1, + EnumAi8::o0_0x00 => 0, + EnumAi8::o1_0x01 => 1, + EnumAi8::o127_0x7f => 127, + } +} + +// EMIT_MIR matches_reduce_branches.match_sext_i8_i16_failed.MatchBranchSimplification.diff +// Converting `-1i8` to `255i16` is zext. +fn match_sext_i8_i16_failed(i: EnumAi8) -> i16 { + // CHECK-LABEL: fn match_sext_i8_i16_failed( + // CHECK: switchInt + // CHECK: return + match i { + EnumAi8::_128_0x80 => -128, + EnumAi8::_1_0xff => 255, // failed + EnumAi8::o0_0x00 => 0, + EnumAi8::o1_0x01 => 1, + EnumAi8::o127_0x7f => 127, + } +} + +// EMIT_MIR matches_reduce_branches.match_sext_i8_u16.MatchBranchSimplification.diff +fn match_sext_i8_u16(i: EnumAi8) -> u16 { + // CHECK-LABEL: fn match_sext_i8_u16( + // CHECK-NOT: switchInt + // CHECK: return + match i { + EnumAi8::_128_0x80 => 0xff80, + EnumAi8::_1_0xff => 0xffff, + EnumAi8::o0_0x00 => 0, + EnumAi8::o1_0x01 => 1, + EnumAi8::o127_0x7f => 127, + } +} + +// EMIT_MIR matches_reduce_branches.match_sext_i8_u16_failed.MatchBranchSimplification.diff +// Converting `-1i8` to `255u16` is zext. +fn match_sext_i8_u16_failed(i: EnumAi8) -> u16 { + // CHECK-LABEL: fn match_sext_i8_u16_failed( + // CHECK: switchInt + // CHECK: return + match i { + EnumAi8::_128_0x80 => 0xff80, + EnumAi8::_1_0xff => 0x00ff, // failed + EnumAi8::o0_0x00 => 0, + EnumAi8::o1_0x01 => 1, + EnumAi8::o127_0x7f => 127, + } +} + +// ## Cast with zext. + +// EMIT_MIR matches_reduce_branches.match_zext_u8_u16.MatchBranchSimplification.diff +fn match_zext_u8_u16(i: EnumAu8) -> u16 { + // CHECK-LABEL: fn match_zext_u8_u16( + // CHECK-NOT: switchInt + // CHECK: return + match i { + EnumAu8::u0_0x00 => 0, + EnumAu8::u127_0x7f => 0x7f, + EnumAu8::u128_0x80 => 128, + EnumAu8::u255_0xff => 255, + } } -// EMIT_MIR matches_reduce_branches.match_i8_i16.MatchBranchSimplification.diff -fn match_i8_i16(i: EnumAi8) -> i16 { - // CHECK-LABEL: fn match_i8_i16( +// EMIT_MIR matches_reduce_branches.match_zext_u8_u16_failed.MatchBranchSimplification.diff +fn match_zext_u8_u16_failed(i: EnumAu8) -> u16 { + // CHECK-LABEL: fn match_zext_u8_u16_failed( // CHECK: switchInt + // CHECK: return + match i { + EnumAu8::u0_0x00 => 0, + EnumAu8::u127_0x7f => 0xff7f, // failed + EnumAu8::u128_0x80 => 128, + EnumAu8::u255_0xff => 255, + } +} + +// EMIT_MIR matches_reduce_branches.match_zext_u8_i16.MatchBranchSimplification.diff +fn match_zext_u8_i16(i: EnumAu8) -> i16 { + // CHECK-LABEL: fn match_zext_u8_i16( + // CHECK-NOT: switchInt + // CHECK: return match i { - EnumAi8::A => -1, - EnumAi8::B => 2, - EnumAi8::C => -3, + EnumAu8::u0_0x00 => 0, + EnumAu8::u127_0x7f => 127, + EnumAu8::u128_0x80 => 128, + EnumAu8::u255_0xff => 255, } } -// EMIT_MIR matches_reduce_branches.match_i8_i16_failed.MatchBranchSimplification.diff -fn match_i8_i16_failed(i: EnumAi8) -> i16 { - // CHECK-LABEL: fn match_i8_i16_failed( +// EMIT_MIR matches_reduce_branches.match_zext_u8_i16_failed.MatchBranchSimplification.diff +fn match_zext_u8_i16_failed(i: EnumAu8) -> i16 { + // CHECK-LABEL: fn match_zext_u8_i16_failed( // CHECK: switchInt + // CHECK: return match i { - EnumAi8::A => -1, - EnumAi8::B => 2, - EnumAi8::C => 3, + EnumAu8::u0_0x00 => 0, + EnumAu8::u127_0x7f => -127, // failed + EnumAu8::u128_0x80 => 128, + EnumAu8::u255_0xff => 255, } } +// ## Cast with trunc. + +#[repr(u16)] +enum EnumAu16 { + // 0x00nn + u0_0x0000 = 0, + u127_0x007f = 127, + u128_0x0080 = 128, + u255_0x00ff = 255, + // 0xffnn + u65280_0xff00 = 65280, + u65407_0xff7f = 65407, + u65408_0xff80 = 65408, + u65535_0xffff = 65535, +} + #[repr(i16)] enum EnumAi16 { - A = -1, - B = 2, - C = -3, + // 0x00nn + o128_0x0080 = 128, + o255_0x00ff = 255, + o0_0x0000 = 0, + o1_0x0001 = 1, + o127_0x007f = 127, + // 0xffnn + _128_0xff80 = -128, + _1_0xffff = -1, + o0_0xff00 = -256, + o1_0xff01 = -255, + o127_0xff7f = -129, } -// EMIT_MIR matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff -fn match_i16_i8(i: EnumAi16) -> i8 { - // CHECK-LABEL: fn match_i16_i8( +// EMIT_MIR matches_reduce_branches.match_trunc_i16_i8.MatchBranchSimplification.diff +fn match_trunc_i16_i8(i: EnumAi16) -> i8 { + // CHECK-LABEL: fn match_trunc_i16_i8( + // CHECK-NOT: switchInt + // CHECK: return + match i { + // 0x00nn + EnumAi16::o128_0x0080 => -128, + EnumAi16::o255_0x00ff => -1, + EnumAi16::o0_0x0000 => 0, + EnumAi16::o1_0x0001 => 1, + EnumAi16::o127_0x007f => 127, + // 0xffnn + EnumAi16::_128_0xff80 => -128, + EnumAi16::_1_0xffff => -1, + EnumAi16::o0_0xff00 => 0, + EnumAi16::o1_0xff01 => 1, + EnumAi16::o127_0xff7f => 127, + } +} + +// EMIT_MIR matches_reduce_branches.match_trunc_i16_i8_failed.MatchBranchSimplification.diff +fn match_trunc_i16_i8_failed(i: EnumAi16) -> i8 { + // CHECK-LABEL: fn match_trunc_i16_i8_failed( // CHECK: switchInt + // CHECK: return match i { - EnumAi16::A => -1, - EnumAi16::B => 2, - EnumAi16::C => -3, + // 0x00nn + EnumAi16::o128_0x0080 => -128, + EnumAi16::o255_0x00ff => -1, + EnumAi16::o0_0x0000 => 0, + EnumAi16::o1_0x0001 => 1, + EnumAi16::o127_0x007f => 127, + // 0xffnn + EnumAi16::_128_0xff80 => -128, + EnumAi16::_1_0xffff => -1, + EnumAi16::o0_0xff00 => 0, + EnumAi16::o1_0xff01 => 1, + EnumAi16::o127_0xff7f => -127, // failed + } +} + +// EMIT_MIR matches_reduce_branches.match_trunc_i16_u8.MatchBranchSimplification.diff +fn match_trunc_i16_u8(i: EnumAi16) -> u8 { + // CHECK-LABEL: fn match_trunc_i16_u8( + // CHECK-NOT: switchInt + // CHECK: return + match i { + // 0x00nn + EnumAi16::o128_0x0080 => 128, + EnumAi16::o255_0x00ff => 255, + EnumAi16::o0_0x0000 => 0, + EnumAi16::o1_0x0001 => 1, + EnumAi16::o127_0x007f => 127, + // 0xffnn + EnumAi16::_128_0xff80 => 128, + EnumAi16::_1_0xffff => 255, + EnumAi16::o0_0xff00 => 0, + EnumAi16::o1_0xff01 => 1, + EnumAi16::o127_0xff7f => 127, + } +} + +// EMIT_MIR matches_reduce_branches.match_trunc_i16_u8_failed.MatchBranchSimplification.diff +fn match_trunc_i16_u8_failed(i: EnumAi16) -> u8 { + // CHECK-LABEL: fn match_trunc_i16_u8_failed( + // CHECK: switchInt + // CHECK: return + match i { + // 0x00nn + EnumAi16::o128_0x0080 => 128, + EnumAi16::o255_0x00ff => 255, + EnumAi16::o0_0x0000 => 0, + EnumAi16::o1_0x0001 => 1, + EnumAi16::o127_0x007f => 127, + // 0xffnn + EnumAi16::_128_0xff80 => 128, + EnumAi16::_1_0xffff => 255, + EnumAi16::o0_0xff00 => 0, + EnumAi16::o1_0xff01 => 1, + EnumAi16::o127_0xff7f => -127i8 as u8, // failed + } +} + +// EMIT_MIR matches_reduce_branches.match_trunc_u16_u8.MatchBranchSimplification.diff +fn match_trunc_u16_u8(i: EnumAu16) -> u8 { + // CHECK-LABEL: fn match_trunc_u16_u8( + // CHECK-NOT: switchInt + // CHECK: return + match i { + // 0x00nn + EnumAu16::u0_0x0000 => 0, + EnumAu16::u127_0x007f => 127, + EnumAu16::u128_0x0080 => 128, + EnumAu16::u255_0x00ff => 255, + // 0xffnn + EnumAu16::u65280_0xff00 => 0, + EnumAu16::u65407_0xff7f => 127, + EnumAu16::u65408_0xff80 => 128, + EnumAu16::u65535_0xffff => 255, + } +} + +// EMIT_MIR matches_reduce_branches.match_trunc_u16_u8_failed.MatchBranchSimplification.diff +fn match_trunc_u16_u8_failed(i: EnumAu16) -> u8 { + // CHECK-LABEL: fn match_trunc_u16_u8_failed( + // CHECK: switchInt + // CHECK: return + match i { + // 0x00nn + EnumAu16::u0_0x0000 => 0, + EnumAu16::u127_0x007f => 127, + EnumAu16::u128_0x0080 => 128, + EnumAu16::u255_0x00ff => 255, + // 0xffnn + EnumAu16::u65280_0xff00 => 0, + EnumAu16::u65407_0xff7f => 127, + EnumAu16::u65408_0xff80 => 128, + EnumAu16::u65535_0xffff => 127, // failed + } +} + +// EMIT_MIR matches_reduce_branches.match_trunc_u16_i8.MatchBranchSimplification.diff +fn match_trunc_u16_i8(i: EnumAu16) -> i8 { + // CHECK-LABEL: fn match_trunc_u16_i8( + // CHECK-NOT: switchInt + // CHECK: return + match i { + // 0x00nn + EnumAu16::u0_0x0000 => 0, + EnumAu16::u127_0x007f => 127, + EnumAu16::u128_0x0080 => -128, + EnumAu16::u255_0x00ff => -1, + // 0xffnn + EnumAu16::u65280_0xff00 => 0, + EnumAu16::u65407_0xff7f => 127, + EnumAu16::u65408_0xff80 => -128, + EnumAu16::u65535_0xffff => -1, + } +} + +// EMIT_MIR matches_reduce_branches.match_trunc_u16_i8_failed.MatchBranchSimplification.diff +fn match_trunc_u16_i8_failed(i: EnumAu16) -> i8 { + // CHECK-LABEL: fn match_trunc_u16_i8_failed( + // CHECK: switchInt + // CHECK: return + match i { + // 0x00nn + EnumAu16::u0_0x0000 => 0, + EnumAu16::u127_0x007f => 127, + EnumAu16::u128_0x0080 => -128, + EnumAu16::u255_0x00ff => -1, + // 0xffnn + EnumAu16::u65280_0xff00 => 0, + EnumAu16::u65407_0xff7f => 127, + EnumAu16::u65408_0xff80 => -128, + EnumAu16::u65535_0xffff => 1, } } @@ -248,7 +606,8 @@ enum EnumAi128 { // EMIT_MIR matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff fn match_i128_u128(i: EnumAi128) -> u128 { // CHECK-LABEL: fn match_i128_u128( - // CHECK: switchInt + // CHECK-NOT: switchInt + // CHECK: return match i { EnumAi128::A => 1, EnumAi128::B => 2, @@ -262,15 +621,34 @@ fn main() { let _ = foo(Some(())); let _ = bar(0); let _ = match_nested_if(); - let _ = match_u8_i16(EnumAu8::A); - let _ = match_u8_i16_2(EnumAu8::A); - let _ = match_u8_i16_failed(EnumAu8::A); - let _ = match_u8_i16_fallback(1); - let _ = match_u8_u16(EnumBu8::A); - let _ = match_u8_u16_2(EnumBu8::A); - let _ = match_i8_i16(EnumAi8::A); - let _ = match_i8_i16_failed(EnumAi8::A); - let _ = match_i8_i16(EnumAi8::A); - let _ = match_i16_i8(EnumAi16::A); + + let _: i8 = match_u8_i8(EnumAu8::u0_0x00); + let _: i8 = match_u8_i8_failed(EnumAu8::u0_0x00); + let _: (i8, i8) = match_u8_i8_2(EnumAu8::u0_0x00); + let _: (i8, i8) = match_u8_i8_2_failed(EnumAu8::u0_0x00); + let _: i8 = match_u8_i8_fallback(EnumAu8::u0_0x00); + let _: i8 = match_u8_i8_failed_len_1(EnumAu8::u0_0x00); + let _: i8 = match_u8_i8_failed_len_2(EnumAu8::u0_0x00); + + let _: i16 = match_sext_i8_i16(EnumAi8::o0_0x00); + let _: i16 = match_sext_i8_i16_failed(EnumAi8::o0_0x00); + let _: u16 = match_sext_i8_u16(EnumAi8::o0_0x00); + let _: u16 = match_sext_i8_u16_failed(EnumAi8::o0_0x00); + + let _: u16 = match_zext_u8_u16(EnumAu8::u0_0x00); + let _: u16 = match_zext_u8_u16_failed(EnumAu8::u0_0x00); + let _: i16 = match_zext_u8_i16(EnumAu8::u0_0x00); + let _: i16 = match_zext_u8_i16_failed(EnumAu8::u0_0x00); + + let _: i8 = match_trunc_i16_i8(EnumAi16::o0_0x0000); + let _: i8 = match_trunc_i16_i8_failed(EnumAi16::o0_0x0000); + let _: u8 = match_trunc_i16_u8(EnumAi16::o0_0x0000); + let _: u8 = match_trunc_i16_u8_failed(EnumAi16::o0_0x0000); + + let _: i8 = match_trunc_u16_i8(EnumAu16::u0_0x0000); + let _: i8 = match_trunc_u16_i8_failed(EnumAu16::u0_0x0000); + let _: u8 = match_trunc_u16_u8(EnumAu16::u0_0x0000); + let _: u8 = match_trunc_u16_u8_failed(EnumAu16::u0_0x0000); + let _ = match_i128_u128(EnumAi128::A); } diff --git a/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff b/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff index 157f9c98353..11a18f58e3a 100644 --- a/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff @@ -5,27 +5,32 @@ debug e => _1; let mut _0: u8; let mut _2: isize; ++ let mut _3: isize; bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const 1_u8; - goto -> bb4; - } - - bb3: { - _0 = const 0_u8; - goto -> bb4; - } - - bb4: { +- switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const 1_u8; +- goto -> bb4; +- } +- +- bb3: { +- _0 = const 0_u8; +- goto -> bb4; +- } +- +- bb4: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as u8 (IntToInt); ++ StorageDead(_3); return; } } diff --git a/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff b/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff index 19083771fd9..809badc41ba 100644 --- a/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff @@ -5,27 +5,32 @@ debug e => _1; let mut _0: i8; let mut _2: isize; ++ let mut _3: isize; bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; - } - - bb1: { - unreachable; - } - - bb2: { - _0 = const 1_i8; - goto -> bb4; - } - - bb3: { - _0 = const 0_i8; - goto -> bb4; - } - - bb4: { +- switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; +- } +- +- bb1: { +- unreachable; +- } +- +- bb2: { +- _0 = const 1_i8; +- goto -> bb4; +- } +- +- bb3: { +- _0 = const 0_i8; +- goto -> bb4; +- } +- +- bb4: { ++ StorageLive(_3); ++ _3 = move _2; ++ _0 = _3 as i8 (IntToInt); ++ StorageDead(_3); return; } } diff --git a/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir b/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir index e357e785e33..6c76a72b775 100644 --- a/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir @@ -39,7 +39,7 @@ fn shortcut_second_or() -> () { } bb5: { - falseEdge -> [real: bb10, imaginary: bb6]; + falseEdge -> [real: bb12, imaginary: bb6]; } bb6: { @@ -47,18 +47,19 @@ fn shortcut_second_or() -> () { } bb7: { - falseEdge -> [real: bb12, imaginary: bb8]; + falseEdge -> [real: bb10, imaginary: bb8]; } bb8: { - falseEdge -> [real: bb13, imaginary: bb3]; + falseEdge -> [real: bb9, imaginary: bb3]; } bb9: { - _0 = const (); - StorageDead(_4); - StorageDead(_3); - goto -> bb14; + StorageLive(_3); + _3 = (_1.0: (i32, i32)); + StorageLive(_4); + _4 = (_1.1: i32); + goto -> bb13; } bb10: { @@ -66,7 +67,7 @@ fn shortcut_second_or() -> () { _3 = (_1.0: (i32, i32)); StorageLive(_4); _4 = (_1.1: i32); - goto -> bb9; + goto -> bb13; } bb11: { @@ -74,7 +75,7 @@ fn shortcut_second_or() -> () { _3 = (_1.0: (i32, i32)); StorageLive(_4); _4 = (_1.1: i32); - goto -> bb9; + goto -> bb13; } bb12: { @@ -82,15 +83,14 @@ fn shortcut_second_or() -> () { _3 = (_1.0: (i32, i32)); StorageLive(_4); _4 = (_1.1: i32); - goto -> bb9; + goto -> bb13; } bb13: { - StorageLive(_3); - _3 = (_1.0: (i32, i32)); - StorageLive(_4); - _4 = (_1.1: i32); - goto -> bb9; + _0 = const (); + StorageDead(_4); + StorageDead(_3); + goto -> bb14; } bb14: { diff --git a/tests/mir-opt/or_pattern.single_switchint.SimplifyCfg-initial.after.mir b/tests/mir-opt/or_pattern.single_switchint.SimplifyCfg-initial.after.mir index eafe95b4a11..8b0ef7b29d7 100644 --- a/tests/mir-opt/or_pattern.single_switchint.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/or_pattern.single_switchint.SimplifyCfg-initial.after.mir @@ -22,7 +22,7 @@ fn single_switchint() -> () { } bb3: { - falseEdge -> [real: bb9, imaginary: bb4]; + falseEdge -> [real: bb12, imaginary: bb4]; } bb4: { @@ -30,11 +30,11 @@ fn single_switchint() -> () { } bb5: { - falseEdge -> [real: bb10, imaginary: bb6]; + falseEdge -> [real: bb11, imaginary: bb6]; } bb6: { - falseEdge -> [real: bb11, imaginary: bb1]; + falseEdge -> [real: bb10, imaginary: bb1]; } bb7: { @@ -43,26 +43,26 @@ fn single_switchint() -> () { } bb8: { - falseEdge -> [real: bb12, imaginary: bb7]; + falseEdge -> [real: bb9, imaginary: bb7]; } bb9: { - _1 = const 1_i32; + _1 = const 4_i32; goto -> bb13; } bb10: { - _1 = const 2_i32; + _1 = const 3_i32; goto -> bb13; } bb11: { - _1 = const 3_i32; + _1 = const 2_i32; goto -> bb13; } bb12: { - _1 = const 4_i32; + _1 = const 1_i32; goto -> bb13; } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 959efa2a548..30c122ddea0 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -73,13 +73,12 @@ StorageLive(_6); StorageLive(_7); _9 = const main::promoted[0]; -- _7 = _9; -+ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + _7 = _9; StorageLive(_8); - _8 = _1; - _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind unreachable]; + _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; ++ _6 = std::alloc::Global::alloc_impl(_9, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; } bb4: { @@ -119,11 +118,9 @@ + nop; return; } - } ++ } + + ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ -+ } -+ -+ ALLOC1 (size: 0, align: 1) {} + } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index 4a37c860320..93449462c3d 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -81,13 +81,12 @@ StorageLive(_6); StorageLive(_7); _9 = const main::promoted[0]; -- _7 = _9; -+ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + _7 = _9; StorageLive(_8); - _8 = _1; - _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb5, unwind continue]; + _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb5, unwind continue]; ++ _6 = std::alloc::Global::alloc_impl(_9, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb5, unwind continue]; } bb5: { @@ -95,11 +94,9 @@ StorageDead(_7); _5 = Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap(move _6) -> [return: bb1, unwind continue]; } - } ++ } + + ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ -+ } -+ -+ ALLOC1 (size: 0, align: 1) {} + } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 97f5245a8c9..44435956ec4 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -73,13 +73,12 @@ StorageLive(_6); StorageLive(_7); _9 = const main::promoted[0]; -- _7 = _9; -+ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + _7 = _9; StorageLive(_8); - _8 = _1; - _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind unreachable]; + _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; ++ _6 = std::alloc::Global::alloc_impl(_9, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind unreachable]; } bb4: { @@ -119,11 +118,9 @@ + nop; return; } - } ++ } + + ALLOC0 (size: 16, align: 8) { + 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ -+ } -+ -+ ALLOC1 (size: 0, align: 1) {} + } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index ec2e95fecb6..c958480a9c7 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -81,13 +81,12 @@ StorageLive(_6); StorageLive(_7); _9 = const main::promoted[0]; -- _7 = _9; -+ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + _7 = _9; StorageLive(_8); - _8 = _1; - _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb5, unwind continue]; + _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb5, unwind continue]; ++ _6 = std::alloc::Global::alloc_impl(_9, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb5, unwind continue]; } bb5: { @@ -95,11 +94,9 @@ StorageDead(_7); _5 = Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap(move _6) -> [return: bb1, unwind continue]; } - } ++ } + + ALLOC0 (size: 16, align: 8) { + 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ -+ } -+ -+ ALLOC1 (size: 0, align: 1) {} + } diff --git a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff index 8d87438a47a..998b89919d1 100644 --- a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff @@ -8,9 +8,9 @@ bb0: { StorageLive(_1); - _1 = const <T as MyTrait>::ASSOC_INT; -- switchInt(_1) -> [7: bb2, 42: bb3, otherwise: bb1]; +- switchInt(_1) -> [7: bb3, 42: bb2, otherwise: bb1]; + nop; -+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb2, 42: bb3, otherwise: bb1]; ++ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb2, otherwise: bb1]; } bb1: { @@ -19,12 +19,12 @@ } bb2: { - _0 = const "hello"; + _0 = const "towel"; goto -> bb4; } bb3: { - _0 = const "towel"; + _0 = const "hello"; goto -> bb4; } diff --git a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff index 8d87438a47a..998b89919d1 100644 --- a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff @@ -8,9 +8,9 @@ bb0: { StorageLive(_1); - _1 = const <T as MyTrait>::ASSOC_INT; -- switchInt(_1) -> [7: bb2, 42: bb3, otherwise: bb1]; +- switchInt(_1) -> [7: bb3, 42: bb2, otherwise: bb1]; + nop; -+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb2, 42: bb3, otherwise: bb1]; ++ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb2, otherwise: bb1]; } bb1: { @@ -19,12 +19,12 @@ } bb2: { - _0 = const "hello"; + _0 = const "towel"; goto -> bb4; } bb3: { - _0 = const "towel"; + _0 = const "hello"; goto -> bb4; } diff --git a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff index f192f3feb96..30f66ef6b82 100644 --- a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff @@ -20,8 +20,8 @@ bb1: { StorageDead(_2); -- switchInt(_1) -> [7: bb3, 42: bb4, otherwise: bb2]; -+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb4, otherwise: bb2]; +- switchInt(_1) -> [7: bb4, 42: bb3, otherwise: bb2]; ++ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb4, 42: bb3, otherwise: bb2]; } bb2: { @@ -30,12 +30,12 @@ } bb3: { - _0 = const "hello"; + _0 = const "towel"; goto -> bb5; } bb4: { - _0 = const "towel"; + _0 = const "hello"; goto -> bb5; } diff --git a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff index 261faf415f3..ed12ad4b93e 100644 --- a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff @@ -20,8 +20,8 @@ bb1: { StorageDead(_2); -- switchInt(_1) -> [7: bb3, 42: bb4, otherwise: bb2]; -+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb4, otherwise: bb2]; +- switchInt(_1) -> [7: bb4, 42: bb3, otherwise: bb2]; ++ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb4, 42: bb3, otherwise: bb2]; } bb2: { @@ -30,12 +30,12 @@ } bb3: { - _0 = const "hello"; + _0 = const "towel"; goto -> bb5; } bb4: { - _0 = const "towel"; + _0 = const "hello"; goto -> bb5; } diff --git a/tests/mir-opt/uninhabited_fallthrough_elimination.eliminate_fallthrough.UnreachableEnumBranching.diff b/tests/mir-opt/uninhabited_fallthrough_elimination.eliminate_fallthrough.UnreachableEnumBranching.diff index 098b620dfaa..c0ea9fae7df 100644 --- a/tests/mir-opt/uninhabited_fallthrough_elimination.eliminate_fallthrough.UnreachableEnumBranching.diff +++ b/tests/mir-opt/uninhabited_fallthrough_elimination.eliminate_fallthrough.UnreachableEnumBranching.diff @@ -8,8 +8,8 @@ bb0: { _2 = discriminant(_1); -- switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1]; -+ switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb5]; +- switchInt(move _2) -> [1: bb2, 2: bb3, otherwise: bb1]; ++ switchInt(move _2) -> [1: bb2, 2: bb3, otherwise: bb5]; } bb1: { @@ -18,12 +18,12 @@ } bb2: { - _0 = const 1_u32; + _0 = const 2_u32; goto -> bb4; } bb3: { - _0 = const 2_u32; + _0 = const 1_u32; goto -> bb4; } diff --git a/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UnreachableEnumBranching.diff b/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UnreachableEnumBranching.diff index 995e32b033f..2082e8046ad 100644 --- a/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UnreachableEnumBranching.diff +++ b/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UnreachableEnumBranching.diff @@ -8,8 +8,8 @@ bb0: { _2 = discriminant(_1); -- switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; -+ switchInt(move _2) -> [0: bb5, 1: bb3, 2: bb1, otherwise: bb5]; +- switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; ++ switchInt(move _2) -> [0: bb5, 1: bb2, 2: bb1, otherwise: bb5]; } bb1: { @@ -18,12 +18,12 @@ } bb2: { - _0 = const 1_u32; + _0 = const 2_u32; goto -> bb4; } bb3: { - _0 = const 2_u32; + _0 = const 1_u32; goto -> bb4; } diff --git a/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-abort.diff index e5dab5d52a6..ed54a38f70b 100644 --- a/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-abort.diff @@ -30,8 +30,8 @@ StorageLive(_4); _4 = &(_1.1: Test3); _5 = discriminant((*_4)); -- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb2, otherwise: bb1]; -+ switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb5, 3: bb2, otherwise: bb1]; +- switchInt(move _5) -> [0: bb5, 1: bb4, 2: bb3, 3: bb2, otherwise: bb1]; ++ switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb3, 3: bb2, otherwise: bb1]; } bb1: { @@ -47,7 +47,10 @@ } bb3: { - _3 = const "A(Empty)"; + StorageLive(_7); + _7 = const "C"; + _3 = &(*_7); + StorageDead(_7); goto -> bb6; } @@ -60,10 +63,7 @@ } bb5: { - StorageLive(_7); - _7 = const "C"; - _3 = &(*_7); - StorageDead(_7); + _3 = const "A(Empty)"; goto -> bb6; } @@ -72,8 +72,8 @@ StorageDead(_3); StorageLive(_9); _10 = discriminant((_1.1: Test3)); -- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb1]; -+ switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb10, 3: bb7, otherwise: bb1]; +- switchInt(move _10) -> [0: bb10, 1: bb9, 2: bb8, 3: bb7, otherwise: bb1]; ++ switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb8, 3: bb7, otherwise: bb1]; } bb7: { @@ -85,7 +85,10 @@ } bb8: { - _9 = const "A(Empty)"; + StorageLive(_12); + _12 = const "C"; + _9 = &(*_12); + StorageDead(_12); goto -> bb11; } @@ -98,10 +101,7 @@ } bb10: { - StorageLive(_12); - _12 = const "C"; - _9 = &(*_12); - StorageDead(_12); + _9 = const "A(Empty)"; goto -> bb11; } diff --git a/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-unwind.diff index e5dab5d52a6..ed54a38f70b 100644 --- a/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.byref.UnreachableEnumBranching.panic-unwind.diff @@ -30,8 +30,8 @@ StorageLive(_4); _4 = &(_1.1: Test3); _5 = discriminant((*_4)); -- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb2, otherwise: bb1]; -+ switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb5, 3: bb2, otherwise: bb1]; +- switchInt(move _5) -> [0: bb5, 1: bb4, 2: bb3, 3: bb2, otherwise: bb1]; ++ switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb3, 3: bb2, otherwise: bb1]; } bb1: { @@ -47,7 +47,10 @@ } bb3: { - _3 = const "A(Empty)"; + StorageLive(_7); + _7 = const "C"; + _3 = &(*_7); + StorageDead(_7); goto -> bb6; } @@ -60,10 +63,7 @@ } bb5: { - StorageLive(_7); - _7 = const "C"; - _3 = &(*_7); - StorageDead(_7); + _3 = const "A(Empty)"; goto -> bb6; } @@ -72,8 +72,8 @@ StorageDead(_3); StorageLive(_9); _10 = discriminant((_1.1: Test3)); -- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb1]; -+ switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb10, 3: bb7, otherwise: bb1]; +- switchInt(move _10) -> [0: bb10, 1: bb9, 2: bb8, 3: bb7, otherwise: bb1]; ++ switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb8, 3: bb7, otherwise: bb1]; } bb7: { @@ -85,7 +85,10 @@ } bb8: { - _9 = const "A(Empty)"; + StorageLive(_12); + _12 = const "C"; + _9 = &(*_12); + StorageDead(_12); goto -> bb11; } @@ -98,10 +101,7 @@ } bb10: { - StorageLive(_12); - _12 = const "C"; - _9 = &(*_12); - StorageDead(_12); + _9 = const "A(Empty)"; goto -> bb11; } diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-abort.diff index 02b9f02f4c0..be934ac688b 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-abort.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5]; } @@ -27,11 +27,6 @@ } bb2: { - _1 = const "A(Empty)"; - goto -> bb4; - } - - bb3: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); @@ -39,6 +34,11 @@ goto -> bb4; } + bb3: { + _1 = const "A(Empty)"; + goto -> bb4; + } + bb4: { StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-unwind.diff index 02b9f02f4c0..be934ac688b 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-unwind.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5]; } @@ -27,11 +27,6 @@ } bb2: { - _1 = const "A(Empty)"; - goto -> bb4; - } - - bb3: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); @@ -39,6 +34,11 @@ goto -> bb4; } + bb3: { + _1 = const "A(Empty)"; + goto -> bb4; + } + bb4: { StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-abort.diff index d3376442376..120061841a0 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-abort.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test3::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb5, 1: bb5, otherwise: bb1]; } @@ -27,11 +27,6 @@ } bb2: { - _1 = const "A(Empty)"; - goto -> bb4; - } - - bb3: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); @@ -39,6 +34,11 @@ goto -> bb4; } + bb3: { + _1 = const "A(Empty)"; + goto -> bb4; + } + bb4: { StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-unwind.diff index d3376442376..120061841a0 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-unwind.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test3::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb5, 1: bb5, otherwise: bb1]; } @@ -27,11 +27,6 @@ } bb2: { - _1 = const "A(Empty)"; - goto -> bb4; - } - - bb3: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); @@ -39,6 +34,11 @@ goto -> bb4; } + bb3: { + _1 = const "A(Empty)"; + goto -> bb4; + } + bb4: { StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-abort.diff index 8f0d5b7cd99..b86814d6119 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-abort.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test4::C; _3 = discriminant(_2); - switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; + switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { @@ -26,11 +26,6 @@ } bb2: { - _1 = const "A(i32)"; - goto -> bb4; - } - - bb3: { StorageLive(_4); _4 = const "B(i32)"; _1 = &(*_4); @@ -38,6 +33,11 @@ goto -> bb4; } + bb3: { + _1 = const "A(i32)"; + goto -> bb4; + } + bb4: { StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-unwind.diff index 8f0d5b7cd99..b86814d6119 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-unwind.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test4::C; _3 = discriminant(_2); - switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; + switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { @@ -26,11 +26,6 @@ } bb2: { - _1 = const "A(i32)"; - goto -> bb4; - } - - bb3: { StorageLive(_4); _4 = const "B(i32)"; _1 = &(*_4); @@ -38,6 +33,11 @@ goto -> bb4; } + bb3: { + _1 = const "A(i32)"; + goto -> bb4; + } + bb4: { StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-abort.diff index b1ecd008582..424ac6ba651 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-abort.diff @@ -15,8 +15,8 @@ StorageLive(_2); _2 = Test4::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb1]; -+ switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, 3: bb1, otherwise: bb6]; +- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, 3: bb1, otherwise: bb6]; } bb1: { @@ -28,7 +28,10 @@ } bb2: { - _1 = const "A(i32)"; + StorageLive(_5); + _5 = const "C"; + _1 = &(*_5); + StorageDead(_5); goto -> bb5; } @@ -41,10 +44,7 @@ } bb4: { - StorageLive(_5); - _5 = const "C"; - _1 = &(*_5); - StorageDead(_5); + _1 = const "A(i32)"; goto -> bb5; } diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-unwind.diff index b1ecd008582..424ac6ba651 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-unwind.diff @@ -15,8 +15,8 @@ StorageLive(_2); _2 = Test4::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb1]; -+ switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, 3: bb1, otherwise: bb6]; +- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, 3: bb1, otherwise: bb6]; } bb1: { @@ -28,7 +28,10 @@ } bb2: { - _1 = const "A(i32)"; + StorageLive(_5); + _5 = const "C"; + _1 = &(*_5); + StorageDead(_5); goto -> bb5; } @@ -41,10 +44,7 @@ } bb4: { - StorageLive(_5); - _5 = const "C"; - _1 = &(*_5); - StorageDead(_5); + _1 = const "A(i32)"; goto -> bb5; } diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-abort.diff index 28c6d4fb675..4cd6d3f5683 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-abort.diff @@ -16,8 +16,8 @@ StorageLive(_2); _2 = Test4::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, otherwise: bb1]; -+ switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, 3: bb1, otherwise: bb8]; +- switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, 3: bb1, otherwise: bb8]; } bb1: { @@ -29,23 +29,18 @@ } bb2: { - switchInt(((_2 as A).0: i32)) -> [1: bb3, 2: bb4, otherwise: bb1]; + switchInt(((_2 as A).0: i32)) -> [1: bb6, 2: bb5, otherwise: bb1]; } bb3: { - _1 = const "A(1)"; + StorageLive(_6); + _6 = const "C"; + _1 = &(*_6); + StorageDead(_6); goto -> bb7; } bb4: { - StorageLive(_4); - _4 = const "A(2)"; - _1 = &(*_4); - StorageDead(_4); - goto -> bb7; - } - - bb5: { StorageLive(_5); _5 = const "B(i32)"; _1 = &(*_5); @@ -53,11 +48,16 @@ goto -> bb7; } + bb5: { + StorageLive(_4); + _4 = const "A(2)"; + _1 = &(*_4); + StorageDead(_4); + goto -> bb7; + } + bb6: { - StorageLive(_6); - _6 = const "C"; - _1 = &(*_6); - StorageDead(_6); + _1 = const "A(1)"; goto -> bb7; } diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-unwind.diff index 28c6d4fb675..4cd6d3f5683 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-unwind.diff @@ -16,8 +16,8 @@ StorageLive(_2); _2 = Test4::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, otherwise: bb1]; -+ switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, 3: bb1, otherwise: bb8]; +- switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, 3: bb1, otherwise: bb8]; } bb1: { @@ -29,23 +29,18 @@ } bb2: { - switchInt(((_2 as A).0: i32)) -> [1: bb3, 2: bb4, otherwise: bb1]; + switchInt(((_2 as A).0: i32)) -> [1: bb6, 2: bb5, otherwise: bb1]; } bb3: { - _1 = const "A(1)"; + StorageLive(_6); + _6 = const "C"; + _1 = &(*_6); + StorageDead(_6); goto -> bb7; } bb4: { - StorageLive(_4); - _4 = const "A(2)"; - _1 = &(*_4); - StorageDead(_4); - goto -> bb7; - } - - bb5: { StorageLive(_5); _5 = const "B(i32)"; _1 = &(*_5); @@ -53,11 +48,16 @@ goto -> bb7; } + bb5: { + StorageLive(_4); + _4 = const "A(2)"; + _1 = &(*_4); + StorageDead(_4); + goto -> bb7; + } + bb6: { - StorageLive(_6); - _6 = const "C"; - _1 = &(*_6); - StorageDead(_6); + _1 = const "A(1)"; goto -> bb7; } diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-abort.diff index f36a7efd80d..2de1f77eeec 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-abort.diff @@ -15,8 +15,8 @@ StorageLive(_2); _2 = Test5::<T>::C; _3 = discriminant(_2); -- switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, otherwise: bb1]; -+ switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, 3: bb1, otherwise: bb7]; +- switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, 3: bb1, otherwise: bb7]; } bb1: { @@ -28,7 +28,10 @@ } bb2: { - _1 = const "A(T)"; + StorageLive(_5); + _5 = const "C"; + _1 = &(*_5); + StorageDead(_5); goto -> bb5; } @@ -41,10 +44,7 @@ } bb4: { - StorageLive(_5); - _5 = const "C"; - _1 = &(*_5); - StorageDead(_5); + _1 = const "A(T)"; goto -> bb5; } diff --git a/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-unwind.diff index 20e31c24c84..5afb78c58a3 100644 --- a/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-unwind.diff @@ -15,8 +15,8 @@ StorageLive(_2); _2 = Test5::<T>::C; _3 = discriminant(_2); -- switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, otherwise: bb1]; -+ switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, 3: bb1, otherwise: bb8]; +- switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, 3: bb1, otherwise: bb8]; } bb1: { @@ -28,7 +28,10 @@ } bb2: { - _1 = const "A(T)"; + StorageLive(_5); + _5 = const "C"; + _1 = &(*_5); + StorageDead(_5); goto -> bb5; } @@ -41,10 +44,7 @@ } bb4: { - StorageLive(_5); - _5 = const "C"; - _1 = &(*_5); - StorageDead(_5); + _1 = const "A(T)"; goto -> bb5; } diff --git a/tests/mir-opt/unreachable_enum_branching.rs b/tests/mir-opt/unreachable_enum_branching.rs index 6005dc546dc..fac14042b10 100644 --- a/tests/mir-opt/unreachable_enum_branching.rs +++ b/tests/mir-opt/unreachable_enum_branching.rs @@ -120,7 +120,7 @@ fn otherwise_t3() { fn otherwise_t4_unreachable_default() { // CHECK-LABEL: fn otherwise_t4_unreachable_default( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: bb2, 1: bb3, 2: bb4, 3: bb1, otherwise: [[unreachable:bb.*]]]; + // CHECK: switchInt(move [[discr]]) -> [0: {{bb.*}}, 1: {{bb.*}}, 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable:bb.*]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test4::C { @@ -135,7 +135,7 @@ fn otherwise_t4_unreachable_default() { fn otherwise_t4_unreachable_default_2() { // CHECK-LABEL: fn otherwise_t4_unreachable_default_2( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: bb2, 1: bb5, 2: bb6, 3: bb1, otherwise: [[unreachable:bb.*]]]; + // CHECK: switchInt(move [[discr]]) -> [0: {{bb.*}}, 1: {{bb.*}}, 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable:bb.*]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test4::C { @@ -151,7 +151,7 @@ fn otherwise_t4_unreachable_default_2() { fn otherwise_t4() { // CHECK-LABEL: fn otherwise_t4( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: bb2, 1: bb3, otherwise: [[unreachable:bb.*]]]; + // CHECK: switchInt(move [[discr]]) -> [0: {{bb.*}}, 1: {{bb.*}}, otherwise: [[unreachable:bb.*]]]; // CHECK: [[unreachable]]: { // CHECK-NOT: unreachable; // CHECK: } @@ -166,7 +166,7 @@ fn otherwise_t4() { fn otherwise_t5_unreachable_default<T>() { // CHECK-LABEL: fn otherwise_t5_unreachable_default( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [255: bb2, 0: bb3, 5: bb4, 3: bb1, otherwise: [[unreachable:bb.*]]]; + // CHECK: switchInt(move [[discr]]) -> [255: {{bb.*}}, 0: {{bb.*}}, 5: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable:bb.*]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test5::<T>::C { @@ -183,7 +183,7 @@ fn byref() { let plop = Plop { xx: 51, test3: Test3::C }; // CHECK: [[ref_discr:_.*]] = discriminant((* - // CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb5, 3: bb2, otherwise: [[unreachable]]]; + // CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable]]]; match &plop.test3 { Test3::A(_) => "A(Empty)", Test3::B(_) => "B(Empty)", @@ -195,7 +195,7 @@ fn byref() { // CHECK-NEXT: unreachable; // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable]], 1: [[unreachable]], 2: bb10, 3: bb7, otherwise: [[unreachable]]]; + // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable]], 1: [[unreachable]], 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable]]]; match plop.test3 { Test3::A(_) => "A(Empty)", Test3::B(_) => "B(Empty)", diff --git a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff index a85fc0da992..8aef9914936 100644 --- a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff +++ b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb2, otherwise: bb1]; +- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1]; } @@ -31,11 +31,6 @@ } bb3: { - _1 = const "A(Empty)"; - goto -> bb5; - } - - bb4: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); @@ -43,6 +38,11 @@ goto -> bb5; } + bb4: { + _1 = const "A(Empty)"; + goto -> bb5; + } + bb5: { StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff index a85fc0da992..8aef9914936 100644 --- a/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff +++ b/tests/mir-opt/unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff @@ -14,7 +14,7 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb2, otherwise: bb1]; +- switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1]; } @@ -31,11 +31,6 @@ } bb3: { - _1 = const "A(Empty)"; - goto -> bb5; - } - - bb4: { StorageLive(_4); _4 = const "B(Empty)"; _1 = &(*_4); @@ -43,6 +38,11 @@ goto -> bb5; } + bb4: { + _1 = const "A(Empty)"; + goto -> bb5; + } + bb5: { StorageDead(_2); StorageDead(_1); diff --git a/tests/run-make/issue-36710/foo.cpp b/tests/run-make/cpp-global-destructors/foo.cpp index 8f878c2c272..8f878c2c272 100644 --- a/tests/run-make/issue-36710/foo.cpp +++ b/tests/run-make/cpp-global-destructors/foo.cpp diff --git a/tests/run-make/issue-36710/foo.rs b/tests/run-make/cpp-global-destructors/foo.rs index f30a35e27c0..f30a35e27c0 100644 --- a/tests/run-make/issue-36710/foo.rs +++ b/tests/run-make/cpp-global-destructors/foo.rs diff --git a/tests/run-make/cpp-global-destructors/rmake.rs b/tests/run-make/cpp-global-destructors/rmake.rs new file mode 100644 index 00000000000..9bc5c84e10d --- /dev/null +++ b/tests/run-make/cpp-global-destructors/rmake.rs @@ -0,0 +1,26 @@ +// Some start files were missed when originally writing the logic to swap in musl start files. +// This caused #36710. After the fix in #50105, this test checks that linking to C++ code +// with global destructors works. +// See https://github.com/rust-lang/rust/pull/50105 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +//@ ignore-none +// Reason: no-std is not supported. +//@ ignore-wasm32 +//@ ignore-wasm64 +// Reason: compiling C++ to WASM may cause problems. + +// Neither of these are tested in full CI. +//@ ignore-nvptx64-nvidia-cuda +// Reason: can't find crate "std" +//@ ignore-sgx + +use run_make_support::{build_native_static_lib_cxx, run, rustc}; + +fn main() { + build_native_static_lib_cxx("foo"); + rustc().input("foo.rs").arg("-lfoo").extra_rs_cxx_flags().run(); + run("foo"); +} diff --git a/tests/run-make/issue-69368/a.rs b/tests/run-make/crate-circular-deps-link/a.rs index a54f429550e..a54f429550e 100644 --- a/tests/run-make/issue-69368/a.rs +++ b/tests/run-make/crate-circular-deps-link/a.rs diff --git a/tests/run-make/issue-69368/b.rs b/tests/run-make/crate-circular-deps-link/b.rs index 4d6af026656..4d6af026656 100644 --- a/tests/run-make/issue-69368/b.rs +++ b/tests/run-make/crate-circular-deps-link/b.rs diff --git a/tests/run-make/issue-69368/c.rs b/tests/run-make/crate-circular-deps-link/c.rs index 9d72657aa59..9d72657aa59 100644 --- a/tests/run-make/issue-69368/c.rs +++ b/tests/run-make/crate-circular-deps-link/c.rs diff --git a/tests/run-make/crate-circular-deps-link/rmake.rs b/tests/run-make/crate-circular-deps-link/rmake.rs new file mode 100644 index 00000000000..7cc28ac93e1 --- /dev/null +++ b/tests/run-make/crate-circular-deps-link/rmake.rs @@ -0,0 +1,20 @@ +// Test that previously triggered a linker failure with root cause +// similar to one found in the issue #69368. +// +// The crate that provides oom lang item is missing some other lang +// items. Necessary to prevent the use of start-group / end-group. +// +// The weak lang items are defined in a separate compilation units, +// so that linker could omit them if not used. +// +// The crates that need those weak lang items are dependencies of +// crates that provide them. +// See https://github.com/rust-lang/rust/issues/69371 + +use run_make_support::rustc; + +fn main() { + rustc().input("a.rs").run(); + rustc().input("b.rs").run(); + rustc().input("c.rs").run(); +} diff --git a/tests/run-make/cross-lang-lto-clang/Makefile b/tests/run-make/cross-lang-lto-clang/Makefile deleted file mode 100644 index acf49c8f5c8..00000000000 --- a/tests/run-make/cross-lang-lto-clang/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# needs-force-clang-based-tests - -# This test makes sure that cross-language inlining actually works by checking -# the generated machine code. - -include ../tools.mk - -all: cpp-executable rust-executable - -cpp-executable: - $(RUSTC) -Clinker-plugin-lto=on -o $(TMPDIR)/librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs - $(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3 - # Make sure we don't find a call instruction to the function we expect to - # always be inlined. - "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined" - # As a sanity check, make sure we do find a call instruction to a - # non-inlined function - "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined" - -rust-executable: - $(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2 - (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o) - $(RUSTC) -Clinker-plugin-lto=on -L$(TMPDIR) -Copt-level=2 -Clinker=$(CLANG) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR)/rsmain - "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -e "call.*c_never_inlined" - "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -v -e "call.*c_always_inlined" diff --git a/tests/run-make/cross-lang-lto-clang/rmake.rs b/tests/run-make/cross-lang-lto-clang/rmake.rs new file mode 100644 index 00000000000..1b15a54aacb --- /dev/null +++ b/tests/run-make/cross-lang-lto-clang/rmake.rs @@ -0,0 +1,62 @@ +// This test checks that cross-language inlining actually works by checking +// the generated machine code. +// See https://github.com/rust-lang/rust/pull/57514 + +//@ needs-force-clang-based-tests +// NOTE(#126180): This test only runs on `x86_64-gnu-debug`, because that CI job sets +// RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their +// name. + +use run_make_support::{clang, env_var, llvm_ar, llvm_objdump, rustc, static_lib_name}; + +fn main() { + rustc() + .linker_plugin_lto("on") + .output(static_lib_name("rustlib-xlto")) + .opt_level("2") + .codegen_units(1) + .input("rustlib.rs") + .run(); + clang() + .lto("thin") + .use_ld("lld") + .arg("-lrustlib-xlto") + .out_exe("cmain") + .input("cmain.c") + .arg("-O3") + .run(); + // Make sure we don't find a call instruction to the function we expect to + // always be inlined. + llvm_objdump() + .disassemble() + .input("cmain") + .run() + .assert_stdout_not_contains_regex("call.*rust_always_inlined"); + // As a sanity check, make sure we do find a call instruction to a + // non-inlined function + llvm_objdump() + .disassemble() + .input("cmain") + .run() + .assert_stdout_contains_regex("call.*rust_never_inlined"); + clang().input("clib.c").lto("thin").arg("-c").out_exe("clib.o").arg("-O2").run(); + llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run(); + rustc() + .linker_plugin_lto("on") + .opt_level("2") + .linker(&env_var("CLANG")) + .link_arg("-fuse-ld=lld") + .input("main.rs") + .output("rsmain") + .run(); + llvm_objdump() + .disassemble() + .input("rsmain") + .run() + .assert_stdout_not_contains_regex("call.*c_always_inlined"); + llvm_objdump() + .disassemble() + .input("rsmain") + .run() + .assert_stdout_contains_regex("call.*c_never_inlined"); +} diff --git a/tests/run-make/cross-lang-lto-pgo-smoketest/clib.c b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/clib.c index 90f33f24dc4..90f33f24dc4 100644 --- a/tests/run-make/cross-lang-lto-pgo-smoketest/clib.c +++ b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/clib.c diff --git a/tests/run-make/cross-lang-lto-pgo-smoketest/cmain.c b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/cmain.c index e3f24828be3..e3f24828be3 100644 --- a/tests/run-make/cross-lang-lto-pgo-smoketest/cmain.c +++ b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/cmain.c diff --git a/tests/run-make/cross-lang-lto-pgo-smoketest/main.rs b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/main.rs index 8129dcb85d9..8129dcb85d9 100644 --- a/tests/run-make/cross-lang-lto-pgo-smoketest/main.rs +++ b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/main.rs diff --git a/tests/run-make/cross-lang-lto-pgo-smoketest-clang/rmake.rs b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/rmake.rs new file mode 100644 index 00000000000..03c9af4bb89 --- /dev/null +++ b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/rmake.rs @@ -0,0 +1,120 @@ +// This test makes sure that cross-language inlining can be used in conjunction +// with profile-guided optimization. The test only tests that the whole workflow +// can be executed without anything crashing. It does not test whether PGO or +// xLTO have any specific effect on the generated code. +// See https://github.com/rust-lang/rust/pull/61036 + +//@ needs-force-clang-based-tests +// NOTE(#126180): This test would only run on `x86_64-gnu-debug`, because that CI job sets +// RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their +// name. + +//@ needs-profiler-support +// FIXME(Oneirical): Except that due to the reliance on llvm-profdata, this test +// never runs, because `x86_64-gnu-debug` does not have the `profiler_builtins` crate. + +//FIXME(Oneirical): There was a strange workaround for MSVC on this test +// which added -C panic=abort to every RUSTC call. It was justified as follows: + +// "LLVM doesn't support instrumenting binaries that use SEH: +// https://bugs.llvm.org/show_bug.cgi?id=41279 +// Things work fine with -Cpanic=abort though." + +// This isn't very pertinent, however, as the test does not get run on any +// MSVC platforms. + +use run_make_support::{ + clang, env_var, has_extension, has_prefix, llvm_ar, llvm_profdata, rfs, run, rustc, + shallow_find_files, static_lib_name, +}; + +fn main() { + rustc() + .linker_plugin_lto("on") + .output(static_lib_name("rustlib-xlto")) + .opt_level("3") + .codegen_units(1) + .input("rustlib.rs") + .arg("-Cprofile-generate=cpp-profdata") + .run(); + clang() + .lto("thin") + .arg("-fprofile-generate=cpp-profdata") + .use_ld("lld") + .arg("-lrustlib-xlto") + .out_exe("cmain") + .input("cmain.c") + .arg("-O3") + .run(); + run("cmain"); + // Postprocess the profiling data so it can be used by the compiler + let profraw_files = shallow_find_files("cpp-profdata", |path| { + has_prefix(path, "default") && has_extension(path, "profraw") + }); + let profraw_file = profraw_files.get(0).unwrap(); + llvm_profdata().merge().output("cpp-profdata/merged.profdata").input(profraw_file).run(); + rustc() + .linker_plugin_lto("on") + .profile_use("cpp-profdata/merged.profdata") + .output(static_lib_name("rustlib-xlto")) + .opt_level("3") + .codegen_units(1) + .input("rustlib.rs") + .run(); + clang() + .lto("thin") + .arg("-fprofile-use=cpp-profdata/merged.profdata") + .use_ld("lld") + .arg("-lrustlib-xlto") + .out_exe("cmain") + .input("cmain.c") + .arg("-O3") + .run(); + + clang() + .input("clib.c") + .arg("-fprofile-generate=rs-profdata") + .lto("thin") + .arg("-c") + .out_exe("clib.o") + .arg("-O3") + .run(); + llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run(); + rustc() + .linker_plugin_lto("on") + .opt_level("3") + .codegen_units(1) + .arg("-Cprofile-generate=rs-profdata") + .linker(&env_var("CLANG")) + .link_arg("-fuse-ld=lld") + .input("main.rs") + .output("rsmain") + .run(); + run("rsmain"); + // Postprocess the profiling data so it can be used by the compiler + let profraw_files = shallow_find_files("rs-profdata", |path| { + has_prefix(path, "default") && has_extension(path, "profraw") + }); + let profraw_file = profraw_files.get(0).unwrap(); + llvm_profdata().merge().output("rs-profdata/merged.profdata").input(profraw_file).run(); + clang() + .input("clib.c") + .arg("-fprofile-use=rs-profdata/merged.profdata") + .arg("-c") + .lto("thin") + .out_exe("clib.o") + .arg("-O3") + .run(); + rfs::remove_file(static_lib_name("xyz")); + llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run(); + rustc() + .linker_plugin_lto("on") + .opt_level("3") + .codegen_units(1) + .arg("-Cprofile-use=rs-profdata/merged.profdata") + .linker(&env_var("CLANG")) + .link_arg("-fuse-ld=lld") + .input("main.rs") + .output("rsmain") + .run(); +} diff --git a/tests/run-make/cross-lang-lto-pgo-smoketest/rustlib.rs b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/rustlib.rs index 9aff29ef9bb..9aff29ef9bb 100644 --- a/tests/run-make/cross-lang-lto-pgo-smoketest/rustlib.rs +++ b/tests/run-make/cross-lang-lto-pgo-smoketest-clang/rustlib.rs diff --git a/tests/run-make/cross-lang-lto-pgo-smoketest/Makefile b/tests/run-make/cross-lang-lto-pgo-smoketest/Makefile deleted file mode 100644 index 738e23f9c66..00000000000 --- a/tests/run-make/cross-lang-lto-pgo-smoketest/Makefile +++ /dev/null @@ -1,90 +0,0 @@ -# needs-force-clang-based-tests - -# FIXME(#126180): This test doesn't actually run anywhere, because the only -# CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. - -# This test makes sure that cross-language inlining can be used in conjunction -# with profile-guided optimization. The test only tests that the whole workflow -# can be executed without anything crashing. It does not test whether PGO or -# xLTO have any specific effect on the generated code. - -include ../tools.mk - -COMMON_FLAGS=-Copt-level=3 -Ccodegen-units=1 - -# LLVM doesn't support instrumenting binaries that use SEH: -# https://bugs.llvm.org/show_bug.cgi?id=41279 -# -# Things work fine with -Cpanic=abort though. -ifdef IS_MSVC -COMMON_FLAGS+= -Cpanic=abort -endif - -all: cpp-executable rust-executable - -cpp-executable: - $(RUSTC) -Clinker-plugin-lto=on \ - -Cprofile-generate="$(TMPDIR)"/cpp-profdata \ - -o "$(TMPDIR)"/librustlib-xlto.a \ - $(COMMON_FLAGS) \ - ./rustlib.rs - $(CLANG) -flto=thin \ - -fprofile-generate="$(TMPDIR)"/cpp-profdata \ - -fuse-ld=lld \ - -L "$(TMPDIR)" \ - -lrustlib-xlto \ - -o "$(TMPDIR)"/cmain \ - -O3 \ - ./cmain.c - $(TMPDIR)/cmain - # Postprocess the profiling data so it can be used by the compiler - "$(LLVM_BIN_DIR)"/llvm-profdata merge \ - -o "$(TMPDIR)"/cpp-profdata/merged.profdata \ - "$(TMPDIR)"/cpp-profdata/default_*.profraw - $(RUSTC) -Clinker-plugin-lto=on \ - -Cprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \ - -o "$(TMPDIR)"/librustlib-xlto.a \ - $(COMMON_FLAGS) \ - ./rustlib.rs - $(CLANG) -flto=thin \ - -fprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \ - -fuse-ld=lld \ - -L "$(TMPDIR)" \ - -lrustlib-xlto \ - -o "$(TMPDIR)"/cmain \ - -O3 \ - ./cmain.c - -rust-executable: - exit - $(CLANG) ./clib.c -fprofile-generate="$(TMPDIR)"/rs-profdata -flto=thin -c -o $(TMPDIR)/clib.o -O3 - (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o) - $(RUSTC) -Clinker-plugin-lto=on \ - -Cprofile-generate="$(TMPDIR)"/rs-profdata \ - -L$(TMPDIR) \ - $(COMMON_FLAGS) \ - -Clinker=$(CLANG) \ - -Clink-arg=-fuse-ld=lld \ - -o $(TMPDIR)/rsmain \ - ./main.rs - $(TMPDIR)/rsmain - # Postprocess the profiling data so it can be used by the compiler - "$(LLVM_BIN_DIR)"/llvm-profdata merge \ - -o "$(TMPDIR)"/rs-profdata/merged.profdata \ - "$(TMPDIR)"/rs-profdata/default_*.profraw - $(CLANG) ./clib.c \ - -fprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \ - -flto=thin \ - -c \ - -o $(TMPDIR)/clib.o \ - -O3 - rm "$(TMPDIR)"/libxyz.a - (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o) - $(RUSTC) -Clinker-plugin-lto=on \ - -Cprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \ - -L$(TMPDIR) \ - $(COMMON_FLAGS) \ - -Clinker=$(CLANG) \ - -Clink-arg=-fuse-ld=lld \ - -o $(TMPDIR)/rsmain \ - ./main.rs diff --git a/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs b/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs index 391759ec5f6..92573353a74 100644 --- a/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs +++ b/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs @@ -3,8 +3,11 @@ //@ needs-force-clang-based-tests //@ needs-llvm-components riscv -// FIXME(#126180): This test doesn't actually run anywhere, because the only -// CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. +//@ needs-force-clang-based-tests +// FIXME(#126180): This test can only run on `x86_64-gnu-debug`, because that CI job sets +// RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their +// name. +// However, this test does not run at all as its name does not contain "clang". use std::path::PathBuf; use std::process::{Command, Output}; diff --git a/tests/run-make/cross-lang-lto/Makefile b/tests/run-make/cross-lang-lto/Makefile deleted file mode 100644 index 92058f952a9..00000000000 --- a/tests/run-make/cross-lang-lto/Makefile +++ /dev/null @@ -1,57 +0,0 @@ - -include ../tools.mk - -# ignore windows due to libLLVM being present in PATH and the PATH and library path being the same -# (so fixing it is harder). See #57765 for context -ifndef IS_WINDOWS - -# This test makes sure that the object files we generate are actually -# LLVM bitcode files (as used by linker LTO plugins) when compiling with -# -Clinker-plugin-lto. - -# this only succeeds for bitcode files -ASSERT_IS_BITCODE_OBJ=("$(LLVM_BIN_DIR)"/llvm-bcanalyzer $(1)) -EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; "$(LLVM_BIN_DIR)"/llvm-ar x $(1)) - -BUILD_LIB=$(RUSTC) lib.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1 -BUILD_EXE=$(RUSTC) main.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1 --emit=obj - -all: staticlib staticlib-fat-lto staticlib-thin-lto rlib exe cdylib rdylib - -staticlib: lib.rs - $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib.a - $(call EXTRACT_OBJS, liblib.a) - for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done - -staticlib-fat-lto: lib.rs - $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-fat-lto.a -Clto=fat - $(call EXTRACT_OBJS, liblib-fat-lto.a) - for file in $(TMPDIR)/liblib-fat-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done - -staticlib-thin-lto: lib.rs - $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-thin-lto.a -Clto=thin - $(call EXTRACT_OBJS, liblib-thin-lto.a) - for file in $(TMPDIR)/liblib-thin-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done - -rlib: lib.rs - $(BUILD_LIB) --crate-type=rlib -o $(TMPDIR)/liblib.rlib - $(call EXTRACT_OBJS, liblib.rlib) - for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done - -cdylib: lib.rs - $(BUILD_LIB) --crate-type=cdylib --emit=obj -o $(TMPDIR)/cdylib.o - $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/cdylib.o) - -rdylib: lib.rs - $(BUILD_LIB) --crate-type=dylib --emit=obj -o $(TMPDIR)/rdylib.o - $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/rdylib.o) - -exe: lib.rs - $(BUILD_EXE) -o $(TMPDIR)/exe.o - $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/exe.o) - -else - -all: - -endif diff --git a/tests/run-make/cross-lang-lto/rmake.rs b/tests/run-make/cross-lang-lto/rmake.rs new file mode 100644 index 00000000000..dc376b561e4 --- /dev/null +++ b/tests/run-make/cross-lang-lto/rmake.rs @@ -0,0 +1,110 @@ +// This test checks that the object files we generate are actually +// LLVM bitcode files (as used by linker LTO plugins) when compiling with +// -Clinker-plugin-lto. +// See https://github.com/rust-lang/rust/pull/50000 + +#![feature(path_file_prefix)] + +use std::path::PathBuf; + +use run_make_support::{ + cwd, has_extension, has_prefix, llvm_ar, llvm_bcanalyzer, path, rfs, rust_lib_name, rustc, + shallow_find_files, static_lib_name, +}; + +fn main() { + check_bitcode(LibBuild { + source: path("lib.rs"), + crate_type: Some("staticlib"), + output: path(static_lib_name("liblib")), + lto: None, + emit_obj: false, + }); + check_bitcode(LibBuild { + source: path("lib.rs"), + crate_type: Some("staticlib"), + output: path(static_lib_name("liblib-fat-lto")), + lto: Some("fat"), + emit_obj: false, + }); + check_bitcode(LibBuild { + source: path("lib.rs"), + crate_type: Some("staticlib"), + output: path(static_lib_name("liblib-thin-lto")), + lto: Some("thin"), + emit_obj: false, + }); + check_bitcode(LibBuild { + source: path("lib.rs"), + crate_type: Some("rlib"), + output: path(rust_lib_name("liblib")), + lto: None, + emit_obj: false, + }); + check_bitcode(LibBuild { + source: path("lib.rs"), + crate_type: Some("cdylib"), + output: path("cdylib.o"), + lto: None, + emit_obj: true, + }); + check_bitcode(LibBuild { + source: path("lib.rs"), + crate_type: Some("dylib"), + output: path("rdylib.o"), + lto: None, + emit_obj: true, + }); + check_bitcode(LibBuild { + source: path("main.rs"), + crate_type: None, + output: path("exe.o"), + lto: None, + emit_obj: true, + }); +} + +#[track_caller] +fn check_bitcode(instructions: LibBuild) { + let mut rustc = rustc(); + rustc + .input(instructions.source) + .output(&instructions.output) + .opt_level("2") + .codegen_units(1) + .arg("-Clinker-plugin-lto"); + if instructions.emit_obj { + rustc.emit("obj"); + } + if let Some(crate_type) = instructions.crate_type { + rustc.crate_type(crate_type); + } + if let Some(lto) = instructions.lto { + rustc.arg(format!("-Clto={lto}")); + } + rustc.run(); + + if instructions.output.extension().unwrap() != "o" { + // Remove all potential leftover object files, then turn the output into an object file. + for object in shallow_find_files(cwd(), |path| has_extension(path, "o")) { + rfs::remove_file(object); + } + llvm_ar().extract().arg(&instructions.output).run(); + } + + for object in shallow_find_files(cwd(), |path| { + has_prefix(path, instructions.output.file_prefix().unwrap().to_str().unwrap()) + && has_extension(path, "o") + }) { + // All generated object files should be LLVM bitcode files - this will fail otherwise. + llvm_bcanalyzer().input(object).run(); + } +} + +struct LibBuild { + source: PathBuf, + crate_type: Option<&'static str>, + output: PathBuf, + lto: Option<&'static str>, + emit_obj: bool, +} diff --git a/tests/run-make/fmt-write-bloat/Makefile b/tests/run-make/fmt-write-bloat/Makefile deleted file mode 100644 index 70e04b9af51..00000000000 --- a/tests/run-make/fmt-write-bloat/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -include ../tools.mk - -# ignore-windows - -ifeq ($(shell $(RUSTC) -vV | grep 'host: $(TARGET)'),) - -# Don't run this test when cross compiling. -all: - -else - -NM = nm - -PANIC_SYMS = panic_bounds_check Debug - -# Allow for debug_assert!() in debug builds of std. -ifdef NO_DEBUG_ASSERTIONS -PANIC_SYMS += panicking panic_fmt pad_integral Display Debug -endif - -all: main.rs - $(RUSTC) $< -O - $(NM) $(call RUN_BINFILE,main) | $(CGREP) -v $(PANIC_SYMS) - -endif diff --git a/tests/run-make/fmt-write-bloat/rmake.rs b/tests/run-make/fmt-write-bloat/rmake.rs new file mode 100644 index 00000000000..4ae226ec0e2 --- /dev/null +++ b/tests/run-make/fmt-write-bloat/rmake.rs @@ -0,0 +1,37 @@ +//! Before #78122, writing any `fmt::Arguments` would trigger the inclusion of `usize` formatting +//! and padding code in the resulting binary, because indexing used in `fmt::write` would generate +//! code using `panic_bounds_check`, which prints the index and length. +//! +//! These bounds checks are not necessary, as `fmt::Arguments` never contains any out-of-bounds +//! indexes. The test is a `run-make` test, because it needs to check the result after linking. A +//! codegen or assembly test doesn't check the parts that will be pulled in from `core` by the +//! linker. +//! +//! In this test, we try to check that the `usize` formatting and padding code are not present in +//! the final binary by checking that panic symbols such as `panic_bounds_check` are **not** +//! present. +//! +//! Some CI jobs try to run faster by disabling debug assertions (through setting +//! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of +//! additional `usize` formatting and padding related symbols. + +// Reason: This test is `ignore-windows` because the `no_std` test (using `#[link(name = "c")])` +// doesn't link on windows. +//@ ignore-windows +//@ ignore-cross-compile + +use run_make_support::env::no_debug_assertions; +use run_make_support::rustc; +use run_make_support::symbols::any_symbol_contains; + +fn main() { + rustc().input("main.rs").opt().run(); + // panic machinery identifiers, these should not appear in the final binary + let mut panic_syms = vec!["panic_bounds_check", "Debug"]; + if no_debug_assertions() { + // if debug assertions are allowed, we need to allow these, + // otherwise, add them to the list of symbols to deny. + panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]); + } + assert!(!any_symbol_contains("main", &panic_syms)); +} diff --git a/tests/run-make/foreign-double-unwind/Makefile b/tests/run-make/foreign-double-unwind/Makefile deleted file mode 100644 index b5e52808d2f..00000000000 --- a/tests/run-make/foreign-double-unwind/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# ignore-cross-compile -# needs-unwind -include ../tools.mk - -all: foo - $(call RUN,foo) | $(CGREP) -v unreachable - -foo: foo.rs $(call NATIVE_STATICLIB,foo) - $(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS) - -$(TMPDIR)/libfoo.o: foo.cpp - $(call COMPILE_OBJ_CXX,$@,$<) diff --git a/tests/run-make/foreign-double-unwind/rmake.rs b/tests/run-make/foreign-double-unwind/rmake.rs new file mode 100644 index 00000000000..9bd3b4c0fea --- /dev/null +++ b/tests/run-make/foreign-double-unwind/rmake.rs @@ -0,0 +1,21 @@ +// When using foreign function interface (FFI) with C++, it is possible +// to run into a "double unwind" if either both Rust and C++ run into a panic +// and exception at the same time, or C++ encounters two exceptions. In this case, +// one of the panic unwinds would be leaked and the other would be kept, leading +// to undefined behaviour. After this was fixed in #92911, this test checks that +// the keyword "unreachable" indicative of this bug triggering in this specific context +// does not appear after successfully compiling and executing the program. +// See https://github.com/rust-lang/rust/pull/92911 + +//@ needs-unwind +// Reason: this test exercises panic unwinding +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib_cxx, run_fail, rustc}; + +fn main() { + build_native_static_lib_cxx("foo"); + rustc().input("foo.rs").arg("-lfoo").extra_rs_cxx_flags().run(); + run_fail("foo").assert_stdout_not_contains("unreachable"); +} diff --git a/tests/run-make/foreign-exceptions/Makefile b/tests/run-make/foreign-exceptions/Makefile deleted file mode 100644 index 56c41b274fb..00000000000 --- a/tests/run-make/foreign-exceptions/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# ignore-cross-compile -# needs-unwind -include ../tools.mk - -all: foo - $(call RUN,foo) - -foo: foo.rs $(call NATIVE_STATICLIB,foo) - $(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS) - -$(TMPDIR)/libfoo.o: foo.cpp - $(call COMPILE_OBJ_CXX,$@,$<) diff --git a/tests/run-make/foreign-exceptions/rmake.rs b/tests/run-make/foreign-exceptions/rmake.rs new file mode 100644 index 00000000000..929319f049f --- /dev/null +++ b/tests/run-make/foreign-exceptions/rmake.rs @@ -0,0 +1,19 @@ +// This test was created to check that compilation and execution still works +// after the addition of a new feature, in #65646: the ability to unwind panics +// and exceptions back and forth between Rust and C++. This is a basic smoke test, +// this feature being broken in quiet or subtle ways could still result in this test +// passing. +// See https://github.com/rust-lang/rust/pull/65646 + +//@ needs-unwind +// Reason: this test exercises panic unwinding +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib_cxx, run, rustc}; + +fn main() { + build_native_static_lib_cxx("foo"); + rustc().input("foo.rs").arg("-lfoo").extra_rs_cxx_flags().run(); + run("foo"); +} diff --git a/tests/run-make/issue-35164/Makefile b/tests/run-make/issue-35164/Makefile deleted file mode 100644 index 38aa6f1265f..00000000000 --- a/tests/run-make/issue-35164/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) main.rs --error-format json 2>&1 | $(CGREP) -e '"byte_start":23\b' '"byte_end":29\b' diff --git a/tests/run-make/issue-36710/Makefile b/tests/run-make/issue-36710/Makefile deleted file mode 100644 index 7b91107a234..00000000000 --- a/tests/run-make/issue-36710/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# ignore-cross-compile -# ignore-none no-std is not supported -# ignore-wasm32 FIXME: don't attempt to compile C++ to WASM -# ignore-wasm64 FIXME: don't attempt to compile C++ to WASM -# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for `std` -# ignore-musl FIXME: this makefile needs teaching how to use a musl toolchain -# (see dist-i586-gnu-i586-i686-musl Dockerfile) -# ignore-sgx - -include ../tools.mk - -all: foo - $(call RUN,foo) - -foo: foo.rs $(call NATIVE_STATICLIB,foo) - $(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS) --target $(TARGET) - -$(TMPDIR)/libfoo.o: foo.cpp - $(call COMPILE_OBJ_CXX,$@,$<) diff --git a/tests/run-make/issue-47551/Makefile b/tests/run-make/issue-47551/Makefile deleted file mode 100644 index 3fe0a6e74e0..00000000000 --- a/tests/run-make/issue-47551/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# only-linux -# ignore-32bit - -include ../tools.mk - -all: - # --target $(TARGET) ensures the right gcc flags are used for cross compilation - $(RUSTC) --target $(TARGET) eh_frame-terminator.rs - $(call RUN,eh_frame-terminator) | $(CGREP) '1122334455667788' - objdump --dwarf=frames $(TMPDIR)/eh_frame-terminator | $(CGREP) 'ZERO terminator' diff --git a/tests/run-make/issue-69368/Makefile b/tests/run-make/issue-69368/Makefile deleted file mode 100644 index b1229d1b07f..00000000000 --- a/tests/run-make/issue-69368/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Test that previously triggered a linker failure with root cause -# similar to one found in the issue #69368. -# -# The crate that provides oom lang item is missing some other lang -# items. Necessary to prevent the use of start-group / end-group. -# -# The weak lang items are defined in a separate compilation units, -# so that linker could omit them if not used. -# -# The crates that need those weak lang items are dependencies of -# crates that provide them. - -all: - $(RUSTC) a.rs - $(RUSTC) b.rs - $(RUSTC) c.rs diff --git a/tests/run-make/issue-88756-default-output/Makefile b/tests/run-make/issue-88756-default-output/Makefile deleted file mode 100644 index d1c3d0fe082..00000000000 --- a/tests/run-make/issue-88756-default-output/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include ../tools.mk - -all: - $(BARE_RUSTDOC) 2>&1 | sed -E 's@/nightly/|/beta/|/stable/|/1\.[0-9]+\.[0-9]+/@/$$CHANNEL/@g' | diff - output-default.stdout diff --git a/tests/run-make/issue-88756-default-output/README.md b/tests/run-make/issue-88756-default-output/README.md deleted file mode 100644 index 8cbfac4f7d2..00000000000 --- a/tests/run-make/issue-88756-default-output/README.md +++ /dev/null @@ -1 +0,0 @@ -This is a test to verify that the default behavior of `rustdoc` is printing out help output instead of erroring out (#88756). diff --git a/tests/run-make/issue-88756-default-output/x.rs b/tests/run-make/issue-88756-default-output/x.rs deleted file mode 100644 index 5df7576133a..00000000000 --- a/tests/run-make/issue-88756-default-output/x.rs +++ /dev/null @@ -1 +0,0 @@ -// nothing to see here diff --git a/tests/run-make/issue-35164/main.rs b/tests/run-make/json-error-no-offset/main.rs index 1333d63224c..1333d63224c 100644 --- a/tests/run-make/issue-35164/main.rs +++ b/tests/run-make/json-error-no-offset/main.rs diff --git a/tests/run-make/json-error-no-offset/rmake.rs b/tests/run-make/json-error-no-offset/rmake.rs new file mode 100644 index 00000000000..629d9c4c16e --- /dev/null +++ b/tests/run-make/json-error-no-offset/rmake.rs @@ -0,0 +1,15 @@ +// The byte positions in json format error logging used to have a small, difficult +// to predict offset. This was changed to be the top of the file every time in #42973, +// and this test checks that the measurements appearing in the standard error are correct. +// See https://github.com/rust-lang/rust/issues/35164 + +use run_make_support::rustc; + +fn main() { + rustc() + .input("main.rs") + .error_format("json") + .run() + .assert_stderr_contains(r#""byte_start":23"#) + .assert_stderr_contains(r#""byte_end":29"#); +} diff --git a/tests/run-make/issue-35164/submodule/mod.rs b/tests/run-make/json-error-no-offset/submodule/mod.rs index a9045b242fb..a9045b242fb 100644 --- a/tests/run-make/issue-35164/submodule/mod.rs +++ b/tests/run-make/json-error-no-offset/submodule/mod.rs diff --git a/tests/run-make/link-cfg/Makefile b/tests/run-make/link-cfg/Makefile deleted file mode 100644 index a4099701144..00000000000 --- a/tests/run-make/link-cfg/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3) - ls $(TMPDIR) - $(BARE_RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static - - $(RUSTC) no-deps.rs --cfg foo - $(call RUN,no-deps) - $(RUSTC) no-deps.rs --cfg bar - $(call RUN,no-deps) - - $(RUSTC) dep.rs - $(RUSTC) with-deps.rs --cfg foo - $(call RUN,with-deps) - $(RUSTC) with-deps.rs --cfg bar - $(call RUN,with-deps) - - $(RUSTC) dep-with-staticlib.rs - $(RUSTC) with-staticlib-deps.rs --cfg foo - $(call RUN,with-staticlib-deps) - $(RUSTC) with-staticlib-deps.rs --cfg bar - $(call RUN,with-staticlib-deps) diff --git a/tests/run-make/link-cfg/rmake.rs b/tests/run-make/link-cfg/rmake.rs new file mode 100644 index 00000000000..732de5dbd0b --- /dev/null +++ b/tests/run-make/link-cfg/rmake.rs @@ -0,0 +1,43 @@ +// The `#[link(cfg(..))]` annotation means that the `#[link]` +// directive is only active in a compilation unit if that `cfg` value is satisfied. +// For example, when compiling an rlib, these directives are just encoded and +// ignored for dylibs, and all staticlibs are continued to be put into the rlib as +// usual. When placing that rlib into a staticlib, executable, or dylib, however, +// the `cfg` is evaluated *as if it were defined in the final artifact* and the +// library is decided to be linked or not. +// This test exercises this new feature by testing it with no dependencies, then +// with only dynamic libraries, then with both a staticlib and dylibs. Compilation +// and execution should be successful. +// See https://github.com/rust-lang/rust/pull/37545 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{bare_rustc, build_native_dynamic_lib, build_native_static_lib, run, rustc}; + +fn main() { + build_native_dynamic_lib("return1"); + build_native_dynamic_lib("return2"); + build_native_static_lib("return3"); + bare_rustc() + .print("cfg") + .target("x86_64-unknown-linux-musl") + .run() + .assert_stdout_contains("crt-static"); + rustc().input("no-deps.rs").cfg("foo").run(); + run("no-deps"); + rustc().input("no-deps.rs").cfg("bar").run(); + run("no-deps"); + + rustc().input("dep.rs").run(); + rustc().input("with-deps.rs").cfg("foo").run(); + run("with-deps"); + rustc().input("with-deps.rs").cfg("bar").run(); + run("with-deps"); + + rustc().input("dep-with-staticlib.rs").run(); + rustc().input("with-staticlib-deps.rs").cfg("foo").run(); + run("with-staticlib-deps"); + rustc().input("with-staticlib-deps.rs").cfg("bar").run(); + run("with-staticlib-deps"); +} diff --git a/tests/run-make/issue-47551/eh_frame-terminator.rs b/tests/run-make/link-eh-frame-terminator/eh_frame-terminator.rs index 0c90d8c791c..0c90d8c791c 100644 --- a/tests/run-make/issue-47551/eh_frame-terminator.rs +++ b/tests/run-make/link-eh-frame-terminator/eh_frame-terminator.rs diff --git a/tests/run-make/link-eh-frame-terminator/rmake.rs b/tests/run-make/link-eh-frame-terminator/rmake.rs new file mode 100644 index 00000000000..6bfae386ea1 --- /dev/null +++ b/tests/run-make/link-eh-frame-terminator/rmake.rs @@ -0,0 +1,23 @@ +// The gcc driver is supposed to add a terminator to link files, and the rustc +// driver previously failed to do this, resulting in a segmentation fault +// with an older version of LLVM. This test checks that the terminator is present +// after the fix in #85395. +// See https://github.com/rust-lang/rust/issues/47551 + +//@ only-linux +// Reason: the ZERO terminator is unique to the Linux architecture. +//@ ignore-32bit +// Reason: the usage of a large array in the test causes an out-of-memory +// error on 32 bit systems. + +use run_make_support::{bin_name, llvm_objdump, run, rustc}; + +fn main() { + rustc().input("eh_frame-terminator.rs").run(); + run("eh_frame-terminator").assert_stdout_contains("1122334455667788"); + llvm_objdump() + .arg("--dwarf=frames") + .input(bin_name("eh_frame-terminator")) + .run() + .assert_stdout_contains("ZERO terminator"); +} diff --git a/tests/run-make/native-link-modifier-whole-archive/Makefile b/tests/run-make/native-link-modifier-whole-archive/Makefile deleted file mode 100644 index 5eb7a416f91..00000000000 --- a/tests/run-make/native-link-modifier-whole-archive/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# ignore-cross-compile -- compiling C++ code does not work well when cross-compiling - -# This test case makes sure that native libraries are linked with appropriate semantics -# when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them. -# -# The test works by checking that the resulting executables produce the expected output, -# part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work -# that code would never make it into the final executable and we'd thus be missing some -# of the output. - -include ../tools.mk - -all: $(TMPDIR)/$(call BIN,directly_linked) \ - $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive) \ - $(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive) \ - $(TMPDIR)/$(call BIN,indirectly_linked) \ - $(TMPDIR)/$(call BIN,indirectly_linked_via_attr) - $(call RUN,directly_linked) | $(CGREP) 'static-initializer.directly_linked.' - $(call RUN,directly_linked_test_plus_whole_archive) --nocapture | $(CGREP) 'static-initializer.' - $(call RUN,directly_linked_test_minus_whole_archive) --nocapture | $(CGREP) -v 'static-initializer.' - $(call RUN,indirectly_linked) | $(CGREP) 'static-initializer.indirectly_linked.' - $(call RUN,indirectly_linked_via_attr) | $(CGREP) 'static-initializer.native_lib_in_src.' - -# Native lib linked directly into executable -$(TMPDIR)/$(call BIN,directly_linked): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) directly_linked.rs -l static:+whole-archive=c_static_lib_with_constructor - -# Native lib linked into test executable, +whole-archive -$(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) directly_linked_test_plus_whole_archive.rs --test -l static:+whole-archive=c_static_lib_with_constructor -# Native lib linked into test executable, -whole-archive -$(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) directly_linked_test_minus_whole_archive.rs --test -l static:-whole-archive=c_static_lib_with_constructor - -# Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable -$(TMPDIR)/$(call BIN,indirectly_linked): $(TMPDIR)/librlib_with_cmdline_native_lib.rlib - $(RUSTC) indirectly_linked.rs - -# Native lib linked into RLIB via #[link] attribute, RLIB linked into executable -$(TMPDIR)/$(call BIN,indirectly_linked_via_attr): $(TMPDIR)/libnative_lib_in_src.rlib - $(RUSTC) indirectly_linked_via_attr.rs - -# Native lib linked into rlib with via commandline -$(TMPDIR)/librlib_with_cmdline_native_lib.rlib: $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) rlib_with_cmdline_native_lib.rs --crate-type=rlib -l static:-bundle,+whole-archive=c_static_lib_with_constructor - -# Native lib linked into rlib via `#[link()]` attribute on extern block. -$(TMPDIR)/libnative_lib_in_src.rlib: $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) native_lib_in_src.rs --crate-type=rlib - -$(TMPDIR)/libc_static_lib_with_constructor.o: c_static_lib_with_constructor.cpp - $(call COMPILE_OBJ_CXX,$@,$<) diff --git a/tests/run-make/native-link-modifier-whole-archive/rmake.rs b/tests/run-make/native-link-modifier-whole-archive/rmake.rs new file mode 100644 index 00000000000..b8b814043e5 --- /dev/null +++ b/tests/run-make/native-link-modifier-whole-archive/rmake.rs @@ -0,0 +1,86 @@ +// This test case makes sure that native libraries are linked with appropriate semantics +// when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them. +// The test works by checking that the resulting executables produce the expected output, +// part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work +// that code would never make it into the final executable and we'd thus be missing some +// of the output. +// See https://github.com/rust-lang/rust/issues/88085 + +//@ ignore-cross-compile +// Reason: compiling C++ code does not work well when cross-compiling +// plus, the compiled binary is executed + +use run_make_support::{cxx, is_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name}; + +fn main() { + let mut cxx = cxx(); + if is_msvc() { + cxx.arg("-EHs"); + } + cxx.input("c_static_lib_with_constructor.cpp") + .arg("-c") + .out_exe("libc_static_lib_with_constructor") + .run(); + + let mut llvm_ar = llvm_ar(); + llvm_ar.obj_to_ar(); + if is_msvc() { + llvm_ar + .output_input( + static_lib_name("c_static_lib_with_constructor"), + "libc_static_lib_with_constructor.obj", + ) + .run(); + } else { + llvm_ar + .output_input( + static_lib_name("c_static_lib_with_constructor"), + "libc_static_lib_with_constructor", + ) + .run(); + } + + // Native lib linked directly into executable + rustc() + .input("directly_linked.rs") + .arg("-lstatic:+whole-archive=c_static_lib_with_constructor") + .run(); + + // Native lib linked into test executable, +whole-archive + rustc() + .input("directly_linked_test_plus_whole_archive.rs") + .arg("--test") + .arg("-lstatic:+whole-archive=c_static_lib_with_constructor") + .run(); + + // Native lib linked into test executable, -whole-archive + rustc() + .input("directly_linked_test_minus_whole_archive.rs") + .arg("--test") + .arg("-lstatic:-whole-archive=c_static_lib_with_constructor") + .run(); + + // Native lib linked into rlib with via commandline + rustc() + .input("rlib_with_cmdline_native_lib.rs") + .crate_type("rlib") + .arg("-lstatic:-bundle,+whole-archive=c_static_lib_with_constructor") + .run(); + // Native lib linked into RLIB via `-l static:-bundle,+whole-archive` + // RLIB linked into executable + rustc().input("indirectly_linked.rs").run(); + + // Native lib linked into rlib via `#[link()]` attribute on extern block. + rustc().input("native_lib_in_src.rs").crate_type("rlib").run(); + // Native lib linked into RLIB via #[link] attribute, RLIB linked into executable + rustc().input("indirectly_linked_via_attr.rs").run(); + + run("directly_linked").assert_stdout_contains("static-initializer.directly_linked."); + run_with_args("directly_linked_test_plus_whole_archive", &["--nocapture"]) + .assert_stdout_contains("static-initializer."); + run_with_args("directly_linked_test_minus_whole_archive", &["--nocapture"]) + .assert_stdout_not_contains("static-initializer."); + run("indirectly_linked").assert_stdout_contains("static-initializer.indirectly_linked."); + run("indirectly_linked_via_attr") + .assert_stdout_contains("static-initializer.native_lib_in_src."); +} diff --git a/tests/run-make/no-builtins-attribute/Makefile b/tests/run-make/no-builtins-attribute/Makefile deleted file mode 100644 index 0ce95facaea..00000000000 --- a/tests/run-make/no-builtins-attribute/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -# We want to check if `no-builtins` is also added to the function declarations in the used crate. - -all: - $(RUSTC) no_builtins.rs --emit=link - $(RUSTC) main.rs --emit=llvm-ir - - cat "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck.main.txt diff --git a/tests/run-make/no-builtins-attribute/rmake.rs b/tests/run-make/no-builtins-attribute/rmake.rs new file mode 100644 index 00000000000..1e15b0c03f1 --- /dev/null +++ b/tests/run-make/no-builtins-attribute/rmake.rs @@ -0,0 +1,13 @@ +// `no_builtins` is an attribute related to LLVM's optimizations. In order to ensure that it has an +// effect on link-time optimizations (LTO), it should be added to function declarations in a crate. +// This test uses the `llvm-filecheck` tool to determine that this attribute is successfully +// being added to these function declarations. +// See https://github.com/rust-lang/rust/pull/113716 + +use run_make_support::{llvm_filecheck, rfs, rustc}; + +fn main() { + rustc().input("no_builtins.rs").emit("link").run(); + rustc().input("main.rs").emit("llvm-ir").run(); + llvm_filecheck().patterns("filecheck.main.txt").stdin(rfs::read("main.ll")).run(); +} diff --git a/tests/run-make/print-calling-conventions/Makefile b/tests/run-make/print-calling-conventions/Makefile deleted file mode 100644 index 27b87e61086..00000000000 --- a/tests/run-make/print-calling-conventions/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --print calling-conventions diff --git a/tests/run-make/print-cfg/rmake.rs b/tests/run-make/print-cfg/rmake.rs index d83e8a36f2c..471a99b90d9 100644 --- a/tests/run-make/print-cfg/rmake.rs +++ b/tests/run-make/print-cfg/rmake.rs @@ -6,7 +6,6 @@ //! It also checks that some targets have the correct set cfgs. use std::collections::HashSet; -use std::ffi::OsString; use std::iter::FromIterator; use std::path::PathBuf; @@ -91,10 +90,8 @@ fn check(PrintCfg { target, includes, disallow }: PrintCfg) { // --print=cfg=PATH { let tmp_path = PathBuf::from(format!("{target}.cfg")); - let mut print_arg = OsString::from("--print=cfg="); - print_arg.push(tmp_path.as_os_str()); - rustc().target(target).arg(print_arg).run(); + rustc().target(target).print(&format!("cfg={}", tmp_path.display())).run(); let output = rfs::read_to_string(&tmp_path); diff --git a/tests/run-make/print-check-cfg/rmake.rs b/tests/run-make/print-check-cfg/rmake.rs index 4a79910c8e0..b10336f88c6 100644 --- a/tests/run-make/print-check-cfg/rmake.rs +++ b/tests/run-make/print-check-cfg/rmake.rs @@ -87,7 +87,7 @@ fn main() { fn check(CheckCfg { args, contains }: CheckCfg) { let output = - rustc().input("lib.rs").arg("-Zunstable-options").arg("--print=check-cfg").args(args).run(); + rustc().input("lib.rs").arg("-Zunstable-options").print("check-cfg").args(args).run(); let stdout = output.stdout_utf8(); diff --git a/tests/run-make/print-target-list/Makefile b/tests/run-make/print-target-list/Makefile deleted file mode 100644 index f23c40d4281..00000000000 --- a/tests/run-make/print-target-list/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -include ../tools.mk - -# Checks that all the targets returned by `rustc --print target-list` are valid -# target specifications -all: - for target in $(shell $(BARE_RUSTC) --print target-list); do \ - $(BARE_RUSTC) --target $$target --print sysroot; \ - done diff --git a/tests/run-make/print-target-list/rmake.rs b/tests/run-make/print-target-list/rmake.rs new file mode 100644 index 00000000000..743ed52069d --- /dev/null +++ b/tests/run-make/print-target-list/rmake.rs @@ -0,0 +1,21 @@ +// Checks that all the targets returned by `rustc --print target-list` are valid +// target specifications + +use run_make_support::bare_rustc; + +// FIXME(127877): certain experimental targets fail with creating a 'LLVM TargetMachine' +// in CI, so we skip them +const EXPERIMENTAL_TARGETS: &[&str] = &["avr", "m68k", "csky", "xtensa"]; + +fn main() { + let targets = bare_rustc().print("target-list").run().stdout_utf8(); + + for target in targets.lines() { + // skip experimental targets that would otherwise fail + if EXPERIMENTAL_TARGETS.iter().any(|experimental| target.contains(experimental)) { + continue; + } + + bare_rustc().target(target).print("sysroot").run(); + } +} diff --git a/tests/run-make/print-to-output/rmake.rs b/tests/run-make/print-to-output/rmake.rs index d0cba725b36..db2a291f8e7 100644 --- a/tests/run-make/print-to-output/rmake.rs +++ b/tests/run-make/print-to-output/rmake.rs @@ -1,7 +1,6 @@ //! This checks the output of some `--print` options when //! output to a file (instead of stdout) -use std::ffi::OsString; use std::path::PathBuf; use run_make_support::{rfs, rustc, target}; @@ -44,10 +43,8 @@ fn check(args: Option) { // --print={option}=PATH let output = { let tmp_path = PathBuf::from(format!("{}.txt", args.option)); - let mut print_arg = OsString::from(format!("--print={}=", args.option)); - print_arg.push(tmp_path.as_os_str()); - rustc().target(args.target).arg(print_arg).run(); + rustc().target(args.target).print(&format!("{}={}", args.option, tmp_path.display())).run(); rfs::read_to_string(&tmp_path) }; diff --git a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile deleted file mode 100644 index d2a740b06b3..00000000000 --- a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include ../tools.mk - -# ignore-cross-compile - -# Make sure -Zpacked_bundled_libs is compatible with verbatim. - -# We're using the llvm-nm instead of the system nm to ensure it is compatible -# with the LLVM bitcode generated by rustc. -# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm. -ifndef IS_WINDOWS -NM = "$(LLVM_BIN_DIR)"/llvm-nm -else -NM = nm -endif - -all: - # Build strange-named dep. - $(RUSTC) native_dep.rs --crate-type=staticlib -o $(TMPDIR)/native_dep.ext - - $(RUSTC) rust_dep.rs --crate-type=rlib -Zpacked_bundled_libs - $(NM) $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "U.*native_f1" - $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) "native_dep.ext" - - # Make sure compiler doesn't use files, that it shouldn't know about. - rm $(TMPDIR)/native_dep.ext - - $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib -Zpacked_bundled_libs diff --git a/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs b/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs new file mode 100644 index 00000000000..5a1460963b6 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs @@ -0,0 +1,28 @@ +// `-Z packed_bundled_libs` is an unstable rustc flag that makes the compiler +// only require a native library and no supplementary object files to compile. +// This test simply checks that this flag can be passed alongside verbatim syntax +// in rustc flags without a compilation failure or the removal of expected symbols. +// See https://github.com/rust-lang/rust/pull/100101 + +use run_make_support::{llvm_ar, llvm_nm, rfs, rust_lib_name, rustc}; + +fn main() { + // Build a strangely named dependency. + rustc().input("native_dep.rs").crate_type("staticlib").output("native_dep.ext").run(); + + rustc().input("rust_dep.rs").crate_type("rlib").arg("-Zpacked_bundled_libs").run(); + llvm_nm().input(rust_lib_name("rust_dep")).run().assert_stdout_contains_regex("U.*native_f1"); + llvm_ar() + .arg("t") + .arg(rust_lib_name("rust_dep")) + .run() + .assert_stdout_contains("native_dep.ext"); + + // Ensure the compiler does not use files it should not be aware of. + rfs::remove_file("native_dep.ext"); + rustc() + .input("main.rs") + .extern_("rust_dep", rust_lib_name("rust_dep")) + .arg("-Zpacked_bundled_libs") + .run(); +} diff --git a/tests/run-make/issue-88756-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout index bc38d9e9dc6..bc38d9e9dc6 100644 --- a/tests/run-make/issue-88756-default-output/output-default.stdout +++ b/tests/run-make/rustdoc-default-output/output-default.stdout diff --git a/tests/run-make/rustdoc-default-output/rmake.rs b/tests/run-make/rustdoc-default-output/rmake.rs new file mode 100644 index 00000000000..06720445a35 --- /dev/null +++ b/tests/run-make/rustdoc-default-output/rmake.rs @@ -0,0 +1,16 @@ +// Calling rustdoc with no arguments, which should bring up a help menu, used to +// cause an error as rustdoc expects an input file. Fixed in #98331, this test +// ensures the output of rustdoc's help menu is as expected. +// See https://github.com/rust-lang/rust/issues/88756 + +use run_make_support::{bare_rustdoc, diff}; + +fn main() { + let out = bare_rustdoc().run().stdout_utf8(); + diff() + .expected_file("output-default.stdout") + .actual_text("actual", out) + // replace the channel type in the URL with $CHANNEL + .normalize(r"nightly/|beta/|stable/|1\.[0-9]+\.[0-9]+/", "$$CHANNEL/") + .run(); +} diff --git a/tests/run-make/rustdoc-scrape-examples-macros/rmake.rs b/tests/run-make/rustdoc-scrape-examples-macros/rmake.rs index bfe4a1df456..b77df7adc8d 100644 --- a/tests/run-make/rustdoc-scrape-examples-macros/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-macros/rmake.rs @@ -11,8 +11,7 @@ fn main() { let dylib_name = rustc() .crate_name(proc_crate_name) .crate_type("dylib") - .arg("--print") - .arg("file-names") + .print("file-names") .arg("-") .run() .stdout_utf8(); diff --git a/tests/run-make/symbol-visibility/Makefile b/tests/run-make/symbol-visibility/Makefile deleted file mode 100644 index 9159af214ca..00000000000 --- a/tests/run-make/symbol-visibility/Makefile +++ /dev/null @@ -1,123 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# ignore-windows-msvc - -NM=nm -D -CDYLIB_NAME=liba_cdylib.so -RDYLIB_NAME=liba_rust_dylib.so -PROC_MACRO_NAME=liba_proc_macro.so -EXE_NAME=an_executable -COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so - -ifeq ($(UNAME),Darwin) -NM=nm -gU -CDYLIB_NAME=liba_cdylib.dylib -RDYLIB_NAME=liba_rust_dylib.dylib -PROC_MACRO_NAME=liba_proc_macro.dylib -EXE_NAME=an_executable -COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib -endif - -ifdef IS_WINDOWS -NM=nm -g -CDYLIB_NAME=liba_cdylib.dll.a -RDYLIB_NAME=liba_rust_dylib.dll.a -PROC_MACRO_NAME=liba_proc_macro.dll -EXE_NAME=an_executable.exe -COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dll.a -endif - -# `grep` regex for symbols produced by either `legacy` or `v0` mangling -RE_ANY_RUST_SYMBOL="_ZN.*h.*E\|_R[a-zA-Z0-9_]+" - -all: - $(RUSTC) -Zshare-generics=no an_rlib.rs - $(RUSTC) -Zshare-generics=no a_cdylib.rs - $(RUSTC) -Zshare-generics=no a_rust_dylib.rs - $(RUSTC) -Zshare-generics=no a_proc_macro.rs - $(RUSTC) -Zshare-generics=no an_executable.rs - $(RUSTC) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib - - # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] - - # Check that a Rust dylib exports its monomorphic functions - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ] - # Check that a Rust dylib does not export generics if -Zshare-generics=no - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "0" ] - - - # Check that a Rust dylib exports the monomorphic functions from its dependencies - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ] - # Check that a Rust dylib does not export generics if -Zshare-generics=no - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "0" ] - - # Check that a proc macro exports its public #[no_mangle] functions - # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a proc macro exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a proc macro DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] - -# FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032 -ifndef IS_WINDOWS - # Check that an executable does not export any dynamic symbols - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ] - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ] -endif - - - # Check the combined case, where we generate a cdylib and an rlib in the same - # compilation session: - # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] - - - $(RUSTC) -Zshare-generics=yes an_rlib.rs - $(RUSTC) -Zshare-generics=yes a_cdylib.rs - $(RUSTC) -Zshare-generics=yes a_rust_dylib.rs - $(RUSTC) -Zshare-generics=yes a_proc_macro.rs - $(RUSTC) -Zshare-generics=yes an_executable.rs - - # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] - - # Check that a Rust dylib exports its monomorphic functions, including generics this time - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "1" ] - - # Check that a Rust dylib exports the monomorphic functions from its dependencies - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "1" ] - - # Check that a proc macro exports its public #[no_mangle] functions - # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a proc macro exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a proc macro DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ] - -ifndef IS_WINDOWS - # Check that an executable does not export any dynamic symbols - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ] - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ] -endif diff --git a/tests/run-make/symbol-visibility/rmake.rs b/tests/run-make/symbol-visibility/rmake.rs new file mode 100644 index 00000000000..b37ff44f4ea --- /dev/null +++ b/tests/run-make/symbol-visibility/rmake.rs @@ -0,0 +1,179 @@ +// Dynamic libraries on Rust used to export a very high amount of symbols, +// going as far as filling the output with mangled names and generic function +// names. After the rework of #38117, this test checks that no mangled Rust symbols +// are exported, and that generics are only shown if explicitely requested. +// See https://github.com/rust-lang/rust/issues/37530 + +//@ ignore-windows-msvc + +//FIXME(Oneirical): This currently uses llvm-nm for symbol detection. However, +// the custom Rust-based solution of #128314 may prove to be an interesting alternative. + +use run_make_support::{bin_name, dynamic_lib_name, is_darwin, is_windows, llvm_nm, regex, rustc}; + +fn main() { + let cdylib_name = dynamic_lib_name("a_cdylib"); + let rdylib_name = dynamic_lib_name("a_rust_dylib"); + let exe_name = bin_name("an_executable"); + let combined_cdylib_name = dynamic_lib_name("combined_rlib_dylib"); + rustc().arg("-Zshare-generics=no").input("an_rlib.rs").run(); + rustc().arg("-Zshare-generics=no").input("a_cdylib.rs").run(); + rustc().arg("-Zshare-generics=no").input("a_rust_dylib.rs").run(); + rustc().arg("-Zshare-generics=no").input("a_proc_macro.rs").run(); + rustc().arg("-Zshare-generics=no").input("an_executable.rs").run(); + rustc() + .arg("-Zshare-generics=no") + .input("a_cdylib.rs") + .crate_name("combined_rlib_dylib") + .crate_type("rlib,cdylib") + .run(); + + // Check that a cdylib exports its public #[no_mangle] functions + symbols_check(&cdylib_name, SymbolCheckType::StrSymbol("public_c_function_from_cdylib"), true); + // Check that a cdylib exports the public #[no_mangle] functions of dependencies + symbols_check(&cdylib_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), true); + // Check that a cdylib DOES NOT export any public Rust functions + symbols_check(&cdylib_name, SymbolCheckType::AnyRustSymbol, false); + + // Check that a Rust dylib exports its monomorphic functions + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_c_function_from_rust_dylib"), + true, + ); + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_rust_function_from_rust_dylib"), + true, + ); + // Check that a Rust dylib does not export generics if -Zshare-generics=no + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_generic_function_from_rust_dylib"), + false, + ); + + // Check that a Rust dylib exports the monomorphic functions from its dependencies + symbols_check(&rdylib_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), true); + symbols_check(&rdylib_name, SymbolCheckType::StrSymbol("public_rust_function_from_rlib"), true); + // Check that a Rust dylib does not export generics if -Zshare-generics=no + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_generic_function_from_rlib"), + false, + ); + + // FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032 + // if is_windows() { + // // Check that an executable does not export any dynamic symbols + // symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib") + //, false); + // symbols_check( + // &exe_name, + // SymbolCheckType::StrSymbol("public_rust_function_from_exe"), + // false, + // ); + // } + + // Check the combined case, where we generate a cdylib and an rlib in the same + // compilation session: + // Check that a cdylib exports its public #[no_mangle] functions + symbols_check( + &combined_cdylib_name, + SymbolCheckType::StrSymbol("public_c_function_from_cdylib"), + true, + ); + // Check that a cdylib exports the public #[no_mangle] functions of dependencies + symbols_check( + &combined_cdylib_name, + SymbolCheckType::StrSymbol("public_c_function_from_rlib"), + true, + ); + // Check that a cdylib DOES NOT export any public Rust functions + symbols_check(&combined_cdylib_name, SymbolCheckType::AnyRustSymbol, false); + + rustc().arg("-Zshare-generics=yes").input("an_rlib.rs").run(); + rustc().arg("-Zshare-generics=yes").input("a_cdylib.rs").run(); + rustc().arg("-Zshare-generics=yes").input("a_rust_dylib.rs").run(); + rustc().arg("-Zshare-generics=yes").input("an_executable.rs").run(); + + // Check that a cdylib exports its public #[no_mangle] functions + symbols_check(&cdylib_name, SymbolCheckType::StrSymbol("public_c_function_from_cdylib"), true); + // Check that a cdylib exports the public #[no_mangle] functions of dependencies + symbols_check(&cdylib_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), true); + // Check that a cdylib DOES NOT export any public Rust functions + symbols_check(&cdylib_name, SymbolCheckType::AnyRustSymbol, false); + + // Check that a Rust dylib exports its monomorphic functions, including generics this time + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_c_function_from_rust_dylib"), + true, + ); + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_rust_function_from_rust_dylib"), + true, + ); + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_generic_function_from_rust_dylib"), + true, + ); + + // Check that a Rust dylib exports the monomorphic functions from its dependencies + symbols_check(&rdylib_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), true); + symbols_check(&rdylib_name, SymbolCheckType::StrSymbol("public_rust_function_from_rlib"), true); + symbols_check( + &rdylib_name, + SymbolCheckType::StrSymbol("public_generic_function_from_rlib"), + true, + ); + + // FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032 + // if is_windows() { + // // Check that an executable does not export any dynamic symbols + // symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib") + //, false); + // symbols_check( + // &exe_name, + // SymbolCheckType::StrSymbol("public_rust_function_from_exe"), + // false, + // ); + // } +} + +#[track_caller] +fn symbols_check(path: &str, symbol_check_type: SymbolCheckType, exists_once: bool) { + let mut nm = llvm_nm(); + if is_windows() { + nm.arg("--extern-only"); + } else if is_darwin() { + nm.arg("--extern-only").arg("--defined-only"); + } else { + nm.arg("--dynamic"); + } + let out = nm.input(path).run().stdout_utf8(); + assert_eq!( + out.lines() + .filter(|&line| !line.contains("__imp_") && has_symbol(line, symbol_check_type)) + .count() + == 1, + exists_once + ); +} + +fn has_symbol(line: &str, symbol_check_type: SymbolCheckType) -> bool { + if let SymbolCheckType::StrSymbol(expected) = symbol_check_type { + line.contains(expected) + } else { + let regex = regex::Regex::new(r#"_ZN.*h.*E\|_R[a-zA-Z0-9_]+"#).unwrap(); + regex.is_match(line) + } +} + +#[derive(Clone, Copy)] +enum SymbolCheckType { + StrSymbol(&'static str), + AnyRustSymbol, +} diff --git a/tests/run-make/used/rmake.rs b/tests/run-make/used/rmake.rs index 56ef5c6b9cc..39f36b2eea8 100644 --- a/tests/run-make/used/rmake.rs +++ b/tests/run-make/used/rmake.rs @@ -4,12 +4,10 @@ // It comes from #39987 which implements this RFC for the #[used] attribute: // https://rust-lang.github.io/rfcs/2386-used.html -//@ ignore-msvc - -use run_make_support::{cmd, rustc}; +use run_make_support::rustc; +use run_make_support::symbols::any_symbol_contains; fn main() { rustc().opt_level("3").emit("obj").input("used.rs").run(); - - cmd("nm").arg("used.o").run().assert_stdout_contains("FOO"); + assert!(any_symbol_contains("used.o", &["FOO"])); } diff --git a/tests/run-make/used/used.rs b/tests/run-make/used/used.rs index dca0a5e1167..133f8121a8e 100644 --- a/tests/run-make/used/used.rs +++ b/tests/run-make/used/used.rs @@ -2,5 +2,3 @@ #[used] static FOO: u32 = 0; - -static BAR: u32 = 0; diff --git a/tests/run-make/wasm-override-linker/rmake.rs b/tests/run-make/wasm-override-linker/rmake.rs index 01bc08e9901..b04edc18eef 100644 --- a/tests/run-make/wasm-override-linker/rmake.rs +++ b/tests/run-make/wasm-override-linker/rmake.rs @@ -2,6 +2,10 @@ // $ RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x.py test tests/run-make/wasm-override-linker/ //@ needs-force-clang-based-tests +// FIXME(#126180): This test can only run on `x86_64-gnu-debug`, because that CI job sets +// RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their +// name. +// However, this test does not run at all as its name does not contain "clang". use run_make_support::{env_var, rustc, target}; diff --git a/tests/rustdoc-json/impl-trait-in-assoc-type.rs b/tests/rustdoc-json/impl-trait-in-assoc-type.rs new file mode 100644 index 00000000000..f02e38ca393 --- /dev/null +++ b/tests/rustdoc-json/impl-trait-in-assoc-type.rs @@ -0,0 +1,29 @@ +// ignore-tidy-linelength +#![feature(impl_trait_in_assoc_type)] + +pub struct AlwaysTrue; + +/// impl IntoIterator +impl IntoIterator for AlwaysTrue { + //@ set Item = '$.index[*][?(@.docs=="type Item")].id' + /// type Item + type Item = bool; + + //@ count '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[*]' 1 + //@ is '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.name' '"Iterator"' + //@ count '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[*]' 1 + //@ is '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].name' '"Item"' + //@ is '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type.primitive' '"bool"' + + //@ set IntoIter = '$.index[*][?(@.docs=="type IntoIter")].id' + /// type IntoIter + type IntoIter = impl Iterator<Item = bool>; + + //@ set into_iter = '$.index[*][?(@.docs=="fn into_iter")].id' + /// fn into_iter + fn into_iter(self) -> Self::IntoIter { + std::iter::repeat(true) + } +} + +//@ ismany '$.index[*][?(@.docs=="impl IntoIterator")].inner.impl.items[*]' $Item $IntoIter $into_iter diff --git a/tests/rustdoc-ui/ice-unresolved-import-100241.stderr b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr index e23e0f01fab..2eebedba9a5 100644 --- a/tests/rustdoc-ui/ice-unresolved-import-100241.stderr +++ b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `inner` LL | pub use inner::S; | ^^^^^ you might be missing crate `inner` | - = help: consider adding `extern crate inner` to use the `inner` crate +help: consider importing the `inner` crate + | +LL + extern crate inner; + | error: aborting due to 1 previous error diff --git a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr index a74e6b73938..e6894319213 100644 --- a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr +++ b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr @@ -4,7 +4,10 @@ error[E0433]: failed to resolve: you might be missing crate `unresolved_crate` LL | use unresolved_crate::module::Name; | ^^^^^^^^^^^^^^^^ you might be missing crate `unresolved_crate` | - = help: consider adding `extern crate unresolved_crate` to use the `unresolved_crate` crate +help: consider importing the `unresolved_crate` crate + | +LL + extern crate unresolved_crate; + | error: aborting due to 1 previous error diff --git a/tests/rustdoc-ui/issues/issue-61732.stderr b/tests/rustdoc-ui/issues/issue-61732.stderr index f49d53b0d9a..0aa7d558c30 100644 --- a/tests/rustdoc-ui/issues/issue-61732.stderr +++ b/tests/rustdoc-ui/issues/issue-61732.stderr @@ -4,7 +4,10 @@ error[E0433]: failed to resolve: you might be missing crate `r#mod` LL | pub(in crate::r#mod) fn main() {} | ^^^^^ you might be missing crate `r#mod` | - = help: consider adding `extern crate r#mod` to use the `r#mod` crate +help: consider importing the `r#mod` crate + | +LL + extern crate r#mod; + | error: aborting due to 1 previous error diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs new file mode 100644 index 00000000000..5d0881029cb --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs @@ -0,0 +1,2 @@ +//@ build-aux-docs +pub struct Quebec; diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs new file mode 100644 index 00000000000..fab9ec4a92b --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs @@ -0,0 +1,4 @@ +//@ aux-build:q.rs +//@ build-aux-docs +extern crate q; +pub trait Tango {} diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs new file mode 100644 index 00000000000..85c460ace64 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs @@ -0,0 +1,16 @@ +//@ aux-build:t.rs +//@ build-aux-docs +//@ has q/struct.Quebec.html +//@ has s/struct.Sierra.html +//@ has t/trait.Tango.html +//@ hasraw s/struct.Sierra.html 'Tango' +//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html' +//@ hasraw search-index.js 'Tango' +//@ hasraw search-index.js 'Sierra' +//@ hasraw search-index.js 'Quebec' + +// We document multiple crates into the same output directory, which +// merges the cross-crate information. Everything is available. +extern crate t; +pub struct Sierra; +impl t::Tango for Sierra {} diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs new file mode 100644 index 00000000000..932a0b17206 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs @@ -0,0 +1,5 @@ +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +pub struct Quebec; diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs new file mode 100644 index 00000000000..c21a59c6518 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs @@ -0,0 +1,7 @@ +//@ aux-build:q.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +extern crate q; +pub trait Tango {} diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs new file mode 100644 index 00000000000..68bfc34883b --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs @@ -0,0 +1,24 @@ +//@ aux-build:t.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +//@ has index.html +//@ has index.html '//h1' 'List of all crates' +//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q' +//@ has index.html '//ul[@class="all-items"]//a[@href="s/index.html"]' 's' +//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't' +//@ has q/struct.Quebec.html +//@ has s/struct.Sierra.html +//@ has t/trait.Tango.html +//@ hasraw s/struct.Sierra.html 'Tango' +//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html' +//@ hasraw search-index.js 'Tango' +//@ hasraw search-index.js 'Sierra' +//@ hasraw search-index.js 'Quebec' + +// We document multiple crates into the same output directory, which +// merges the cross-crate information. Everything is available. +extern crate t; +pub struct Sierra; +impl t::Tango for Sierra {} diff --git a/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs new file mode 100644 index 00000000000..abc580a388c --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs @@ -0,0 +1,2 @@ +//@ build-aux-docs +pub trait Foxtrot {} diff --git a/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs new file mode 100644 index 00000000000..c93298f969e --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs @@ -0,0 +1,14 @@ +//@ aux-build:f.rs +//@ build-aux-docs +//@ has e/enum.Echo.html +//@ has f/trait.Foxtrot.html +//@ hasraw e/enum.Echo.html 'Foxtrot' +//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html' +//@ hasraw search-index.js 'Foxtrot' +//@ hasraw search-index.js 'Echo' + +// document two crates in the same way that cargo does. do not provide +// --enable-index-page +extern crate f; +pub enum Echo {} +impl f::Foxtrot for Echo {} diff --git a/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs new file mode 100644 index 00000000000..a2a7033b131 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs @@ -0,0 +1,5 @@ +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +pub trait Foxtrot {} diff --git a/tests/rustdoc/cross-crate-info/cargo-two/e.rs b/tests/rustdoc/cross-crate-info/cargo-two/e.rs new file mode 100644 index 00000000000..00f86cbc348 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/cargo-two/e.rs @@ -0,0 +1,21 @@ +//@ aux-build:f.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +//@ has index.html +//@ has index.html '//h1' 'List of all crates' +//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f' +//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e' +//@ has e/enum.Echo.html +//@ has f/trait.Foxtrot.html +//@ hasraw e/enum.Echo.html 'Foxtrot' +//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html' +//@ hasraw search-index.js 'Foxtrot' +//@ hasraw search-index.js 'Echo' + +// document two crates in the same way that cargo does, writing them both +// into the same output directory +extern crate f; +pub enum Echo {} +impl f::Foxtrot for Echo {} diff --git a/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs new file mode 100644 index 00000000000..abc580a388c --- /dev/null +++ b/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs @@ -0,0 +1,2 @@ +//@ build-aux-docs +pub trait Foxtrot {} diff --git a/tests/rustdoc/cross-crate-info/index-on-last/e.rs b/tests/rustdoc/cross-crate-info/index-on-last/e.rs new file mode 100644 index 00000000000..ffee898cd96 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/index-on-last/e.rs @@ -0,0 +1,20 @@ +//@ aux-build:f.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +//@ has index.html +//@ has index.html '//h1' 'List of all crates' +//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f' +//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e' +//@ has e/enum.Echo.html +//@ has f/trait.Foxtrot.html +//@ hasraw e/enum.Echo.html 'Foxtrot' +//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html' +//@ hasraw search-index.js 'Foxtrot' +//@ hasraw search-index.js 'Echo' + +// only declare --enable-index-page to the last rustdoc invocation +extern crate f; +pub enum Echo {} +impl f::Foxtrot for Echo {} diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs new file mode 100644 index 00000000000..932a0b17206 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs @@ -0,0 +1,5 @@ +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +pub struct Quebec; diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs new file mode 100644 index 00000000000..2c0db2abc53 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs @@ -0,0 +1,7 @@ +//@ aux-build:s.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +extern crate s; +pub type Romeo = s::Sierra; diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs new file mode 100644 index 00000000000..355d3f1aaa8 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs @@ -0,0 +1,8 @@ +//@ aux-build:t.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +extern crate t; +pub struct Sierra; +impl t::Tango for Sierra {} diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs new file mode 100644 index 00000000000..c21a59c6518 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs @@ -0,0 +1,7 @@ +//@ aux-build:q.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +extern crate q; +pub trait Tango {} diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs new file mode 100644 index 00000000000..bcb9464795a --- /dev/null +++ b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs @@ -0,0 +1,30 @@ +//@ aux-build:r.rs +//@ aux-build:q.rs +//@ aux-build:t.rs +//@ aux-build:s.rs +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +//@ has index.html '//h1' 'List of all crates' +//@ has index.html +//@ has index.html '//ul[@class="all-items"]//a[@href="i/index.html"]' 'i' +//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q' +//@ has index.html '//ul[@class="all-items"]//a[@href="r/index.html"]' 'r' +//@ has index.html '//ul[@class="all-items"]//a[@href="s/index.html"]' 's' +//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't' +//@ has q/struct.Quebec.html +//@ has r/type.Romeo.html +//@ has s/struct.Sierra.html +//@ has t/trait.Tango.html +//@ hasraw s/struct.Sierra.html 'Tango' +//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html' +//@ hasraw search-index.js 'Quebec' +//@ hasraw search-index.js 'Romeo' +//@ hasraw search-index.js 'Sierra' +//@ hasraw search-index.js 'Tango' +//@ has type.impl/s/struct.Sierra.js +//@ hasraw type.impl/s/struct.Sierra.js 'Tango' +//@ hasraw type.impl/s/struct.Sierra.js 'Romeo' + +// document everything in the default mode diff --git a/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs new file mode 100644 index 00000000000..c5e3dc0a0f4 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs @@ -0,0 +1,12 @@ +//@ build-aux-docs +//@ doc-flags:--enable-index-page +//@ doc-flags:-Zunstable-options + +//@ has index.html +//@ has index.html '//h1' 'List of all crates' +//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q' +//@ has q/struct.Quebec.html +//@ hasraw search-index.js 'Quebec' + +// there's nothing cross-crate going on here +pub struct Quebec; diff --git a/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs new file mode 100644 index 00000000000..d3e71fa0ce3 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs @@ -0,0 +1,6 @@ +//@ build-aux-docs +//@ has q/struct.Quebec.html +//@ hasraw search-index.js 'Quebec' + +// there's nothing cross-crate going on here +pub struct Quebec; diff --git a/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs new file mode 100644 index 00000000000..5d0881029cb --- /dev/null +++ b/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs @@ -0,0 +1,2 @@ +//@ build-aux-docs +pub struct Quebec; diff --git a/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs new file mode 100644 index 00000000000..fab9ec4a92b --- /dev/null +++ b/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs @@ -0,0 +1,4 @@ +//@ aux-build:q.rs +//@ build-aux-docs +extern crate q; +pub trait Tango {} diff --git a/tests/rustdoc/cross-crate-info/transitive/s.rs b/tests/rustdoc/cross-crate-info/transitive/s.rs new file mode 100644 index 00000000000..0a4e5f646dd --- /dev/null +++ b/tests/rustdoc/cross-crate-info/transitive/s.rs @@ -0,0 +1,6 @@ +//@ aux-build:t.rs +//@ build-aux-docs +// simple test to see if we support building transitive crates +extern crate t; +pub struct Sierra; +impl t::Tango for Sierra {} diff --git a/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs new file mode 100644 index 00000000000..abc580a388c --- /dev/null +++ b/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs @@ -0,0 +1,2 @@ +//@ build-aux-docs +pub trait Foxtrot {} diff --git a/tests/rustdoc/cross-crate-info/two/e.rs b/tests/rustdoc/cross-crate-info/two/e.rs new file mode 100644 index 00000000000..9665af62706 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/two/e.rs @@ -0,0 +1,6 @@ +//@ aux-build:f.rs +//@ build-aux-docs +// simple test to assert that we can do a two-level aux-build +extern crate f; +pub enum Echo {} +impl f::Foxtrot for Echo {} diff --git a/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs new file mode 100644 index 00000000000..a7ab062fd9e --- /dev/null +++ b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs @@ -0,0 +1,10 @@ +//@ build-aux-docs +//@ doc-flags:--scrape-examples-output-path=examples +//@ doc-flags:--scrape-examples-target-crate=q +//@ doc-flags:-Zunstable-options + +//@ has examples + +// where will --scrape-examples-output-path resolve the path to be? +// should be the root output directory +pub struct Quebec; diff --git a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs new file mode 100644 index 00000000000..f8c9adcaf9c --- /dev/null +++ b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs @@ -0,0 +1,3 @@ +//@ build-aux-docs +//@ unique-doc-out-dir +pub trait Foxtrot {} diff --git a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs new file mode 100644 index 00000000000..9dcec211e17 --- /dev/null +++ b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs @@ -0,0 +1,14 @@ +//@ aux-build:f.rs +//@ build-aux-docs +//@ has e/enum.Echo.html +//@ !has f/trait.Foxtrot.html +//@ hasraw e/enum.Echo.html 'Foxtrot' +//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html' +//@ !hasraw search-index.js 'Foxtrot' +//@ hasraw search-index.js 'Echo' + +// test the fact that our test runner will document this crate somewhere +// else +extern crate f; +pub enum Echo {} +impl f::Foxtrot for Echo {} diff --git a/tests/rustdoc/type-alias/impl_trait_in_assoc_type.rs b/tests/rustdoc/type-alias/impl_trait_in_assoc_type.rs new file mode 100644 index 00000000000..2846710cbed --- /dev/null +++ b/tests/rustdoc/type-alias/impl_trait_in_assoc_type.rs @@ -0,0 +1,17 @@ +#![feature(impl_trait_in_assoc_type)] + +pub struct AlwaysTrue; + +//@ has impl_trait_in_assoc_type/struct.AlwaysTrue.html + +impl IntoIterator for AlwaysTrue { + type Item = bool; + + //@ has - '//*[@id="associatedtype.IntoIter"]//h4[@class="code-header"]' \ + // 'type IntoIter = impl Iterator<Item = bool>' + type IntoIter = impl Iterator<Item = bool>; + + fn into_iter(self) -> Self::IntoIter { + std::iter::repeat(true) + } +} diff --git a/tests/rustdoc/unsafe-extern-blocks.rs b/tests/rustdoc/unsafe-extern-blocks.rs index 22d3beea6c3..829095f300f 100644 --- a/tests/rustdoc/unsafe-extern-blocks.rs +++ b/tests/rustdoc/unsafe-extern-blocks.rs @@ -1,6 +1,5 @@ // Test to ensure the feature is working as expected. -#![feature(unsafe_extern_blocks)] #![crate_name = "foo"] // @has 'foo/index.html' @@ -13,7 +12,7 @@ // @count - '//ul[@class="item-table"]//sup[@title="unsafe function"]' 1 // @has - '//ul[@class="item-table"]//sup[@title="unsafe function"]' '⚠' -unsafe extern { +unsafe extern "C" { // @has 'foo/static.FOO.html' // @has - '//pre[@class="rust item-decl"]' 'pub static FOO: i32' pub safe static FOO: i32; diff --git a/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs index 33e10a00713..c761b8e94bd 100644 --- a/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs +++ b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.rs @@ -1,5 +1,4 @@ //@ compile-flags: -Z unstable-options -//@ ignore-stage1 (can be removed after beta bump, #[cfg(bootstrap)]) #![feature(rustc_private)] #![deny(rustc::non_glob_import_of_type_ir_inherent)] diff --git a/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr index 84e3867c95b..c5c10bb070a 100644 --- a/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr +++ b/tests/ui-fulldeps/internal-lints/non_glob_import_of_type_ir_inherent.stderr @@ -1,5 +1,5 @@ error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:17:9 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:16:9 | LL | use rustc_type_ir::inherent::Predicate; | ^^^^^^^^^^^^^^^^^^^^^^^^^--------- @@ -7,25 +7,25 @@ LL | use rustc_type_ir::inherent::Predicate; | help: try using a glob import instead: `*` | note: the lint level is defined here - --> $DIR/non_glob_import_of_type_ir_inherent.rs:4:9 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:3:9 | LL | #![deny(rustc::non_glob_import_of_type_ir_inherent)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:18:35 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:17:35 | LL | use rustc_type_ir::inherent::{AdtDef, Ty}; | ^^^^^^ help: try using a glob import instead: `*` error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:18:43 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:17:43 | LL | use rustc_type_ir::inherent::{AdtDef, Ty}; | ^^ help: try using a glob import instead: `*` error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:21:9 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:20:9 | LL | use rustc_type_ir::inherent::ParamEnv as _; | ^^^^^^^^^^^^^^^^^^^^^^^^^------------- @@ -33,31 +33,31 @@ LL | use rustc_type_ir::inherent::ParamEnv as _; | help: try using a glob import instead: `*` error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:25:9 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:24:9 | LL | use rustc_type_ir::inherent; | ^^^^^^^^^^^^^^^^^^^^^^^- help: try using a glob import instead: `::*` error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:26:9 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:25:9 | LL | use rustc_type_ir::inherent as inh; | ^^^^^^^^^^^^^^^^^^^^^^^------- help: try using a glob import instead: `::*` error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:27:25 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:26:25 | LL | use rustc_type_ir::{inherent as _}; | ^^^^^^^^----- help: try using a glob import instead: `::*` error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:34:35 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:33:35 | LL | use rustc_type_ir::inherent::{self}; | ^^^^ help: try using a glob import instead: `*` error: non-glob import of `rustc_type_ir::inherent` - --> $DIR/non_glob_import_of_type_ir_inherent.rs:35:35 + --> $DIR/non_glob_import_of_type_ir_inherent.rs:34:35 | LL | use rustc_type_ir::inherent::{self as innate}; | ^^^^---------- diff --git a/tests/crashes/121444.rs b/tests/ui/abi/large-byval-align.rs index a6373a58c42..e39170df72b 100644 --- a/tests/crashes/121444.rs +++ b/tests/ui/abi/large-byval-align.rs @@ -1,11 +1,13 @@ -//@ known-bug: #121444 //@ compile-flags: -Copt-level=0 -//@ edition:2021 //@ only-x86_64 //@ ignore-windows +//@ min-llvm-version: 19 +//@ build-pass + #[repr(align(536870912))] pub struct A(i64); +#[allow(improper_ctypes_definitions)] pub extern "C" fn foo(x: A) {} fn main() { diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs index 6d335ac2def..cb1e5c325c2 100644 --- a/tests/ui/asm/naked-functions.rs +++ b/tests/ui/asm/naked-functions.rs @@ -239,6 +239,9 @@ pub unsafe extern "C" fn compatible_target_feature() { } #[doc = "foo bar baz"] +/// a doc comment +// a normal comment +#[doc(alias = "ADocAlias")] #[naked] pub unsafe extern "C" fn compatible_doc_attributes() { asm!("", options(noreturn, raw)); diff --git a/tests/ui/asm/parse-error.rs b/tests/ui/asm/parse-error.rs index 9dec3a1c394..16ae0282864 100644 --- a/tests/ui/asm/parse-error.rs +++ b/tests/ui/asm/parse-error.rs @@ -146,5 +146,16 @@ global_asm!(format!("{{{}}}", 0), const FOO); //~^ ERROR asm template must be a string literal global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); //~^ ERROR asm template must be a string literal -global_asm!("{}", label {}); -//~^ ERROR expected operand, options, or additional template string + +global_asm!("{}", in(reg)); +//~^ ERROR the `in` operand cannot be used with `global_asm!` +global_asm!("{}", out(reg)); +//~^ ERROR the `out` operand cannot be used with `global_asm!` +global_asm!("{}", lateout(reg)); +//~^ ERROR the `lateout` operand cannot be used with `global_asm!` +global_asm!("{}", inout(reg)); +//~^ ERROR the `inout` operand cannot be used with `global_asm!` +global_asm!("{}", inlateout(reg)); +//~^ ERROR the `inlateout` operand cannot be used with `global_asm!` +global_asm!("{}", label(reg)); +//~^ ERROR the `label` operand cannot be used with `global_asm!` diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr index e9ecd712bc3..f5f8d537d86 100644 --- a/tests/ui/asm/parse-error.stderr +++ b/tests/ui/asm/parse-error.stderr @@ -380,11 +380,41 @@ LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) -error: expected operand, options, or additional template string - --> $DIR/parse-error.rs:149:19 +error: the `in` operand cannot be used with `global_asm!` + --> $DIR/parse-error.rs:150:19 + | +LL | global_asm!("{}", in(reg)); + | ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it + +error: the `out` operand cannot be used with `global_asm!` + --> $DIR/parse-error.rs:152:19 + | +LL | global_asm!("{}", out(reg)); + | ^^^ the `out` operand is not meaningful for global-scoped inline assembly, remove it + +error: the `lateout` operand cannot be used with `global_asm!` + --> $DIR/parse-error.rs:154:19 + | +LL | global_asm!("{}", lateout(reg)); + | ^^^^^^^ the `lateout` operand is not meaningful for global-scoped inline assembly, remove it + +error: the `inout` operand cannot be used with `global_asm!` + --> $DIR/parse-error.rs:156:19 + | +LL | global_asm!("{}", inout(reg)); + | ^^^^^ the `inout` operand is not meaningful for global-scoped inline assembly, remove it + +error: the `inlateout` operand cannot be used with `global_asm!` + --> $DIR/parse-error.rs:158:19 + | +LL | global_asm!("{}", inlateout(reg)); + | ^^^^^^^^^ the `inlateout` operand is not meaningful for global-scoped inline assembly, remove it + +error: the `label` operand cannot be used with `global_asm!` + --> $DIR/parse-error.rs:160:19 | -LL | global_asm!("{}", label {}); - | ^^^^^^^^ expected operand, options, or additional template string +LL | global_asm!("{}", label(reg)); + | ^^^^^ the `label` operand is not meaningful for global-scoped inline assembly, remove it error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:39:37 @@ -441,6 +471,6 @@ help: consider using `const` instead of `let` LL | const bar: /* Type */ = 0; | ~~~~~ ++++++++++++ -error: aborting due to 67 previous errors +error: aborting due to 72 previous errors For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/associated-types/associated-types-outlives.stderr b/tests/ui/associated-types/associated-types-outlives.stderr index 1164869bf19..bd6022fcec6 100644 --- a/tests/ui/associated-types/associated-types-outlives.stderr +++ b/tests/ui/associated-types/associated-types-outlives.stderr @@ -18,7 +18,7 @@ LL | pub fn free_and_use<T: for<'a> Foo<'a>, | ^ consider constraining this type parameter with `Clone` ... LL | 's: loop { y = denormalise(&x); break } - | -- you could clone this value + | - you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/async-await/unreachable-lint-2.rs b/tests/ui/async-await/unreachable-lint-2.rs new file mode 100644 index 00000000000..137cb32481b --- /dev/null +++ b/tests/ui/async-await/unreachable-lint-2.rs @@ -0,0 +1,15 @@ +//@ edition:2018 + +#![deny(unreachable_code)] + +async fn foo() { + endless().await; + println!("this is unreachable!"); + //~^ ERROR unreachable statement +} + +async fn endless() -> ! { + loop {} +} + +fn main() { } diff --git a/tests/ui/async-await/unreachable-lint-2.stderr b/tests/ui/async-await/unreachable-lint-2.stderr new file mode 100644 index 00000000000..cbebc9951f3 --- /dev/null +++ b/tests/ui/async-await/unreachable-lint-2.stderr @@ -0,0 +1,17 @@ +error: unreachable statement + --> $DIR/unreachable-lint-2.rs:7:5 + | +LL | endless().await; + | ----- any code following this expression is unreachable +LL | println!("this is unreachable!"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement + | +note: the lint level is defined here + --> $DIR/unreachable-lint-2.rs:3:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + diff --git a/tests/ui/attributes/field-attributes-vis-unresolved.stderr b/tests/ui/attributes/field-attributes-vis-unresolved.stderr index 819cd859ae9..f8610c08b02 100644 --- a/tests/ui/attributes/field-attributes-vis-unresolved.stderr +++ b/tests/ui/attributes/field-attributes-vis-unresolved.stderr @@ -4,7 +4,10 @@ error[E0433]: failed to resolve: you might be missing crate `nonexistent` LL | pub(in nonexistent) field: u8 | ^^^^^^^^^^^ you might be missing crate `nonexistent` | - = help: consider adding `extern crate nonexistent` to use the `nonexistent` crate +help: consider importing the `nonexistent` crate + | +LL + extern crate nonexistent; + | error[E0433]: failed to resolve: you might be missing crate `nonexistent` --> $DIR/field-attributes-vis-unresolved.rs:22:12 @@ -12,7 +15,10 @@ error[E0433]: failed to resolve: you might be missing crate `nonexistent` LL | pub(in nonexistent) u8 | ^^^^^^^^^^^ you might be missing crate `nonexistent` | - = help: consider adding `extern crate nonexistent` to use the `nonexistent` crate +help: consider importing the `nonexistent` crate + | +LL + extern crate nonexistent; + | error: aborting due to 2 previous errors diff --git a/tests/ui/attributes/optimize.rs b/tests/ui/attributes/optimize.rs new file mode 100644 index 00000000000..b01806165c1 --- /dev/null +++ b/tests/ui/attributes/optimize.rs @@ -0,0 +1,28 @@ +#![feature(optimize_attribute)] +#![feature(stmt_expr_attributes)] +#![deny(unused_attributes)] +#![allow(dead_code)] + +#[optimize(speed)] //~ ERROR attribute should be applied to function or closure +struct F; + +fn invalid() { + #[optimize(speed)] //~ ERROR attribute should be applied to function or closure + { + 1 + }; +} + +#[optimize(speed)] +fn valid() {} + +#[optimize(speed)] +mod valid_module {} + +#[optimize(speed)] +impl F {} + +fn main() { + let _ = #[optimize(speed)] + (|| 1); +} diff --git a/tests/ui/attributes/optimize.stderr b/tests/ui/attributes/optimize.stderr new file mode 100644 index 00000000000..3c445d73c2e --- /dev/null +++ b/tests/ui/attributes/optimize.stderr @@ -0,0 +1,20 @@ +error: attribute should be applied to function or closure + --> $DIR/optimize.rs:6:1 + | +LL | #[optimize(speed)] + | ^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/optimize.rs:3:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: attribute should be applied to function or closure + --> $DIR/optimize.rs:10:5 + | +LL | #[optimize(speed)] + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/attributes/unsafe/derive-unsafe-attributes.rs b/tests/ui/attributes/unsafe/derive-unsafe-attributes.rs index 774ce86c096..b8edb4aab90 100644 --- a/tests/ui/attributes/unsafe/derive-unsafe-attributes.rs +++ b/tests/ui/attributes/unsafe/derive-unsafe-attributes.rs @@ -1,6 +1,15 @@ #![feature(unsafe_attributes)] -#[derive(unsafe(Debug))] //~ ERROR: traits in `#[derive(...)]` don't accept `unsafe(...)` +#[derive(unsafe(Debug))] +//~^ ERROR: expected identifier, found keyword `unsafe` +//~| ERROR: traits in `#[derive(...)]` don't accept arguments +//~| ERROR: expected identifier, found keyword `unsafe` +//~| ERROR: expected identifier, found keyword `unsafe` +//~| ERROR: cannot find derive macro `r#unsafe` in this scope +//~| ERROR: cannot find derive macro `r#unsafe` in this scope struct Foo; +#[unsafe(derive(Debug))] //~ ERROR: is not an unsafe attribute +struct Bar; + fn main() {} diff --git a/tests/ui/attributes/unsafe/derive-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/derive-unsafe-attributes.stderr index fc0daf16790..c40a5512fd5 100644 --- a/tests/ui/attributes/unsafe/derive-unsafe-attributes.stderr +++ b/tests/ui/attributes/unsafe/derive-unsafe-attributes.stderr @@ -1,8 +1,65 @@ -error: traits in `#[derive(...)]` don't accept `unsafe(...)` +error: expected identifier, found keyword `unsafe` + --> $DIR/derive-unsafe-attributes.rs:3:10 + | +LL | #[derive(unsafe(Debug))] + | ^^^^^^ expected identifier, found keyword + | +help: escape `unsafe` to use it as an identifier + | +LL | #[derive(r#unsafe(Debug))] + | ++ + +error: traits in `#[derive(...)]` don't accept arguments + --> $DIR/derive-unsafe-attributes.rs:3:16 + | +LL | #[derive(unsafe(Debug))] + | ^^^^^^^ help: remove the arguments + +error: `derive` is not an unsafe attribute + --> $DIR/derive-unsafe-attributes.rs:12:3 + | +LL | #[unsafe(derive(Debug))] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: expected identifier, found keyword `unsafe` + --> $DIR/derive-unsafe-attributes.rs:3:10 + | +LL | #[derive(unsafe(Debug))] + | ^^^^^^ expected identifier, found keyword + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: escape `unsafe` to use it as an identifier + | +LL | #[derive(r#unsafe(Debug))] + | ++ + +error: expected identifier, found keyword `unsafe` + --> $DIR/derive-unsafe-attributes.rs:3:10 + | +LL | #[derive(unsafe(Debug))] + | ^^^^^^ expected identifier, found keyword + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: escape `unsafe` to use it as an identifier + | +LL | #[derive(r#unsafe(Debug))] + | ++ + +error: cannot find derive macro `r#unsafe` in this scope --> $DIR/derive-unsafe-attributes.rs:3:10 | LL | #[derive(unsafe(Debug))] | ^^^^^^ -error: aborting due to 1 previous error +error: cannot find derive macro `r#unsafe` in this scope + --> $DIR/derive-unsafe-attributes.rs:3:10 + | +LL | #[derive(unsafe(Debug))] + | ^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 7 previous errors diff --git a/tests/ui/attributes/unsafe/double-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/double-unsafe-attributes.stderr index ea82bac6df0..950b2636993 100644 --- a/tests/ui/attributes/unsafe/double-unsafe-attributes.stderr +++ b/tests/ui/attributes/unsafe/double-unsafe-attributes.stderr @@ -13,7 +13,7 @@ error: `r#unsafe` is not an unsafe attribute --> $DIR/double-unsafe-attributes.rs:3:3 | LL | #[unsafe(unsafe(no_mangle))] - | ^^^^^^ + | ^^^^^^ this is not an unsafe attribute | = note: extraneous unsafe is not allowed in attributes diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs new file mode 100644 index 00000000000..0181add843b --- /dev/null +++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs @@ -0,0 +1,31 @@ +//@ edition: 2024 +//@ compile-flags: -Zunstable-options +#![feature(unsafe_attributes)] + +#[unsafe(cfg(any()))] //~ ERROR: is not an unsafe attribute +fn a() {} + +#[unsafe(cfg_attr(any(), allow(dead_code)))] //~ ERROR: is not an unsafe attribute +fn b() {} + +#[unsafe(test)] //~ ERROR: is not an unsafe attribute +fn aa() {} + +#[unsafe(ignore = "test")] //~ ERROR: is not an unsafe attribute +fn bb() {} + +#[unsafe(should_panic(expected = "test"))] //~ ERROR: is not an unsafe attribute +fn cc() {} + +#[unsafe(macro_use)] //~ ERROR: is not an unsafe attribute +mod inner { + #[unsafe(macro_export)] //~ ERROR: is not an unsafe attribute + macro_rules! m { + () => {}; + } +} + +#[unsafe(used)] //~ ERROR: is not an unsafe attribute +static FOO: usize = 0; + +fn main() {} diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr new file mode 100644 index 00000000000..f39074b613d --- /dev/null +++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr @@ -0,0 +1,66 @@ +error: `cfg` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:5:3 + | +LL | #[unsafe(cfg(any()))] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `cfg_attr` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:8:3 + | +LL | #[unsafe(cfg_attr(any(), allow(dead_code)))] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `test` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:11:3 + | +LL | #[unsafe(test)] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `ignore` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:14:3 + | +LL | #[unsafe(ignore = "test")] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `should_panic` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:17:3 + | +LL | #[unsafe(should_panic(expected = "test"))] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `macro_use` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:20:3 + | +LL | #[unsafe(macro_use)] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `macro_export` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:22:7 + | +LL | #[unsafe(macro_export)] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `used` is not an unsafe attribute + --> $DIR/extraneous-unsafe-attributes.rs:28:3 + | +LL | #[unsafe(used)] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: aborting due to 8 previous errors + diff --git a/tests/ui/attributes/unsafe/proc-unsafe-attributes.rs b/tests/ui/attributes/unsafe/proc-unsafe-attributes.rs new file mode 100644 index 00000000000..f29a5b3252b --- /dev/null +++ b/tests/ui/attributes/unsafe/proc-unsafe-attributes.rs @@ -0,0 +1,37 @@ +#![feature(unsafe_attributes)] + +#[unsafe(proc_macro)] +//~^ ERROR: is not an unsafe attribute +//~| ERROR attribute is only usable with crates of the `proc-macro` crate type +pub fn a() {} + + +#[unsafe(proc_macro_derive(Foo))] +//~^ ERROR: is not an unsafe attribute +//~| ERROR attribute is only usable with crates of the `proc-macro` crate type +pub fn b() {} + +#[proc_macro_derive(unsafe(Foo))] +//~^ ERROR attribute is only usable with crates of the `proc-macro` crate type +//~| ERROR: expected identifier, found keyword `unsafe` +pub fn c() {} + +#[unsafe(proc_macro_attribute)] +//~^ ERROR: is not an unsafe attribute +//~| ERROR attribute is only usable with crates of the `proc-macro` crate type +pub fn d() {} + +#[unsafe(allow(dead_code))] +//~^ ERROR: is not an unsafe attribute +pub fn e() {} + +#[unsafe(allow(unsafe(dead_code)))] +//~^ ERROR: is not an unsafe attribute +//~| ERROR: malformed lint attribute input +//~| ERROR: malformed lint attribute input +//~| ERROR: expected identifier, found keyword `unsafe` +//~| ERROR: malformed lint attribute input +//~| ERROR: malformed lint attribute input +pub fn f() {} + +fn main() {} diff --git a/tests/ui/attributes/unsafe/proc-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/proc-unsafe-attributes.stderr new file mode 100644 index 00000000000..79d34d458bd --- /dev/null +++ b/tests/ui/attributes/unsafe/proc-unsafe-attributes.stderr @@ -0,0 +1,119 @@ +error[E0452]: malformed lint attribute input + --> $DIR/proc-unsafe-attributes.rs:28:16 + | +LL | #[unsafe(allow(unsafe(dead_code)))] + | ^^^^^^^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/proc-unsafe-attributes.rs:28:16 + | +LL | #[unsafe(allow(unsafe(dead_code)))] + | ^^^^^^^^^^^^^^^^^ bad attribute argument + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `proc_macro` is not an unsafe attribute + --> $DIR/proc-unsafe-attributes.rs:3:3 + | +LL | #[unsafe(proc_macro)] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `proc_macro_derive` is not an unsafe attribute + --> $DIR/proc-unsafe-attributes.rs:9:3 + | +LL | #[unsafe(proc_macro_derive(Foo))] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: expected identifier, found keyword `unsafe` + --> $DIR/proc-unsafe-attributes.rs:14:21 + | +LL | #[proc_macro_derive(unsafe(Foo))] + | ^^^^^^ expected identifier, found keyword + | +help: escape `unsafe` to use it as an identifier + | +LL | #[proc_macro_derive(r#unsafe(Foo))] + | ++ + +error: `proc_macro_attribute` is not an unsafe attribute + --> $DIR/proc-unsafe-attributes.rs:19:3 + | +LL | #[unsafe(proc_macro_attribute)] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `allow` is not an unsafe attribute + --> $DIR/proc-unsafe-attributes.rs:24:3 + | +LL | #[unsafe(allow(dead_code))] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: `allow` is not an unsafe attribute + --> $DIR/proc-unsafe-attributes.rs:28:3 + | +LL | #[unsafe(allow(unsafe(dead_code)))] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: expected identifier, found keyword `unsafe` + --> $DIR/proc-unsafe-attributes.rs:28:16 + | +LL | #[unsafe(allow(unsafe(dead_code)))] + | ^^^^^^ expected identifier, found keyword + | +help: escape `unsafe` to use it as an identifier + | +LL | #[unsafe(allow(r#unsafe(dead_code)))] + | ++ + +error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/proc-unsafe-attributes.rs:3:1 + | +LL | #[unsafe(proc_macro)] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/proc-unsafe-attributes.rs:9:1 + | +LL | #[unsafe(proc_macro_derive(Foo))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/proc-unsafe-attributes.rs:14:1 + | +LL | #[proc_macro_derive(unsafe(Foo))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/proc-unsafe-attributes.rs:19:1 + | +LL | #[unsafe(proc_macro_attribute)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0452]: malformed lint attribute input + --> $DIR/proc-unsafe-attributes.rs:28:16 + | +LL | #[unsafe(allow(unsafe(dead_code)))] + | ^^^^^^^^^^^^^^^^^ bad attribute argument + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0452]: malformed lint attribute input + --> $DIR/proc-unsafe-attributes.rs:28:16 + | +LL | #[unsafe(allow(unsafe(dead_code)))] + | ^^^^^^^^^^^^^^^^^ bad attribute argument + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 15 previous errors + +For more information about this error, try `rustc --explain E0452`. diff --git a/tests/ui/attributes/unsafe/unsafe-attributes.rs b/tests/ui/attributes/unsafe/unsafe-attributes.rs index e7620a18048..33a412add50 100644 --- a/tests/ui/attributes/unsafe/unsafe-attributes.rs +++ b/tests/ui/attributes/unsafe/unsafe-attributes.rs @@ -4,4 +4,10 @@ #[unsafe(no_mangle)] fn a() {} +#[unsafe(export_name = "foo")] +fn b() {} + +#[cfg_attr(any(), unsafe(no_mangle))] +static VAR2: u32 = 1; + fn main() {} diff --git a/tests/ui/attributes/unsafe/unsafe-safe-attribute.stderr b/tests/ui/attributes/unsafe/unsafe-safe-attribute.stderr index 0602af34e4f..584b0ea797d 100644 --- a/tests/ui/attributes/unsafe/unsafe-safe-attribute.stderr +++ b/tests/ui/attributes/unsafe/unsafe-safe-attribute.stderr @@ -2,7 +2,7 @@ error: `repr` is not an unsafe attribute --> $DIR/unsafe-safe-attribute.rs:3:3 | LL | #[unsafe(repr(C))] - | ^^^^^^ + | ^^^^^^ this is not an unsafe attribute | = note: extraneous unsafe is not allowed in attributes diff --git a/tests/ui/attributes/unsafe/unsafe-safe-attribute_diagnostic.stderr b/tests/ui/attributes/unsafe/unsafe-safe-attribute_diagnostic.stderr index 584dacf4d8c..26b5e4e37b9 100644 --- a/tests/ui/attributes/unsafe/unsafe-safe-attribute_diagnostic.stderr +++ b/tests/ui/attributes/unsafe/unsafe-safe-attribute_diagnostic.stderr @@ -2,7 +2,7 @@ error: `diagnostic::on_unimplemented` is not an unsafe attribute --> $DIR/unsafe-safe-attribute_diagnostic.rs:3:3 | LL | #[unsafe(diagnostic::on_unimplemented( - | ^^^^^^ + | ^^^^^^ this is not an unsafe attribute | = note: extraneous unsafe is not allowed in attributes diff --git a/tests/ui/augmented-assignments.rs b/tests/ui/augmented-assignments.rs index 8b263e03593..440a4a7fd65 100644 --- a/tests/ui/augmented-assignments.rs +++ b/tests/ui/augmented-assignments.rs @@ -17,7 +17,6 @@ fn main() { x; //~^ ERROR cannot move out of `x` because it is borrowed //~| move out of `x` occurs here - //~| HELP consider cloning let y = Int(2); //~^ HELP consider changing this to be mutable diff --git a/tests/ui/augmented-assignments.stderr b/tests/ui/augmented-assignments.stderr index 6b2900dd5d1..a4b75cbf6e8 100644 --- a/tests/ui/augmented-assignments.stderr +++ b/tests/ui/augmented-assignments.stderr @@ -8,14 +8,9 @@ LL | x ... LL | x; | ^ move out of `x` occurs here - | -help: consider cloning the value if the performance cost is acceptable - | -LL | x.clone(); - | ++++++++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/augmented-assignments.rs:25:5 + --> $DIR/augmented-assignments.rs:24:5 | LL | y | ^ cannot borrow as mutable diff --git a/tests/ui/backtrace/synchronized-panic-handler.rs b/tests/ui/backtrace/synchronized-panic-handler.rs index 00eb249da1d..29431ae3c45 100644 --- a/tests/ui/backtrace/synchronized-panic-handler.rs +++ b/tests/ui/backtrace/synchronized-panic-handler.rs @@ -3,6 +3,7 @@ //@ edition:2021 //@ exec-env:RUST_BACKTRACE=0 //@ needs-threads +//@ needs-unwind use std::thread; const PANIC_MESSAGE: &str = "oops oh no woe is me"; diff --git a/tests/ui/backtrace/synchronized-panic-handler.run.stderr b/tests/ui/backtrace/synchronized-panic-handler.run.stderr index b7c815a94c8..8a06d00ea59 100644 --- a/tests/ui/backtrace/synchronized-panic-handler.run.stderr +++ b/tests/ui/backtrace/synchronized-panic-handler.run.stderr @@ -1,5 +1,5 @@ -thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:10:5: +thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:11:5: oops oh no woe is me note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:10:5: +thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:11:5: oops oh no woe is me diff --git a/tests/ui/binop/binop-move-semantics.stderr b/tests/ui/binop/binop-move-semantics.stderr index 83c27590e90..45c7f110406 100644 --- a/tests/ui/binop/binop-move-semantics.stderr +++ b/tests/ui/binop/binop-move-semantics.stderr @@ -65,7 +65,7 @@ help: if `T` implemented `Clone`, you could clone the value LL | fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) { | ^ consider constraining this type parameter with `Clone` LL | let m = &x; - | -- you could clone this value + | - you could clone this value error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/binop-move-semantics.rs:23:5 @@ -88,7 +88,7 @@ LL | fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) { | ^ consider constraining this type parameter with `Clone` LL | let m = &x; LL | let n = &mut y; - | ------ you could clone this value + | - you could clone this value error[E0507]: cannot move out of `*m` which is behind a mutable reference --> $DIR/binop-move-semantics.rs:30:5 diff --git a/tests/ui/borrowck/borrow-tuple-fields.stderr b/tests/ui/borrowck/borrow-tuple-fields.stderr index 8ea7a9a4989..277c335cfcc 100644 --- a/tests/ui/borrowck/borrow-tuple-fields.stderr +++ b/tests/ui/borrowck/borrow-tuple-fields.stderr @@ -13,9 +13,8 @@ LL | r.use_ref(); | help: consider cloning the value if the performance cost is acceptable | -LL - let r = &x.0; -LL + let r = x.0.clone(); - | +LL | let r = &x.0.clone(); + | ++++++++ error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable --> $DIR/borrow-tuple-fields.rs:18:13 @@ -51,9 +50,8 @@ LL | r.use_ref(); | help: consider cloning the value if the performance cost is acceptable | -LL - let r = &x.0; -LL + let r = x.0.clone(); - | +LL | let r = &x.0.clone(); + | ++++++++ error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable --> $DIR/borrow-tuple-fields.rs:33:13 diff --git a/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr b/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr index b96949fbb0e..5e7eee0422e 100644 --- a/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr +++ b/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr @@ -14,7 +14,7 @@ LL | a); help: consider cloning the value if the performance cost is acceptable | LL - &*a, -LL + a.clone(), +LL + &a.clone(), | error[E0505]: cannot move out of `a` because it is borrowed @@ -32,7 +32,7 @@ LL | a); help: consider cloning the value if the performance cost is acceptable | LL - &*a, -LL + a.clone(), +LL + &a.clone(), | error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-field-sensitivity.stderr b/tests/ui/borrowck/borrowck-field-sensitivity.stderr index ea552ff7820..b30dd144a4d 100644 --- a/tests/ui/borrowck/borrowck-field-sensitivity.stderr +++ b/tests/ui/borrowck/borrowck-field-sensitivity.stderr @@ -52,9 +52,8 @@ LL | drop(**p); | help: consider cloning the value if the performance cost is acceptable | -LL - let p = &x.b; -LL + let p = x.b.clone(); - | +LL | let p = &x.b.clone(); + | ++++++++ error[E0505]: cannot move out of `x.b` because it is borrowed --> $DIR/borrowck-field-sensitivity.rs:41:14 @@ -70,9 +69,8 @@ LL | drop(**p); | help: consider cloning the value if the performance cost is acceptable | -LL - let p = &x.b; -LL + let p = x.b.clone(); - | +LL | let p = &x.b.clone(); + | ++++++++ error[E0499]: cannot borrow `x.a` as mutable more than once at a time --> $DIR/borrowck-field-sensitivity.rs:48:13 diff --git a/tests/ui/borrowck/borrowck-issue-48962.stderr b/tests/ui/borrowck/borrowck-issue-48962.stderr index 6e821a4c6b0..ee174f6736e 100644 --- a/tests/ui/borrowck/borrowck-issue-48962.stderr +++ b/tests/ui/borrowck/borrowck-issue-48962.stderr @@ -17,11 +17,6 @@ LL | {src}; | --- value moved here LL | src.0 = 66; | ^^^^^^^^^^ value used here after move - | -help: consider cloning the value if the performance cost is acceptable - | -LL | {src.clone()}; - | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr index 370ae058f44..d9af5cf7d12 100644 --- a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr +++ b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr @@ -16,9 +16,8 @@ LL | w.use_ref(); | help: consider cloning the value if the performance cost is acceptable | -LL - let w = &v; -LL + let w = v.clone(); - | +LL | let w = &v.clone(); + | ++++++++ error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 @@ -38,9 +37,8 @@ LL | w.use_ref(); | help: consider cloning the value if the performance cost is acceptable | -LL - let w = &v; -LL + let w = v.clone(); - | +LL | let w = &v.clone(); + | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr index 8a8005dbb83..1698035f20f 100644 --- a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr +++ b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr @@ -12,9 +12,8 @@ LL | w.use_ref(); | help: consider cloning the value if the performance cost is acceptable | -LL - let w = &v; -LL + let w = v.clone(); - | +LL | let w = &v.clone(); + | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr index a23a203d999..b78c374c456 100644 --- a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr +++ b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr @@ -13,9 +13,8 @@ LL | b.use_ref(); | help: consider cloning the value if the performance cost is acceptable | -LL - let b = &a; -LL + let b = a.clone(); - | +LL | let b = &a.clone(); + | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr index acf426906c3..4b9351b64a0 100644 --- a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr +++ b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr @@ -14,7 +14,7 @@ LL | p.use_ref(); help: consider cloning the value if the performance cost is acceptable | LL - let p: &isize = &*t0; // Freezes `*t0` -LL + let p: &isize = t0.clone(); // Freezes `*t0` +LL + let p: &isize = &t0.clone(); // Freezes `*t0` | error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrowck-move-subcomponent.stderr b/tests/ui/borrowck/borrowck-move-subcomponent.stderr index cc6c3bdeb10..b5dc01f180b 100644 --- a/tests/ui/borrowck/borrowck-move-subcomponent.stderr +++ b/tests/ui/borrowck/borrowck-move-subcomponent.stderr @@ -17,7 +17,7 @@ LL | struct S { | ^^^^^^^^ consider implementing `Clone` for this type ... LL | let pb = &a; - | -- you could clone this value + | - you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/borrowck-multiple-captures.stderr b/tests/ui/borrowck/borrowck-multiple-captures.stderr index fdac4c27cee..01b648ea647 100644 --- a/tests/ui/borrowck/borrowck-multiple-captures.stderr +++ b/tests/ui/borrowck/borrowck-multiple-captures.stderr @@ -17,9 +17,8 @@ LL | borrow(&*p1); | help: consider cloning the value if the performance cost is acceptable | -LL - let p1 = &x1; -LL + let p1 = x1.clone(); - | +LL | let p1 = &x1.clone(); + | ++++++++ error[E0505]: cannot move out of `x2` because it is borrowed --> $DIR/borrowck-multiple-captures.rs:12:19 @@ -39,9 +38,8 @@ LL | borrow(&*p2); | help: consider cloning the value if the performance cost is acceptable | -LL - let p2 = &x2; -LL + let p2 = x2.clone(); - | +LL | let p2 = &x2.clone(); + | ++++++++ error[E0382]: use of moved value: `x1` --> $DIR/borrowck-multiple-captures.rs:27:19 @@ -108,9 +106,8 @@ LL | borrow(&*p); | help: consider cloning the value if the performance cost is acceptable | -LL - let p = &x; -LL + let p = x.clone(); - | +LL | let p = &x.clone(); + | ++++++++ error[E0382]: use of moved value: `x` --> $DIR/borrowck-multiple-captures.rs:52:14 diff --git a/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr b/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr index 7f8cc74a715..3366853b8e2 100644 --- a/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr +++ b/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr @@ -11,6 +11,11 @@ LL | println!("{}", f[s]); ... LL | use_mut(rs); | -- borrow later used here + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let rs = &mut s.clone(); + | ++++++++ error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 @@ -25,6 +30,11 @@ LL | f[s] = 10; ... LL | use_mut(rs); | -- borrow later used here + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let rs = &mut s.clone(); + | ++++++++ error[E0382]: use of moved value: `s` --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 diff --git a/tests/ui/borrowck/borrowck-unary-move.stderr b/tests/ui/borrowck/borrowck-unary-move.stderr index 598ecb53778..0aec6d42630 100644 --- a/tests/ui/borrowck/borrowck-unary-move.stderr +++ b/tests/ui/borrowck/borrowck-unary-move.stderr @@ -13,7 +13,7 @@ LL | *y help: consider cloning the value if the performance cost is acceptable | LL - let y = &*x; -LL + let y = x.clone(); +LL + let y = &x.clone(); | error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/clone-on-ref.stderr b/tests/ui/borrowck/clone-on-ref.stderr index 19f040556f8..d5d21296a3f 100644 --- a/tests/ui/borrowck/clone-on-ref.stderr +++ b/tests/ui/borrowck/clone-on-ref.stderr @@ -38,7 +38,7 @@ help: if `T` implemented `Clone`, you could clone the value LL | fn bar<T: std::fmt::Display>(x: T) { | ^ consider constraining this type parameter with `Clone` LL | let a = &x; - | -- you could clone this value + | - you could clone this value help: consider further restricting this bound | LL | fn bar<T: std::fmt::Display + Clone>(x: T) { @@ -66,7 +66,7 @@ LL | struct A; | ^^^^^^^^ consider implementing `Clone` for this type LL | fn qux(x: A) { LL | let a = &x; - | -- you could clone this value + | - you could clone this value help: consider annotating `A` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/borrowck/issue-101119.stderr b/tests/ui/borrowck/issue-101119.stderr index a894fa63ace..7fec81b59b3 100644 --- a/tests/ui/borrowck/issue-101119.stderr +++ b/tests/ui/borrowck/issue-101119.stderr @@ -18,14 +18,6 @@ LL | fn fill_segment(_: &mut State) {} | ------------ ^^^^^^^^^^ this parameter takes ownership of the value | | | in this function -note: if `State` implemented `Clone`, you could clone the value - --> $DIR/issue-101119.rs:1:1 - | -LL | struct State; - | ^^^^^^^^^^^^ consider implementing `Clone` for this type -... -LL | fill_segment(state); - | ----- you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/btreemap/btreemap_dropck.stderr b/tests/ui/btreemap/btreemap_dropck.stderr index 873f8cf9a01..e8f14552af2 100644 --- a/tests/ui/btreemap/btreemap_dropck.stderr +++ b/tests/ui/btreemap/btreemap_dropck.stderr @@ -12,9 +12,8 @@ LL | } | help: consider cloning the value if the performance cost is acceptable | -LL - let _map = BTreeMap::from_iter([((), PrintOnDrop(&s))]); -LL + let _map = BTreeMap::from_iter([((), PrintOnDrop(s.clone()))]); - | +LL | let _map = BTreeMap::from_iter([((), PrintOnDrop(&s.clone()))]); + | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index 57cbe173c78..520cffc4b02 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -251,7 +251,7 @@ warning: unexpected `cfg` condition value: `zebra` LL | cfg!(target_feature = "zebra"); | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 199 more + = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 201 more = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: 27 warnings emitted diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 00abb5f5e5c..d780e04e729 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -165,7 +165,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_feature = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sign-ext`, `simd128`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt` + = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` diff --git a/tests/ui/coherence/re-rebalance-coherence.rs b/tests/ui/coherence/re-rebalance-coherence.rs index 5383a634617..9c176d5b1b1 100644 --- a/tests/ui/coherence/re-rebalance-coherence.rs +++ b/tests/ui/coherence/re-rebalance-coherence.rs @@ -4,7 +4,6 @@ extern crate re_rebalance_coherence_lib as lib; use lib::*; -#[allow(dead_code)] struct Oracle; impl Backend for Oracle {} impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {} diff --git a/tests/ui/const-generics/cross_crate_complex.rs b/tests/ui/const-generics/cross_crate_complex.rs index b44d889f5e9..d13b69aa0cf 100644 --- a/tests/ui/const-generics/cross_crate_complex.rs +++ b/tests/ui/const-generics/cross_crate_complex.rs @@ -11,7 +11,6 @@ async fn foo() { async_in_foo(async_out_foo::<4>().await).await; } -#[allow(dead_code)] struct Faz<const N: usize>; impl<const N: usize> Foo<N> for Faz<N> {} diff --git a/tests/ui/const-generics/defaults/repr-c-issue-82792.rs b/tests/ui/const-generics/defaults/repr-c-issue-82792.rs index 4bf2fa761ea..c23187598bc 100644 --- a/tests/ui/const-generics/defaults/repr-c-issue-82792.rs +++ b/tests/ui/const-generics/defaults/repr-c-issue-82792.rs @@ -2,7 +2,6 @@ //@ run-pass -#[allow(dead_code)] #[repr(C)] pub struct Loaf<T: Sized, const N: usize = 1> { head: [T; N], diff --git a/tests/ui/const-generics/generic_const_exprs/associated-consts.rs b/tests/ui/const-generics/generic_const_exprs/associated-consts.rs index 50a6102c605..5d2198f50ad 100644 --- a/tests/ui/const-generics/generic_const_exprs/associated-consts.rs +++ b/tests/ui/const-generics/generic_const_exprs/associated-consts.rs @@ -16,8 +16,7 @@ impl BlockCipher for BarCipher { const BLOCK_SIZE: usize = 32; } -#[allow(dead_code)] -pub struct Block<C>(C); +pub struct Block<C>(#[allow(dead_code)] C); pub fn test<C: BlockCipher, const M: usize>() where diff --git a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs index 4ba696f4ae0..9f20cf08579 100644 --- a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs +++ b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.rs @@ -9,9 +9,10 @@ fn bug<const N: Nat>(&self) where for<const N: usize = 3, T = u32> [(); COT::BYTES]:, //~^ ERROR only lifetime parameters can be used in this context - //~^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders - //~^^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders - //~^^^^ ERROR failed to resolve: use of undeclared type `COT` + //~| ERROR defaults for generic parameters are not allowed in `for<...>` binders + //~| ERROR defaults for generic parameters are not allowed in `for<...>` binders + //~| ERROR failed to resolve: use of undeclared type `COT` + //~| ERROR the name `N` is already used for a generic parameter in this item's generic parameters { } diff --git a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr index ee0ec38ab06..6037e685e44 100644 --- a/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr +++ b/tests/ui/const-generics/generic_const_exprs/ice-predicates-of-no-entry-found-for-key-119275.stderr @@ -6,6 +6,15 @@ LL | fn bug<const N: Nat>(&self) | = note: associated functions are those in `impl` or `trait` definitions +error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters + --> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:15 + | +LL | fn bug<const N: Nat>(&self) + | - first use of `N` +... +LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:, + | ^ already used + error[E0412]: cannot find type `Nat` in this scope --> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:6:17 | @@ -40,7 +49,7 @@ error[E0433]: failed to resolve: use of undeclared type `COT` LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:, | ^^^ use of undeclared type `COT` -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors -Some errors have detailed explanations: E0412, E0433, E0658. -For more information about an error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0403, E0412, E0433, E0658. +For more information about an error, try `rustc --explain E0403`. diff --git a/tests/ui/const-generics/generic_const_exprs/issue-105608.stderr b/tests/ui/const-generics/generic_const_exprs/issue-105608.stderr index 09b618fb3f0..1c97eaddfe1 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-105608.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-105608.stderr @@ -4,10 +4,6 @@ error[E0282]: type annotations needed LL | Combination::<0>.and::<_>().and::<_>(); | ^^^ cannot infer type of the type parameter `M` declared on the method `and` | -help: consider specifying the generic argument - | -LL | Combination::<0>.and::<_>().and::<_>(); - | ~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-86535-2.rs b/tests/ui/const-generics/issues/issue-86535-2.rs index ab68c6b78df..8d064f3eeb1 100644 --- a/tests/ui/const-generics/issues/issue-86535-2.rs +++ b/tests/ui/const-generics/issues/issue-86535-2.rs @@ -9,7 +9,6 @@ pub trait Foo { [(); Self::ASSOC_C]:; } -#[allow(dead_code)] struct Bar<const N: &'static ()>; impl<const N: &'static ()> Foo for Bar<N> { const ASSOC_C: usize = 3; diff --git a/tests/ui/const-generics/issues/issue-86535.rs b/tests/ui/const-generics/issues/issue-86535.rs index 9aaf7ddc9e8..62454f4a388 100644 --- a/tests/ui/const-generics/issues/issue-86535.rs +++ b/tests/ui/const-generics/issues/issue-86535.rs @@ -2,7 +2,6 @@ #![feature(adt_const_params, unsized_const_params, generic_const_exprs)] #![allow(incomplete_features, unused_variables)] -#[allow(dead_code)] struct F<const S: &'static str>; impl<const S: &'static str> X for F<{ S }> { const W: usize = 3; diff --git a/tests/ui/const-generics/transparent-maybeunit-array-wrapper.rs b/tests/ui/const-generics/transparent-maybeunit-array-wrapper.rs index 35c41ae4615..419d605d0c8 100644 --- a/tests/ui/const-generics/transparent-maybeunit-array-wrapper.rs +++ b/tests/ui/const-generics/transparent-maybeunit-array-wrapper.rs @@ -6,7 +6,6 @@ use std::mem::MaybeUninit; -#[allow(dead_code)] #[repr(transparent)] pub struct MaybeUninitWrapper<const N: usize>(MaybeUninit<[u64; N]>); diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index 034e8bd1852..fad078ad2b2 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -118,7 +118,7 @@ LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 and there are only 4 bytes starting at that pointer + = note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 which is only 4 bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u32>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -177,7 +177,7 @@ LL | pub static R7: &[u16] = unsafe { error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 and there are only 7 bytes starting at that pointer + = note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u64>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 8a923779a5b..7f83dee6409 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -20,13 +20,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:22:9 | LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0 and there are only 3 bytes starting at that pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0 which is only 3 bytes from the end of the allocation error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:26:9 | LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC1 and there are only 3 bytes starting at that pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC1 which is only 3 bytes from the end of the allocation error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:30:9 diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 5fce25701bd..aeb46725c06 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -35,7 +35,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/raw-pointer-ub.rs:41:16 | LL | let _val = *ptr; - | ^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got ALLOC0 and there are only 4 bytes starting at that pointer + | ^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got ALLOC0 which is only 4 bytes from the end of the allocation error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index fe3060dda17..0e4926eb49e 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -13,7 +13,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-nonnull.rs:20:29 | LL | let out_of_bounds_ptr = &ptr[255]; - | ^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 255 bytes of memory, but got ALLOC1 and there are only 1 bytes starting at that pointer + | ^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 255 bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:24:1 diff --git a/tests/ui/consts/offset_from_ub.rs b/tests/ui/consts/offset_from_ub.rs index 66bb056ceb0..7efc5dd3e28 100644 --- a/tests/ui/consts/offset_from_ub.rs +++ b/tests/ui/consts/offset_from_ub.rs @@ -1,4 +1,4 @@ -//@ normalize-stderr-test: "to \d+ bytes of memory" -> "to $$BYTES bytes of memory" +//@ normalize-stderr-test: "\d+ bytes" -> "$$BYTES bytes" #![feature(const_ptr_sub_ptr)] #![feature(core_intrinsics)] @@ -55,7 +55,7 @@ const OUT_OF_BOUNDS_2: isize = { let end_ptr = (start_ptr).wrapping_add(length); // Second ptr is out of bounds unsafe { ptr_offset_from(start_ptr, end_ptr) } //~ERROR evaluation of constant value failed - //~| expected a pointer to 10 bytes of memory + //~| expected a pointer to the end of 10 bytes of memory }; pub const DIFFERENT_ALLOC_UNSIGNED: usize = { diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index f2f27735630..ac4597ff011 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -27,19 +27,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:39:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got 0x8[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to $BYTES bytes of memory, but got 0x8[noalloc] which is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:48:14 | LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got ALLOC0 and there are only 4 bytes starting at that pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to $BYTES bytes of memory, but got ALLOC0 which is only $BYTES bytes from the end of the allocation error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:57:14 | LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got ALLOC1 and there are only 4 bytes starting at that pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC1+0xa which does not have enough space to the beginning of the allocation error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:66:14 @@ -80,7 +80,7 @@ LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got a null pointer + = note: out-of-bounds `offset_from` origin: expected a pointer to $BYTES bytes of memory, but got a null pointer | note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/offset_ub.rs b/tests/ui/consts/offset_ub.rs index b239b91e11c..5026d9a2713 100644 --- a/tests/ui/consts/offset_ub.rs +++ b/tests/ui/consts/offset_ub.rs @@ -2,7 +2,7 @@ use std::ptr; //@ normalize-stderr-test: "0xf+" -> "0xf..f" //@ normalize-stderr-test: "0x7f+" -> "0x7f..f" -//@ normalize-stderr-test: "to \d+ bytes of memory" -> "to $$BYTES bytes of memory" +//@ normalize-stderr-test: "\d+ bytes" -> "$$BYTES bytes" pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; //~NOTE diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index b42d9482f8a..779cb9654f4 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -1,7 +1,7 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: overflowing in-bounds pointer arithmetic + = note: out-of-bounds pointer arithmetic: expected a pointer to the end of 1 byte of memory, but got ALLOC0 which is at the beginning of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -14,7 +14,7 @@ LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC0 and there are only 1 bytes starting at that pointer + = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -27,7 +27,7 @@ LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC1 and there are only 100 bytes starting at that pointer + = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC2 which is only $BYTES bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -40,7 +40,7 @@ LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: overflowing in-bounds pointer arithmetic + = note: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` | note: inside `std::ptr::const_ptr::<impl *const u16>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -53,7 +53,7 @@ LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize:: error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: overflowing in-bounds pointer arithmetic + = note: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` | note: inside `std::ptr::const_ptr::<impl *const u16>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -66,7 +66,7 @@ LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize: error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: overflowing in-bounds pointer arithmetic + = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -79,7 +79,7 @@ LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *cons error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: overflowing in-bounds pointer arithmetic + = note: out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -92,7 +92,7 @@ LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).of error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC2-0x4 which points to before the beginning of the allocation + = note: out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC3-0x2 which points to before the beginning of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -105,7 +105,7 @@ LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC3 which is at or beyond the end of the allocation of size 0 bytes + = note: out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -131,7 +131,7 @@ LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x7f..f[noalloc] which is a dangling pointer (it has no provenance) + = note: out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/coroutine/invalid_attr_usage.rs b/tests/ui/coroutine/invalid_attr_usage.rs new file mode 100644 index 00000000000..995a3aa3100 --- /dev/null +++ b/tests/ui/coroutine/invalid_attr_usage.rs @@ -0,0 +1,11 @@ +//! The `coroutine` attribute is only allowed on closures. + +#![feature(coroutines)] + +#[coroutine] +//~^ ERROR: attribute should be applied to closures +struct Foo; + +#[coroutine] +//~^ ERROR: attribute should be applied to closures +fn main() {} diff --git a/tests/ui/coroutine/invalid_attr_usage.stderr b/tests/ui/coroutine/invalid_attr_usage.stderr new file mode 100644 index 00000000000..316a0117e5d --- /dev/null +++ b/tests/ui/coroutine/invalid_attr_usage.stderr @@ -0,0 +1,14 @@ +error: attribute should be applied to closures + --> $DIR/invalid_attr_usage.rs:5:1 + | +LL | #[coroutine] + | ^^^^^^^^^^^^ + +error: attribute should be applied to closures + --> $DIR/invalid_attr_usage.rs:9:1 + | +LL | #[coroutine] + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/delegation/explicit-paths.rs b/tests/ui/delegation/explicit-paths.rs index d42e305b252..3b0454eb524 100644 --- a/tests/ui/delegation/explicit-paths.rs +++ b/tests/ui/delegation/explicit-paths.rs @@ -22,9 +22,7 @@ mod fn_to_other { use super::*; reuse Trait::foo1; - //~^ ERROR delegation to a trait method from a free function is not supported yet reuse <S as Trait>::foo2; - //~^ ERROR delegation to a trait method from a free function is not supported yet reuse to_reuse::foo3; reuse S::foo4; //~^ ERROR cannot find function `foo4` in `S` diff --git a/tests/ui/delegation/explicit-paths.stderr b/tests/ui/delegation/explicit-paths.stderr index b5afe19f878..8098ea8c54f 100644 --- a/tests/ui/delegation/explicit-paths.stderr +++ b/tests/ui/delegation/explicit-paths.stderr @@ -1,5 +1,5 @@ error[E0407]: method `foo3` is not a member of trait `Trait` - --> $DIR/explicit-paths.rs:51:9 + --> $DIR/explicit-paths.rs:49:9 | LL | reuse to_reuse::foo3; | ^^^^^^^^^^^^^^^^----^ @@ -8,7 +8,7 @@ LL | reuse to_reuse::foo3; | not a member of trait `Trait` error[E0407]: method `foo4` is not a member of trait `Trait` - --> $DIR/explicit-paths.rs:53:9 + --> $DIR/explicit-paths.rs:51:9 | LL | reuse F::foo4 { &self.0 } | ^^^^^^^^^----^^^^^^^^^^^^ @@ -17,49 +17,49 @@ LL | reuse F::foo4 { &self.0 } | not a member of trait `Trait` error[E0425]: cannot find function `foo4` in `S` - --> $DIR/explicit-paths.rs:29:14 + --> $DIR/explicit-paths.rs:27:14 | LL | reuse S::foo4; | ^^^^ not found in `S` error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:40:18 + --> $DIR/explicit-paths.rs:38:18 | LL | reuse F::foo4 { &self.0 } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:29:5 + --> $DIR/explicit-paths.rs:27:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:53:18 + --> $DIR/explicit-paths.rs:51:18 | LL | reuse F::foo4 { &self.0 } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:29:5 + --> $DIR/explicit-paths.rs:27:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:67:18 + --> $DIR/explicit-paths.rs:65:18 | LL | reuse F::foo4 { &F } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:29:5 + --> $DIR/explicit-paths.rs:27:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0119]: conflicting implementations of trait `Trait` for type `S` - --> $DIR/explicit-paths.rs:76:5 + --> $DIR/explicit-paths.rs:74:5 | LL | impl Trait for S { | ---------------- first implementation here @@ -67,26 +67,8 @@ LL | impl Trait for S { LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ conflicting implementation for `S` -error: delegation to a trait method from a free function is not supported yet - --> $DIR/explicit-paths.rs:24:18 - | -LL | fn foo1(&self, x: i32) -> i32 { x } - | ----------------------------- callee defined here -... -LL | reuse Trait::foo1; - | ^^^^ - -error: delegation to a trait method from a free function is not supported yet - --> $DIR/explicit-paths.rs:26:25 - | -LL | fn foo2(x: i32) -> i32 { x } - | ---------------------- callee defined here -... -LL | reuse <S as Trait>::foo2; - | ^^^^ - error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:63:36 + --> $DIR/explicit-paths.rs:61:36 | LL | trait Trait2 : Trait { | -------------------- found this type parameter @@ -104,7 +86,7 @@ LL | fn foo1(&self, x: i32) -> i32 { x } | ^^^^ ----- error[E0277]: the trait bound `S2: Trait` is not satisfied - --> $DIR/explicit-paths.rs:78:16 + --> $DIR/explicit-paths.rs:76:16 | LL | reuse <S2 as Trait>::foo1; | ^^ the trait `Trait` is not implemented for `S2` @@ -114,7 +96,7 @@ LL | reuse <S2 as Trait>::foo1; S error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:78:30 + --> $DIR/explicit-paths.rs:76:30 | LL | reuse <S2 as Trait>::foo1; | ^^^^ @@ -130,7 +112,7 @@ note: method defined here LL | fn foo1(&self, x: i32) -> i32 { x } | ^^^^ ----- -error: aborting due to 12 previous errors +error: aborting due to 10 previous errors Some errors have detailed explanations: E0119, E0277, E0308, E0407, E0425. For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs b/tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs new file mode 100644 index 00000000000..625bbdd758c --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs @@ -0,0 +1,28 @@ +//@ run-pass +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod to_reuse { + pub fn types<T, U>(x: U, y: T) -> (T, U) { + (y, x) + } + pub fn late<'a, 'b>(x: &'a u8, y: &'b u8) -> u8 { + *x + *y + } + pub fn early<'a: 'a>(x: &'a str) -> &'a str { + x + } +} + +reuse to_reuse::types; +reuse to_reuse::late; +reuse to_reuse::early; + +fn main() { + assert_eq!(types(0, "str"), ("str", 0)); + assert_eq!(late(&1u8, &2u8), 3); + { + let s: &'static str = "hello world"; + assert_eq!(early::<'static>(s), "hello world"); + } +} diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn.rs b/tests/ui/delegation/generics/free-fn-to-free-fn.rs new file mode 100644 index 00000000000..3741ad66485 --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-free-fn.rs @@ -0,0 +1,27 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod to_reuse { + pub fn consts<const N: i32>() -> i32 { + N + } + pub fn late<'a>(x: &'a u8) -> u8 { + *x + } + pub fn bounds<T: Clone>(_: T) {} +} + +// FIXME(fn_delegation): this is supposed to work eventually +reuse to_reuse::consts; +//~^ ERROR type annotations needed +reuse to_reuse::late; +reuse to_reuse::bounds; + +fn main() { + late::<'static>(&0u8); + //~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + + struct S; + bounds(S); + //~^ ERROR the trait bound `S: Clone` is not satisfied +} diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn.stderr b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr new file mode 100644 index 00000000000..5ba56ce1718 --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr @@ -0,0 +1,54 @@ +error[E0284]: type annotations needed + --> $DIR/free-fn-to-free-fn.rs:15:17 + | +LL | reuse to_reuse::consts; + | ^^^^^^ cannot infer the value of the const parameter `N` declared on the function `consts` + | +note: required by a const generic parameter in `to_reuse::consts` + --> $DIR/free-fn-to-free-fn.rs:5:19 + | +LL | pub fn consts<const N: i32>() -> i32 { + | ^^^^^^^^^^^^ required by this const generic parameter in `consts` +help: consider specifying the generic argument + | +LL | reuse to_reuse::consts::<N>; + | +++++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/free-fn-to-free-fn.rs:21:12 + | +LL | late::<'static>(&0u8); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/free-fn-to-free-fn.rs:8:17 + | +LL | pub fn late<'a>(x: &'a u8) -> u8 { + | ^^ + +error[E0277]: the trait bound `S: Clone` is not satisfied + --> $DIR/free-fn-to-free-fn.rs:25:12 + | +LL | bounds(S); + | ------ ^ the trait `Clone` is not implemented for `S` + | | + | required by a bound introduced by this call + | +note: required by a bound in `bounds` + --> $DIR/free-fn-to-free-fn.rs:11:22 + | +LL | pub fn bounds<T: Clone>(_: T) {} + | ^^^^^ required by this bound in `bounds` +... +LL | reuse to_reuse::bounds; + | ------ required by a bound in this function +help: consider annotating `S` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct S; + | + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0284, E0794. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs b/tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs new file mode 100644 index 00000000000..f7b7c09e2ca --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs @@ -0,0 +1,30 @@ +//@ run-pass +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod types { + pub trait Trait<T> { + fn foo<U>(&self, x: U, y: T) -> (T, U) {(y, x)} + } + impl<T> Trait<T> for u8 {} +} + +mod types_and_lifetimes { + pub trait Trait<'a, T> { + fn foo<'b, U>(&self, _: &'b U, _: &'a T) -> bool { + true + } + } + impl<'a, T> Trait<'a, T> for u8 {} +} + +reuse types::Trait::foo as types; +reuse types_and_lifetimes::Trait::foo as types_and_lifetimes; + +fn main() { + assert_eq!(types(&2, "str", 1), (1, "str")); + + struct T; + struct U; + assert_eq!(types_and_lifetimes::<u8, T, U>(&1, &U, &T), true); +} diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method.rs b/tests/ui/delegation/generics/free-fn-to-trait-method.rs new file mode 100644 index 00000000000..70be1a4ace7 --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-trait-method.rs @@ -0,0 +1,56 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod default_param { + pub trait Trait<T = u32> { + fn foo(&self, _: T) {} + } + + impl<T> Trait<T> for u8 {} +} + +mod types_and_lifetimes { + pub trait Trait<'a, T> { + fn foo<'b: 'b>(&'a self, x: &'b T) { + loop {} + } + } + impl<'a, T> Trait<'a, T> for u8 {} +} + +mod bounds { + pub trait Trait<T> { + fn foo<U: Clone>(&self, t: T, u: U) where T: Copy {} + } + + impl<T> Trait<T> for u8 {} +} + +mod generic_arguments { + trait Trait<T> { + fn foo<U>(&self, _: U, _: T) {} + } + + impl<T> Trait<T> for u8 {} + + reuse Trait::<_>::foo::<i32> as generic_arguments1; + //~^ ERROR mismatched types + reuse <u8 as Trait<_>>::foo as generic_arguments2; + //~^ ERROR mismatched types + reuse <_ as Trait<_>>::foo as generic_arguments3; // OK +} + +reuse default_param::Trait::foo as default_param; +reuse types_and_lifetimes::Trait::foo as types_and_lifetimes; +reuse bounds::Trait::foo as bounds; + +fn main() { + default_param(&0u8, "hello world"); // OK, default params are not substituted + types_and_lifetimes::<'static, 'static, _, _>(&0u8, &0u16); // OK, lifetimes go first + + struct S; + struct U; + bounds(&0u8, S, U); + //~^ ERROR the trait bound `S: Copy` is not satisfied + //~| ERROR the trait bound `U: Clone` is not satisfied +} diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method.stderr b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr new file mode 100644 index 00000000000..d8299d00c7e --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr @@ -0,0 +1,88 @@ +error[E0308]: mismatched types + --> $DIR/free-fn-to-trait-method.rs:36:23 + | +LL | fn foo<U>(&self, _: U, _: T) {} + | - found this type parameter +... +LL | reuse Trait::<_>::foo::<i32> as generic_arguments1; + | ^^^ + | | + | expected `i32`, found type parameter `U` + | arguments to this function are incorrect + | + = note: expected type `i32` + found type parameter `U` +note: method defined here + --> $DIR/free-fn-to-trait-method.rs:31:12 + | +LL | fn foo<U>(&self, _: U, _: T) {} + | ^^^ ---- + +error[E0308]: mismatched types + --> $DIR/free-fn-to-trait-method.rs:38:29 + | +LL | trait Trait<T> { + | -------------- found this type parameter +... +LL | reuse <u8 as Trait<_>>::foo as generic_arguments2; + | ^^^ + | | + | expected `&u8`, found `&Self` + | arguments to this function are incorrect + | + = note: expected reference `&u8` + found reference `&Self` +note: method defined here + --> $DIR/free-fn-to-trait-method.rs:31:12 + | +LL | fn foo<U>(&self, _: U, _: T) {} + | ^^^ ----- + +error[E0277]: the trait bound `S: Copy` is not satisfied + --> $DIR/free-fn-to-trait-method.rs:53:18 + | +LL | bounds(&0u8, S, U); + | ------ ^ the trait `Copy` is not implemented for `S` + | | + | required by a bound introduced by this call + | +note: required by a bound in `bounds` + --> $DIR/free-fn-to-trait-method.rs:23:54 + | +LL | fn foo<U: Clone>(&self, t: T, u: U) where T: Copy {} + | ^^^^ required by this bound in `bounds` +... +LL | reuse bounds::Trait::foo as bounds; + | ------ required by a bound in this function +help: consider annotating `S` with `#[derive(Copy)]` + | +LL + #[derive(Copy)] +LL | struct S; + | + +error[E0277]: the trait bound `U: Clone` is not satisfied + --> $DIR/free-fn-to-trait-method.rs:53:21 + | +LL | bounds(&0u8, S, U); + | ------ ^ the trait `Clone` is not implemented for `U` + | | + | required by a bound introduced by this call + | +note: required by a bound in `bounds` + --> $DIR/free-fn-to-trait-method.rs:23:19 + | +LL | fn foo<U: Clone>(&self, t: T, u: U) where T: Copy {} + | ^^^^^ required by this bound in `bounds` +... +LL | reuse bounds::Trait::foo as bounds; + | ------ required by a bound in this function +help: consider annotating `U` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct U; + | + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/ice-issue-124347.rs b/tests/ui/delegation/ice-issue-124347.rs index 82a96055099..3bfae8face5 100644 --- a/tests/ui/delegation/ice-issue-124347.rs +++ b/tests/ui/delegation/ice-issue-124347.rs @@ -6,7 +6,8 @@ trait Trait { //~^ ERROR recursive delegation is not supported yet } +// FIXME(fn_delegation): `recursive delegation` error should be emitted here reuse foo; -//~^ ERROR recursive delegation is not supported yet +//~^ ERROR cycle detected when computing generics of `foo` fn main() {} diff --git a/tests/ui/delegation/ice-issue-124347.stderr b/tests/ui/delegation/ice-issue-124347.stderr index 5a3f4525d29..87dd75ffec8 100644 --- a/tests/ui/delegation/ice-issue-124347.stderr +++ b/tests/ui/delegation/ice-issue-124347.stderr @@ -4,11 +4,20 @@ error: recursive delegation is not supported yet LL | reuse Trait::foo { &self.0 } | ^^^ callee defined here -error: recursive delegation is not supported yet - --> $DIR/ice-issue-124347.rs:9:7 +error[E0391]: cycle detected when computing generics of `foo` + --> $DIR/ice-issue-124347.rs:10:7 + | +LL | reuse foo; + | ^^^ + | + = note: ...which immediately requires computing generics of `foo` again +note: cycle used when checking that `foo` is well-formed + --> $DIR/ice-issue-124347.rs:10:7 | LL | reuse foo; - | ^^^ callee defined here + | ^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/delegation/not-supported.rs b/tests/ui/delegation/not-supported.rs index 25d7a4cb895..5701cc6055d 100644 --- a/tests/ui/delegation/not-supported.rs +++ b/tests/ui/delegation/not-supported.rs @@ -1,4 +1,6 @@ +#![feature(const_trait_impl)] #![feature(c_variadic)] +#![feature(effects)] #![feature(fn_delegation)] #![allow(incomplete_features)] @@ -14,9 +16,9 @@ mod generics { fn foo3<'a: 'a>(_: &'a u32) {} reuse GenericTrait::bar; - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items reuse GenericTrait::bar1; - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items } struct F; @@ -27,37 +29,37 @@ mod generics { impl<T> GenericTrait<T> for S { reuse <F as GenericTrait<T>>::bar { &self.0 } - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items reuse GenericTrait::<T>::bar1; - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items } impl GenericTrait<()> for () { reuse GenericTrait::bar { &F } - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items reuse GenericTrait::bar1; - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items } impl Trait for &S { reuse Trait::foo; - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items } impl Trait for S { reuse Trait::foo1 { &self.0 } reuse Trait::foo2 { &self.0 } - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items //~| ERROR method `foo2` has 0 type parameters but its trait declaration has 1 type parameter reuse <F as Trait>::foo3; - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items //~| ERROR lifetime parameters or bounds on method `foo3` do not match the trait declaration } struct GenericS<T>(T); impl<T> Trait for GenericS<T> { reuse Trait::foo { &self.0 } - //~^ ERROR delegation with early bound generics is not supported yet + //~^ ERROR early bound generics are not supported for associated delegation items } } @@ -68,13 +70,10 @@ mod opaque { mod to_reuse { use super::Trait; - pub fn opaque_arg(_: impl Trait) -> i32 { 0 } pub fn opaque_ret() -> impl Trait { unimplemented!() } //~^ warn: this function depends on never type fallback being `()` //~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } - reuse to_reuse::opaque_arg; - //~^ ERROR delegation with early bound generics is not supported yet trait ToReuse { fn opaque_ret() -> impl Trait { unimplemented!() } @@ -104,4 +103,14 @@ mod recursive { //~^ ERROR recursive delegation is not supported yet } +mod effects { + #[const_trait] + trait Trait { + fn foo(); + } + + reuse Trait::foo; + //~^ ERROR delegation to a function with effect parameter is not supported yet +} + fn main() {} diff --git a/tests/ui/delegation/not-supported.stderr b/tests/ui/delegation/not-supported.stderr index 4ce01fd5d88..e7ba9fc6719 100644 --- a/tests/ui/delegation/not-supported.stderr +++ b/tests/ui/delegation/not-supported.stderr @@ -1,5 +1,10 @@ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:16:29 +error: using `#![feature(effects)]` without enabling next trait solver globally + | + = note: the next trait solver must be enabled globally for the effects feature to work correctly + = help: use `-Znext-solver` to enable + +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:18:29 | LL | fn bar(&self, x: T) -> T { x } | ------------------------ callee defined here @@ -7,8 +12,8 @@ LL | fn bar(&self, x: T) -> T { x } LL | reuse GenericTrait::bar; | ^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:18:29 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:20:29 | LL | fn bar1() {} | --------- callee defined here @@ -16,8 +21,8 @@ LL | fn bar1() {} LL | reuse GenericTrait::bar1; | ^^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:29:39 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:31:39 | LL | fn bar(&self, x: T) -> T { x } | ------------------------ callee defined here @@ -25,8 +30,8 @@ LL | fn bar(&self, x: T) -> T { x } LL | reuse <F as GenericTrait<T>>::bar { &self.0 } | ^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:31:34 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:33:34 | LL | fn bar1() {} | --------- callee defined here @@ -34,8 +39,8 @@ LL | fn bar1() {} LL | reuse GenericTrait::<T>::bar1; | ^^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:36:29 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:38:29 | LL | fn bar(&self, x: T) -> T { x } | ------------------------ callee defined here @@ -43,8 +48,8 @@ LL | fn bar(&self, x: T) -> T { x } LL | reuse GenericTrait::bar { &F } | ^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:38:29 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:40:29 | LL | fn bar1() {} | --------- callee defined here @@ -52,8 +57,8 @@ LL | fn bar1() {} LL | reuse GenericTrait::bar1; | ^^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:43:22 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:45:22 | LL | fn foo(&self, x: i32) -> i32 { x } | ---------------------------- callee defined here @@ -62,7 +67,7 @@ LL | reuse Trait::foo; | ^^^ error[E0049]: method `foo2` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/not-supported.rs:49:22 + --> $DIR/not-supported.rs:51:22 | LL | fn foo2<T>(&self, x: T) -> T { x } | - expected 1 type parameter @@ -70,8 +75,8 @@ LL | fn foo2<T>(&self, x: T) -> T { x } LL | reuse Trait::foo2 { &self.0 } | ^^^^ found 0 type parameters -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:52:29 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:54:29 | LL | fn foo3<'a: 'a>(_: &'a u32) {} | --------------------------- callee defined here @@ -80,7 +85,7 @@ LL | reuse <F as Trait>::foo3; | ^^^^ error[E0195]: lifetime parameters or bounds on method `foo3` do not match the trait declaration - --> $DIR/not-supported.rs:52:29 + --> $DIR/not-supported.rs:54:29 | LL | fn foo3<'a: 'a>(_: &'a u32) {} | -------- lifetimes in impl do not match this method in trait @@ -88,8 +93,17 @@ LL | fn foo3<'a: 'a>(_: &'a u32) {} LL | reuse <F as Trait>::foo3; | ^^^^ lifetimes do not match method in trait -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:59:22 +error: delegation to a function with effect parameter is not supported yet + --> $DIR/not-supported.rs:112:18 + | +LL | fn foo(); + | --------- callee defined here +... +LL | reuse Trait::foo; + | ^^^ + +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:61:22 | LL | fn foo(&self, x: i32) -> i32 { x } | ---------------------------- callee defined here @@ -97,8 +111,8 @@ LL | fn foo(&self, x: i32) -> i32 { x } LL | reuse Trait::foo { &self.0 } | ^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:49:22 +error: early bound generics are not supported for associated delegation items + --> $DIR/not-supported.rs:51:22 | LL | fn foo2<T>(&self, x: T) -> T { x } | ---------------------------- callee defined here @@ -106,17 +120,8 @@ LL | fn foo2<T>(&self, x: T) -> T { x } LL | reuse Trait::foo2 { &self.0 } | ^^^^ -error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:76:21 - | -LL | pub fn opaque_arg(_: impl Trait) -> i32 { 0 } - | --------------------------------------- callee defined here -... -LL | reuse to_reuse::opaque_arg; - | ^^^^^^^^^^ - warning: this function depends on never type fallback being `()` - --> $DIR/not-supported.rs:80:9 + --> $DIR/not-supported.rs:79:9 | LL | fn opaque_ret() -> impl Trait { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -125,33 +130,33 @@ LL | fn opaque_ret() -> impl Trait { unimplemented!() } = note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> = help: specify the types explicitly note: in edition 2024, the requirement `!: opaque::Trait` will fail - --> $DIR/not-supported.rs:80:28 + --> $DIR/not-supported.rs:79:28 | LL | fn opaque_ret() -> impl Trait { unimplemented!() } | ^^^^^^^^^^ = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default -error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/not-supported.rs:86:5: 86:24>::{synthetic#0}` - --> $DIR/not-supported.rs:87:25 +error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/not-supported.rs:85:5: 85:24>::{synthetic#0}` + --> $DIR/not-supported.rs:86:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/not-supported.rs:87:25 + --> $DIR/not-supported.rs:86:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::<impl at $DIR/not-supported.rs:86:5: 86:24>::{synthetic#0}`, completing the cycle -note: cycle used when checking that `opaque::<impl at $DIR/not-supported.rs:86:5: 86:24>` is well-formed - --> $DIR/not-supported.rs:86:5 + = note: ...which again requires computing type of `opaque::<impl at $DIR/not-supported.rs:85:5: 85:24>::{synthetic#0}`, completing the cycle +note: cycle used when checking that `opaque::<impl at $DIR/not-supported.rs:85:5: 85:24>` is well-formed + --> $DIR/not-supported.rs:85:5 | LL | impl ToReuse for u8 { | ^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information warning: this function depends on never type fallback being `()` - --> $DIR/not-supported.rs:72:9 + --> $DIR/not-supported.rs:73:9 | LL | pub fn opaque_ret() -> impl Trait { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -160,32 +165,32 @@ LL | pub fn opaque_ret() -> impl Trait { unimplemented!() } = note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> = help: specify the types explicitly note: in edition 2024, the requirement `!: opaque::Trait` will fail - --> $DIR/not-supported.rs:72:32 + --> $DIR/not-supported.rs:73:32 | LL | pub fn opaque_ret() -> impl Trait { unimplemented!() } | ^^^^^^^^^^ -error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/not-supported.rs:89:5: 89:25>::{synthetic#0}` - --> $DIR/not-supported.rs:90:24 +error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/not-supported.rs:88:5: 88:25>::{synthetic#0}` + --> $DIR/not-supported.rs:89:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/not-supported.rs:90:24 + --> $DIR/not-supported.rs:89:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::<impl at $DIR/not-supported.rs:89:5: 89:25>::{synthetic#0}`, completing the cycle -note: cycle used when checking that `opaque::<impl at $DIR/not-supported.rs:89:5: 89:25>` is well-formed - --> $DIR/not-supported.rs:89:5 + = note: ...which again requires computing type of `opaque::<impl at $DIR/not-supported.rs:88:5: 88:25>::{synthetic#0}`, completing the cycle +note: cycle used when checking that `opaque::<impl at $DIR/not-supported.rs:88:5: 88:25>` is well-formed + --> $DIR/not-supported.rs:88:5 | LL | impl ToReuse for u16 { | ^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: recursive delegation is not supported yet - --> $DIR/not-supported.rs:103:22 + --> $DIR/not-supported.rs:102:22 | LL | pub reuse to_reuse2::foo; | --- callee defined here @@ -193,7 +198,7 @@ LL | pub reuse to_reuse2::foo; LL | reuse to_reuse1::foo; | ^^^ -error: aborting due to 16 previous errors; 2 warnings emitted +error: aborting due to 17 previous errors; 2 warnings emitted Some errors have detailed explanations: E0049, E0195, E0391. For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/delegation/target-expr.rs b/tests/ui/delegation/target-expr.rs index fd7ea943b9d..f766ca7356a 100644 --- a/tests/ui/delegation/target-expr.rs +++ b/tests/ui/delegation/target-expr.rs @@ -14,9 +14,7 @@ fn foo(x: i32) -> i32 { x } fn bar<T: Default>(_: T) { reuse Trait::static_method { - //~^ ERROR delegation to a trait method from a free function is not supported yet - //~| ERROR delegation with early bound generics is not supported yet - //~| ERROR mismatched types + //~^ ERROR mismatched types let _ = T::Default(); //~^ ERROR can't use generic parameters from outer item } @@ -25,7 +23,6 @@ fn bar<T: Default>(_: T) { fn main() { let y = 0; reuse <S as Trait>::static_method { - //~^ ERROR delegation to a trait method from a free function is not supported yet let x = y; //~^ ERROR can't capture dynamic environment in a fn item foo(self); diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr index b30f0c474c6..f5556bf9f45 100644 --- a/tests/ui/delegation/target-expr.stderr +++ b/tests/ui/delegation/target-expr.stderr @@ -1,16 +1,16 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/target-expr.rs:20:17 + --> $DIR/target-expr.rs:18:17 | LL | fn bar<T: Default>(_: T) { | - type parameter from outer item LL | reuse Trait::static_method { | - help: try introducing a local generic parameter here: `T,` -... +LL | LL | let _ = T::Default(); | ^^^^^^^^^^ use of generic parameter from outer item error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/target-expr.rs:29:17 + --> $DIR/target-expr.rs:26:17 | LL | let x = y; | ^ @@ -18,7 +18,7 @@ LL | let x = y; = help: use the `|| { ... }` closure form instead error[E0424]: expected value, found module `self` - --> $DIR/target-expr.rs:36:5 + --> $DIR/target-expr.rs:33:5 | LL | fn main() { | ---- this function can't have a `self` parameter @@ -27,58 +27,29 @@ LL | self.0; | ^^^^ `self` value is a keyword only available in methods with a `self` parameter error[E0425]: cannot find value `x` in this scope - --> $DIR/target-expr.rs:38:13 + --> $DIR/target-expr.rs:35:13 | LL | let z = x; | ^ | help: the binding `x` is available in a different scope in the same function - --> $DIR/target-expr.rs:29:13 + --> $DIR/target-expr.rs:26:13 | LL | let x = y; | ^ -error: delegation with early bound generics is not supported yet - --> $DIR/target-expr.rs:16:18 - | -LL | fn static_method(x: i32) -> i32 { x } - | ------------------------------- callee defined here -... -LL | reuse Trait::static_method { - | ^^^^^^^^^^^^^ - -error: delegation to a trait method from a free function is not supported yet - --> $DIR/target-expr.rs:16:18 - | -LL | fn static_method(x: i32) -> i32 { x } - | ------------------------------- callee defined here -... -LL | reuse Trait::static_method { - | ^^^^^^^^^^^^^ - -error: delegation to a trait method from a free function is not supported yet - --> $DIR/target-expr.rs:27:25 - | -LL | fn static_method(x: i32) -> i32 { x } - | ------------------------------- callee defined here -... -LL | reuse <S as Trait>::static_method { - | ^^^^^^^^^^^^^ - error[E0308]: mismatched types --> $DIR/target-expr.rs:16:32 | LL | reuse Trait::static_method { | ________________________________^ LL | | -LL | | -LL | | LL | | let _ = T::Default(); LL | | LL | | } | |_____^ expected `i32`, found `()` -error: aborting due to 8 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0308, E0401, E0424, E0425, E0434. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/derives/deriving-with-repr-packed.rs b/tests/ui/derives/deriving-with-repr-packed.rs index 58be4519720..d17b52842ce 100644 --- a/tests/ui/derives/deriving-with-repr-packed.rs +++ b/tests/ui/derives/deriving-with-repr-packed.rs @@ -22,25 +22,22 @@ struct Y(usize); struct X(Y); //~^ ERROR cannot move out of `self` which is behind a shared reference -// This is currently allowed, but will be phased out at some point. From -// `zerovec` within icu4x-0.9.0. #[derive(Debug)] #[repr(packed)] struct FlexZeroSlice { width: u8, data: [u8], - //~^ WARNING byte slice in a packed struct that derives a built-in trait - //~^^ this was previously accepted + //~^ ERROR cannot move + //~| ERROR cannot move } -// Again, currently allowed, but will be phased out. #[derive(Debug)] #[repr(packed)] struct WithStr { width: u8, data: str, - //~^ WARNING string slice in a packed struct that derives a built-in trait - //~^^ this was previously accepted + //~^ ERROR cannot move + //~| ERROR cannot move } fn main() {} diff --git a/tests/ui/derives/deriving-with-repr-packed.stderr b/tests/ui/derives/deriving-with-repr-packed.stderr index a8523d25cab..321ffb27eeb 100644 --- a/tests/ui/derives/deriving-with-repr-packed.stderr +++ b/tests/ui/derives/deriving-with-repr-packed.stderr @@ -1,32 +1,3 @@ -warning: byte slice in a packed struct that derives a built-in trait - --> $DIR/deriving-with-repr-packed.rs:31:5 - | -LL | #[derive(Debug)] - | ----- in this derive macro expansion -... -LL | data: [u8], - | ^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default - = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: string slice in a packed struct that derives a built-in trait - --> $DIR/deriving-with-repr-packed.rs:41:5 - | -LL | #[derive(Debug)] - | ----- in this derive macro expansion -... -LL | data: str, - | ^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0507]: cannot move out of `self` which is behind a shared reference --> $DIR/deriving-with-repr-packed.rs:22:10 | @@ -47,38 +18,43 @@ LL | struct X(Y); = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error; 2 warnings emitted +error[E0161]: cannot move a value of type `[u8]` + --> $DIR/deriving-with-repr-packed.rs:29:5 + | +LL | data: [u8], + | ^^^^^^^^^^ the size of `[u8]` cannot be statically determined -For more information about this error, try `rustc --explain E0507`. -Future incompatibility report: Future breakage diagnostic: -warning: byte slice in a packed struct that derives a built-in trait - --> $DIR/deriving-with-repr-packed.rs:31:5 +error[E0507]: cannot move out of `self.data` which is behind a shared reference + --> $DIR/deriving-with-repr-packed.rs:29:5 | LL | #[derive(Debug)] | ----- in this derive macro expansion ... LL | data: [u8], - | ^^^^^^^^^^ + | ^^^^^^^^^^ move occurs because `self.data` has type `[u8]`, which does not implement the `Copy` trait + | + = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour + = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0161]: cannot move a value of type `str` + --> $DIR/deriving-with-repr-packed.rs:38:5 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default - = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | data: str, + | ^^^^^^^^^ the size of `str` cannot be statically determined -Future breakage diagnostic: -warning: string slice in a packed struct that derives a built-in trait - --> $DIR/deriving-with-repr-packed.rs:41:5 +error[E0507]: cannot move out of `self.data` which is behind a shared reference + --> $DIR/deriving-with-repr-packed.rs:38:5 | LL | #[derive(Debug)] | ----- in this derive macro expansion ... LL | data: str, - | ^^^^^^^^^ + | ^^^^^^^^^ move occurs because `self.data` has type `str`, which does not implement the `Copy` trait | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default - = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour + = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors +Some errors have detailed explanations: E0161, E0507. +For more information about an error, try `rustc --explain E0161`. diff --git a/tests/ui/deriving/deriving-all-codegen.rs b/tests/ui/deriving/deriving-all-codegen.rs index 6fa4f74f2a5..eab2b4f1f53 100644 --- a/tests/ui/deriving/deriving-all-codegen.rs +++ b/tests/ui/deriving/deriving-all-codegen.rs @@ -73,16 +73,6 @@ impl Copy for PackedManualCopy {} #[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] struct Unsized([u32]); -// A packed struct with an unsized `[u8]` field. This is currently allowed, but -// causes a warning and will be phased out at some point. -#[derive(Debug, Hash)] -#[repr(packed)] -struct PackedUnsizedU8([u8]); -//~^ WARNING byte slice in a packed struct that derives a built-in trait -//~^^ WARNING byte slice in a packed struct that derives a built-in trait -//~^^^ this was previously accepted -//~^^^^ this was previously accepted - trait Trait { type A; } diff --git a/tests/ui/deriving/deriving-all-codegen.stderr b/tests/ui/deriving/deriving-all-codegen.stderr deleted file mode 100644 index 503f0cae73b..00000000000 --- a/tests/ui/deriving/deriving-all-codegen.stderr +++ /dev/null @@ -1,63 +0,0 @@ -warning: byte slice in a packed struct that derives a built-in trait - --> $DIR/deriving-all-codegen.rs:80:24 - | -LL | #[derive(Debug, Hash)] - | ----- in this derive macro expansion -LL | #[repr(packed)] -LL | struct PackedUnsizedU8([u8]); - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default - = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: byte slice in a packed struct that derives a built-in trait - --> $DIR/deriving-all-codegen.rs:80:24 - | -LL | #[derive(Debug, Hash)] - | ---- in this derive macro expansion -LL | #[repr(packed)] -LL | struct PackedUnsizedU8([u8]); - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: this warning originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: 2 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: byte slice in a packed struct that derives a built-in trait - --> $DIR/deriving-all-codegen.rs:80:24 - | -LL | #[derive(Debug, Hash)] - | ----- in this derive macro expansion -LL | #[repr(packed)] -LL | struct PackedUnsizedU8([u8]); - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default - = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -warning: byte slice in a packed struct that derives a built-in trait - --> $DIR/deriving-all-codegen.rs:80:24 - | -LL | #[derive(Debug, Hash)] - | ---- in this derive macro expansion -LL | #[repr(packed)] -LL | struct PackedUnsizedU8([u8]); - | ^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #107457 <https://github.com/rust-lang/rust/issues/107457> - = help: consider implementing the trait by hand, or remove the `packed` attribute - = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default - = note: this warning originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) - diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index 6b69b57c516..6503c870990 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -516,26 +516,6 @@ impl ::core::cmp::Ord for Unsized { } } -// A packed struct with an unsized `[u8]` field. This is currently allowed, but -// causes a warning and will be phased out at some point. -#[repr(packed)] -struct PackedUnsizedU8([u8]); -#[automatically_derived] -impl ::core::fmt::Debug for PackedUnsizedU8 { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::debug_tuple_field1_finish(f, - "PackedUnsizedU8", &&self.0) - } -} -#[automatically_derived] -impl ::core::hash::Hash for PackedUnsizedU8 { - #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { - ::core::hash::Hash::hash(&self.0, state) - } -} - trait Trait { type A; } diff --git a/tests/ui/deriving/deriving-smart-pointer-expanded.rs b/tests/ui/deriving/deriving-smart-pointer-expanded.rs new file mode 100644 index 00000000000..b78258c2529 --- /dev/null +++ b/tests/ui/deriving/deriving-smart-pointer-expanded.rs @@ -0,0 +1,22 @@ +//@ check-pass +//@ compile-flags: -Zunpretty=expanded +#![feature(derive_smart_pointer)] +use std::marker::SmartPointer; + +pub trait MyTrait<T: ?Sized> {} + +#[derive(SmartPointer)] +#[repr(transparent)] +struct MyPointer<'a, #[pointee] T: ?Sized> { + ptr: &'a T, +} + +#[derive(core::marker::SmartPointer)] +#[repr(transparent)] +pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, X: MyTrait<T> = ()> +where + Y: MyTrait<T>, +{ + data: &'a mut T, + x: core::marker::PhantomData<X>, +} diff --git a/tests/ui/deriving/deriving-smart-pointer-expanded.stdout b/tests/ui/deriving/deriving-smart-pointer-expanded.stdout new file mode 100644 index 00000000000..3c7e7198180 --- /dev/null +++ b/tests/ui/deriving/deriving-smart-pointer-expanded.stdout @@ -0,0 +1,44 @@ +#![feature(prelude_import)] +#![no_std] +//@ check-pass +//@ compile-flags: -Zunpretty=expanded +#![feature(derive_smart_pointer)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +use std::marker::SmartPointer; + +pub trait MyTrait<T: ?Sized> {} + +#[repr(transparent)] +struct MyPointer<'a, #[pointee] T: ?Sized> { + ptr: &'a T, +} +#[automatically_derived] +impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> + ::core::ops::DispatchFromDyn<MyPointer<'a, __S>> for MyPointer<'a, T> { +} +#[automatically_derived] +impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> + ::core::ops::CoerceUnsized<MyPointer<'a, __S>> for MyPointer<'a, T> { +} + +#[repr(transparent)] +pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, + X: MyTrait<T> = ()> where Y: MyTrait<T> { + data: &'a mut T, + x: core::marker::PhantomData<X>, +} +#[automatically_derived] +impl<'a, Y, Z: MyTrait<T> + MyTrait<__S>, T: ?Sized + MyTrait<T> + + ::core::marker::Unsize<__S>, __S: ?Sized + MyTrait<__S>, X: MyTrait<T> + + MyTrait<__S>> ::core::ops::DispatchFromDyn<MyPointer2<'a, Y, Z, __S, X>> + for MyPointer2<'a, Y, Z, T, X> where Y: MyTrait<T>, Y: MyTrait<__S> { +} +#[automatically_derived] +impl<'a, Y, Z: MyTrait<T> + MyTrait<__S>, T: ?Sized + MyTrait<T> + + ::core::marker::Unsize<__S>, __S: ?Sized + MyTrait<__S>, X: MyTrait<T> + + MyTrait<__S>> ::core::ops::CoerceUnsized<MyPointer2<'a, Y, Z, __S, X>> for + MyPointer2<'a, Y, Z, T, X> where Y: MyTrait<T>, Y: MyTrait<__S> { +} diff --git a/tests/ui/deriving/deriving-smart-pointer-neg.rs b/tests/ui/deriving/deriving-smart-pointer-neg.rs index bfb4e86b396..04f52a154fe 100644 --- a/tests/ui/deriving/deriving-smart-pointer-neg.rs +++ b/tests/ui/deriving/deriving-smart-pointer-neg.rs @@ -1,5 +1,6 @@ #![feature(derive_smart_pointer, arbitrary_self_types)] +extern crate core; use std::marker::SmartPointer; #[derive(SmartPointer)] @@ -35,6 +36,13 @@ struct NotTransparent<'a, #[pointee] T: ?Sized> { ptr: &'a T, } +#[derive(SmartPointer)] +#[repr(transparent)] +struct NoMaybeSized<'a, #[pointee] T> { + //~^ ERROR: `derive(SmartPointer)` requires T to be marked `?Sized` + ptr: &'a T, +} + // However, reordering attributes should work nevertheless. #[repr(transparent)] #[derive(SmartPointer)] @@ -42,4 +50,26 @@ struct ThisIsAPossibleSmartPointer<'a, #[pointee] T: ?Sized> { ptr: &'a T, } +// Also, these paths to Sized should work +#[derive(SmartPointer)] +#[repr(transparent)] +struct StdSized<'a, #[pointee] T: ?std::marker::Sized> { + ptr: &'a T, +} +#[derive(SmartPointer)] +#[repr(transparent)] +struct CoreSized<'a, #[pointee] T: ?core::marker::Sized> { + ptr: &'a T, +} +#[derive(SmartPointer)] +#[repr(transparent)] +struct GlobalStdSized<'a, #[pointee] T: ?::std::marker::Sized> { + ptr: &'a T, +} +#[derive(SmartPointer)] +#[repr(transparent)] +struct GlobalCoreSized<'a, #[pointee] T: ?::core::marker::Sized> { + ptr: &'a T, +} + fn main() {} diff --git a/tests/ui/deriving/deriving-smart-pointer-neg.stderr b/tests/ui/deriving/deriving-smart-pointer-neg.stderr index d994a6ee376..8b0f91d41fb 100644 --- a/tests/ui/deriving/deriving-smart-pointer-neg.stderr +++ b/tests/ui/deriving/deriving-smart-pointer-neg.stderr @@ -1,5 +1,5 @@ error: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]` - --> $DIR/deriving-smart-pointer-neg.rs:5:10 + --> $DIR/deriving-smart-pointer-neg.rs:6:10 | LL | #[derive(SmartPointer)] | ^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[derive(SmartPointer)] = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) error: At least one generic type should be designated as `#[pointee]` in order to derive `SmartPointer` traits - --> $DIR/deriving-smart-pointer-neg.rs:11:10 + --> $DIR/deriving-smart-pointer-neg.rs:12:10 | LL | #[derive(SmartPointer)] | ^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[derive(SmartPointer)] = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) error: `SmartPointer` can only be derived on `struct`s with at least one field - --> $DIR/deriving-smart-pointer-neg.rs:18:10 + --> $DIR/deriving-smart-pointer-neg.rs:19:10 | LL | #[derive(SmartPointer)] | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[derive(SmartPointer)] = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) error: `SmartPointer` can only be derived on `struct`s with at least one field - --> $DIR/deriving-smart-pointer-neg.rs:25:10 + --> $DIR/deriving-smart-pointer-neg.rs:26:10 | LL | #[derive(SmartPointer)] | ^^^^^^^^^^^^ @@ -31,15 +31,21 @@ LL | #[derive(SmartPointer)] = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) error: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]` - --> $DIR/deriving-smart-pointer-neg.rs:32:10 + --> $DIR/deriving-smart-pointer-neg.rs:33:10 | LL | #[derive(SmartPointer)] | ^^^^^^^^^^^^ | = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) +error: `derive(SmartPointer)` requires T to be marked `?Sized` + --> $DIR/deriving-smart-pointer-neg.rs:41:36 + | +LL | struct NoMaybeSized<'a, #[pointee] T> { + | ^ + error[E0392]: lifetime parameter `'a` is never used - --> $DIR/deriving-smart-pointer-neg.rs:21:16 + --> $DIR/deriving-smart-pointer-neg.rs:22:16 | LL | struct NoField<'a, #[pointee] T: ?Sized> {} | ^^ unused lifetime parameter @@ -47,7 +53,7 @@ LL | struct NoField<'a, #[pointee] T: ?Sized> {} = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` error[E0392]: type parameter `T` is never used - --> $DIR/deriving-smart-pointer-neg.rs:21:31 + --> $DIR/deriving-smart-pointer-neg.rs:22:31 | LL | struct NoField<'a, #[pointee] T: ?Sized> {} | ^ unused type parameter @@ -55,7 +61,7 @@ LL | struct NoField<'a, #[pointee] T: ?Sized> {} = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` error[E0392]: lifetime parameter `'a` is never used - --> $DIR/deriving-smart-pointer-neg.rs:28:20 + --> $DIR/deriving-smart-pointer-neg.rs:29:20 | LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>(); | ^^ unused lifetime parameter @@ -63,13 +69,13 @@ LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>(); = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` error[E0392]: type parameter `T` is never used - --> $DIR/deriving-smart-pointer-neg.rs:28:35 + --> $DIR/deriving-smart-pointer-neg.rs:29:35 | LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>(); | ^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0392`. diff --git a/tests/ui/deriving/smart-pointer-bounds-issue-127647.rs b/tests/ui/deriving/smart-pointer-bounds-issue-127647.rs new file mode 100644 index 00000000000..4cae1b32896 --- /dev/null +++ b/tests/ui/deriving/smart-pointer-bounds-issue-127647.rs @@ -0,0 +1,78 @@ +//@ check-pass + +#![feature(derive_smart_pointer)] + +#[derive(core::marker::SmartPointer)] +#[repr(transparent)] +pub struct Ptr<'a, #[pointee] T: OnDrop + ?Sized, X> { + data: &'a mut T, + x: core::marker::PhantomData<X>, +} + +pub trait OnDrop { + fn on_drop(&mut self); +} + +#[derive(core::marker::SmartPointer)] +#[repr(transparent)] +pub struct Ptr2<'a, #[pointee] T: ?Sized, X> +where + T: OnDrop, +{ + data: &'a mut T, + x: core::marker::PhantomData<X>, +} + +pub trait MyTrait<T: ?Sized> {} + +#[derive(core::marker::SmartPointer)] +#[repr(transparent)] +pub struct Ptr3<'a, #[pointee] T: ?Sized, X> +where + T: MyTrait<T>, +{ + data: &'a mut T, + x: core::marker::PhantomData<X>, +} + +#[derive(core::marker::SmartPointer)] +#[repr(transparent)] +pub struct Ptr4<'a, #[pointee] T: MyTrait<T> + ?Sized, X> { + data: &'a mut T, + x: core::marker::PhantomData<X>, +} + +#[derive(core::marker::SmartPointer)] +#[repr(transparent)] +pub struct Ptr5<'a, #[pointee] T: ?Sized, X> +where + Ptr5Companion<T>: MyTrait<T>, + Ptr5Companion2: MyTrait<T>, +{ + data: &'a mut T, + x: core::marker::PhantomData<X>, +} + +pub struct Ptr5Companion<T: ?Sized>(core::marker::PhantomData<T>); +pub struct Ptr5Companion2; + +#[derive(core::marker::SmartPointer)] +#[repr(transparent)] +pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize = 0> { + data: &'a mut T, + x: core::marker::PhantomData<X>, +} + +// a reduced example from https://lore.kernel.org/all/20240402-linked-list-v1-1-b1c59ba7ae3b@google.com/ +#[repr(transparent)] +#[derive(core::marker::SmartPointer)] +pub struct ListArc<#[pointee] T, const ID: u64 = 0> +where + T: ListArcSafe<ID> + ?Sized, +{ + arc: *const T, +} + +pub trait ListArcSafe<const ID: u64> {} + +fn main() {} diff --git a/tests/ui/dropck/drop-with-active-borrows-1.stderr b/tests/ui/dropck/drop-with-active-borrows-1.stderr index 7d1633267f0..229514c6fee 100644 --- a/tests/ui/dropck/drop-with-active-borrows-1.stderr +++ b/tests/ui/dropck/drop-with-active-borrows-1.stderr @@ -9,11 +9,6 @@ LL | drop(a); | ^ move out of `a` occurs here LL | for s in &b { | -- borrow later used here - | -help: consider cloning the value if the performance cost is acceptable - | -LL | let b: Vec<&str> = a.clone().lines().collect(); - | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/dropck/dropck-empty-array.rs b/tests/ui/dropck/dropck-empty-array.rs new file mode 100644 index 00000000000..f3eca6aed8d --- /dev/null +++ b/tests/ui/dropck/dropck-empty-array.rs @@ -0,0 +1,23 @@ +//@ run-pass + +#[allow(dead_code)] +struct Struct<'s>(&'s str); + +impl<'s> Drop for Struct<'s> { + fn drop(&mut self) {} +} + +fn to_array_zero<T>(_: T) -> [T; 0] { + [] +} + +pub fn array_zero_in_tuple() { + let mut x = ([], String::new()); + { + let s = String::from("temporary"); + let p = Struct(&s); + x.0 = to_array_zero(p); + } +} + +fn main() {} diff --git a/tests/ui/error-codes/E0432.stderr b/tests/ui/error-codes/E0432.stderr index a0b17e35c94..36fefc95897 100644 --- a/tests/ui/error-codes/E0432.stderr +++ b/tests/ui/error-codes/E0432.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `something` LL | use something::Foo; | ^^^^^^^^^ you might be missing crate `something` | - = help: consider adding `extern crate something` to use the `something` crate +help: consider importing the `something` crate + | +LL + extern crate something; + | error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0504.stderr b/tests/ui/error-codes/E0504.stderr index 343bca9a72e..58266959333 100644 --- a/tests/ui/error-codes/E0504.stderr +++ b/tests/ui/error-codes/E0504.stderr @@ -21,7 +21,7 @@ LL | struct FancyNum { | ^^^^^^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let fancy_ref = &fancy_num; - | ---------- you could clone this value + | --------- you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0505.stderr b/tests/ui/error-codes/E0505.stderr index 266df9ea32a..3f2913e9fe3 100644 --- a/tests/ui/error-codes/E0505.stderr +++ b/tests/ui/error-codes/E0505.stderr @@ -18,7 +18,7 @@ LL | struct Value {} | ^^^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let _ref_to_val: &Value = &x; - | -- you could clone this value + | - you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/extern/extern-types-field-offset.run.stderr b/tests/ui/extern/extern-types-field-offset.run.stderr index 1b04b860db5..f1407398980 100644 --- a/tests/ui/extern/extern-types-field-offset.run.stderr +++ b/tests/ui/extern/extern-types-field-offset.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: attempted to compute the size or alignment of extern type `Opaque` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.align.run.stderr b/tests/ui/extern/extern-types-size_of_val.align.run.stderr index 20c4d8785e8..faad1aa13fa 100644 --- a/tests/ui/extern/extern-types-size_of_val.align.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.align.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: attempted to compute the size or alignment of extern type `A` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.size.run.stderr b/tests/ui/extern/extern-types-size_of_val.size.run.stderr index 20c4d8785e8..faad1aa13fa 100644 --- a/tests/ui/extern/extern-types-size_of_val.size.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.size.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: attempted to compute the size or alignment of extern type `A` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr b/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr deleted file mode 100644 index 308de269293..00000000000 --- a/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/feature-gate-default_type_parameter_fallback.rs:3:8 - | -LL | fn avg<T=i32>(_: T) {} - | ^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default - -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/feature-gate-default_type_parameter_fallback.rs:8:6 - | -LL | impl<T=i32> S<T> {} - | ^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> - -error: aborting due to 2 previous errors - diff --git a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs new file mode 100644 index 00000000000..176a40ecf53 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs @@ -0,0 +1,6 @@ +//@ only-x86_64 +#[target_feature(enable = "sha512")] +//~^ ERROR: currently unstable +unsafe fn foo() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr new file mode 100644 index 00000000000..da9eea095a3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr @@ -0,0 +1,13 @@ +error[E0658]: the target feature `sha512` is currently unstable + --> $DIR/feature-gate-sha512_sm_x86.rs:2:18 + | +LL | #[target_feature(enable = "sha512")] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #126624 <https://github.com/rust-lang/rust/issues/126624> for more information + = help: add `#![feature(sha512_sm_x86)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.rs b/tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.rs deleted file mode 100644 index 3ea62e875b8..00000000000 --- a/tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.rs +++ /dev/null @@ -1,13 +0,0 @@ -unsafe extern "C" { - //~^ ERROR extern block cannot be declared unsafe -} - -// We can't gate `unsafe extern` blocks themselves since they were previously -// allowed, but we should gate the `safe` soft keyword. -#[cfg(any())] -unsafe extern "C" { - safe fn foo(); - //~^ ERROR `unsafe extern {}` blocks and `safe` keyword are experimental -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.stderr b/tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.stderr deleted file mode 100644 index 56534946308..00000000000 --- a/tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: extern block cannot be declared unsafe - --> $DIR/feature-gate-unsafe-extern-blocks.rs:1:1 - | -LL | unsafe extern "C" { - | ^^^^^^ - | - = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information - = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental - --> $DIR/feature-gate-unsafe-extern-blocks.rs:9:5 - | -LL | safe fn foo(); - | ^^^^ - | - = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information - = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/version_check.rs b/tests/ui/feature-gates/version_check.rs new file mode 100644 index 00000000000..e212dc74fd1 --- /dev/null +++ b/tests/ui/feature-gates/version_check.rs @@ -0,0 +1,17 @@ +//@ run-pass +//@ only-linux +//@ only-x86 +// FIXME: this should be more like //@ needs-subprocesses +use std::process::Command; + +fn main() { + let signalled_version = "Ceci n'est pas une rustc"; + let version = Command::new(std::env::var_os("RUSTC").unwrap()) + .env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version) + .arg("--version") + .output() + .unwrap() + .stdout; + let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end(); + assert_eq!(version, signalled_version); +} diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr index b8ec2e3b7e7..4e64ed6f482 100644 --- a/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr +++ b/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr @@ -13,9 +13,8 @@ LL | println!("{}", y); | help: consider cloning the value if the performance cost is acceptable | -LL - let y = f(&x, ()); -LL + let y = f(x.clone(), ()); - | +LL | let y = f(&x.clone(), ()); + | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr index 382ab8636a2..b898df0835c 100644 --- a/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr +++ b/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr @@ -30,9 +30,8 @@ LL | println!("{}", y); | help: consider cloning the value if the performance cost is acceptable | -LL - let y = f(&x, ()); -LL + let y = f(x.clone(), ()); - | +LL | let y = f(&x.clone(), ()); + | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr index ce97d8527e8..2a7431305fe 100644 --- a/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr +++ b/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr @@ -13,9 +13,8 @@ LL | println!("{}", y); | help: consider cloning the value if the performance cost is acceptable | -LL - let y = f(&x, ()); -LL + let y = f(x.clone(), ()); - | +LL | let y = f(&x.clone(), ()); + | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/missing-bounds.fixed b/tests/ui/generic-associated-types/missing-bounds.fixed index ff69016d862..703d3c1e0fb 100644 --- a/tests/ui/generic-associated-types/missing-bounds.fixed +++ b/tests/ui/generic-associated-types/missing-bounds.fixed @@ -2,7 +2,6 @@ use std::ops::Add; -#[allow(dead_code)] struct A<B>(B); impl<B> Add for A<B> where B: Add<Output = B> { @@ -13,7 +12,6 @@ impl<B> Add for A<B> where B: Add<Output = B> { } } -#[allow(dead_code)] struct C<B>(B); impl<B: Add<Output = B>> Add for C<B> { @@ -24,7 +22,6 @@ impl<B: Add<Output = B>> Add for C<B> { } } -#[allow(dead_code)] struct D<B>(B); impl<B: std::ops::Add<Output = B>> Add for D<B> { @@ -35,7 +32,6 @@ impl<B: std::ops::Add<Output = B>> Add for D<B> { } } -#[allow(dead_code)] struct E<B>(B); impl<B: Add<Output = B>> Add for E<B> where B: Add<Output = B> { diff --git a/tests/ui/generic-associated-types/missing-bounds.rs b/tests/ui/generic-associated-types/missing-bounds.rs index 1f83356c2fa..f40b4228873 100644 --- a/tests/ui/generic-associated-types/missing-bounds.rs +++ b/tests/ui/generic-associated-types/missing-bounds.rs @@ -2,7 +2,6 @@ use std::ops::Add; -#[allow(dead_code)] struct A<B>(B); impl<B> Add for A<B> where B: Add { @@ -13,7 +12,6 @@ impl<B> Add for A<B> where B: Add { } } -#[allow(dead_code)] struct C<B>(B); impl<B: Add> Add for C<B> { @@ -24,7 +22,6 @@ impl<B: Add> Add for C<B> { } } -#[allow(dead_code)] struct D<B>(B); impl<B> Add for D<B> { @@ -35,7 +32,6 @@ impl<B> Add for D<B> { } } -#[allow(dead_code)] struct E<B>(B); impl<B: Add> Add for E<B> where <B as Add>::Output = B { diff --git a/tests/ui/generic-associated-types/missing-bounds.stderr b/tests/ui/generic-associated-types/missing-bounds.stderr index 0f0dc24c06c..1d7d80d1b07 100644 --- a/tests/ui/generic-associated-types/missing-bounds.stderr +++ b/tests/ui/generic-associated-types/missing-bounds.stderr @@ -1,5 +1,5 @@ error: equality constraints are not yet supported in `where` clauses - --> $DIR/missing-bounds.rs:41:33 + --> $DIR/missing-bounds.rs:37:33 | LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { | ^^^^^^^^^^^^^^^^^^^^^^ not supported @@ -11,7 +11,7 @@ LL | impl<B: Add> Add for E<B> where B: Add<Output = B> { | ~~~~~~~~~~~~~~~~~~ error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:12:11 + --> $DIR/missing-bounds.rs:11:11 | LL | impl<B> Add for A<B> where B: Add { | - expected this type parameter @@ -24,14 +24,14 @@ LL | A(self.0 + rhs.0) = note: expected type parameter `B` found associated type `<B as Add>::Output` help: the type constructed contains `<B as Add>::Output` due to the type of the argument passed - --> $DIR/missing-bounds.rs:12:9 + --> $DIR/missing-bounds.rs:11:9 | LL | A(self.0 + rhs.0) | ^^--------------^ | | | this argument influences the type of `A` note: tuple struct defined here - --> $DIR/missing-bounds.rs:6:8 + --> $DIR/missing-bounds.rs:5:8 | LL | struct A<B>(B); | ^ @@ -41,7 +41,7 @@ LL | impl<B> Add for A<B> where B: Add<Output = B> { | ++++++++++++ error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:23:14 + --> $DIR/missing-bounds.rs:21:14 | LL | impl<B: Add> Add for C<B> { | - expected this type parameter @@ -54,7 +54,7 @@ LL | Self(self.0 + rhs.0) = note: expected type parameter `B` found associated type `<B as Add>::Output` note: tuple struct defined here - --> $DIR/missing-bounds.rs:17:8 + --> $DIR/missing-bounds.rs:15:8 | LL | struct C<B>(B); | ^ @@ -64,7 +64,7 @@ LL | impl<B: Add<Output = B>> Add for C<B> { | ++++++++++++ error[E0369]: cannot add `B` to `B` - --> $DIR/missing-bounds.rs:34:21 + --> $DIR/missing-bounds.rs:31:21 | LL | Self(self.0 + rhs.0) | ------ ^ ----- B @@ -77,7 +77,7 @@ LL | impl<B: std::ops::Add<Output = B>> Add for D<B> { | +++++++++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:46:14 + --> $DIR/missing-bounds.rs:42:14 | LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { | - expected this type parameter @@ -90,7 +90,7 @@ LL | Self(self.0 + rhs.0) = note: expected type parameter `B` found associated type `<B as Add>::Output` note: tuple struct defined here - --> $DIR/missing-bounds.rs:39:8 + --> $DIR/missing-bounds.rs:35:8 | LL | struct E<B>(B); | ^ diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index 5c1778bc485..bfed4cd6650 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at library/alloc/src/raw_vec.rs:LL:CC: +thread 'main' panicked at alloc/src/raw_vec.rs:LL:CC: capacity overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed b/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed index 3c4499f0173..886fc1d0058 100644 --- a/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed @@ -1,8 +1,6 @@ //@ run-rustfix -#[allow(dead_code)] struct S<T>(T); -#[allow(dead_code)] struct S2; impl<T: Default> Default for S<T> { diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.rs b/tests/ui/impl-trait/extra-impl-in-trait-impl.rs index ac078329524..f3271993867 100644 --- a/tests/ui/impl-trait/extra-impl-in-trait-impl.rs +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.rs @@ -1,8 +1,6 @@ //@ run-rustfix -#[allow(dead_code)] struct S<T>(T); -#[allow(dead_code)] struct S2; impl<T: Default> impl Default for S<T> { diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr index 91c7da5a04f..5aafc8b64d4 100644 --- a/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr @@ -1,23 +1,23 @@ error: unexpected `impl` keyword - --> $DIR/extra-impl-in-trait-impl.rs:8:18 + --> $DIR/extra-impl-in-trait-impl.rs:6:18 | LL | impl<T: Default> impl Default for S<T> { | ^^^^^ help: remove the extra `impl` | note: this is parsed as an `impl Trait` type, but a trait is expected at this position - --> $DIR/extra-impl-in-trait-impl.rs:8:18 + --> $DIR/extra-impl-in-trait-impl.rs:6:18 | LL | impl<T: Default> impl Default for S<T> { | ^^^^^^^^^^^^ error: unexpected `impl` keyword - --> $DIR/extra-impl-in-trait-impl.rs:14:6 + --> $DIR/extra-impl-in-trait-impl.rs:12:6 | LL | impl impl Default for S2 { | ^^^^^ help: remove the extra `impl` | note: this is parsed as an `impl Trait` type, but a trait is expected at this position - --> $DIR/extra-impl-in-trait-impl.rs:14:6 + --> $DIR/extra-impl-in-trait-impl.rs:12:6 | LL | impl impl Default for S2 { | ^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index f0d259d01de..1fb69db98c1 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -433,3 +433,25 @@ error: aborting due to 50 previous errors Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666. For more information about an error, try `rustc --explain E0053`. +Future incompatibility report: Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/where-allowed.rs:239:7 + | +LL | impl <T = impl Debug> T {} + | ^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/where-allowed.rs:246:36 + | +LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} + | ^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + diff --git a/tests/ui/imports/import-from-missing-star-2.stderr b/tests/ui/imports/import-from-missing-star-2.stderr index 59b000a4382..dd35627c684 100644 --- a/tests/ui/imports/import-from-missing-star-2.stderr +++ b/tests/ui/imports/import-from-missing-star-2.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ you might be missing crate `spam` | - = help: consider adding `extern crate spam` to use the `spam` crate +help: consider importing the `spam` crate + | +LL + extern crate spam; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/import-from-missing-star-3.stderr b/tests/ui/imports/import-from-missing-star-3.stderr index 23df6b35445..1e2412b0959 100644 --- a/tests/ui/imports/import-from-missing-star-3.stderr +++ b/tests/ui/imports/import-from-missing-star-3.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ you might be missing crate `spam` | - = help: consider adding `extern crate spam` to use the `spam` crate +help: consider importing the `spam` crate + | +LL + extern crate spam; + | error[E0432]: unresolved import `spam` --> $DIR/import-from-missing-star-3.rs:27:13 @@ -12,7 +15,10 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ you might be missing crate `spam` | - = help: consider adding `extern crate spam` to use the `spam` crate +help: consider importing the `spam` crate + | +LL + extern crate spam; + | error: aborting due to 2 previous errors diff --git a/tests/ui/imports/import-from-missing-star.stderr b/tests/ui/imports/import-from-missing-star.stderr index b311527bc28..c9bb9baeb4d 100644 --- a/tests/ui/imports/import-from-missing-star.stderr +++ b/tests/ui/imports/import-from-missing-star.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ you might be missing crate `spam` | - = help: consider adding `extern crate spam` to use the `spam` crate +help: consider importing the `spam` crate + | +LL + extern crate spam; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/import3.stderr b/tests/ui/imports/import3.stderr index 06260ef9ebc..157b5b63566 100644 --- a/tests/ui/imports/import3.stderr +++ b/tests/ui/imports/import3.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `main` LL | use main::bar; | ^^^^ you might be missing crate `main` | - = help: consider adding `extern crate main` to use the `main` crate +help: consider importing the `main` crate + | +LL + extern crate main; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-109343.stderr b/tests/ui/imports/issue-109343.stderr index fe06eddeada..e66528e8df5 100644 --- a/tests/ui/imports/issue-109343.stderr +++ b/tests/ui/imports/issue-109343.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `unresolved` LL | pub use unresolved::f; | ^^^^^^^^^^ you might be missing crate `unresolved` | - = help: consider adding `extern crate unresolved` to use the `unresolved` crate +help: consider importing the `unresolved` crate + | +LL + extern crate unresolved; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-1697.rs b/tests/ui/imports/issue-1697.rs index 8ec48d4d286..019237611df 100644 --- a/tests/ui/imports/issue-1697.rs +++ b/tests/ui/imports/issue-1697.rs @@ -3,6 +3,6 @@ use unresolved::*; //~^ ERROR unresolved import `unresolved` [E0432] //~| NOTE you might be missing crate `unresolved` -//~| HELP consider adding `extern crate unresolved` to use the `unresolved` crate +//~| HELP consider importing the `unresolved` crate fn main() {} diff --git a/tests/ui/imports/issue-1697.stderr b/tests/ui/imports/issue-1697.stderr index df2957b8f2b..ec0d94bd672 100644 --- a/tests/ui/imports/issue-1697.stderr +++ b/tests/ui/imports/issue-1697.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `unresolved` LL | use unresolved::*; | ^^^^^^^^^^ you might be missing crate `unresolved` | - = help: consider adding `extern crate unresolved` to use the `unresolved` crate +help: consider importing the `unresolved` crate + | +LL + extern crate unresolved; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-33464.stderr b/tests/ui/imports/issue-33464.stderr index 17cc0e4469e..28fbcee401f 100644 --- a/tests/ui/imports/issue-33464.stderr +++ b/tests/ui/imports/issue-33464.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `abc` LL | use abc::one_el; | ^^^ you might be missing crate `abc` | - = help: consider adding `extern crate abc` to use the `abc` crate +help: consider importing the `abc` crate + | +LL + extern crate abc; + | error[E0432]: unresolved import `abc` --> $DIR/issue-33464.rs:5:5 @@ -12,7 +15,10 @@ error[E0432]: unresolved import `abc` LL | use abc::{a, bbb, cccccc}; | ^^^ you might be missing crate `abc` | - = help: consider adding `extern crate abc` to use the `abc` crate +help: consider importing the `abc` crate + | +LL + extern crate abc; + | error[E0432]: unresolved import `a_very_long_name` --> $DIR/issue-33464.rs:7:5 @@ -20,7 +26,10 @@ error[E0432]: unresolved import `a_very_long_name` LL | use a_very_long_name::{el, el2}; | ^^^^^^^^^^^^^^^^ you might be missing crate `a_very_long_name` | - = help: consider adding `extern crate a_very_long_name` to use the `a_very_long_name` crate +help: consider importing the `a_very_long_name` crate + | +LL + extern crate a_very_long_name; + | error: aborting due to 3 previous errors diff --git a/tests/ui/imports/issue-36881.stderr b/tests/ui/imports/issue-36881.stderr index 3c136df83fe..004836e072c 100644 --- a/tests/ui/imports/issue-36881.stderr +++ b/tests/ui/imports/issue-36881.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `issue_36881_aux` LL | use issue_36881_aux::Foo; | ^^^^^^^^^^^^^^^ you might be missing crate `issue_36881_aux` | - = help: consider adding `extern crate issue_36881_aux` to use the `issue_36881_aux` crate +help: consider importing the `issue_36881_aux` crate + | +LL + extern crate issue_36881_aux; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-37887.stderr b/tests/ui/imports/issue-37887.stderr index 36020707405..02c2c803262 100644 --- a/tests/ui/imports/issue-37887.stderr +++ b/tests/ui/imports/issue-37887.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `test` LL | use test::*; | ^^^^ you might be missing crate `test` | - = help: consider adding `extern crate test` to use the `test` crate +help: consider importing the `test` crate + | +LL + extern crate test; + | error[E0658]: use of unstable library feature 'test' --> $DIR/issue-37887.rs:2:5 diff --git a/tests/ui/imports/issue-53269.stderr b/tests/ui/imports/issue-53269.stderr index 317b3c633a6..d25d85bf46f 100644 --- a/tests/ui/imports/issue-53269.stderr +++ b/tests/ui/imports/issue-53269.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `nonexistent_module` LL | use nonexistent_module::mac; | ^^^^^^^^^^^^^^^^^^ you might be missing crate `nonexistent_module` | - = help: consider adding `extern crate nonexistent_module` to use the `nonexistent_module` crate +help: consider importing the `nonexistent_module` crate + | +LL + extern crate nonexistent_module; + | error[E0659]: `mac` is ambiguous --> $DIR/issue-53269.rs:8:5 diff --git a/tests/ui/imports/issue-55457.stderr b/tests/ui/imports/issue-55457.stderr index e9126e6575c..9c99b6a20de 100644 --- a/tests/ui/imports/issue-55457.stderr +++ b/tests/ui/imports/issue-55457.stderr @@ -13,7 +13,10 @@ error[E0432]: unresolved import `non_existent` LL | use non_existent::non_existent; | ^^^^^^^^^^^^ you might be missing crate `non_existent` | - = help: consider adding `extern crate non_existent` to use the `non_existent` crate +help: consider importing the `non_existent` crate + | +LL + extern crate non_existent; + | error: aborting due to 2 previous errors diff --git a/tests/ui/imports/issue-55884-2.stderr b/tests/ui/imports/issue-55884-2.stderr index 8a9d5f2a6d8..0d4f01aeafc 100644 --- a/tests/ui/imports/issue-55884-2.stderr +++ b/tests/ui/imports/issue-55884-2.stderr @@ -24,10 +24,6 @@ note: ...and refers to the struct `ParseOptions` which is defined here | LL | pub struct ParseOptions {} | ^^^^^^^^^^^^^^^^^^^^^^^ you could import this directly -help: import `ParseOptions` through the re-export - | -LL | pub use parser::ParseOptions; - | ~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-81413.stderr b/tests/ui/imports/issue-81413.stderr index 321b3695d2c..aa1246c1d2f 100644 --- a/tests/ui/imports/issue-81413.stderr +++ b/tests/ui/imports/issue-81413.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `doesnt_exist` LL | pub use doesnt_exist::*; | ^^^^^^^^^^^^ you might be missing crate `doesnt_exist` | - = help: consider adding `extern crate doesnt_exist` to use the `doesnt_exist` crate +help: consider importing the `doesnt_exist` crate + | +LL + extern crate doesnt_exist; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/redundant-import-extern-prelude.rs b/tests/ui/imports/redundant-import-extern-prelude.rs index f1de06417aa..0064eaa9318 100644 --- a/tests/ui/imports/redundant-import-extern-prelude.rs +++ b/tests/ui/imports/redundant-import-extern-prelude.rs @@ -1,16 +1,17 @@ -//@ check-pass // Check that we detect imports that are redundant due to the extern prelude // and that we emit a reasonable diagnostic. // issue: rust-lang/rust#121915 +//~^^^ NOTE the item `aux_issue_121915` is already defined by the extern prelude // See also the discussion in <https://github.com/rust-lang/rust/pull/122954>. //@ compile-flags: --extern aux_issue_121915 --edition 2018 //@ aux-build: aux-issue-121915.rs -#[deny(unused_imports)] +#[deny(redundant_imports)] +//~^ NOTE the lint level is defined here fn main() { use aux_issue_121915; - //FIXME(unused_imports): ~^ ERROR the item `aux_issue_121915` is imported redundantly + //~^ ERROR the item `aux_issue_121915` is imported redundantly aux_issue_121915::item(); } diff --git a/tests/ui/imports/redundant-import-extern-prelude.stderr b/tests/ui/imports/redundant-import-extern-prelude.stderr new file mode 100644 index 00000000000..6d2518c1284 --- /dev/null +++ b/tests/ui/imports/redundant-import-extern-prelude.stderr @@ -0,0 +1,14 @@ +error: the item `aux_issue_121915` is imported redundantly + --> $DIR/redundant-import-extern-prelude.rs:14:9 + | +LL | use aux_issue_121915; + | ^^^^^^^^^^^^^^^^ the item `aux_issue_121915` is already defined by the extern prelude + | +note: the lint level is defined here + --> $DIR/redundant-import-extern-prelude.rs:11:8 + | +LL | #[deny(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/imports/redundant-import-issue-121915-2015.rs b/tests/ui/imports/redundant-import-issue-121915-2015.rs index be3b8209ada..dc499bc40b6 100644 --- a/tests/ui/imports/redundant-import-issue-121915-2015.rs +++ b/tests/ui/imports/redundant-import-issue-121915-2015.rs @@ -1,12 +1,11 @@ -//@ check-pass //@ compile-flags: --extern aux_issue_121915 --edition 2015 //@ aux-build: aux-issue-121915.rs extern crate aux_issue_121915; -#[deny(unused_imports)] +#[deny(redundant_imports)] fn main() { use aux_issue_121915; - //FIXME(unused_imports): ~^ ERROR the item `aux_issue_121915` is imported redundantly + //~^ ERROR the item `aux_issue_121915` is imported redundantly aux_issue_121915::item(); } diff --git a/tests/ui/imports/redundant-import-issue-121915-2015.stderr b/tests/ui/imports/redundant-import-issue-121915-2015.stderr new file mode 100644 index 00000000000..f4e9f604896 --- /dev/null +++ b/tests/ui/imports/redundant-import-issue-121915-2015.stderr @@ -0,0 +1,17 @@ +error: the item `aux_issue_121915` is imported redundantly + --> $DIR/redundant-import-issue-121915-2015.rs:8:9 + | +LL | extern crate aux_issue_121915; + | ------------------------------ the item `aux_issue_121915` is already imported here +... +LL | use aux_issue_121915; + | ^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/redundant-import-issue-121915-2015.rs:6:8 + | +LL | #[deny(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/imports/redundant-import-lang-prelude-attr.rs b/tests/ui/imports/redundant-import-lang-prelude-attr.rs index 59cd570f44c..f7ee91880ba 100644 --- a/tests/ui/imports/redundant-import-lang-prelude-attr.rs +++ b/tests/ui/imports/redundant-import-lang-prelude-attr.rs @@ -1,6 +1,6 @@ -//@ check-pass // Check that we detect imports (of built-in attributes) that are redundant due to // the language prelude and that we emit a reasonable diagnostic. +//~^^ NOTE the item `allow` is already defined by the extern prelude // Note that we use the term "extern prelude" in the label even though "language prelude" // would be more correct. However, it's not worth special-casing this. @@ -9,9 +9,10 @@ //@ edition: 2018 -#![deny(unused_imports)] +#![deny(redundant_imports)] +//~^ NOTE the lint level is defined here -use allow; //FIXME(unused_imports): ~ ERROR the item `allow` is imported redundantly +use allow; //~ ERROR the item `allow` is imported redundantly #[allow(unused)] fn main() {} diff --git a/tests/ui/imports/redundant-import-lang-prelude-attr.stderr b/tests/ui/imports/redundant-import-lang-prelude-attr.stderr new file mode 100644 index 00000000000..f0016f5fab4 --- /dev/null +++ b/tests/ui/imports/redundant-import-lang-prelude-attr.stderr @@ -0,0 +1,14 @@ +error: the item `allow` is imported redundantly + --> $DIR/redundant-import-lang-prelude-attr.rs:15:5 + | +LL | use allow; + | ^^^^^ the item `allow` is already defined by the extern prelude + | +note: the lint level is defined here + --> $DIR/redundant-import-lang-prelude-attr.rs:12:9 + | +LL | #![deny(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/imports/redundant-import-lang-prelude.rs b/tests/ui/imports/redundant-import-lang-prelude.rs index 53d3b709963..3f95ffbe02e 100644 --- a/tests/ui/imports/redundant-import-lang-prelude.rs +++ b/tests/ui/imports/redundant-import-lang-prelude.rs @@ -1,16 +1,17 @@ -//@ check-pass // Check that we detect imports that are redundant due to the language prelude // and that we emit a reasonable diagnostic. +//~^^ NOTE the item `u8` is already defined by the extern prelude // Note that we use the term "extern prelude" in the label even though "language prelude" // would be more correct. However, it's not worth special-casing this. // See also the discussion in <https://github.com/rust-lang/rust/pull/122954>. -#![deny(unused_imports)] +#![deny(redundant_imports)] +//~^ NOTE the lint level is defined here use std::primitive::u8; -//FIXME(unused_imports): ~^ ERROR the item `u8` is imported redundantly +//~^ ERROR the item `u8` is imported redundantly const _: u8 = 0; diff --git a/tests/ui/imports/redundant-import-lang-prelude.stderr b/tests/ui/imports/redundant-import-lang-prelude.stderr new file mode 100644 index 00000000000..4fd57639781 --- /dev/null +++ b/tests/ui/imports/redundant-import-lang-prelude.stderr @@ -0,0 +1,14 @@ +error: the item `u8` is imported redundantly + --> $DIR/redundant-import-lang-prelude.rs:13:5 + | +LL | use std::primitive::u8; + | ^^^^^^^^^^^^^^^^^^ the item `u8` is already defined by the extern prelude + | +note: the lint level is defined here + --> $DIR/redundant-import-lang-prelude.rs:10:9 + | +LL | #![deny(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/imports/suggest-remove-issue-121315.rs b/tests/ui/imports/suggest-remove-issue-121315.rs index 2bb82833a5b..ee3ceb6e3a3 100644 --- a/tests/ui/imports/suggest-remove-issue-121315.rs +++ b/tests/ui/imports/suggest-remove-issue-121315.rs @@ -1,20 +1,19 @@ //@ compile-flags: --edition 2021 - -#![deny(unused_imports)] +#![deny(unused_imports, redundant_imports)] #![allow(dead_code)] fn test0() { // Test remove FlatUnused use std::convert::TryFrom; - //FIXME(unused_imports): ~^ ERROR the item `TryFrom` is imported redundantly + //~^ ERROR the item `TryFrom` is imported redundantly let _ = u32::try_from(5i32); } fn test1() { // FIXME(yukang) Test remove NestedFullUnused use std::convert::{TryFrom, TryInto}; - //FIXME(unused_imports): ~^ ERROR the item `TryFrom` is imported redundantly - //FIXME(unused_imports): ~| ERROR the item `TryInto` is imported redundantly + //~^ ERROR the item `TryFrom` is imported redundantly + //~| ERROR the item `TryInto` is imported redundantly let _ = u32::try_from(5i32); let _a: i32 = u32::try_into(5u32).unwrap(); @@ -24,7 +23,7 @@ fn test2() { // FIXME(yukang): Test remove both redundant and unused use std::convert::{AsMut, Into}; //~^ ERROR unused import: `AsMut` - //FIXME(unused_imports): ~| ERROR the item `Into` is imported redundantly + //~| ERROR the item `Into` is imported redundantly let _a: u32 = (5u8).into(); } diff --git a/tests/ui/imports/suggest-remove-issue-121315.stderr b/tests/ui/imports/suggest-remove-issue-121315.stderr index 5701514e1bd..5d0bf9bea6a 100644 --- a/tests/ui/imports/suggest-remove-issue-121315.stderr +++ b/tests/ui/imports/suggest-remove-issue-121315.stderr @@ -1,20 +1,62 @@ +error: the item `TryFrom` is imported redundantly + --> $DIR/suggest-remove-issue-121315.rs:7:9 + | +LL | use std::convert::TryFrom; + | ^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `TryFrom` is already defined here + | +note: the lint level is defined here + --> $DIR/suggest-remove-issue-121315.rs:2:25 + | +LL | #![deny(unused_imports, redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +error: the item `TryFrom` is imported redundantly + --> $DIR/suggest-remove-issue-121315.rs:14:24 + | +LL | use std::convert::{TryFrom, TryInto}; + | ^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `TryFrom` is already defined here + +error: the item `TryInto` is imported redundantly + --> $DIR/suggest-remove-issue-121315.rs:14:33 + | +LL | use std::convert::{TryFrom, TryInto}; + | ^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `TryInto` is already defined here + error: unused import: `AsMut` - --> $DIR/suggest-remove-issue-121315.rs:25:24 + --> $DIR/suggest-remove-issue-121315.rs:24:24 | LL | use std::convert::{AsMut, Into}; | ^^^^^ | note: the lint level is defined here - --> $DIR/suggest-remove-issue-121315.rs:3:9 + --> $DIR/suggest-remove-issue-121315.rs:2:9 | -LL | #![deny(unused_imports)] +LL | #![deny(unused_imports, redundant_imports)] | ^^^^^^^^^^^^^^ +error: the item `Into` is imported redundantly + --> $DIR/suggest-remove-issue-121315.rs:24:31 + | +LL | use std::convert::{AsMut, Into}; + | ^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `Into` is already defined here + error: unused import: `From` - --> $DIR/suggest-remove-issue-121315.rs:34:24 + --> $DIR/suggest-remove-issue-121315.rs:33:24 | LL | use std::convert::{From, Infallible}; | ^^^^ -error: aborting due to 2 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/imports/tool-mod-child.stderr b/tests/ui/imports/tool-mod-child.stderr index 764256e76f0..ec110ccd75d 100644 --- a/tests/ui/imports/tool-mod-child.stderr +++ b/tests/ui/imports/tool-mod-child.stderr @@ -4,7 +4,10 @@ error[E0433]: failed to resolve: you might be missing crate `clippy` LL | use clippy::a::b; | ^^^^^^ you might be missing crate `clippy` | - = help: consider adding `extern crate clippy` to use the `clippy` crate +help: consider importing the `clippy` crate + | +LL + extern crate clippy; + | error[E0432]: unresolved import `clippy` --> $DIR/tool-mod-child.rs:1:5 @@ -12,7 +15,10 @@ error[E0432]: unresolved import `clippy` LL | use clippy::a; | ^^^^^^ you might be missing crate `clippy` | - = help: consider adding `extern crate clippy` to use the `clippy` crate +help: consider importing the `clippy` crate + | +LL + extern crate clippy; + | error[E0433]: failed to resolve: you might be missing crate `rustdoc` --> $DIR/tool-mod-child.rs:5:5 @@ -20,7 +26,10 @@ error[E0433]: failed to resolve: you might be missing crate `rustdoc` LL | use rustdoc::a::b; | ^^^^^^^ you might be missing crate `rustdoc` | - = help: consider adding `extern crate rustdoc` to use the `rustdoc` crate +help: consider importing the `rustdoc` crate + | +LL + extern crate rustdoc; + | error[E0432]: unresolved import `rustdoc` --> $DIR/tool-mod-child.rs:4:5 @@ -28,7 +37,10 @@ error[E0432]: unresolved import `rustdoc` LL | use rustdoc::a; | ^^^^^^^ you might be missing crate `rustdoc` | - = help: consider adding `extern crate rustdoc` to use the `rustdoc` crate +help: consider importing the `rustdoc` crate + | +LL + extern crate rustdoc; + | error: aborting due to 4 previous errors diff --git a/tests/ui/imports/unresolved-imports-used.stderr b/tests/ui/imports/unresolved-imports-used.stderr index 1cbc2356320..4bf02ff6e3a 100644 --- a/tests/ui/imports/unresolved-imports-used.stderr +++ b/tests/ui/imports/unresolved-imports-used.stderr @@ -16,7 +16,10 @@ error[E0432]: unresolved import `foo` LL | use foo::bar; | ^^^ you might be missing crate `foo` | - = help: consider adding `extern crate foo` to use the `foo` crate +help: consider importing the `foo` crate + | +LL + extern crate foo; + | error[E0432]: unresolved import `baz` --> $DIR/unresolved-imports-used.rs:12:5 @@ -24,7 +27,10 @@ error[E0432]: unresolved import `baz` LL | use baz::*; | ^^^ you might be missing crate `baz` | - = help: consider adding `extern crate baz` to use the `baz` crate +help: consider importing the `baz` crate + | +LL + extern crate baz; + | error[E0432]: unresolved import `foo2` --> $DIR/unresolved-imports-used.rs:14:5 @@ -32,7 +38,10 @@ error[E0432]: unresolved import `foo2` LL | use foo2::bar2; | ^^^^ you might be missing crate `foo2` | - = help: consider adding `extern crate foo2` to use the `foo2` crate +help: consider importing the `foo2` crate + | +LL + extern crate foo2; + | error[E0432]: unresolved import `baz2` --> $DIR/unresolved-imports-used.rs:15:5 @@ -40,7 +49,10 @@ error[E0432]: unresolved import `baz2` LL | use baz2::*; | ^^^^ you might be missing crate `baz2` | - = help: consider adding `extern crate baz2` to use the `baz2` crate +help: consider importing the `baz2` crate + | +LL + extern crate baz2; + | error[E0603]: function `quz` is private --> $DIR/unresolved-imports-used.rs:9:10 diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs index 0e894ef581c..ab46fd796c5 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs @@ -10,7 +10,7 @@ const RAW_EQ_PADDING: bool = unsafe { const RAW_EQ_PTR: bool = unsafe { std::intrinsics::raw_eq(&(&0), &(&1)) //~^ ERROR evaluation of constant value failed -//~| `raw_eq` on bytes with provenance +//~| unable to turn pointer into integer }; pub fn main() { diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index 317466eb322..af16c2bc64a 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -8,7 +8,10 @@ error[E0080]: evaluation of constant value failed --> $DIR/intrinsic-raw_eq-const-bad.rs:11:5 | LL | std::intrinsics::raw_eq(&(&0), &(&1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `raw_eq` on bytes with provenance + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-26812.rs b/tests/ui/issues/issue-26812.rs index 3391ea4b350..e0723e016b3 100644 --- a/tests/ui/issues/issue-26812.rs +++ b/tests/ui/issues/issue-26812.rs @@ -1,6 +1,6 @@ -#![feature(default_type_parameter_fallback)] - fn avg<T=T::Item>(_: T) {} //~^ ERROR generic parameters with a default cannot use forward declared identifiers +//~| ERROR defaults for type parameters +//~| WARN previously accepted fn main() {} diff --git a/tests/ui/issues/issue-26812.stderr b/tests/ui/issues/issue-26812.stderr index c2a3d4b83d5..4a18b23fd8b 100644 --- a/tests/ui/issues/issue-26812.stderr +++ b/tests/ui/issues/issue-26812.stderr @@ -1,9 +1,30 @@ error[E0128]: generic parameters with a default cannot use forward declared identifiers - --> $DIR/issue-26812.rs:3:10 + --> $DIR/issue-26812.rs:1:10 | LL | fn avg<T=T::Item>(_: T) {} | ^^^^^^^ defaulted generic parameters cannot be forward declared -error: aborting due to 1 previous error +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/issue-26812.rs:1:8 + | +LL | fn avg<T=T::Item>(_: T) {} + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0128`. +Future incompatibility report: Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/issue-26812.rs:1:8 + | +LL | fn avg<T=T::Item>(_: T) {} + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + diff --git a/tests/ui/issues/issue-5708.rs b/tests/ui/issues/issue-5708.rs index 89ea9fbdcd8..ce9ef78ffcd 100644 --- a/tests/ui/issues/issue-5708.rs +++ b/tests/ui/issues/issue-5708.rs @@ -44,7 +44,6 @@ pub trait MyTrait<T> { fn dummy(&self, t: T) -> T { panic!() } } -#[allow(dead_code)] pub struct MyContainer<'a, T:'a> { foos: Vec<&'a (dyn MyTrait<T>+'a)> , } diff --git a/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr b/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr index a647ca27f1c..f23f855c9e8 100644 --- a/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr +++ b/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr @@ -15,7 +15,10 @@ error[E0432]: unresolved import `r#extern` LL | use extern::foo; | ^^^^^^ you might be missing crate `r#extern` | - = help: consider adding `extern crate r#extern` to use the `r#extern` crate +help: consider importing the `r#extern` crate + | +LL + extern crate r#extern; + | error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes/elided-lint-in-mod.rs b/tests/ui/lifetimes/elided-lint-in-mod.rs new file mode 100644 index 00000000000..afe85cb607d --- /dev/null +++ b/tests/ui/lifetimes/elided-lint-in-mod.rs @@ -0,0 +1,11 @@ +struct Foo<'a>(&'a ()); + +fn test(_: Foo) {} + +#[deny(elided_lifetimes_in_paths)] +mod w { + fn test2(_: super::Foo) {} + //~^ ERROR hidden lifetime parameters in types are deprecated +} + +fn main() {} diff --git a/tests/ui/lifetimes/elided-lint-in-mod.stderr b/tests/ui/lifetimes/elided-lint-in-mod.stderr new file mode 100644 index 00000000000..1fee18028c6 --- /dev/null +++ b/tests/ui/lifetimes/elided-lint-in-mod.stderr @@ -0,0 +1,20 @@ +error: hidden lifetime parameters in types are deprecated + --> $DIR/elided-lint-in-mod.rs:7:24 + | +LL | fn test2(_: super::Foo) {} + | -------^^^ + | | + | expected lifetime parameter + | +note: the lint level is defined here + --> $DIR/elided-lint-in-mod.rs:5:8 + | +LL | #[deny(elided_lifetimes_in_paths)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +help: indicate the anonymous lifetime + | +LL | fn test2(_: super::Foo<'_>) {} + | ++++ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index e446345aedc..ebf6f6ca403 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -72,3 +72,14 @@ error: aborting due to 8 previous errors Some errors have detailed explanations: E0106, E0214, E0308, E0770. For more information about an error, try `rustc --explain E0106`. +Future incompatibility report: Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/unusual-rib-combinations.rs:15:6 + | +LL | fn c<T = u8()>() {} + | ^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + diff --git a/tests/ui/lint/dead-code/allow-unconstructed-pub-struct.rs b/tests/ui/lint/dead-code/allow-unconstructed-pub-struct.rs deleted file mode 100644 index 8cd1524045b..00000000000 --- a/tests/ui/lint/dead-code/allow-unconstructed-pub-struct.rs +++ /dev/null @@ -1,33 +0,0 @@ -//@ check-pass - -mod ffi { - use super::*; - - extern "C" { - pub fn DomPromise_AddRef(promise: *const Promise); - pub fn DomPromise_Release(promise: *const Promise); - } -} - -#[repr(C)] -#[allow(unused)] -pub struct Promise { - private: [u8; 0], - __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, -} - -pub unsafe trait RefCounted { - unsafe fn addref(&self); - unsafe fn release(&self); -} - -unsafe impl RefCounted for Promise { - unsafe fn addref(&self) { - ffi::DomPromise_AddRef(self) - } - unsafe fn release(&self) { - ffi::DomPromise_Release(self) - } -} - -fn main() {} diff --git a/tests/ui/lint/dead-code/issue-59003.rs b/tests/ui/lint/dead-code/issue-59003.rs index 319cf2db149..e3dcaca5778 100644 --- a/tests/ui/lint/dead-code/issue-59003.rs +++ b/tests/ui/lint/dead-code/issue-59003.rs @@ -4,8 +4,8 @@ #![deny(dead_code)] -#[allow(dead_code)] struct Foo { + #[allow(dead_code)] inner: u32, } diff --git a/tests/ui/lint/dead-code/lint-dead-code-1.rs b/tests/ui/lint/dead-code/lint-dead-code-1.rs index 3386dfa4747..ddcafedf7bc 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-1.rs +++ b/tests/ui/lint/dead-code/lint-dead-code-1.rs @@ -46,10 +46,11 @@ struct SemiUsedStruct; impl SemiUsedStruct { fn la_la_la() {} } -struct StructUsedAsField; //~ ERROR struct `StructUsedAsField` is never constructed +struct StructUsedAsField; pub struct StructUsedInEnum; struct StructUsedInGeneric; -pub struct PubStruct2 { //~ ERROR struct `PubStruct2` is never constructed +pub struct PubStruct2 { + #[allow(dead_code)] struct_used_as_field: *const StructUsedAsField } diff --git a/tests/ui/lint/dead-code/lint-dead-code-1.stderr b/tests/ui/lint/dead-code/lint-dead-code-1.stderr index b0163df8855..eb728b5b930 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-1.stderr +++ b/tests/ui/lint/dead-code/lint-dead-code-1.stderr @@ -22,26 +22,14 @@ error: struct `PrivStruct` is never constructed LL | struct PrivStruct; | ^^^^^^^^^^ -error: struct `StructUsedAsField` is never constructed - --> $DIR/lint-dead-code-1.rs:49:8 - | -LL | struct StructUsedAsField; - | ^^^^^^^^^^^^^^^^^ - -error: struct `PubStruct2` is never constructed - --> $DIR/lint-dead-code-1.rs:52:12 - | -LL | pub struct PubStruct2 { - | ^^^^^^^^^^ - error: enum `priv_enum` is never used - --> $DIR/lint-dead-code-1.rs:63:6 + --> $DIR/lint-dead-code-1.rs:64:6 | LL | enum priv_enum { foo2, bar2 } | ^^^^^^^^^ error: variant `bar3` is never constructed - --> $DIR/lint-dead-code-1.rs:66:5 + --> $DIR/lint-dead-code-1.rs:67:5 | LL | enum used_enum { | --------- variant in this enum @@ -50,25 +38,25 @@ LL | bar3 | ^^^^ error: function `priv_fn` is never used - --> $DIR/lint-dead-code-1.rs:87:4 + --> $DIR/lint-dead-code-1.rs:88:4 | LL | fn priv_fn() { | ^^^^^^^ error: function `foo` is never used - --> $DIR/lint-dead-code-1.rs:92:4 + --> $DIR/lint-dead-code-1.rs:93:4 | LL | fn foo() { | ^^^ error: function `bar` is never used - --> $DIR/lint-dead-code-1.rs:97:4 + --> $DIR/lint-dead-code-1.rs:98:4 | LL | fn bar() { | ^^^ error: function `baz` is never used - --> $DIR/lint-dead-code-1.rs:101:4 + --> $DIR/lint-dead-code-1.rs:102:4 | LL | fn baz() -> impl Copy { | ^^^ @@ -79,5 +67,5 @@ error: struct `Bar` is never constructed LL | pub struct Bar; | ^^^ -error: aborting due to 12 previous errors +error: aborting due to 10 previous errors diff --git a/tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.rs b/tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.rs deleted file mode 100644 index 25777438456..00000000000 --- a/tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![deny(dead_code)] - -struct Foo(u8); //~ ERROR struct `Foo` is never constructed - -enum Bar { //~ ERROR enum `Bar` is never used - Var1(u8), - Var2(u8), -} - -pub trait Tr1 { - fn f1() -> Self; -} - -impl Tr1 for Foo { - fn f1() -> Foo { - let f = Foo(0); - let Foo(tag) = f; - Foo(tag) - } -} - -impl Tr1 for Bar { - fn f1() -> Bar { - let b = Bar::Var1(0); - let b = if let Bar::Var1(_) = b { - Bar::Var1(0) - } else { - Bar::Var2(0) - }; - match b { - Bar::Var1(_) => Bar::Var2(0), - Bar::Var2(_) => Bar::Var1(0), - } - } -} - -fn main() {} diff --git a/tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.stderr b/tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.stderr deleted file mode 100644 index 7c1a4b45977..00000000000 --- a/tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: struct `Foo` is never constructed - --> $DIR/lint-unused-adt-appeared-in-pattern.rs:3:8 - | -LL | struct Foo(u8); - | ^^^ - | -note: the lint level is defined here - --> $DIR/lint-unused-adt-appeared-in-pattern.rs:1:9 - | -LL | #![deny(dead_code)] - | ^^^^^^^^^ - -error: enum `Bar` is never used - --> $DIR/lint-unused-adt-appeared-in-pattern.rs:5:6 - | -LL | enum Bar { - | ^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/dead-code/not-lint-used-adt-appeared-in-pattern.rs b/tests/ui/lint/dead-code/not-lint-used-adt-appeared-in-pattern.rs deleted file mode 100644 index 43a2e431904..00000000000 --- a/tests/ui/lint/dead-code/not-lint-used-adt-appeared-in-pattern.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ check-pass - -#![deny(dead_code)] - -#[repr(u8)] -#[derive(Copy, Clone, Debug)] -pub enum RecordField { - Target = 1, - Level, - Module, - File, - Line, - NumArgs, -} - -unsafe trait Pod {} - -#[repr(transparent)] -struct RecordFieldWrapper(RecordField); - -unsafe impl Pod for RecordFieldWrapper {} - -fn try_read<T: Pod>(buf: &[u8]) -> T { - unsafe { std::ptr::read_unaligned(buf.as_ptr() as *const T) } -} - -pub fn foo(buf: &[u8]) -> RecordField { - let RecordFieldWrapper(tag) = try_read(buf); - tag -} - -fn main() {} diff --git a/tests/ui/lint/dead-code/unconstructible-pub-struct.rs b/tests/ui/lint/dead-code/unconstructible-pub-struct.rs deleted file mode 100644 index 2202cbb6730..00000000000 --- a/tests/ui/lint/dead-code/unconstructible-pub-struct.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![feature(never_type)] -#![deny(dead_code)] - -pub struct T1(!); -pub struct T2(()); -pub struct T3<X>(std::marker::PhantomData<X>); - -pub struct T4 { - _x: !, -} - -pub struct T5<X> { - _x: !, - _y: X, -} - -pub struct T6 { - _x: (), -} - -pub struct T7<X> { - _x: (), - _y: X, -} - -pub struct T8<X> { - _x: std::marker::PhantomData<X>, -} - -pub struct T9<X> { //~ ERROR struct `T9` is never constructed - _x: std::marker::PhantomData<X>, - _y: i32, -} - -fn main() {} diff --git a/tests/ui/lint/dead-code/unconstructible-pub-struct.stderr b/tests/ui/lint/dead-code/unconstructible-pub-struct.stderr deleted file mode 100644 index a3dde042bbe..00000000000 --- a/tests/ui/lint/dead-code/unconstructible-pub-struct.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: struct `T9` is never constructed - --> $DIR/unconstructible-pub-struct.rs:30:12 - | -LL | pub struct T9<X> { - | ^^ - | -note: the lint level is defined here - --> $DIR/unconstructible-pub-struct.rs:2:9 - | -LL | #![deny(dead_code)] - | ^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.rs b/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.rs index 658cc3d6c61..5b755d62a05 100644 --- a/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.rs +++ b/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.rs @@ -1,9 +1,8 @@ #![deny(dead_code)] struct T1; //~ ERROR struct `T1` is never constructed -struct T2; //~ ERROR struct `T2` is never constructed -pub struct T3(i32); //~ ERROR struct `T3` is never constructed -pub struct T4(i32); //~ ERROR field `0` is never read +pub struct T2(i32); //~ ERROR field `0` is never read +struct T3; trait Trait1 { //~ ERROR trait `Trait1` is never used const UNUSED: i32; @@ -12,13 +11,13 @@ trait Trait1 { //~ ERROR trait `Trait1` is never used } pub trait Trait2 { - const MAY_USED: i32; - fn may_used(&self) {} + const USED: i32; + fn used(&self) {} } pub trait Trait3 { - const MAY_USED: i32; - fn may_used() -> Self; + const USED: i32; + fn construct_self() -> Self; } impl Trait1 for T1 { @@ -31,34 +30,23 @@ impl Trait1 for T1 { impl Trait1 for T2 { const UNUSED: i32 = 0; fn construct_self() -> Self { - Self + T2(0) } } impl Trait2 for T1 { - const MAY_USED: i32 = 0; + const USED: i32 = 0; } impl Trait2 for T2 { - const MAY_USED: i32 = 0; -} - -impl Trait2 for T3 { - const MAY_USED: i32 = 0; + const USED: i32 = 0; } -impl Trait3 for T2 { - const MAY_USED: i32 = 0; - fn may_used() -> Self { +impl Trait3 for T3 { + const USED: i32 = 0; + fn construct_self() -> Self { Self } } -impl Trait3 for T4 { - const MAY_USED: i32 = 0; - fn may_used() -> Self { - T4(0) - } -} - fn main() {} diff --git a/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.stderr b/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.stderr index 08c7a5cb4b0..2441a3f868d 100644 --- a/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.stderr +++ b/tests/ui/lint/dead-code/unused-adt-impl-pub-trait-with-assoc-const.stderr @@ -10,22 +10,10 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: struct `T2` is never constructed - --> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:4:8 - | -LL | struct T2; - | ^^ - -error: struct `T3` is never constructed - --> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:5:12 - | -LL | pub struct T3(i32); - | ^^ - error: field `0` is never read - --> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:6:15 + --> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:4:15 | -LL | pub struct T4(i32); +LL | pub struct T2(i32); | -- ^^^ | | | field in this struct @@ -33,10 +21,10 @@ LL | pub struct T4(i32); = help: consider removing this field error: trait `Trait1` is never used - --> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:8:7 + --> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:7:7 | LL | trait Trait1 { | ^^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/lint/dead-code/unused-assoc-const.rs b/tests/ui/lint/dead-code/unused-assoc-const.rs deleted file mode 100644 index 36e8315ad36..00000000000 --- a/tests/ui/lint/dead-code/unused-assoc-const.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![deny(dead_code)] - -trait Trait { - const UNUSED_CONST: i32; //~ ERROR associated constant `UNUSED_CONST` is never used - const USED_CONST: i32; - - fn foo(&self) {} -} - -pub struct T(()); - -impl Trait for T { - const UNUSED_CONST: i32 = 0; - const USED_CONST: i32 = 1; -} - -fn main() { - T(()).foo(); - T::USED_CONST; -} diff --git a/tests/ui/lint/dead-code/unused-assoc-const.stderr b/tests/ui/lint/dead-code/unused-assoc-const.stderr deleted file mode 100644 index 78296d70663..00000000000 --- a/tests/ui/lint/dead-code/unused-assoc-const.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: associated constant `UNUSED_CONST` is never used - --> $DIR/unused-assoc-const.rs:4:11 - | -LL | trait Trait { - | ----- associated constant in this trait -LL | const UNUSED_CONST: i32; - | ^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/unused-assoc-const.rs:1:9 - | -LL | #![deny(dead_code)] - | ^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/lint/dead-code/unused-impl-for-non-adts.rs b/tests/ui/lint/dead-code/unused-impl-for-non-adts.rs deleted file mode 100644 index 46065dcee81..00000000000 --- a/tests/ui/lint/dead-code/unused-impl-for-non-adts.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![deny(dead_code)] - -struct Foo; //~ ERROR struct `Foo` is never constructed - -trait Trait { //~ ERROR trait `Trait` is never used - fn foo(&self) {} -} - -impl Trait for Foo {} - -impl Trait for [Foo] {} -impl<const N: usize> Trait for [Foo; N] {} - -impl Trait for *const Foo {} -impl Trait for *mut Foo {} - -impl Trait for &Foo {} -impl Trait for &&Foo {} -impl Trait for &mut Foo {} - -impl Trait for [&Foo] {} -impl Trait for &[Foo] {} -impl Trait for &*const Foo {} - -pub trait Trait2 { - fn foo(&self) {} -} - -impl Trait2 for Foo {} - -impl Trait2 for [Foo] {} -impl<const N: usize> Trait2 for [Foo; N] {} - -impl Trait2 for *const Foo {} -impl Trait2 for *mut Foo {} - -impl Trait2 for &Foo {} -impl Trait2 for &&Foo {} -impl Trait2 for &mut Foo {} - -impl Trait2 for [&Foo] {} -impl Trait2 for &[Foo] {} -impl Trait2 for &*const Foo {} - -fn main() {} diff --git a/tests/ui/lint/dead-code/unused-impl-for-non-adts.stderr b/tests/ui/lint/dead-code/unused-impl-for-non-adts.stderr deleted file mode 100644 index e61fc403e81..00000000000 --- a/tests/ui/lint/dead-code/unused-impl-for-non-adts.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: struct `Foo` is never constructed - --> $DIR/unused-impl-for-non-adts.rs:3:8 - | -LL | struct Foo; - | ^^^ - | -note: the lint level is defined here - --> $DIR/unused-impl-for-non-adts.rs:1:9 - | -LL | #![deny(dead_code)] - | ^^^^^^^^^ - -error: trait `Trait` is never used - --> $DIR/unused-impl-for-non-adts.rs:5:7 - | -LL | trait Trait { - | ^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/dead-code/unused-pub-struct.rs b/tests/ui/lint/dead-code/unused-pub-struct.rs deleted file mode 100644 index aaf4dd612de..00000000000 --- a/tests/ui/lint/dead-code/unused-pub-struct.rs +++ /dev/null @@ -1,48 +0,0 @@ -#![deny(dead_code)] - -pub struct NotLint1(()); -pub struct NotLint2(std::marker::PhantomData<i32>); - -pub struct NeverConstructed(i32); //~ ERROR struct `NeverConstructed` is never constructed - -impl NeverConstructed { - pub fn not_construct_self(&self) {} -} - -impl Clone for NeverConstructed { - fn clone(&self) -> NeverConstructed { - NeverConstructed(0) - } -} - -pub trait Trait { - fn not_construct_self(&self); -} - -impl Trait for NeverConstructed { - fn not_construct_self(&self) { - self.0; - } -} - -pub struct Constructed(i32); - -impl Constructed { - pub fn construct_self() -> Self { - Constructed(0) - } -} - -impl Clone for Constructed { - fn clone(&self) -> Constructed { - Constructed(0) - } -} - -impl Trait for Constructed { - fn not_construct_self(&self) { - self.0; - } -} - -fn main() {} diff --git a/tests/ui/lint/dead-code/unused-pub-struct.stderr b/tests/ui/lint/dead-code/unused-pub-struct.stderr deleted file mode 100644 index 3667ddb97bd..00000000000 --- a/tests/ui/lint/dead-code/unused-pub-struct.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: struct `NeverConstructed` is never constructed - --> $DIR/unused-pub-struct.rs:6:12 - | -LL | pub struct NeverConstructed(i32); - | ^^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/unused-pub-struct.rs:1:9 - | -LL | #![deny(dead_code)] - | ^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/lint/dead-code/unused-struct-derive-default.rs b/tests/ui/lint/dead-code/unused-struct-derive-default.rs index f20b7cb66ee..330ad32dd57 100644 --- a/tests/ui/lint/dead-code/unused-struct-derive-default.rs +++ b/tests/ui/lint/dead-code/unused-struct-derive-default.rs @@ -22,5 +22,4 @@ pub struct T2 { fn main() { let _x: Used = Default::default(); - let _e: E = Default::default(); } diff --git a/tests/ui/lint/dead-code/unused-struct-derive-default.stderr b/tests/ui/lint/dead-code/unused-struct-derive-default.stderr index 7422f9a39f3..bbb0bd7be70 100644 --- a/tests/ui/lint/dead-code/unused-struct-derive-default.stderr +++ b/tests/ui/lint/dead-code/unused-struct-derive-default.stderr @@ -4,6 +4,7 @@ error: struct `T` is never constructed LL | struct T; | ^ | + = note: `T` has a derived impl for the trait `Default`, but this is intentionally ignored during dead code analysis note: the lint level is defined here --> $DIR/unused-struct-derive-default.rs:1:9 | diff --git a/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs deleted file mode 100644 index e8116d83ebf..00000000000 --- a/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![deny(dead_code)] - -struct T1; //~ ERROR struct `T1` is never constructed - -trait Foo { type Unused; } //~ ERROR trait `Foo` is never used -impl Foo for T1 { type Unused = Self; } - -pub trait Bar { type Used; } -impl Bar for T1 { type Used = Self; } - -fn main() {} diff --git a/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr deleted file mode 100644 index ab73c640634..00000000000 --- a/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: struct `T1` is never constructed - --> $DIR/unused-trait-with-assoc-ty.rs:3:8 - | -LL | struct T1; - | ^^ - | -note: the lint level is defined here - --> $DIR/unused-trait-with-assoc-ty.rs:1:9 - | -LL | #![deny(dead_code)] - | ^^^^^^^^^ - -error: trait `Foo` is never used - --> $DIR/unused-trait-with-assoc-ty.rs:5:7 - | -LL | trait Foo { type Unused; } - | ^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/negative_literals.rs b/tests/ui/lint/negative_literals.rs index 048fcd6ff57..5964bbb559a 100644 --- a/tests/ui/lint/negative_literals.rs +++ b/tests/ui/lint/negative_literals.rs @@ -1,5 +1,7 @@ //@ check-fail +#![deny(ambiguous_negative_literals)] + fn main() { let _ = -1i32.abs(); //~^ ERROR `-` has lower precedence than method calls diff --git a/tests/ui/lint/negative_literals.stderr b/tests/ui/lint/negative_literals.stderr index df000a71882..b0323cc96a0 100644 --- a/tests/ui/lint/negative_literals.stderr +++ b/tests/ui/lint/negative_literals.stderr @@ -1,11 +1,15 @@ error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:4:13 + --> $DIR/negative_literals.rs:6:13 | LL | let _ = -1i32.abs(); | ^^^^^^^^^^^ | = note: e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4` - = note: `#[deny(ambiguous_negative_literals)]` on by default +note: the lint level is defined here + --> $DIR/negative_literals.rs:3:9 + | +LL | #![deny(ambiguous_negative_literals)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add parentheses around the `-` and the literal to call the method on a negative literal | LL | let _ = (-1i32).abs(); @@ -16,7 +20,7 @@ LL | let _ = -(1i32.abs()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:6:13 + --> $DIR/negative_literals.rs:8:13 | LL | let _ = -1f32.abs(); | ^^^^^^^^^^^ @@ -32,7 +36,7 @@ LL | let _ = -(1f32.abs()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:8:13 + --> $DIR/negative_literals.rs:10:13 | LL | let _ = -1f64.asin(); | ^^^^^^^^^^^^ @@ -48,7 +52,7 @@ LL | let _ = -(1f64.asin()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:10:13 + --> $DIR/negative_literals.rs:12:13 | LL | let _ = -1f64.asinh(); | ^^^^^^^^^^^^^ @@ -64,7 +68,7 @@ LL | let _ = -(1f64.asinh()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:12:13 + --> $DIR/negative_literals.rs:14:13 | LL | let _ = -1f64.tan(); | ^^^^^^^^^^^ @@ -80,7 +84,7 @@ LL | let _ = -(1f64.tan()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:14:13 + --> $DIR/negative_literals.rs:16:13 | LL | let _ = -1f64.tanh(); | ^^^^^^^^^^^^ @@ -96,7 +100,7 @@ LL | let _ = -(1f64.tanh()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:16:13 + --> $DIR/negative_literals.rs:18:13 | LL | let _ = -1.0_f64.cos().cos(); | ^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +116,7 @@ LL | let _ = -(1.0_f64.cos().cos()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:18:13 + --> $DIR/negative_literals.rs:20:13 | LL | let _ = -1.0_f64.cos().sin(); | ^^^^^^^^^^^^^^^^^^^^ @@ -128,7 +132,7 @@ LL | let _ = -(1.0_f64.cos().sin()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:20:13 + --> $DIR/negative_literals.rs:22:13 | LL | let _ = -1.0_f64.sin().cos(); | ^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +148,7 @@ LL | let _ = -(1.0_f64.sin().cos()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:22:13 + --> $DIR/negative_literals.rs:24:13 | LL | let _ = -1f64.sin().sin(); | ^^^^^^^^^^^^^^^^^ @@ -160,7 +164,7 @@ LL | let _ = -(1f64.sin().sin()); | + + error: `-` has lower precedence than method calls, which might be unexpected - --> $DIR/negative_literals.rs:25:11 + --> $DIR/negative_literals.rs:27:11 | LL | dbg!( -1.0_f32.cos() ); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs index 6f2ead70db8..c264fa1c8da 100644 --- a/tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs +++ b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.rs @@ -1,4 +1,3 @@ -#![feature(unsafe_extern_blocks)] #![deny(unsafe_code)] #[allow(unsafe_code)] diff --git a/tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr index 5439a311256..6d3b064da34 100644 --- a/tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr +++ b/tests/ui/lint/unsafe_code/unsafe-extern-blocks.stderr @@ -1,5 +1,5 @@ error: usage of an `unsafe extern` block - --> $DIR/unsafe-extern-blocks.rs:9:1 + --> $DIR/unsafe-extern-blocks.rs:8:1 | LL | / unsafe extern "C" { LL | | @@ -8,7 +8,7 @@ LL | | } | |_^ | note: the lint level is defined here - --> $DIR/unsafe-extern-blocks.rs:2:9 + --> $DIR/unsafe-extern-blocks.rs:1:9 | LL | #![deny(unsafe_code)] | ^^^^^^^^^^^ diff --git a/tests/ui/lint/unused/issue-59896.rs b/tests/ui/lint/unused/issue-59896.rs index a98017524f5..5624e7f02fb 100644 --- a/tests/ui/lint/unused/issue-59896.rs +++ b/tests/ui/lint/unused/issue-59896.rs @@ -1,10 +1,9 @@ -//@ check-pass -#![deny(unused_imports)] +#![deny(redundant_imports)] struct S; fn main() { - use S; //FIXME(unused_imports): ~ ERROR the item `S` is imported redundantly + use S; //~ ERROR the item `S` is imported redundantly let _s = S; } diff --git a/tests/ui/lint/unused/issue-59896.stderr b/tests/ui/lint/unused/issue-59896.stderr new file mode 100644 index 00000000000..363a6419d9c --- /dev/null +++ b/tests/ui/lint/unused/issue-59896.stderr @@ -0,0 +1,17 @@ +error: the item `S` is imported redundantly + --> $DIR/issue-59896.rs:6:9 + | +LL | struct S; + | --------- the item `S` is already defined here +... +LL | use S; + | ^ + | +note: the lint level is defined here + --> $DIR/issue-59896.rs:1:9 + | +LL | #![deny(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs index 797e57f48e9..c8c413dccd3 100644 --- a/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs +++ b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs @@ -1,5 +1,5 @@ //@ check-pass -#![warn(unused_imports)] +#![warn(redundant_imports)] pub mod bar { pub struct Foo(pub Bar); @@ -9,7 +9,7 @@ pub mod bar { use bar::*; pub fn warning() -> Foo { - use bar::Foo; //FIXME(unused_imports): ~ WARNING imported redundantly + use bar::Foo; //~ WARNING imported redundantly Foo(Bar('a')) } diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr b/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr new file mode 100644 index 00000000000..3b06b2df674 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr @@ -0,0 +1,17 @@ +warning: the item `Foo` is imported redundantly + --> $DIR/use-redundant-glob-parent.rs:12:9 + | +LL | use bar::*; + | ------ the item `Foo` is already imported here +... +LL | use bar::Foo; + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/use-redundant-glob-parent.rs:2:9 + | +LL | #![warn(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.rs b/tests/ui/lint/use-redundant/use-redundant-glob.rs index e5835be89d8..52383d4ceff 100644 --- a/tests/ui/lint/use-redundant/use-redundant-glob.rs +++ b/tests/ui/lint/use-redundant/use-redundant-glob.rs @@ -1,5 +1,5 @@ //@ check-pass -#![warn(unused_imports)] +#![warn(redundant_imports)] pub mod bar { pub struct Foo(pub Bar); @@ -8,7 +8,7 @@ pub mod bar { pub fn warning() -> bar::Foo { use bar::*; - use bar::Foo; //FIXME(unused_imports): ~ WARNING imported redundantly + use bar::Foo; //~ WARNING imported redundantly Foo(Bar('a')) } diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.stderr b/tests/ui/lint/use-redundant/use-redundant-glob.stderr new file mode 100644 index 00000000000..47b2ce54bb7 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-glob.stderr @@ -0,0 +1,16 @@ +warning: the item `Foo` is imported redundantly + --> $DIR/use-redundant-glob.rs:11:9 + | +LL | use bar::*; + | ------ the item `Foo` is already imported here +LL | use bar::Foo; + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/use-redundant-glob.rs:2:9 + | +LL | #![warn(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs b/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs index 2db3435d46d..6a3ffa4522a 100644 --- a/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs +++ b/tests/ui/lint/use-redundant/use-redundant-issue-71450.rs @@ -1,6 +1,6 @@ //@ check-pass -#![warn(unused_imports)] +#![warn(redundant_imports)] mod foo { use std::fmt; @@ -23,8 +23,7 @@ mod foo { fn main() { { - use std::string::String; - //FIXME(unused_imports): ~^ WARNING the item `String` is imported redundantly + use std::string::String; //~ WARNING the item `String` is imported redundantly // 'String' from 'std::string::String'. let s = String::new(); println!("{}", s); diff --git a/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr b/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr new file mode 100644 index 00000000000..c14ab9e11e0 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr @@ -0,0 +1,17 @@ +warning: the item `String` is imported redundantly + --> $DIR/use-redundant-issue-71450.rs:26:13 + | +LL | use std::string::String; + | ^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `String` is already defined here + | +note: the lint level is defined here + --> $DIR/use-redundant-issue-71450.rs:3:9 + | +LL | #![warn(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs index 62f50c8a0df..6abe3602abe 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs @@ -1,16 +1,12 @@ //@ check-pass -#![warn(unused_imports)] +#![warn(redundant_imports)] -use std::option::Option::Some; -//FIXME(unused_imports): ~^ WARNING the item `Some` is imported redundantly -use std::option::Option::None; -//FIXME(unused_imports): ~ WARNING the item `None` is imported redundantly +use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly +use std::option::Option::None; //~ WARNING the item `None` is imported redundantly -use std::result::Result::Ok; -//FIXME(unused_imports): ~^ WARNING the item `Ok` is imported redundantly -use std::result::Result::Err; -//FIXME(unused_imports): ~^ WARNING the item `Err` is imported redundantly +use std::result::Result::Ok;//~ WARNING the item `Ok` is imported redundantly +use std::result::Result::Err;//~ WARNING the item `Err` is imported redundantly use std::convert::{TryFrom, TryInto}; fn main() { diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr new file mode 100644 index 00000000000..2b0e16a87dc --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr @@ -0,0 +1,44 @@ +warning: the item `Some` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:5:5 + | +LL | use std::option::Option::Some; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `Some` is already defined here + | +note: the lint level is defined here + --> $DIR/use-redundant-prelude-rust-2015.rs:2:9 + | +LL | #![warn(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +warning: the item `None` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:6:5 + | +LL | use std::option::Option::None; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `None` is already defined here + +warning: the item `Ok` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:8:5 + | +LL | use std::result::Result::Ok; + | ^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `Ok` is already defined here + +warning: the item `Err` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2015.rs:9:5 + | +LL | use std::result::Result::Err; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `Err` is already defined here + +warning: 4 warnings emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs index 1baa1ac1b8c..236ee032b67 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs @@ -1,11 +1,9 @@ //@ check-pass //@ edition:2021 -#![warn(unused_imports)] +#![warn(redundant_imports)] -use std::convert::TryFrom; -//FIXME(unused_imports): ~^ WARNING the item `TryFrom` is imported redundantly -use std::convert::TryInto; -//FIXME(unused_imports): ~^ WARNING the item `TryInto` is imported redundantly +use std::convert::TryFrom;//~ WARNING the item `TryFrom` is imported redundantly +use std::convert::TryInto;//~ WARNING the item `TryInto` is imported redundantly fn main() { let _e: Result<i32, _> = 8u8.try_into(); diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr new file mode 100644 index 00000000000..526771c597a --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr @@ -0,0 +1,26 @@ +warning: the item `TryFrom` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2021.rs:5:5 + | +LL | use std::convert::TryFrom; + | ^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `TryFrom` is already defined here + | +note: the lint level is defined here + --> $DIR/use-redundant-prelude-rust-2021.rs:3:9 + | +LL | #![warn(redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +warning: the item `TryInto` is imported redundantly + --> $DIR/use-redundant-prelude-rust-2021.rs:6:5 + | +LL | use std::convert::TryInto; + | ^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL + | + = note: the item `TryInto` is already defined here + +warning: 2 warnings emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant.rs b/tests/ui/lint/use-redundant/use-redundant.rs index 9e4902af34b..0efed378f98 100644 --- a/tests/ui/lint/use-redundant/use-redundant.rs +++ b/tests/ui/lint/use-redundant/use-redundant.rs @@ -1,5 +1,5 @@ //@ check-pass -#![warn(unused_imports)] +#![warn(unused_imports, redundant_imports)] use crate::foo::Bar; @@ -18,7 +18,7 @@ use m1::*; //~ WARNING unused import use m2::*; //~ WARNING unused import fn main() { - use crate::foo::Bar; //FIXME(unused_imports): ~ WARNING imported redundantly + use crate::foo::Bar; //~ WARNING imported redundantly let _a: Bar = 3; baz(); diff --git a/tests/ui/lint/use-redundant/use-redundant.stderr b/tests/ui/lint/use-redundant/use-redundant.stderr index 224e8411237..76846a1dca9 100644 --- a/tests/ui/lint/use-redundant/use-redundant.stderr +++ b/tests/ui/lint/use-redundant/use-redundant.stderr @@ -7,7 +7,7 @@ LL | use m1::*; note: the lint level is defined here --> $DIR/use-redundant.rs:2:9 | -LL | #![warn(unused_imports)] +LL | #![warn(unused_imports, redundant_imports)] | ^^^^^^^^^^^^^^ warning: unused import: `m2::*` @@ -16,5 +16,20 @@ warning: unused import: `m2::*` LL | use m2::*; | ^^^^^ -warning: 2 warnings emitted +warning: the item `Bar` is imported redundantly + --> $DIR/use-redundant.rs:21:9 + | +LL | use crate::foo::Bar; + | --------------- the item `Bar` is already imported here +... +LL | use crate::foo::Bar; + | ^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/use-redundant.rs:2:25 + | +LL | #![warn(unused_imports, redundant_imports)] + | ^^^^^^^^^^^^^^^^^ + +warning: 3 warnings emitted diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr index 81a221c0ee6..7fe382393d7 100644 --- a/tests/ui/lint/wide_pointer_comparisons.stderr +++ b/tests/ui/lint/wide_pointer_comparisons.stderr @@ -74,7 +74,7 @@ LL | let _ = PartialEq::eq(&a, &b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~ ~ ~ + | ~~~~~~~~~~~~~~~~~~ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:35:13 @@ -85,7 +85,7 @@ LL | let _ = PartialEq::ne(&a, &b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = !std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~~ ~ ~ + | ~~~~~~~~~~~~~~~~~~~ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:37:13 @@ -96,7 +96,7 @@ LL | let _ = a.eq(&b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = std::ptr::addr_eq(a, b); - | ++++++++++++++++++ ~ ~ + | ++++++++++++++++++ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:39:13 @@ -107,7 +107,7 @@ LL | let _ = a.ne(&b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = !std::ptr::addr_eq(a, b); - | +++++++++++++++++++ ~ ~ + | +++++++++++++++++++ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:41:13 @@ -283,7 +283,7 @@ LL | let _ = PartialEq::eq(a, b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~ ~~~ ~ + | ~~~~~~~~~~~~~~~~~~~ ~~~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:85:17 @@ -294,7 +294,7 @@ LL | let _ = PartialEq::ne(a, b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = !std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~~ ~~~ ~ + | ~~~~~~~~~~~~~~~~~~~~ ~~~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:87:17 @@ -305,7 +305,7 @@ LL | let _ = PartialEq::eq(&a, &b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~ ~~~ ~ + | ~~~~~~~~~~~~~~~~~~~ ~~~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:89:17 @@ -316,7 +316,7 @@ LL | let _ = PartialEq::ne(&a, &b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = !std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~~ ~~~ ~ + | ~~~~~~~~~~~~~~~~~~~~ ~~~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:91:17 @@ -327,7 +327,7 @@ LL | let _ = a.eq(b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = std::ptr::addr_eq(*a, *b); - | +++++++++++++++++++ ~~~ ~ + | +++++++++++++++++++ ~~~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:93:17 @@ -338,7 +338,7 @@ LL | let _ = a.ne(b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = !std::ptr::addr_eq(*a, *b); - | ++++++++++++++++++++ ~~~ ~ + | ++++++++++++++++++++ ~~~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:95:17 @@ -519,11 +519,11 @@ LL | let _ = PartialEq::eq(&a, &b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~ ~ ~ + | ~~~~~~~~~~~~~~~~~~ ~ help: use explicit `std::ptr::eq` method to compare metadata and addresses | LL | let _ = std::ptr::eq(a, b); - | ~~~~~~~~~~~~~ ~ ~ + | ~~~~~~~~~~~~~ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:133:17 @@ -534,11 +534,11 @@ LL | let _ = PartialEq::ne(&a, &b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = !std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~~ ~ ~ + | ~~~~~~~~~~~~~~~~~~~ ~ help: use explicit `std::ptr::eq` method to compare metadata and addresses | LL | let _ = !std::ptr::eq(a, b); - | ~~~~~~~~~~~~~~ ~ ~ + | ~~~~~~~~~~~~~~ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:135:17 @@ -549,11 +549,11 @@ LL | let _ = a.eq(&b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = std::ptr::addr_eq(a, b); - | ++++++++++++++++++ ~ ~ + | ++++++++++++++++++ ~ help: use explicit `std::ptr::eq` method to compare metadata and addresses | LL | let _ = std::ptr::eq(a, b); - | +++++++++++++ ~ ~ + | +++++++++++++ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:137:17 @@ -564,11 +564,11 @@ LL | let _ = a.ne(&b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | let _ = !std::ptr::addr_eq(a, b); - | +++++++++++++++++++ ~ ~ + | +++++++++++++++++++ ~ help: use explicit `std::ptr::eq` method to compare metadata and addresses | LL | let _ = !std::ptr::eq(a, b); - | ++++++++++++++ ~ ~ + | ++++++++++++++ ~ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:142:9 @@ -594,7 +594,7 @@ LL | cmp!(a, b); help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | LL | cmp!(std::ptr::addr_eq(a, b)); - | ++++++++++++++++++ ~ + + | ++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:159:39 diff --git a/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr b/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr new file mode 100644 index 00000000000..335b3f61343 --- /dev/null +++ b/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr @@ -0,0 +1,32 @@ +error: no rules expected the token `_` + --> $DIR/expr_2024_underscore_expr.rs:22:12 + | +LL | macro_rules! m2021 { + | ------------------ when calling this macro +... +LL | m2021!(_); + | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr_2021` + --> $DIR/expr_2024_underscore_expr.rs:10:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + +error: no rules expected the token `_` + --> $DIR/expr_2024_underscore_expr.rs:23:12 + | +LL | macro_rules! m2024 { + | ------------------ when calling this macro +... +LL | m2024!(_); + | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/expr_2024_underscore_expr.rs:16:6 + | +LL | ($e:expr) => { + | ^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr b/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr new file mode 100644 index 00000000000..9e49f66a89a --- /dev/null +++ b/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr @@ -0,0 +1,17 @@ +error: no rules expected the token `_` + --> $DIR/expr_2024_underscore_expr.rs:22:12 + | +LL | macro_rules! m2021 { + | ------------------ when calling this macro +... +LL | m2021!(_); + | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr_2021` + --> $DIR/expr_2024_underscore_expr.rs:10:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/expr_2024_underscore_expr.rs b/tests/ui/macros/expr_2024_underscore_expr.rs new file mode 100644 index 00000000000..b2129bf154f --- /dev/null +++ b/tests/ui/macros/expr_2024_underscore_expr.rs @@ -0,0 +1,24 @@ +//@ revisions: edi2021 edi2024 +//@[edi2024]compile-flags: --edition=2024 -Z unstable-options +//@[edi2021]compile-flags: --edition=2021 +// This test ensures that the `_` tok is considered an +// expression on edition 2024. +#![feature(expr_fragment_specifier_2024)] +#![allow(incomplete_features)] + +macro_rules! m2021 { + ($e:expr_2021) => { + $e = 1; + }; +} + +macro_rules! m2024 { + ($e:expr) => { + $e = 1; + }; +} + +fn main() { + m2021!(_); //~ ERROR: no rules expected the token `_` + m2024!(_); //[edi2021]~ ERROR: no rules expected the token `_` +} diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr index f2c6008d27e..de19a99d388 100644 --- a/tests/ui/moves/move-fn-self-receiver.stderr +++ b/tests/ui/moves/move-fn-self-receiver.stderr @@ -101,15 +101,6 @@ LL | mut_foo; | ^^^^^^^ move out of `mut_foo` occurs here LL | ret; | --- borrow later used here - | -note: if `Foo` implemented `Clone`, you could clone the value - --> $DIR/move-fn-self-receiver.rs:5:1 - | -LL | struct Foo; - | ^^^^^^^^^^ consider implementing `Clone` for this type -... -LL | let ret = mut_foo.use_mut_self(); - | ------- you could clone this value error[E0382]: use of moved value: `rc_foo` --> $DIR/move-fn-self-receiver.rs:55:5 diff --git a/tests/ui/nll/closure-access-spans.stderr b/tests/ui/nll/closure-access-spans.stderr index f789e5e9f95..a8024a8c20b 100644 --- a/tests/ui/nll/closure-access-spans.stderr +++ b/tests/ui/nll/closure-access-spans.stderr @@ -60,9 +60,8 @@ LL | r.use_ref(); | help: consider cloning the value if the performance cost is acceptable | -LL - let r = &x; -LL + let r = x.clone(); - | +LL | let r = &x.clone(); + | ++++++++ error[E0382]: borrow of moved value: `x` --> $DIR/closure-access-spans.rs:35:5 @@ -109,11 +108,6 @@ LL | || *x = String::new(); | ^^ -- borrow occurs due to use in closure | | | value borrowed here after move - | -help: consider cloning the value if the performance cost is acceptable - | -LL | let r = x.clone(); - | ++++++++ error[E0382]: use of moved value: `x` --> $DIR/closure-access-spans.rs:50:5 @@ -126,11 +120,6 @@ LL | || x; | ^^ - use occurs due to use in closure | | | value used here after move - | -help: consider cloning the value if the performance cost is acceptable - | -LL | let r = x.clone(); - | ++++++++ error: aborting due to 9 previous errors diff --git a/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr b/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr index 39ec45b20ea..ae797800457 100644 --- a/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr +++ b/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr @@ -10,11 +10,6 @@ LL | _ if { (|| { let bar = b; *bar = false; })(); | -- - variable moved due to use in closure | | | value moved into closure here - | -help: consider cloning the value if the performance cost is acceptable - | -LL | _ if { (|| { let bar = b.clone(); *bar = false; })(); - | ++++++++ error[E0382]: use of moved value: `b` --> $DIR/issue-27282-move-match-input-into-guard.rs:24:5 @@ -28,11 +23,6 @@ LL | (|| { let bar = b; *bar = false; })(); | -- - variable moved due to use in closure | | | value moved into closure here - | -help: consider cloning the value if the performance cost is acceptable - | -LL | (|| { let bar = b.clone(); *bar = false; })(); - | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.fixed b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.fixed deleted file mode 100644 index 7692be7ccc8..00000000000 --- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.fixed +++ /dev/null @@ -1,23 +0,0 @@ -// Issue 27282: Example 1: This sidesteps the AST checks disallowing -// mutable borrows in match guards by hiding the mutable borrow in a -// guard behind a move (of the ref mut pattern id) within a closure. -//@ run-rustfix -#![feature(if_let_guard)] - -fn main() { - match Some(&4) { - None => {}, - ref mut foo - if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {}, - //~^ ERROR cannot move out of `foo` in pattern guard [E0507] - Some(s) => std::process::exit(*s), - } - - match Some(&4) { - None => {}, - ref mut foo - if let Some(()) = { (|| { let mut bar = foo.clone(); bar.take() })(); None } => {}, - //~^ ERROR cannot move out of `foo` in pattern guard [E0507] - Some(s) => std::process::exit(*s), - } -} diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs index f3d0a184e03..c3b19886a50 100644 --- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs +++ b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs @@ -1,7 +1,7 @@ // Issue 27282: Example 1: This sidesteps the AST checks disallowing // mutable borrows in match guards by hiding the mutable borrow in a // guard behind a move (of the ref mut pattern id) within a closure. -//@ run-rustfix + #![feature(if_let_guard)] fn main() { diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr index 7781e77894b..e790fda4d7c 100644 --- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr +++ b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr @@ -7,10 +7,6 @@ LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -help: consider cloning the value if the performance cost is acceptable - | -LL | if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {}, - | ++++++++ error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-move-ref-mut-into-guard.rs:19:34 @@ -21,10 +17,6 @@ LL | if let Some(()) = { (|| { let mut bar = foo; bar.take() })(); N | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -help: consider cloning the value if the performance cost is acceptable - | -LL | if let Some(()) = { (|| { let mut bar = foo.clone(); bar.take() })(); None } => {}, - | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/nll/issue-27282-mutation-in-guard.stderr b/tests/ui/nll/issue-27282-mutation-in-guard.stderr index f73e4aaa489..0b5d723172c 100644 --- a/tests/ui/nll/issue-27282-mutation-in-guard.stderr +++ b/tests/ui/nll/issue-27282-mutation-in-guard.stderr @@ -7,10 +7,6 @@ LL | (|| { let bar = foo; bar.take() })(); | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -help: consider cloning the value if the performance cost is acceptable - | -LL | (|| { let bar = foo.clone(); bar.take() })(); - | ++++++++ error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-mutation-in-guard.rs:20:18 @@ -21,10 +17,6 @@ LL | (|| { let bar = foo; bar.take() })(); | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -help: consider cloning the value if the performance cost is acceptable - | -LL | (|| { let bar = foo.clone(); bar.take() })(); - | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr b/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr index f4e7869bf00..7f9cbc3c30a 100644 --- a/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr +++ b/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr @@ -41,10 +41,6 @@ help: consider borrowing here | LL | let p = &s.url; p | + -help: consider cloning the value if the performance cost is acceptable - | -LL | let p = s.url.clone(); p - | ++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/nll/match-guards-always-borrow.fixed b/tests/ui/nll/match-guards-always-borrow.fixed deleted file mode 100644 index 56e743bf196..00000000000 --- a/tests/ui/nll/match-guards-always-borrow.fixed +++ /dev/null @@ -1,66 +0,0 @@ -#![feature(if_let_guard)] -#![allow(unused_mut)] -//@ run-rustfix - -// Here is arielb1's basic example from rust-lang/rust#27282 -// that AST borrowck is flummoxed by: - -fn should_reject_destructive_mutate_in_guard() { - match Some(&4) { - None => {}, - ref mut foo if { - (|| { let mut bar = foo.clone(); bar.take() })(); - //~^ ERROR cannot move out of `foo` in pattern guard [E0507] - false } => { }, - Some(s) => std::process::exit(*s), - } - - match Some(&4) { - None => {}, - ref mut foo if let Some(()) = { - (|| { let mut bar = foo.clone(); bar.take() })(); - //~^ ERROR cannot move out of `foo` in pattern guard [E0507] - None } => { }, - Some(s) => std::process::exit(*s), - } -} - -// Here below is a case that needs to keep working: we only use the -// binding via immutable-borrow in the guard, and we mutate in the arm -// body. -fn allow_mutate_in_arm_body() { - match Some(&4) { - None => {}, - ref mut foo if foo.is_some() => { foo.take(); () } - Some(s) => std::process::exit(*s), - } - - match Some(&4) { - None => {}, - ref mut foo if let Some(_) = foo => { foo.take(); () } - Some(s) => std::process::exit(*s), - } -} - -// Here below is a case that needs to keep working: we only use the -// binding via immutable-borrow in the guard, and we move into the arm -// body. -fn allow_move_into_arm_body() { - match Some(&4) { - None => {}, - mut foo if foo.is_some() => { foo.unwrap(); () } - Some(s) => std::process::exit(*s), - } - - match Some(&4) { - None => {}, - mut foo if let Some(_) = foo => { foo.unwrap(); () } - Some(s) => std::process::exit(*s), - } -} - -fn main() { - should_reject_destructive_mutate_in_guard(); - allow_mutate_in_arm_body(); - allow_move_into_arm_body(); -} diff --git a/tests/ui/nll/match-guards-always-borrow.rs b/tests/ui/nll/match-guards-always-borrow.rs index 927d55c42a6..5271e3cfc66 100644 --- a/tests/ui/nll/match-guards-always-borrow.rs +++ b/tests/ui/nll/match-guards-always-borrow.rs @@ -1,6 +1,5 @@ #![feature(if_let_guard)] #![allow(unused_mut)] -//@ run-rustfix // Here is arielb1's basic example from rust-lang/rust#27282 // that AST borrowck is flummoxed by: diff --git a/tests/ui/nll/match-guards-always-borrow.stderr b/tests/ui/nll/match-guards-always-borrow.stderr index bb0c5bd4c97..71977bd8472 100644 --- a/tests/ui/nll/match-guards-always-borrow.stderr +++ b/tests/ui/nll/match-guards-always-borrow.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/match-guards-always-borrow.rs:12:14 + --> $DIR/match-guards-always-borrow.rs:11:14 | LL | (|| { let mut bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -7,13 +7,9 @@ LL | (|| { let mut bar = foo; bar.take() })(); | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -help: consider cloning the value if the performance cost is acceptable - | -LL | (|| { let mut bar = foo.clone(); bar.take() })(); - | ++++++++ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/match-guards-always-borrow.rs:21:14 + --> $DIR/match-guards-always-borrow.rs:20:14 | LL | (|| { let mut bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -21,10 +17,6 @@ LL | (|| { let mut bar = foo; bar.take() })(); | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -help: consider cloning the value if the performance cost is acceptable - | -LL | (|| { let mut bar = foo.clone(); bar.take() })(); - | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/nll/polonius/polonius-smoke-test.stderr b/tests/ui/nll/polonius/polonius-smoke-test.stderr index 534813b2d9f..a8a8267290d 100644 --- a/tests/ui/nll/polonius/polonius-smoke-test.stderr +++ b/tests/ui/nll/polonius/polonius-smoke-test.stderr @@ -27,6 +27,12 @@ LL | let z = x; | ^ move out of `x` occurs here LL | y | - returning this value requires that `*x` is borrowed for `'1` + | +help: consider cloning the value if the performance cost is acceptable + | +LL - let y = &mut *x; +LL + let y = &mut x.clone(); + | error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/polonius-smoke-test.rs:42:5 @@ -40,6 +46,12 @@ LL | s; | ^ move out of `s` occurs here LL | tmp; | --- borrow later used here + | +help: consider cloning the value if the performance cost is acceptable + | +LL - let r = &mut *s; +LL + let r = &mut s.clone(); + | error: aborting due to 4 previous errors diff --git a/tests/ui/panics/panic-in-cleanup.run.stderr b/tests/ui/panics/panic-in-cleanup.run.stderr index e7def11b0e9..3417d4bf1a3 100644 --- a/tests/ui/panics/panic-in-cleanup.run.stderr +++ b/tests/ui/panics/panic-in-cleanup.run.stderr @@ -4,6 +4,6 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'main' panicked at $DIR/panic-in-cleanup.rs:16:9: BOOM stack backtrace: -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: panic in a destructor during cleanup thread caused non-unwinding panic. aborting. diff --git a/tests/ui/panics/panic-in-ffi.run.stderr b/tests/ui/panics/panic-in-ffi.run.stderr index 596355399c8..fc70847ad9a 100644 --- a/tests/ui/panics/panic-in-ffi.run.stderr +++ b/tests/ui/panics/panic-in-ffi.run.stderr @@ -1,7 +1,7 @@ thread 'main' panicked at $DIR/panic-in-ffi.rs:12:5: Test note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/tests/ui/parser/brace-in-let-chain.stderr b/tests/ui/parser/brace-in-let-chain.stderr index d76cb25ad8b..913a34700df 100644 --- a/tests/ui/parser/brace-in-let-chain.stderr +++ b/tests/ui/parser/brace-in-let-chain.stderr @@ -17,14 +17,8 @@ LL | fn qux() { | - unclosed delimiter ... LL | fn foo() { - | - unclosed delimiter -... -LL | fn bar() { - | - unclosed delimiter + | - another 3 unclosed delimiters begin from here ... -LL | fn baz() { - | - unclosed delimiter -LL | if false { LL | { | - this delimiter might not be properly closed... LL | && let () = () diff --git a/tests/ui/parser/issues/issue-105366.fixed b/tests/ui/parser/issues/issue-105366.fixed index 95419dc07f2..7157b647524 100644 --- a/tests/ui/parser/issues/issue-105366.fixed +++ b/tests/ui/parser/issues/issue-105366.fixed @@ -1,6 +1,5 @@ //@ run-rustfix -#[allow(dead_code)] struct Foo; impl From<i32> for Foo { diff --git a/tests/ui/parser/issues/issue-105366.rs b/tests/ui/parser/issues/issue-105366.rs index 3278b737991..dc3cb8b343d 100644 --- a/tests/ui/parser/issues/issue-105366.rs +++ b/tests/ui/parser/issues/issue-105366.rs @@ -1,6 +1,5 @@ //@ run-rustfix -#[allow(dead_code)] struct Foo; fn From<i32> for Foo { diff --git a/tests/ui/parser/issues/issue-105366.stderr b/tests/ui/parser/issues/issue-105366.stderr index 195305a2ec8..18c04dfaf20 100644 --- a/tests/ui/parser/issues/issue-105366.stderr +++ b/tests/ui/parser/issues/issue-105366.stderr @@ -1,5 +1,5 @@ error: you might have meant to write `impl` instead of `fn` - --> $DIR/issue-105366.rs:6:1 + --> $DIR/issue-105366.rs:5:1 | LL | fn From<i32> for Foo { | ^^ diff --git a/tests/ui/parser/mismatched-delimiter-corner-case-issue-127868.rs b/tests/ui/parser/mismatched-delimiter-corner-case-issue-127868.rs new file mode 100644 index 00000000000..5dcaa266325 --- /dev/null +++ b/tests/ui/parser/mismatched-delimiter-corner-case-issue-127868.rs @@ -0,0 +1,6 @@ +// issue: rust-lang/rust#127868 + +fn main() { + let a = [[[[[[[[[[[[[[[[[[[[1, {, (, [,; +} //~ ERROR mismatched closing delimiter: `}` +//~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/mismatched-delimiter-corner-case-issue-127868.stderr b/tests/ui/parser/mismatched-delimiter-corner-case-issue-127868.stderr new file mode 100644 index 00000000000..94e25c18e40 --- /dev/null +++ b/tests/ui/parser/mismatched-delimiter-corner-case-issue-127868.stderr @@ -0,0 +1,30 @@ +error: mismatched closing delimiter: `}` + --> $DIR/mismatched-delimiter-corner-case-issue-127868.rs:4:42 + | +LL | fn main() { + | - closing delimiter possibly meant for this +LL | let a = [[[[[[[[[[[[[[[[[[[[1, {, (, [,; + | ^ unclosed delimiter +LL | } + | ^ mismatched closing delimiter + +error: this file contains an unclosed delimiter + --> $DIR/mismatched-delimiter-corner-case-issue-127868.rs:6:52 + | +LL | fn main() { + | - unclosed delimiter +LL | let a = [[[[[[[[[[[[[[[[[[[[1, {, (, [,; + | ----- - this delimiter might not be properly closed... + | ||||| + | ||||another 16 unclosed delimiters begin from here + | |||unclosed delimiter + | ||unclosed delimiter + | |unclosed delimiter + | unclosed delimiter +LL | } + | - ...as it matches this but it has different indentation +LL | + | ^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed index e9c89807fa5..a851300a982 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed @@ -1,8 +1,7 @@ // Regression test for issues #100790 and #106439. //@ run-rustfix -#[allow(dead_code)] -pub struct Example(usize) +pub struct Example(#[allow(dead_code)] usize) where (): Sized; //~^^^ ERROR where clauses are not allowed before tuple struct bodies diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs index 3bd0f51ec2c..10f435859f1 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs @@ -1,11 +1,10 @@ // Regression test for issues #100790 and #106439. //@ run-rustfix -#[allow(dead_code)] pub struct Example where (): Sized, -(usize); +(#[allow(dead_code)] usize); //~^^^ ERROR where clauses are not allowed before tuple struct bodies struct _Demo diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr index 77eafa6bea3..ddbf237e866 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr @@ -1,23 +1,23 @@ error: where clauses are not allowed before tuple struct bodies - --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:6:1 + --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:5:1 | LL | pub struct Example | ------- while parsing this tuple struct LL | / where LL | | (): Sized, | |______________^ unexpected where clause -LL | (usize); - | ------- the struct body +LL | (#[allow(dead_code)] usize); + | --------------------------- the struct body | help: move the body before the where clause | -LL ~ pub struct Example(usize) +LL ~ pub struct Example(#[allow(dead_code)] usize) LL | where LL ~ (): Sized; | error: where clauses are not allowed before tuple struct bodies - --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:12:1 + --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:11:1 | LL | struct _Demo | ----- while parsing this tuple struct diff --git a/tests/ui/parser/removed-syntax/removed-syntax-box.stderr b/tests/ui/parser/removed-syntax/removed-syntax-box.stderr index 46b891587d5..60c39fd37c4 100644 --- a/tests/ui/parser/removed-syntax/removed-syntax-box.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-box.stderr @@ -7,7 +7,7 @@ LL | let _ = box (); help: use `Box::new()` instead | LL | let _ = Box::new(()); - | ~~~~~~~~~~~~ + | ~~~~~~~~~ + error: `box_syntax` has been removed --> $DIR/removed-syntax-box.rs:10:13 @@ -18,7 +18,7 @@ LL | let _ = box 1; help: use `Box::new()` instead | LL | let _ = Box::new(1); - | ~~~~~~~~~~~ + | ~~~~~~~~~ + error: `box_syntax` has been removed --> $DIR/removed-syntax-box.rs:11:13 @@ -29,7 +29,7 @@ LL | let _ = box T { a: 12, b: 18 }; help: use `Box::new()` instead | LL | let _ = Box::new(T { a: 12, b: 18 }); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~ + error: `box_syntax` has been removed --> $DIR/removed-syntax-box.rs:12:13 @@ -40,7 +40,7 @@ LL | let _ = box [5; 30]; help: use `Box::new()` instead | LL | let _ = Box::new([5; 30]); - | ~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~ + error: `box_syntax` has been removed --> $DIR/removed-syntax-box.rs:13:22 @@ -51,7 +51,7 @@ LL | let _: Box<()> = box (); help: use `Box::new()` instead | LL | let _: Box<()> = Box::new(()); - | ~~~~~~~~~~~~ + | ~~~~~~~~~ + error: aborting due to 5 previous errors diff --git a/tests/ui/parser/unsafe-foreign-mod-2.rs b/tests/ui/parser/unsafe-foreign-mod-2.rs index 0b63a993c5b..6d339cd9088 100644 --- a/tests/ui/parser/unsafe-foreign-mod-2.rs +++ b/tests/ui/parser/unsafe-foreign-mod-2.rs @@ -1,8 +1,6 @@ extern "C" unsafe { //~^ ERROR expected `{`, found keyword `unsafe` - //~| ERROR extern block cannot be declared unsafe unsafe fn foo(); - //~^ ERROR items in unadorned `extern` blocks cannot have safety qualifiers } fn main() {} diff --git a/tests/ui/parser/unsafe-foreign-mod-2.stderr b/tests/ui/parser/unsafe-foreign-mod-2.stderr index 8bd592b5d43..0625e3362ed 100644 --- a/tests/ui/parser/unsafe-foreign-mod-2.stderr +++ b/tests/ui/parser/unsafe-foreign-mod-2.stderr @@ -4,21 +4,5 @@ error: expected `{`, found keyword `unsafe` LL | extern "C" unsafe { | ^^^^^^ expected `{` -error: extern block cannot be declared unsafe - --> $DIR/unsafe-foreign-mod-2.rs:1:12 - | -LL | extern "C" unsafe { - | ^^^^^^ - | - = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information - = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/unsafe-foreign-mod-2.rs:4:5 - | -LL | unsafe fn foo(); - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/parser/unsafe-foreign-mod.rs b/tests/ui/parser/unsafe-foreign-mod.rs index eab134a4a4d..623c3bb81e4 100644 --- a/tests/ui/parser/unsafe-foreign-mod.rs +++ b/tests/ui/parser/unsafe-foreign-mod.rs @@ -1,5 +1,5 @@ -unsafe extern "C" { - //~^ ERROR extern block cannot be declared unsafe -} +//@ check-pass + +unsafe extern "C" {} fn main() {} diff --git a/tests/ui/parser/unsafe-foreign-mod.stderr b/tests/ui/parser/unsafe-foreign-mod.stderr deleted file mode 100644 index 60b918a89b3..00000000000 --- a/tests/ui/parser/unsafe-foreign-mod.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: extern block cannot be declared unsafe - --> $DIR/unsafe-foreign-mod.rs:1:1 - | -LL | unsafe extern "C" { - | ^^^^^^ - | - = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information - = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index e925fe78f33..9359244c6eb 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -333,14 +333,6 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -note: if `U` implemented `Clone`, you could clone the value - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:17:5 - | -LL | struct U; - | ^^^^^^^^ consider implementing `Clone` for this type -... -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | - you could clone this value error[E0507]: cannot move out of `b` in pattern guard --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66 @@ -349,14 +341,6 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -note: if `U` implemented `Clone`, you could clone the value - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:17:5 - | -LL | struct U; - | ^^^^^^^^ consider implementing `Clone` for this type -... -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | - you could clone this value = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0507]: cannot move out of `a` in pattern guard diff --git a/tests/ui/pattern/issue-22546.rs b/tests/ui/pattern/issue-22546.rs index d5c5b68be78..fd1d5fb6c47 100644 --- a/tests/ui/pattern/issue-22546.rs +++ b/tests/ui/pattern/issue-22546.rs @@ -15,7 +15,7 @@ impl<T: ::std::fmt::Display> Foo<T> { } } -trait Tr { +trait Tr { //~ WARN trait `Tr` is never used type U; } diff --git a/tests/ui/pattern/issue-22546.stderr b/tests/ui/pattern/issue-22546.stderr new file mode 100644 index 00000000000..e067a95e422 --- /dev/null +++ b/tests/ui/pattern/issue-22546.stderr @@ -0,0 +1,10 @@ +warning: trait `Tr` is never used + --> $DIR/issue-22546.rs:18:7 + | +LL | trait Tr { + | ^^ + | + = note: `#[warn(dead_code)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/print-calling-conventions.rs b/tests/ui/print-calling-conventions.rs new file mode 100644 index 00000000000..302ed088142 --- /dev/null +++ b/tests/ui/print-calling-conventions.rs @@ -0,0 +1,2 @@ +//@ compile-flags: --print calling-conventions +//@ build-pass diff --git a/tests/ui/print-calling-conventions.stdout b/tests/ui/print-calling-conventions.stdout new file mode 100644 index 00000000000..da67a57f420 --- /dev/null +++ b/tests/ui/print-calling-conventions.stdout @@ -0,0 +1,34 @@ +C +C-cmse-nonsecure-call +C-unwind +Rust +aapcs +aapcs-unwind +avr-interrupt +avr-non-blocking-interrupt +cdecl +cdecl-unwind +efiapi +fastcall +fastcall-unwind +msp430-interrupt +ptx-kernel +riscv-interrupt-m +riscv-interrupt-s +rust-call +rust-cold +rust-intrinsic +stdcall +stdcall-unwind +system +system-unwind +sysv64 +sysv64-unwind +thiscall +thiscall-unwind +unadjusted +vectorcall +vectorcall-unwind +win64 +win64-unwind +x86-interrupt diff --git a/tests/ui/privacy/issue-75907.stderr b/tests/ui/privacy/issue-75907.stderr index f7cb874c2cc..3121cc04478 100644 --- a/tests/ui/privacy/issue-75907.stderr +++ b/tests/ui/privacy/issue-75907.stderr @@ -14,7 +14,7 @@ LL | let Bar(x, y, Foo(z)) = make_bar(); help: consider making the fields publicly accessible | LL | pub(crate) struct Bar(pub u8, pub u8, pub Foo); - | ~~~ ~~~ +++ + | ~~~ +++ error[E0532]: cannot match against a tuple struct which contains private fields --> $DIR/issue-75907.rs:15:19 diff --git a/tests/ui/privacy/privacy5.stderr b/tests/ui/privacy/privacy5.stderr index 615b0af2762..ec3abe9b816 100644 --- a/tests/ui/privacy/privacy5.stderr +++ b/tests/ui/privacy/privacy5.stderr @@ -53,7 +53,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `A` is private --> $DIR/privacy5.rs:56:12 @@ -262,7 +262,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `C` is private --> $DIR/privacy5.rs:69:12 @@ -281,7 +281,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `C` is private --> $DIR/privacy5.rs:70:12 @@ -300,7 +300,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `C` is private --> $DIR/privacy5.rs:71:12 @@ -319,7 +319,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `C` is private --> $DIR/privacy5.rs:72:18 @@ -338,7 +338,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `C` is private --> $DIR/privacy5.rs:73:18 @@ -357,7 +357,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `C` is private --> $DIR/privacy5.rs:74:18 @@ -376,7 +376,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `C` is private --> $DIR/privacy5.rs:75:18 @@ -395,7 +395,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `A` is private --> $DIR/privacy5.rs:83:17 @@ -452,7 +452,7 @@ LL | pub struct C(pub isize, isize); help: consider making the fields publicly accessible | LL | pub struct C(pub isize, pub isize); - | ~~~ +++ + | +++ error[E0603]: tuple struct constructor `A` is private --> $DIR/privacy5.rs:90:20 diff --git a/tests/ui/privacy/restricted/test.stderr b/tests/ui/privacy/restricted/test.stderr index a48bb671d9f..5deaffbdbf3 100644 --- a/tests/ui/privacy/restricted/test.stderr +++ b/tests/ui/privacy/restricted/test.stderr @@ -4,7 +4,10 @@ error[E0433]: failed to resolve: you might be missing crate `bad` LL | pub(in bad::path) mod m1 {} | ^^^ you might be missing crate `bad` | - = help: consider adding `extern crate bad` to use the `bad` crate +help: consider importing the `bad` crate + | +LL + extern crate bad; + | error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/test.rs:51:12 diff --git a/tests/ui/process/println-with-broken-pipe.run.stderr b/tests/ui/process/println-with-broken-pipe.run.stderr index a334c0ad204..f9d138a0424 100644 --- a/tests/ui/process/println-with-broken-pipe.run.stderr +++ b/tests/ui/process/println-with-broken-pipe.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at library/std/src/io/stdio.rs:LL:CC: +thread 'main' panicked at std/src/io/stdio.rs:LL:CC: failed printing to stdout: Broken pipe (os error 32) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/pub/pub-ident-struct-4.fixed b/tests/ui/pub/pub-ident-struct-4.fixed index a62ece43ece..5fedbb72437 100644 --- a/tests/ui/pub/pub-ident-struct-4.fixed +++ b/tests/ui/pub/pub-ident-struct-4.fixed @@ -1,7 +1,6 @@ //@ run-rustfix -#[allow(dead_code)] -pub struct T(String); +pub struct T(#[allow(dead_code)] String); //~^ ERROR missing `struct` for struct definition fn main() {} diff --git a/tests/ui/pub/pub-ident-struct-4.rs b/tests/ui/pub/pub-ident-struct-4.rs index 0d56a31beaf..5c721c25a78 100644 --- a/tests/ui/pub/pub-ident-struct-4.rs +++ b/tests/ui/pub/pub-ident-struct-4.rs @@ -1,7 +1,6 @@ //@ run-rustfix -#[allow(dead_code)] -pub T(String); +pub T(#[allow(dead_code)] String); //~^ ERROR missing `struct` for struct definition fn main() {} diff --git a/tests/ui/pub/pub-ident-struct-4.stderr b/tests/ui/pub/pub-ident-struct-4.stderr index d3072464e05..04965a1a737 100644 --- a/tests/ui/pub/pub-ident-struct-4.stderr +++ b/tests/ui/pub/pub-ident-struct-4.stderr @@ -1,12 +1,12 @@ error: missing `struct` for struct definition - --> $DIR/pub-ident-struct-4.rs:4:1 + --> $DIR/pub-ident-struct-4.rs:3:1 | -LL | pub T(String); +LL | pub T(#[allow(dead_code)] String); | ^^^^^ | help: add `struct` here to parse `T` as a struct | -LL | pub struct T(String); +LL | pub struct T(#[allow(dead_code)] String); | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/regions/regions-issue-21422.rs b/tests/ui/regions/regions-issue-21422.rs index 67852a6f5de..54beed9b3ac 100644 --- a/tests/ui/regions/regions-issue-21422.rs +++ b/tests/ui/regions/regions-issue-21422.rs @@ -5,7 +5,6 @@ //@ pretty-expanded FIXME #23616 -#[allow(dead_code)] pub struct P<'a> { _ptr: *const &'a u8, } diff --git a/tests/ui/resolve/editions-crate-root-2015.stderr b/tests/ui/resolve/editions-crate-root-2015.stderr index 74fb7e6019f..7a842aca0fd 100644 --- a/tests/ui/resolve/editions-crate-root-2015.stderr +++ b/tests/ui/resolve/editions-crate-root-2015.stderr @@ -4,7 +4,10 @@ error[E0433]: failed to resolve: you might be missing crate `nonexistant` LL | fn global_inner(_: ::nonexistant::Foo) { | ^^^^^^^^^^^ you might be missing crate `nonexistant` | - = help: consider adding `extern crate nonexistant` to use the `nonexistant` crate +help: consider importing the `nonexistant` crate + | +LL + extern crate nonexistant; + | error[E0433]: failed to resolve: you might be missing crate `nonexistant` --> $DIR/editions-crate-root-2015.rs:7:30 @@ -12,7 +15,10 @@ error[E0433]: failed to resolve: you might be missing crate `nonexistant` LL | fn crate_inner(_: crate::nonexistant::Foo) { | ^^^^^^^^^^^ you might be missing crate `nonexistant` | - = help: consider adding `extern crate nonexistant` to use the `nonexistant` crate +help: consider importing the `nonexistant` crate + | +LL + extern crate nonexistant; + | error[E0412]: cannot find type `nonexistant` in the crate root --> $DIR/editions-crate-root-2015.rs:11:25 diff --git a/tests/ui/resolve/extern-prelude-fail.stderr b/tests/ui/resolve/extern-prelude-fail.stderr index 4c2d5abb782..77c10f5f995 100644 --- a/tests/ui/resolve/extern-prelude-fail.stderr +++ b/tests/ui/resolve/extern-prelude-fail.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `extern_prelude` LL | use extern_prelude::S; | ^^^^^^^^^^^^^^ you might be missing crate `extern_prelude` | - = help: consider adding `extern crate extern_prelude` to use the `extern_prelude` crate +help: consider importing the `extern_prelude` crate + | +LL + extern crate extern_prelude; + | error[E0433]: failed to resolve: you might be missing crate `extern_prelude` --> $DIR/extern-prelude-fail.rs:8:15 @@ -12,7 +15,10 @@ error[E0433]: failed to resolve: you might be missing crate `extern_prelude` LL | let s = ::extern_prelude::S; | ^^^^^^^^^^^^^^ you might be missing crate `extern_prelude` | - = help: consider adding `extern crate extern_prelude` to use the `extern_prelude` crate +help: consider importing the `extern_prelude` crate + | +LL + extern crate extern_prelude; + | error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/issue-82865.stderr b/tests/ui/resolve/issue-82865.stderr index ce0061a2b66..bc7e0f07981 100644 --- a/tests/ui/resolve/issue-82865.stderr +++ b/tests/ui/resolve/issue-82865.stderr @@ -4,7 +4,10 @@ error[E0433]: failed to resolve: you might be missing crate `x` LL | use x::y::z; | ^ you might be missing crate `x` | - = help: consider adding `extern crate x` to use the `x` crate +help: consider importing the `x` crate + | +LL + extern crate x; + | error[E0599]: no function or associated item named `z` found for struct `Box<_, _>` in the current scope --> $DIR/issue-82865.rs:8:10 diff --git a/tests/ui/resolve/resolve-bad-visibility.stderr b/tests/ui/resolve/resolve-bad-visibility.stderr index 8e475735403..281e5afb223 100644 --- a/tests/ui/resolve/resolve-bad-visibility.stderr +++ b/tests/ui/resolve/resolve-bad-visibility.stderr @@ -22,7 +22,10 @@ error[E0433]: failed to resolve: you might be missing crate `nonexistent` LL | pub(in nonexistent) struct G; | ^^^^^^^^^^^ you might be missing crate `nonexistent` | - = help: consider adding `extern crate nonexistent` to use the `nonexistent` crate +help: consider importing the `nonexistent` crate + | +LL + extern crate nonexistent; + | error[E0433]: failed to resolve: you might be missing crate `too_soon` --> $DIR/resolve-bad-visibility.rs:8:8 @@ -30,7 +33,10 @@ error[E0433]: failed to resolve: you might be missing crate `too_soon` LL | pub(in too_soon) struct H; | ^^^^^^^^ you might be missing crate `too_soon` | - = help: consider adding `extern crate too_soon` to use the `too_soon` crate +help: consider importing the `too_soon` crate + | +LL + extern crate too_soon; + | error: aborting due to 5 previous errors diff --git a/tests/ui/rust-2024/safe-outside-extern.rs b/tests/ui/rust-2024/safe-outside-extern.rs index 6773df5ef03..674b78dc571 100644 --- a/tests/ui/rust-2024/safe-outside-extern.rs +++ b/tests/ui/rust-2024/safe-outside-extern.rs @@ -1,29 +1,21 @@ -//@ revisions: gated ungated -#![cfg_attr(gated, feature(unsafe_extern_blocks))] - safe fn foo() {} //~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier -//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] safe static FOO: i32 = 1; //~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier -//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] trait Foo { safe fn foo(); //~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier - //[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] } impl Foo for () { safe fn foo() {} //~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier - //[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] } type FnPtr = safe fn(i32, i32) -> i32; //~^ ERROR: function pointers cannot be declared with `safe` safety qualifier -//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] unsafe static LOL: u8 = 0; //~^ ERROR: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block diff --git a/tests/ui/rust-2024/safe-outside-extern.stderr b/tests/ui/rust-2024/safe-outside-extern.stderr new file mode 100644 index 00000000000..19d7c5fde0b --- /dev/null +++ b/tests/ui/rust-2024/safe-outside-extern.stderr @@ -0,0 +1,38 @@ +error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier + --> $DIR/safe-outside-extern.rs:1:1 + | +LL | safe fn foo() {} + | ^^^^^^^^^^^^^^^^ + +error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier + --> $DIR/safe-outside-extern.rs:4:1 + | +LL | safe static FOO: i32 = 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier + --> $DIR/safe-outside-extern.rs:8:5 + | +LL | safe fn foo(); + | ^^^^^^^^^^^^^^ + +error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier + --> $DIR/safe-outside-extern.rs:13:5 + | +LL | safe fn foo() {} + | ^^^^^^^^^^^^^^^^ + +error: function pointers cannot be declared with `safe` safety qualifier + --> $DIR/safe-outside-extern.rs:17:14 + | +LL | type FnPtr = safe fn(i32, i32) -> i32; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block + --> $DIR/safe-outside-extern.rs:20:1 + | +LL | unsafe static LOL: u8 = 0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2021.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2021.stderr index 3a99caa719b..77554da10e6 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2021.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2021.stderr @@ -1,5 +1,5 @@ error[E0133]: call to unsafe function `test1` is unsafe and requires unsafe function or block - --> $DIR/extern-items-unsafe.rs:14:5 + --> $DIR/extern-items-unsafe.rs:12:5 | LL | test1(TEST1); | ^^^^^^^^^^^^ call to unsafe function @@ -7,7 +7,7 @@ LL | test1(TEST1); = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/extern-items-unsafe.rs:14:11 + --> $DIR/extern-items-unsafe.rs:12:11 | LL | test1(TEST1); | ^^^^^ use of extern static diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2024.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2024.stderr index fcf937b7ac5..33b752782d5 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2024.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2024.stderr @@ -1,5 +1,5 @@ error[E0133]: call to unsafe function `test1` is unsafe and requires unsafe block - --> $DIR/extern-items-unsafe.rs:14:5 + --> $DIR/extern-items-unsafe.rs:12:5 | LL | test1(TEST1); | ^^^^^^^^^^^^ call to unsafe function @@ -7,7 +7,7 @@ LL | test1(TEST1); = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: use of extern static is unsafe and requires unsafe block - --> $DIR/extern-items-unsafe.rs:14:11 + --> $DIR/extern-items-unsafe.rs:12:11 | LL | test1(TEST1); | ^^^^^ use of extern static diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.rs b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.rs index ad569a256db..721e07acca5 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.rs @@ -3,8 +3,6 @@ //@[edition2024] edition:2024 //@[edition2024] compile-flags: -Zunstable-options -#![feature(unsafe_extern_blocks)] - unsafe extern "C" { static TEST1: i32; fn test1(i: i32); diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.edition2024.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.edition2024.stderr index d456cfc6829..8ef7c2caf21 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.edition2024.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.edition2024.stderr @@ -1,5 +1,5 @@ error: extern blocks must be unsafe - --> $DIR/extern-items.rs:9:1 + --> $DIR/extern-items.rs:7:1 | LL | / extern "C" { LL | | diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.rs b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.rs index 16fa1bbb8a4..08805c36347 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/extern-items.rs @@ -4,8 +4,6 @@ //@[edition2024] edition:2024 //@[edition2024] compile-flags: -Zunstable-options -#![feature(unsafe_extern_blocks)] - extern "C" { //[edition2024]~^ ERROR extern blocks must be unsafe static TEST1: i32; diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs index 57c03e4d896..67df8c14b39 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.rs @@ -1,6 +1,3 @@ -//@ revisions: gated ungated -#![cfg_attr(gated, feature(unsafe_extern_blocks))] - trait Bar {} safe impl Bar for () { } //~^ ERROR expected one of `!` or `::`, found keyword `impl` diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.gated.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.stderr index 80e7a45f57e..f1021726b18 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.gated.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.stderr @@ -1,5 +1,5 @@ error: expected one of `!` or `::`, found keyword `impl` - --> $DIR/safe-impl-trait.rs:5:6 + --> $DIR/safe-impl-trait.rs:2:6 | LL | safe impl Bar for () { } | ^^^^ expected one of `!` or `::` diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-items.rs b/tests/ui/rust-2024/unsafe-extern-blocks/safe-items.rs index 74cd5621fce..b0b8a8b012a 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/safe-items.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-items.rs @@ -4,8 +4,6 @@ //@[edition2024] compile-flags: -Zunstable-options //@ check-pass -#![feature(unsafe_extern_blocks)] - unsafe extern "C" { safe static TEST1: i32; safe fn test1(i: i32); diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs index e73cb45b188..52773b4cbbb 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.rs @@ -1,6 +1,3 @@ -//@ revisions: gated ungated -#![cfg_attr(gated, feature(unsafe_extern_blocks))] - safe trait Foo {} //~^ ERROR expected one of `!` or `::`, found keyword `trait` diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.stderr new file mode 100644 index 00000000000..1733336a797 --- /dev/null +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-trait.stderr @@ -0,0 +1,8 @@ +error: expected one of `!` or `::`, found keyword `trait` + --> $DIR/safe-trait.rs:1:6 + | +LL | safe trait Foo {} + | ^^^^^ expected one of `!` or `::` + +error: aborting due to 1 previous error + diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2021.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2021.stderr index e90613357b1..93797987286 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2021.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2021.stderr @@ -1,5 +1,5 @@ error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:10:5 + --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:8:5 | LL | safe static TEST1: i32; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | unsafe extern "C" { | ++++++ error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:12:5 + --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:10:5 | LL | safe fn test1(i: i32); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2024.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2024.stderr index 1207ee158cc..e9db6006c0b 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2024.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.edition2024.stderr @@ -1,5 +1,5 @@ error: extern blocks must be unsafe - --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:8:1 + --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:6:1 | LL | / extern "C" { LL | | @@ -11,7 +11,7 @@ LL | | } | |_^ error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:10:5 + --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:8:5 | LL | safe static TEST1: i32; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | unsafe extern "C" { | ++++++ error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:12:5 + --> $DIR/safe-unsafe-on-unadorned-extern-block.rs:10:5 | LL | safe fn test1(i: i32); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.rs b/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.rs index 11f55cb195f..4badb50b267 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.rs @@ -3,8 +3,6 @@ //@[edition2024] edition:2024 //@[edition2024] compile-flags: -Zunstable-options -#![feature(unsafe_extern_blocks)] - extern "C" { //[edition2024]~^ ERROR extern blocks must be unsafe safe static TEST1: i32; diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.fixed b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.fixed index 10c19759d8a..f686809615f 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.fixed +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.fixed @@ -1,6 +1,5 @@ //@ run-rustfix -#![feature(unsafe_extern_blocks)] #![deny(missing_unsafe_on_extern)] #![allow(unused)] diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.rs b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.rs index b81e52ddc58..00f1cbdab54 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.rs @@ -1,6 +1,5 @@ //@ run-rustfix -#![feature(unsafe_extern_blocks)] #![deny(missing_unsafe_on_extern)] #![allow(unused)] diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr index 0a3c2cd25e3..bb1d068ceb9 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr @@ -1,5 +1,5 @@ error: extern blocks should be unsafe - --> $DIR/unsafe-extern-suggestion.rs:7:1 + --> $DIR/unsafe-extern-suggestion.rs:6:1 | LL | extern "C" { | ^ @@ -16,7 +16,7 @@ LL | | } = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! = note: for more information, see issue #123743 <https://github.com/rust-lang/rust/issues/123743> note: the lint level is defined here - --> $DIR/unsafe-extern-suggestion.rs:4:9 + --> $DIR/unsafe-extern-suggestion.rs:3:9 | LL | #![deny(missing_unsafe_on_extern)] | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2021.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2021.stderr index 8bb7ffefeea..e3626bb497e 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2021.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2021.stderr @@ -1,5 +1,5 @@ error[E0133]: call to unsafe function `test1` is unsafe and requires unsafe function or block - --> $DIR/unsafe-items.rs:20:5 + --> $DIR/unsafe-items.rs:18:5 | LL | test1(TEST1); | ^^^^^^^^^^^^ call to unsafe function @@ -7,7 +7,7 @@ LL | test1(TEST1); = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/unsafe-items.rs:20:11 + --> $DIR/unsafe-items.rs:18:11 | LL | test1(TEST1); | ^^^^^ use of extern static diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2024.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2024.stderr index 9a30142a632..89bc501b7b5 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2024.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.edition2024.stderr @@ -1,5 +1,5 @@ error[E0133]: call to unsafe function `test1` is unsafe and requires unsafe block - --> $DIR/unsafe-items.rs:20:5 + --> $DIR/unsafe-items.rs:18:5 | LL | test1(TEST1); | ^^^^^^^^^^^^ call to unsafe function @@ -7,7 +7,7 @@ LL | test1(TEST1); = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: use of extern static is unsafe and requires unsafe block - --> $DIR/unsafe-items.rs:20:11 + --> $DIR/unsafe-items.rs:18:11 | LL | test1(TEST1); | ^^^^^ use of extern static diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.rs b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.rs index 9066953abc6..dc2bae892a9 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-items.rs @@ -3,8 +3,6 @@ //@[edition2024] edition:2024 //@[edition2024] compile-flags: -Zunstable-options -#![feature(unsafe_extern_blocks)] - unsafe extern "C" { unsafe static TEST1: i32; unsafe fn test1(i: i32); diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.fixed b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.fixed index 2ff595cc44d..857d34eef85 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.fixed +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.fixed @@ -1,6 +1,5 @@ //@ run-rustfix -#![feature(unsafe_extern_blocks)] #![allow(dead_code)] unsafe extern "C" { diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.rs b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.rs index 6fe43f7a5b4..edab9850d79 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.rs +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.rs @@ -1,6 +1,5 @@ //@ run-rustfix -#![feature(unsafe_extern_blocks)] #![allow(dead_code)] extern "C" { diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.stderr index 05d23d001ad..073245e650b 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.stderr @@ -1,5 +1,5 @@ error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/unsafe-on-extern-block-issue-126756.rs:7:5 + --> $DIR/unsafe-on-extern-block-issue-126756.rs:6:5 | LL | unsafe fn foo(); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr b/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr index e01e1edab5a..6559845c23e 100644 --- a/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr +++ b/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr @@ -17,10 +17,6 @@ error[E0282]: type annotations needed LL | .sum::<_>() | ^^^ cannot infer type of the type parameter `S` declared on the method `sum` | -help: consider specifying the generic argument - | -LL | .sum::<_>() - | ~~~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/span/send-is-not-static-std-sync.stderr b/tests/ui/span/send-is-not-static-std-sync.stderr index 50b8ffe0114..6bc3ed8d24f 100644 --- a/tests/ui/span/send-is-not-static-std-sync.stderr +++ b/tests/ui/span/send-is-not-static-std-sync.stderr @@ -15,7 +15,7 @@ LL | *lock.lock().unwrap() = &z; help: consider cloning the value if the performance cost is acceptable | LL - *lock.lock().unwrap() = &*y; -LL + *lock.lock().unwrap() = y.clone(); +LL + *lock.lock().unwrap() = &y.clone(); | error[E0597]: `z` does not live long enough @@ -48,7 +48,7 @@ LL | *lock.write().unwrap() = &z; help: consider cloning the value if the performance cost is acceptable | LL - *lock.write().unwrap() = &*y; -LL + *lock.write().unwrap() = y.clone(); +LL + *lock.write().unwrap() = &y.clone(); | error[E0597]: `z` does not live long enough @@ -81,7 +81,7 @@ LL | tx.send(&z).unwrap(); help: consider cloning the value if the performance cost is acceptable | LL - tx.send(&*y); -LL + tx.send(y.clone()); +LL + tx.send(&y.clone()); | error[E0597]: `z` does not live long enough diff --git a/tests/ui/stable-mir-print/basic_function.stdout b/tests/ui/stable-mir-print/basic_function.stdout index 3926c1048f5..76288c2aa49 100644 --- a/tests/ui/stable-mir-print/basic_function.stdout +++ b/tests/ui/stable-mir-print/basic_function.stdout @@ -44,14 +44,14 @@ fn demux(_1: u8) -> u8 { let mut _0: u8; debug input => _1; bb0: { - switchInt(_1) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb1]; + switchInt(_1) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1]; } bb1: { _0 = 0_u8; goto -> bb5; } bb2: { - _0 = 10_u8; + _0 = 8_u8; goto -> bb5; } bb3: { @@ -59,7 +59,7 @@ fn demux(_1: u8) -> u8 { goto -> bb5; } bb4: { - _0 = 8_u8; + _0 = 10_u8; goto -> bb5; } bb5: { diff --git a/tests/ui/structs-enums/newtype-struct-with-dtor.rs b/tests/ui/structs-enums/newtype-struct-with-dtor.rs index 16439a7fedd..19672e41c9a 100644 --- a/tests/ui/structs-enums/newtype-struct-with-dtor.rs +++ b/tests/ui/structs-enums/newtype-struct-with-dtor.rs @@ -3,10 +3,8 @@ #![allow(unused_variables)] //@ pretty-expanded FIXME #23616 -#[allow(dead_code)] pub struct Fd(u32); -#[allow(dead_code)] fn foo(a: u32) {} impl Drop for Fd { diff --git a/tests/ui/structs-enums/uninstantiable-struct.rs b/tests/ui/structs-enums/uninstantiable-struct.rs index 1074dbcd6e6..97bc7d8414e 100644 --- a/tests/ui/structs-enums/uninstantiable-struct.rs +++ b/tests/ui/structs-enums/uninstantiable-struct.rs @@ -1,5 +1,4 @@ //@ run-pass -#[allow(dead_code)] -pub struct Z(&'static Z); +pub struct Z(#[allow(dead_code)] &'static Z); pub fn main() {} diff --git a/tests/ui/suggestions/borrow-for-loop-head.stderr b/tests/ui/suggestions/borrow-for-loop-head.stderr index a8de9986c31..55fcb44168c 100644 --- a/tests/ui/suggestions/borrow-for-loop-head.stderr +++ b/tests/ui/suggestions/borrow-for-loop-head.stderr @@ -10,9 +10,8 @@ LL | for j in a { | help: consider cloning the value if the performance cost is acceptable | -LL - for i in &a { -LL + for i in a.clone() { - | +LL | for i in &a.clone() { + | ++++++++ error[E0382]: use of moved value: `a` --> $DIR/borrow-for-loop-head.rs:4:18 diff --git a/tests/ui/suggestions/derive-clone-for-eq.fixed b/tests/ui/suggestions/derive-clone-for-eq.fixed index cf800c6e47d..4dc362f9478 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.fixed +++ b/tests/ui/suggestions/derive-clone-for-eq.fixed @@ -1,7 +1,6 @@ //@ run-rustfix // https://github.com/rust-lang/rust/issues/79076 -#[allow(dead_code)] #[derive(Clone, Eq)] //~ ERROR [E0277] pub struct Struct<T: std::clone::Clone>(T); diff --git a/tests/ui/suggestions/derive-clone-for-eq.rs b/tests/ui/suggestions/derive-clone-for-eq.rs index 84736426bac..b3635000f16 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.rs +++ b/tests/ui/suggestions/derive-clone-for-eq.rs @@ -1,7 +1,6 @@ //@ run-rustfix // https://github.com/rust-lang/rust/issues/79076 -#[allow(dead_code)] #[derive(Clone, Eq)] //~ ERROR [E0277] pub struct Struct<T>(T); diff --git a/tests/ui/suggestions/derive-clone-for-eq.stderr b/tests/ui/suggestions/derive-clone-for-eq.stderr index 54670fbffcf..6fae6e1316d 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.stderr +++ b/tests/ui/suggestions/derive-clone-for-eq.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/derive-clone-for-eq.rs:5:17 + --> $DIR/derive-clone-for-eq.rs:4:17 | LL | #[derive(Clone, Eq)] | ^^ the trait `Clone` is not implemented for `T`, which is required by `Struct<T>: PartialEq` | note: required for `Struct<T>` to implement `PartialEq` - --> $DIR/derive-clone-for-eq.rs:8:19 + --> $DIR/derive-clone-for-eq.rs:7:19 | LL | impl<T: Clone, U> PartialEq<U> for Struct<T> | ----- ^^^^^^^^^^^^ ^^^^^^^^^ diff --git a/tests/ui/suggestions/option-content-move.fixed b/tests/ui/suggestions/option-content-move.fixed index ef07d55871e..4a5a9483c20 100644 --- a/tests/ui/suggestions/option-content-move.fixed +++ b/tests/ui/suggestions/option-content-move.fixed @@ -1,5 +1,4 @@ //@ run-rustfix -#[allow(dead_code)] pub struct LipogramCorpora { selections: Vec<(char, Option<String>)>, } @@ -18,7 +17,6 @@ impl LipogramCorpora { } } -#[allow(dead_code)] pub struct LipogramCorpora2 { selections: Vec<(char, Result<String, String>)>, } diff --git a/tests/ui/suggestions/option-content-move.rs b/tests/ui/suggestions/option-content-move.rs index 5be6358fd6a..90d05c74399 100644 --- a/tests/ui/suggestions/option-content-move.rs +++ b/tests/ui/suggestions/option-content-move.rs @@ -1,5 +1,4 @@ //@ run-rustfix -#[allow(dead_code)] pub struct LipogramCorpora { selections: Vec<(char, Option<String>)>, } @@ -18,7 +17,6 @@ impl LipogramCorpora { } } -#[allow(dead_code)] pub struct LipogramCorpora2 { selections: Vec<(char, Result<String, String>)>, } diff --git a/tests/ui/suggestions/option-content-move.stderr b/tests/ui/suggestions/option-content-move.stderr index b4ec5b180d2..a382a04344a 100644 --- a/tests/ui/suggestions/option-content-move.stderr +++ b/tests/ui/suggestions/option-content-move.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `selection.1` which is behind a shared reference - --> $DIR/option-content-move.rs:11:20 + --> $DIR/option-content-move.rs:10:20 | LL | if selection.1.unwrap().contains(selection.0) { | ^^^^^^^^^^^ -------- `selection.1` moved due to this method call @@ -19,7 +19,7 @@ LL | if selection.1.clone().unwrap().contains(selection.0) { | ++++++++ error[E0507]: cannot move out of `selection.1` which is behind a shared reference - --> $DIR/option-content-move.rs:30:20 + --> $DIR/option-content-move.rs:28:20 | LL | if selection.1.unwrap().contains(selection.0) { | ^^^^^^^^^^^ -------- `selection.1` moved due to this method call diff --git a/tests/ui/suggestions/recover-missing-turbofish-surrounding-angle-braket.stderr b/tests/ui/suggestions/recover-missing-turbofish-surrounding-angle-braket.stderr index 618ccba0d3d..dde6060c433 100644 --- a/tests/ui/suggestions/recover-missing-turbofish-surrounding-angle-braket.stderr +++ b/tests/ui/suggestions/recover-missing-turbofish-surrounding-angle-braket.stderr @@ -40,7 +40,7 @@ LL | let _ = vec![1, 2, 3].into_iter().collect::Vec<_>>(); help: surround the type parameters with angle brackets | LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<_>>(); - | + ~ + | + error: aborting due to 4 previous errors diff --git a/tests/ui/traits/non_lifetime_binders/shadowed.rs b/tests/ui/traits/non_lifetime_binders/shadowed.rs new file mode 100644 index 00000000000..1c480e3940b --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/shadowed.rs @@ -0,0 +1,18 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +fn function<T>() where for<T> (): Sized {} +//~^ ERROR the name `T` is already used for a generic parameter + +struct Struct<T>(T) where for<T> (): Sized; +//~^ ERROR the name `T` is already used for a generic parameter + +impl<T> Struct<T> { + fn method() where for<T> (): Sized {} + //~^ ERROR the name `T` is already used for a generic parameter +} + +fn repeated() where for<T, T> (): Sized {} +//~^ ERROR the name `T` is already used for a generic parameter + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/shadowed.stderr b/tests/ui/traits/non_lifetime_binders/shadowed.stderr new file mode 100644 index 00000000000..59a073aefc9 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/shadowed.stderr @@ -0,0 +1,44 @@ +error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters + --> $DIR/shadowed.rs:4:28 + | +LL | fn function<T>() where for<T> (): Sized {} + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters + --> $DIR/shadowed.rs:7:31 + | +LL | struct Struct<T>(T) where for<T> (): Sized; + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters + --> $DIR/shadowed.rs:11:27 + | +LL | impl<T> Struct<T> { + | - first use of `T` +LL | fn method() where for<T> (): Sized {} + | ^ already used + +error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters + --> $DIR/shadowed.rs:15:28 + | +LL | fn repeated() where for<T, T> (): Sized {} + | - ^ already used + | | + | first use of `T` + +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/shadowed.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to 4 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0403`. diff --git a/tests/ui/traits/object/generics.rs b/tests/ui/traits/object/generics.rs index 0ae562c0d30..462b0bc5bb7 100644 --- a/tests/ui/traits/object/generics.rs +++ b/tests/ui/traits/object/generics.rs @@ -7,7 +7,6 @@ pub trait Trait2<A> { fn doit(&self) -> A; } -#[allow(dead_code)] pub struct Impl<A1, A2, A3> { m1: marker::PhantomData<(A1,A2,A3)>, /* diff --git a/tests/ui/try-block/try-block-bad-lifetime.stderr b/tests/ui/try-block/try-block-bad-lifetime.stderr index 6f693295357..28941cb0a9e 100644 --- a/tests/ui/try-block/try-block-bad-lifetime.stderr +++ b/tests/ui/try-block/try-block-bad-lifetime.stderr @@ -34,11 +34,6 @@ LL | Err(k) ?; ... LL | ::std::mem::drop(k); | ^ value used here after move - | -help: consider cloning the value if the performance cost is acceptable - | -LL | Err(k.clone()) ?; - | ++++++++ error[E0506]: cannot assign to `i` because it is borrowed --> $DIR/try-block-bad-lifetime.rs:32:9 diff --git a/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr b/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr index dc0bea58a70..bf8829c0925 100644 --- a/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr +++ b/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr @@ -12,3 +12,13 @@ LL | foo::<T, U>(); error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0282`. +Future incompatibility report: Future breakage diagnostic: +warning: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:3:11 + | +LL | fn foo<T, U = u64>() -> (T, U) { + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + diff --git a/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs b/tests/ui/type/default_type_parameter_in_fn_or_impl.rs index 33038e24bc6..33038e24bc6 100644 --- a/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs +++ b/tests/ui/type/default_type_parameter_in_fn_or_impl.rs diff --git a/tests/ui/type/default_type_parameter_in_fn_or_impl.stderr b/tests/ui/type/default_type_parameter_in_fn_or_impl.stderr new file mode 100644 index 00000000000..a3205cd3c29 --- /dev/null +++ b/tests/ui/type/default_type_parameter_in_fn_or_impl.stderr @@ -0,0 +1,43 @@ +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8 + | +LL | fn avg<T=i32>(_: T) {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6 + | +LL | impl<T=i32> S<T> {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + +error: aborting due to 2 previous errors + +Future incompatibility report: Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8 + | +LL | fn avg<T=i32>(_: T) {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6 + | +LL | impl<T=i32> S<T> {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + diff --git a/tests/ui/type/pattern_types/missing-is.rs b/tests/ui/type/pattern_types/missing-is.rs new file mode 100644 index 00000000000..2fbcc1908ef --- /dev/null +++ b/tests/ui/type/pattern_types/missing-is.rs @@ -0,0 +1,8 @@ +#![feature(core_pattern_type, core_pattern_types)] + +use std::pat::pattern_type; + +fn main() { + let x: pattern_type!(i32 0..1); + //~^ ERROR expected one of `!`, `(`, `+`, `::`, `<`, or `is`, found `0` +} diff --git a/tests/ui/type/pattern_types/missing-is.stderr b/tests/ui/type/pattern_types/missing-is.stderr new file mode 100644 index 00000000000..8ed654fe907 --- /dev/null +++ b/tests/ui/type/pattern_types/missing-is.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, or `is`, found `0` + --> $DIR/missing-is.rs:6:30 + | +LL | let x: pattern_type!(i32 0..1); + | ^ expected one of `!`, `(`, `+`, `::`, `<`, or `is` + +error: aborting due to 1 previous error + diff --git a/tests/ui/underscore-imports/issue-110164.stderr b/tests/ui/underscore-imports/issue-110164.stderr index 240742996e1..d8a4b6bbb75 100644 --- a/tests/ui/underscore-imports/issue-110164.stderr +++ b/tests/ui/underscore-imports/issue-110164.stderr @@ -38,33 +38,25 @@ error[E0432]: unresolved import `_` --> $DIR/issue-110164.rs:8:5 | LL | use _::*; - | ^ you might be missing crate `_` - | - = help: consider adding `extern crate _` to use the `_` crate + | ^ `_` is not a valid crate or module name error[E0432]: unresolved import `_` --> $DIR/issue-110164.rs:5:5 | LL | use _::a; - | ^ you might be missing crate `_` - | - = help: consider adding `extern crate _` to use the `_` crate + | ^ `_` is not a valid crate or module name error[E0432]: unresolved import `_` --> $DIR/issue-110164.rs:13:9 | LL | use _::a; - | ^ you might be missing crate `_` - | - = help: consider adding `extern crate _` to use the `_` crate + | ^ `_` is not a valid crate or module name error[E0432]: unresolved import `_` --> $DIR/issue-110164.rs:16:9 | LL | use _::*; - | ^ you might be missing crate `_` - | - = help: consider adding `extern crate _` to use the `_` crate + | ^ `_` is not a valid crate or module name error: aborting due to 10 previous errors diff --git a/tests/ui/unop/unop-move-semantics.stderr b/tests/ui/unop/unop-move-semantics.stderr index bc9b3ea9903..0ae918d434a 100644 --- a/tests/ui/unop/unop-move-semantics.stderr +++ b/tests/ui/unop/unop-move-semantics.stderr @@ -40,7 +40,7 @@ help: if `T` implemented `Clone`, you could clone the value LL | fn move_borrowed<T: Not<Output=T>>(x: T, mut y: T) { | ^ consider constraining this type parameter with `Clone` LL | let m = &x; - | -- you could clone this value + | - you could clone this value error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/unop-move-semantics.rs:17:6 @@ -63,7 +63,7 @@ LL | fn move_borrowed<T: Not<Output=T>>(x: T, mut y: T) { | ^ consider constraining this type parameter with `Clone` LL | let m = &x; LL | let n = &mut y; - | ------ you could clone this value + | - you could clone this value error[E0507]: cannot move out of `*m` which is behind a mutable reference --> $DIR/unop-move-semantics.rs:24:6 diff --git a/tests/ui/unpretty/expanded-exhaustive.rs b/tests/ui/unpretty/expanded-exhaustive.rs index 92c2e7b4884..29472df897a 100644 --- a/tests/ui/unpretty/expanded-exhaustive.rs +++ b/tests/ui/unpretty/expanded-exhaustive.rs @@ -25,7 +25,6 @@ #![feature(trait_alias)] #![feature(try_blocks)] #![feature(unnamed_fields)] -#![feature(unsafe_extern_blocks)] #![feature(yeet_expr)] #![allow(incomplete_features)] diff --git a/tests/ui/unpretty/expanded-exhaustive.stdout b/tests/ui/unpretty/expanded-exhaustive.stdout index 137a8aa5510..cf2f6f8cbaa 100644 --- a/tests/ui/unpretty/expanded-exhaustive.stdout +++ b/tests/ui/unpretty/expanded-exhaustive.stdout @@ -26,7 +26,6 @@ #![feature(trait_alias)] #![feature(try_blocks)] #![feature(unnamed_fields)] -#![feature(unsafe_extern_blocks)] #![feature(yeet_expr)] #![allow(incomplete_features)] #[prelude_import] diff --git a/tests/ui/unresolved/unresolved-asterisk-imports.stderr b/tests/ui/unresolved/unresolved-asterisk-imports.stderr index 299ec699775..ed01f3fdbea 100644 --- a/tests/ui/unresolved/unresolved-asterisk-imports.stderr +++ b/tests/ui/unresolved/unresolved-asterisk-imports.stderr @@ -4,7 +4,10 @@ error[E0432]: unresolved import `not_existing_crate` LL | use not_existing_crate::*; | ^^^^^^^^^^^^^^^^^^ you might be missing crate `not_existing_crate` | - = help: consider adding `extern crate not_existing_crate` to use the `not_existing_crate` crate +help: consider importing the `not_existing_crate` crate + | +LL + extern crate not_existing_crate; + | error: aborting due to 1 previous error diff --git a/tests/ui/unresolved/unresolved-import.rs b/tests/ui/unresolved/unresolved-import.rs index e8f3b323e33..ee520d65e6f 100644 --- a/tests/ui/unresolved/unresolved-import.rs +++ b/tests/ui/unresolved/unresolved-import.rs @@ -1,7 +1,8 @@ use foo::bar; //~^ ERROR unresolved import `foo` [E0432] //~| NOTE you might be missing crate `foo` -//~| HELP consider adding `extern crate foo` to use the `foo` crate +//~| HELP consider importing the `foo` crate +//~| SUGGESTION extern crate foo; use bar::Baz as x; //~^ ERROR unresolved import `bar::Baz` [E0432] diff --git a/tests/ui/unresolved/unresolved-import.stderr b/tests/ui/unresolved/unresolved-import.stderr index 7b03717c827..a1ff2f19eb6 100644 --- a/tests/ui/unresolved/unresolved-import.stderr +++ b/tests/ui/unresolved/unresolved-import.stderr @@ -4,10 +4,13 @@ error[E0432]: unresolved import `foo` LL | use foo::bar; | ^^^ you might be missing crate `foo` | - = help: consider adding `extern crate foo` to use the `foo` crate +help: consider importing the `foo` crate + | +LL + extern crate foo; + | error[E0432]: unresolved import `bar::Baz` - --> $DIR/unresolved-import.rs:6:5 + --> $DIR/unresolved-import.rs:7:5 | LL | use bar::Baz as x; | ^^^^^---^^^^^ @@ -16,7 +19,7 @@ LL | use bar::Baz as x; | no `Baz` in `bar` error[E0432]: unresolved import `food::baz` - --> $DIR/unresolved-import.rs:12:5 + --> $DIR/unresolved-import.rs:13:5 | LL | use food::baz; | ^^^^^^--- @@ -25,7 +28,7 @@ LL | use food::baz; | no `baz` in `food` error[E0432]: unresolved import `food::beens` - --> $DIR/unresolved-import.rs:18:12 + --> $DIR/unresolved-import.rs:19:12 | LL | use food::{beens as Foo}; | -----^^^^^^^ @@ -34,13 +37,13 @@ LL | use food::{beens as Foo}; | help: a similar name exists in the module: `beans` error[E0432]: unresolved import `MyEnum` - --> $DIR/unresolved-import.rs:43:9 + --> $DIR/unresolved-import.rs:44:9 | LL | use MyEnum::*; | ^^^^^^ help: a similar path exists: `self::MyEnum` error[E0432]: unresolved import `Enum` - --> $DIR/unresolved-import.rs:54:9 + --> $DIR/unresolved-import.rs:55:9 | LL | use Enum::*; | ^^^^ help: a similar path exists: `self::Enum` diff --git a/tests/ui/variance/variance-issue-20533.stderr b/tests/ui/variance/variance-issue-20533.stderr index 0a810b7222e..21d8de6ae88 100644 --- a/tests/ui/variance/variance-issue-20533.stderr +++ b/tests/ui/variance/variance-issue-20533.stderr @@ -17,7 +17,7 @@ LL | struct AffineU32(u32); | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let x = foo(&a); - | -- you could clone this value + | - you could clone this value error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:41:14 @@ -38,7 +38,7 @@ LL | struct AffineU32(u32); | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let x = bar(&a); - | -- you could clone this value + | - you could clone this value error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:47:14 @@ -59,7 +59,7 @@ LL | struct AffineU32(u32); | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let x = baz(&a); - | -- you could clone this value + | - you could clone this value error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:53:14 @@ -80,7 +80,7 @@ LL | struct AffineU32(u32); | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let x = bat(&a); - | -- you could clone this value + | - you could clone this value error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:59:14 @@ -96,9 +96,8 @@ LL | drop(x); | help: consider cloning the value if the performance cost is acceptable | -LL - let x = foo(&a); -LL + let x = foo(a.clone()); - | +LL | let x = foo(&a.clone()); + | ++++++++ error: aborting due to 5 previous errors |
