diff options
Diffstat (limited to 'tests')
198 files changed, 1596 insertions, 855 deletions
diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index e375724bc1b..c9a1cd58af3 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -29,28 +29,28 @@ pub struct Aggregate8(u8); // CHECK-LABEL: @check_bigger_size( #[no_mangle] pub unsafe fn check_bigger_size(x: u16) -> u32 { - // CHECK: call void @llvm.assume(i1 false) + // CHECK: store i1 true, ptr poison, align 1 transmute_unchecked(x) } // CHECK-LABEL: @check_smaller_size( #[no_mangle] pub unsafe fn check_smaller_size(x: u32) -> u16 { - // CHECK: call void @llvm.assume(i1 false) + // CHECK: store i1 true, ptr poison, align 1 transmute_unchecked(x) } // CHECK-LABEL: @check_smaller_array( #[no_mangle] pub unsafe fn check_smaller_array(x: [u32; 7]) -> [u32; 3] { - // CHECK: call void @llvm.assume(i1 false) + // CHECK: store i1 true, ptr poison, align 1 transmute_unchecked(x) } // CHECK-LABEL: @check_bigger_array( #[no_mangle] pub unsafe fn check_bigger_array(x: [u32; 3]) -> [u32; 7] { - // CHECK: call void @llvm.assume(i1 false) + // CHECK: store i1 true, ptr poison, align 1 transmute_unchecked(x) } @@ -58,9 +58,9 @@ pub unsafe fn check_bigger_array(x: [u32; 3]) -> [u32; 7] { #[no_mangle] #[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_to_empty_array(x: [u32; 5]) -> [u32; 0] { - // CHECK-NOT: trap - // CHECK: call void @llvm.trap - // CHECK-NOT: trap + // CHECK: start + // CHECK-NEXT: store i1 true, ptr poison, align 1 + // CHECK-NEXT: ret void mir! { { RET = CastTransmute(x); @@ -73,9 +73,9 @@ pub unsafe fn check_to_empty_array(x: [u32; 5]) -> [u32; 0] { #[no_mangle] #[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_from_empty_array(x: [u32; 0]) -> [u32; 5] { - // CHECK-NOT: call - // CHECK: call void @llvm.assume(i1 false) - // CHECK-NOT: call + // CHECK: start + // CHECK-NEXT: store i1 true, ptr poison, align 1 + // CHECK-NEXT: ret void mir! { { RET = CastTransmute(x); @@ -88,9 +88,9 @@ pub unsafe fn check_from_empty_array(x: [u32; 0]) -> [u32; 5] { #[no_mangle] #[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_to_uninhabited(x: u16) { - // CHECK-NOT: trap - // CHECK: call void @llvm.trap - // CHECK-NOT: trap + // CHECK: start + // CHECK-NEXT: store i1 true, ptr poison, align 1 + // CHECK-NEXT: ret void mir! { let temp: BigNever; { @@ -104,7 +104,9 @@ pub unsafe fn check_to_uninhabited(x: u16) { #[no_mangle] #[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_from_uninhabited(x: BigNever) -> u16 { - // CHECK: ret i16 poison + // CHECK: start + // CHECK-NEXT: store i1 true, ptr poison, align 1 + // CHECK-NEXT: ret i16 poison mir! { { RET = CastTransmute(x); @@ -401,9 +403,9 @@ pub unsafe fn check_issue_109992(x: ()) -> [(); 1] { pub unsafe fn check_unit_to_never(x: ()) { // This uses custom MIR to avoid MIR optimizations having removed ZST ops. - // CHECK-NOT: trap - // CHECK: call void @llvm.trap - // CHECK-NOT: trap + // CHECK: start + // CHECK-NEXT: store i1 true, ptr poison, align 1 + // CHECK-NEXT: ret void mir! { let temp: ZstNever; { @@ -420,6 +422,7 @@ pub unsafe fn check_unit_from_never(x: ZstNever) -> () { // This uses custom MIR to avoid MIR optimizations having removed ZST ops. // CHECK: start + // CHECK-NEXT: store i1 true, ptr poison, align 1 // CHECK-NEXT: ret void mir! { { diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff index 285cd0f6527..40e8c06f357 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff @@ -7,13 +7,14 @@ let mut _3: &T; bb0: { - _2 = copy _1; +- _2 = copy _1; _3 = &_1; _0 = opaque::<&T>(copy _3) -> [return: bb1, unwind unreachable]; } bb1: { - _0 = opaque::<T>(copy _2) -> [return: bb2, unwind unreachable]; +- _0 = opaque::<T>(copy _2) -> [return: bb2, unwind unreachable]; ++ _0 = opaque::<T>(copy _1) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff index f189615ea95..d09c96c0f2b 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff @@ -7,13 +7,14 @@ let mut _3: &T; bb0: { - _2 = copy _1; +- _2 = copy _1; _3 = &_1; _0 = opaque::<&T>(copy _3) -> [return: bb1, unwind continue]; } bb1: { - _0 = opaque::<T>(copy _2) -> [return: bb2, unwind continue]; +- _0 = opaque::<T>(copy _2) -> [return: bb2, unwind continue]; ++ _0 = opaque::<T>(copy _1) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index 68cdc57483a..08c46fea5f0 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -50,11 +50,10 @@ fn compare_address() -> bool { fn borrowed<T: Copy + Freeze>(x: T) -> bool { // CHECK-LABEL: fn borrowed( // CHECK: bb0: { - // CHECK-NEXT: _2 = copy _1; // CHECK-NEXT: _3 = &_1; // CHECK-NEXT: _0 = opaque::<&T>(copy _3) // CHECK: bb1: { - // CHECK-NEXT: _0 = opaque::<T>(copy _2) + // CHECK-NEXT: _0 = opaque::<T>(copy _1) mir! { { let a = x; diff --git a/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff b/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff index baa71501047..eab06b1ba1e 100644 --- a/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff +++ b/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff @@ -16,10 +16,11 @@ _3 = const 'b'; _5 = copy _3; _6 = &_3; - _4 = copy _5; +- _4 = copy _5; (*_1) = copy (*_6); _6 = &_5; - _7 = dump_var::<char>(copy _4) -> [return: bb1, unwind unreachable]; +- _7 = dump_var::<char>(copy _4) -> [return: bb1, unwind unreachable]; ++ _7 = dump_var::<char>(copy _5) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/copy-prop/write_to_borrowed.rs b/tests/mir-opt/copy-prop/write_to_borrowed.rs index 05aa2fba18d..06e617b8bfb 100644 --- a/tests/mir-opt/copy-prop/write_to_borrowed.rs +++ b/tests/mir-opt/copy-prop/write_to_borrowed.rs @@ -27,13 +27,12 @@ fn main() { _5 = _3; // CHECK-NEXT: _6 = &_3; _6 = &_3; - // CHECK-NEXT: _4 = copy _5; _4 = _5; // CHECK-NEXT: (*_1) = copy (*_6); *_1 = *_6; // CHECK-NEXT: _6 = &_5; _6 = &_5; - // CHECK-NEXT: _7 = dump_var::<char>(copy _4) + // CHECK-NEXT: _7 = dump_var::<char>(copy _5) Call(_7 = dump_var(_4), ReturnTo(bb1), UnwindUnreachable()) } bb1 = { Return() } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index 97036745009..cbdd194afd3 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -10,18 +10,18 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 let mut _8: &&usize; let _9: &usize; let mut _10: &&usize; - let mut _15: bool; + let mut _13: bool; + let mut _14: &&usize; + let _15: &usize; let mut _16: &&usize; - let _17: &usize; - let mut _18: &&usize; + let mut _19: bool; + let mut _20: &&usize; + let _21: &usize; + let mut _22: &&usize; let mut _23: bool; let mut _24: &&usize; let _25: &usize; let mut _26: &&usize; - let mut _29: bool; - let mut _30: &&usize; - let _31: &usize; - let mut _32: &&usize; scope 1 { debug a => _4; debug b => _5; @@ -30,47 +30,39 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 scope 2 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { debug self => _8; debug other => _10; - let mut _11: &usize; - let mut _12: &usize; scope 3 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _11; - debug other => _12; - let mut _13: usize; - let mut _14: usize; + debug self => _4; + debug other => _6; + let mut _11: usize; + let mut _12: usize; } } scope 4 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _16; - debug other => _18; - let mut _19: &usize; - let mut _20: &usize; + debug self => _14; + debug other => _16; scope 5 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _19; - debug other => _20; - let mut _21: usize; - let mut _22: usize; + debug self => _7; + debug other => _5; + let mut _17: usize; + let mut _18: usize; } } scope 6 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _24; - debug other => _26; - let mut _27: &usize; - let mut _28: &usize; + debug self => _20; + debug other => _22; scope 7 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _27; - debug other => _28; + debug self => _6; + debug other => _4; } } scope 8 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _30; - debug other => _32; - let mut _33: &usize; - let mut _34: &usize; + debug self => _24; + debug other => _26; scope 9 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _33; - debug other => _34; - let mut _35: usize; - let mut _36: usize; + debug self => _5; + debug other => _7; + let mut _27: usize; + let mut _28: usize; } } } @@ -81,23 +73,17 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 _5 = &((*_3).1: usize); _6 = &((*_3).2: usize); _7 = &((*_3).3: usize); - StorageLive(_15); + StorageLive(_13); StorageLive(_8); _8 = &_4; StorageLive(_10); StorageLive(_9); _9 = copy _6; _10 = &_9; - StorageLive(_11); - StorageLive(_12); - _11 = copy _4; - _12 = copy _6; - _13 = copy ((*_3).0: usize); - _14 = copy ((*_3).2: usize); - _15 = Le(copy _13, copy _14); - StorageDead(_12); - StorageDead(_11); - switchInt(move _15) -> [0: bb1, otherwise: bb2]; + _11 = copy ((*_3).0: usize); + _12 = copy ((*_3).2: usize); + _13 = Le(copy _11, copy _12); + switchInt(move _13) -> [0: bb1, otherwise: bb2]; } bb1: { @@ -111,107 +97,89 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 StorageDead(_9); StorageDead(_10); StorageDead(_8); - StorageLive(_23); + StorageLive(_19); + StorageLive(_14); + _14 = &_7; StorageLive(_16); - _16 = &_7; - StorageLive(_18); + StorageLive(_15); + _15 = copy _5; + _16 = &_15; StorageLive(_17); - _17 = copy _5; - _18 = &_17; - StorageLive(_19); - StorageLive(_20); - _19 = copy _7; - _20 = copy _5; - StorageLive(_21); - _21 = copy ((*_3).3: usize); - StorageLive(_22); - _22 = copy ((*_3).1: usize); - _23 = Le(move _21, move _22); - StorageDead(_22); - StorageDead(_21); - StorageDead(_20); - StorageDead(_19); - switchInt(move _23) -> [0: bb3, otherwise: bb8]; + _17 = copy ((*_3).3: usize); + StorageLive(_18); + _18 = copy ((*_3).1: usize); + _19 = Le(move _17, move _18); + StorageDead(_18); + StorageDead(_17); + switchInt(move _19) -> [0: bb3, otherwise: bb8]; } bb3: { - StorageDead(_17); - StorageDead(_18); + StorageDead(_15); StorageDead(_16); + StorageDead(_14); goto -> bb4; } bb4: { - StorageLive(_29); - StorageLive(_24); - _24 = &_6; - StorageLive(_26); - StorageLive(_25); - _25 = copy _4; - _26 = &_25; - StorageLive(_27); - StorageLive(_28); - _27 = copy _6; - _28 = copy _4; - _29 = Le(copy _14, copy _13); - StorageDead(_28); - StorageDead(_27); - switchInt(move _29) -> [0: bb5, otherwise: bb6]; + StorageLive(_23); + StorageLive(_20); + _20 = &_6; + StorageLive(_22); + StorageLive(_21); + _21 = copy _4; + _22 = &_21; + _23 = Le(copy _12, copy _11); + switchInt(move _23) -> [0: bb5, otherwise: bb6]; } bb5: { - StorageDead(_25); - StorageDead(_26); - StorageDead(_24); + StorageDead(_21); + StorageDead(_22); + StorageDead(_20); _0 = const false; goto -> bb7; } bb6: { + StorageDead(_21); + StorageDead(_22); + StorageDead(_20); + StorageLive(_24); + _24 = &_5; + StorageLive(_26); + StorageLive(_25); + _25 = copy _7; + _26 = &_25; + StorageLive(_27); + _27 = copy ((*_3).1: usize); + StorageLive(_28); + _28 = copy ((*_3).3: usize); + _0 = Le(move _27, move _28); + StorageDead(_28); + StorageDead(_27); StorageDead(_25); StorageDead(_26); StorageDead(_24); - StorageLive(_30); - _30 = &_5; - StorageLive(_32); - StorageLive(_31); - _31 = copy _7; - _32 = &_31; - StorageLive(_33); - StorageLive(_34); - _33 = copy _5; - _34 = copy _7; - StorageLive(_35); - _35 = copy ((*_3).1: usize); - StorageLive(_36); - _36 = copy ((*_3).3: usize); - _0 = Le(move _35, move _36); - StorageDead(_36); - StorageDead(_35); - StorageDead(_34); - StorageDead(_33); - StorageDead(_31); - StorageDead(_32); - StorageDead(_30); goto -> bb7; } bb7: { - StorageDead(_29); + StorageDead(_23); goto -> bb9; } bb8: { - StorageDead(_17); - StorageDead(_18); + StorageDead(_15); StorageDead(_16); + StorageDead(_14); _0 = const true; goto -> bb9; } bb9: { - StorageDead(_23); - StorageDead(_15); + StorageDead(_19); + StorageDead(_13); return; } } diff --git a/tests/run-make/fmt-write-bloat/rmake.rs b/tests/run-make/fmt-write-bloat/rmake.rs index 3348651d501..af6ff6c2983 100644 --- a/tests/run-make/fmt-write-bloat/rmake.rs +++ b/tests/run-make/fmt-write-bloat/rmake.rs @@ -18,7 +18,7 @@ //@ ignore-cross-compile use run_make_support::artifact_names::bin_name; -use run_make_support::env::no_debug_assertions; +use run_make_support::env::std_debug_assertions_enabled; use run_make_support::rustc; use run_make_support::symbols::any_symbol_contains; @@ -26,7 +26,7 @@ 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 std_debug_assertions_enabled() { // 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"]); diff --git a/tests/rustdoc-json/attrs/target_feature.rs b/tests/rustdoc-json/attrs/target_feature.rs index 80262d8e332..5c8aeb84ee3 100644 --- a/tests/rustdoc-json/attrs/target_feature.rs +++ b/tests/rustdoc-json/attrs/target_feature.rs @@ -6,17 +6,17 @@ pub fn test1() {} //@ is "$.index[?(@.name=='test2')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]' -//@ is "$.index[?(@.name=='test1')].inner.function.header.is_unsafe" false +//@ is "$.index[?(@.name=='test2')].inner.function.header.is_unsafe" false #[target_feature(enable = "avx,avx2")] pub fn test2() {} //@ is "$.index[?(@.name=='test3')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]' -//@ is "$.index[?(@.name=='test1')].inner.function.header.is_unsafe" false +//@ is "$.index[?(@.name=='test3')].inner.function.header.is_unsafe" false #[target_feature(enable = "avx", enable = "avx2")] pub fn test3() {} //@ is "$.index[?(@.name=='test4')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\", enable=\"avx512f\")]"]' -//@ is "$.index[?(@.name=='test1')].inner.function.header.is_unsafe" false +//@ is "$.index[?(@.name=='test4')].inner.function.header.is_unsafe" false #[target_feature(enable = "avx", enable = "avx2,avx512f")] pub fn test4() {} diff --git a/tests/ui/allocator/weak-uninhabited-type.rs b/tests/ui/allocator/weak-uninhabited-type.rs new file mode 100644 index 00000000000..74258eedc6a --- /dev/null +++ b/tests/ui/allocator/weak-uninhabited-type.rs @@ -0,0 +1,13 @@ +//! Checks that `Weak` pointers can be created with an empty enum type parameter. +//! And generic `Weak` handles zero-variant enums without error. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/48493> + +//@ run-pass + +enum Void {} + +fn main() { + let _ = std::rc::Weak::<Void>::new(); + let _ = std::sync::Weak::<Void>::new(); +} diff --git a/tests/ui/associated-consts/equality-unused-issue-126729.rs b/tests/ui/associated-consts/equality-unused-issue-126729.rs new file mode 100644 index 00000000000..1482b874b9d --- /dev/null +++ b/tests/ui/associated-consts/equality-unused-issue-126729.rs @@ -0,0 +1,44 @@ +//@ check-pass + +#![feature(associated_const_equality)] +#![deny(dead_code)] + +trait Tr { + const I: i32; +} + +impl Tr for () { + const I: i32 = 1; +} + +fn foo() -> impl Tr<I = 1> {} + +trait Tr2 { + const J: i32; + const K: i32; +} + +impl Tr2 for () { + const J: i32 = 1; + const K: i32 = 1; +} + +fn foo2() -> impl Tr2<J = 1, K = 1> {} + +mod t { + pub trait Tr3 { + const L: i32; + } + + impl Tr3 for () { + const L: i32 = 1; + } +} + +fn foo3() -> impl t::Tr3<L = 1> {} + +fn main() { + foo(); + foo2(); + foo3(); +} diff --git a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr index a7647cf26aa..71a1360cb5a 100644 --- a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr +++ b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr @@ -42,7 +42,7 @@ LL + type X = <CString as Deref>::Target; LL - type X = std::ops::Deref::Target; LL + type X = <IoSlice<'_> as Deref>::Target; | - and N other candidates + = and N other candidates error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:13:23 diff --git a/tests/ui/attributes/builtin-attribute-prefix.rs b/tests/ui/attributes/builtin-attribute-prefix.rs new file mode 100644 index 00000000000..d184c6d008d --- /dev/null +++ b/tests/ui/attributes/builtin-attribute-prefix.rs @@ -0,0 +1,8 @@ +// Regression test for https://github.com/rust-lang/rust/issues/143789 +#[must_use::skip] +//~^ ERROR failed to resolve: use of unresolved module or unlinked crate `must_use` +fn main() { } + +// Regression test for https://github.com/rust-lang/rust/issues/137590 +struct S(#[stable::skip] u8, u16, u32); +//~^ ERROR failed to resolve: use of unresolved module or unlinked crate `stable` diff --git a/tests/ui/attributes/builtin-attribute-prefix.stderr b/tests/ui/attributes/builtin-attribute-prefix.stderr new file mode 100644 index 00000000000..a16080c003f --- /dev/null +++ b/tests/ui/attributes/builtin-attribute-prefix.stderr @@ -0,0 +1,15 @@ +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `stable` + --> $DIR/builtin-attribute-prefix.rs:7:12 + | +LL | struct S(#[stable::skip] u8, u16, u32); + | ^^^^^^ use of unresolved module or unlinked crate `stable` + +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `must_use` + --> $DIR/builtin-attribute-prefix.rs:2:3 + | +LL | #[must_use::skip] + | ^^^^^^^^ use of unresolved module or unlinked crate `must_use` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index 5bcb0c4dc0a..f16ba706485 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -116,24 +116,6 @@ error: malformed `cfi_encoding` attribute input LL | #[cfi_encoding] | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` -error: malformed `type_const` attribute input - --> $DIR/malformed-attrs.rs:143:5 - | -LL | #[type_const = 1] - | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[type_const]` - -error: malformed `marker` attribute input - --> $DIR/malformed-attrs.rs:155:1 - | -LL | #[marker = 3] - | ^^^^^^^^^^^^^ help: must be of the form: `#[marker]` - -error: malformed `fundamental` attribute input - --> $DIR/malformed-attrs.rs:157:1 - | -LL | #[fundamental()] - | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[fundamental]` - error: malformed `link_ordinal` attribute input --> $DIR/malformed-attrs.rs:167:5 | @@ -528,6 +510,24 @@ LL | #[rustc_layout_scalar_valid_range_end] | expected this to be a list | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` +error[E0565]: malformed `marker` attribute input + --> $DIR/malformed-attrs.rs:155:1 + | +LL | #[marker = 3] + | ^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[marker]` + +error[E0565]: malformed `fundamental` attribute input + --> $DIR/malformed-attrs.rs:157:1 + | +LL | #[fundamental()] + | ^^^^^^^^^^^^^--^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[fundamental]` + error[E0565]: malformed `ffi_pure` attribute input --> $DIR/malformed-attrs.rs:165:5 | @@ -555,6 +555,15 @@ LL | #[non_exhaustive = 1] | | didn't expect any arguments here | help: must be of the form: `#[non_exhaustive]` +error[E0565]: malformed `type_const` attribute input + --> $DIR/malformed-attrs.rs:143:5 + | +LL | #[type_const = 1] + | ^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[type_const]` + error: attribute should be applied to `const fn` --> $DIR/malformed-attrs.rs:34:1 | @@ -585,7 +594,7 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments LL | #[diagnostic::do_not_recommend()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: missing options for `on_unimplemented` attribute --> $DIR/malformed-attrs.rs:138:1 diff --git a/tests/ui/type-param-constraints.rs b/tests/ui/auto-traits/auto-traits-type-parameter.rs index 83d81c0d833..0c448f58996 100644 --- a/tests/ui/type-param-constraints.rs +++ b/tests/ui/auto-traits/auto-traits-type-parameter.rs @@ -1,24 +1,25 @@ +//! Checks how type parameters interact with auto-traits like `Send` and `Sync` with implicit +//! bounds + //@ run-pass #![allow(non_camel_case_types)] #![allow(dead_code)] -fn p_foo<T>(_pinned: T) { } -fn s_foo<T>(_shared: T) { } -fn u_foo<T:Send>(_unique: T) { } +fn p_foo<T>(_pinned: T) {} +fn s_foo<T>(_shared: T) {} +fn u_foo<T: Send>(_unique: T) {} struct r { - i: isize, + i: isize, } impl Drop for r { fn drop(&mut self) {} } -fn r(i:isize) -> r { - r { - i: i - } +fn r(i: isize) -> r { + r { i } } pub fn main() { diff --git a/tests/ui/auxiliary/svh-a-base.rs b/tests/ui/auxiliary/svh-a-base.rs deleted file mode 100644 index 36b41fc818f..00000000000 --- a/tests/ui/auxiliary/svh-a-base.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! The `svh-a-*.rs` files are all deviations from the base file -//! svh-a-base.rs with some difference (usually in `fn foo`) that -//! should not affect the strict version hash (SVH) computation -//! (#14132). - -#![crate_name = "a"] - -macro_rules! three { - () => { 3 } -} - -pub trait U {} -pub trait V {} -impl U for () {} -impl V for () {} - -static A_CONSTANT : isize = 2; - -pub fn foo<T:U>(_: isize) -> isize { - 3 -} - -pub fn an_unused_name() -> isize { - 4 -} diff --git a/tests/ui/auxiliary/svh-b.rs b/tests/ui/auxiliary/svh-b.rs deleted file mode 100644 index 57029f70888..00000000000 --- a/tests/ui/auxiliary/svh-b.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! This is a client of the `a` crate defined in `svn-a-base.rs`. The -//! rpass and cfail tests (such as `run-pass/svh-add-comment.rs`) use -//! it by swapping in a different object code library crate built from -//! some variant of `svn-a-base.rs`, and then we are checking if the -//! compiler properly ignores or accepts the change, based on whether -//! the change could affect the downstream crate content or not -//! (#14132). - -#![crate_name = "b"] - -extern crate a; - -pub fn foo() { assert_eq!(a::foo::<()>(0), 3); } diff --git a/tests/ui/binding/underscore-prefixed-function-argument.rs b/tests/ui/binding/underscore-prefixed-function-argument.rs new file mode 100644 index 00000000000..e5b2ec1b5f0 --- /dev/null +++ b/tests/ui/binding/underscore-prefixed-function-argument.rs @@ -0,0 +1,15 @@ +//! Test that argument names starting with `_` are usable. + +//@ run-pass + +fn good(_a: &isize) {} + +fn called<F>(_f: F) +where + F: FnOnce(&isize), +{ +} + +pub fn main() { + called(good); +} diff --git a/tests/ui/borrowck/ownership-struct-update-moved-error.rs b/tests/ui/borrowck/ownership-struct-update-moved-error.rs new file mode 100644 index 00000000000..62fc1f42969 --- /dev/null +++ b/tests/ui/borrowck/ownership-struct-update-moved-error.rs @@ -0,0 +1,19 @@ +//! Checks borrow after move error when using `self` consuming method with struct update syntax. + +struct Mine { + test: String, + other_val: isize, +} + +impl Mine { + fn make_string_bar(mut self) -> Mine { + self.test = "Bar".to_string(); + self + } +} + +fn main() { + let start = Mine { test: "Foo".to_string(), other_val: 0 }; + let end = Mine { other_val: 1, ..start.make_string_bar() }; + println!("{}", start.test); //~ ERROR borrow of moved value: `start` +} diff --git a/tests/ui/walk-struct-literal-with.stderr b/tests/ui/borrowck/ownership-struct-update-moved-error.stderr index 34b501f8ec8..83cfc7bb412 100644 --- a/tests/ui/walk-struct-literal-with.stderr +++ b/tests/ui/borrowck/ownership-struct-update-moved-error.stderr @@ -1,17 +1,17 @@ error[E0382]: borrow of moved value: `start` - --> $DIR/walk-struct-literal-with.rs:16:20 + --> $DIR/ownership-struct-update-moved-error.rs:18:20 | -LL | let start = Mine{test:"Foo".to_string(), other_val:0}; +LL | let start = Mine { test: "Foo".to_string(), other_val: 0 }; | ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait -LL | let end = Mine{other_val:1, ..start.make_string_bar()}; - | ----------------- `start` moved due to this method call +LL | let end = Mine { other_val: 1, ..start.make_string_bar() }; + | ----------------- `start` moved due to this method call LL | println!("{}", start.test); | ^^^^^^^^^^ value borrowed here after move | note: `Mine::make_string_bar` takes ownership of the receiver `self`, which moves `start` - --> $DIR/walk-struct-literal-with.rs:7:28 + --> $DIR/ownership-struct-update-moved-error.rs:9:28 | -LL | fn make_string_bar(mut self) -> Mine{ +LL | fn make_string_bar(mut self) -> Mine { | ^^^^ = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/super-let.borrowck.stderr b/tests/ui/borrowck/super-let-lifetime-and-drop.borrowck.stderr index 01ef29d8758..7fe0b47ed57 100644 --- a/tests/ui/super-let.borrowck.stderr +++ b/tests/ui/borrowck/super-let-lifetime-and-drop.borrowck.stderr @@ -1,5 +1,5 @@ error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:30:28 + --> $DIR/super-let-lifetime-and-drop.rs:30:28 | LL | super let b = DropMe(&mut x); | ------ `x` is borrowed here @@ -11,7 +11,7 @@ LL | } | - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:46:28 + --> $DIR/super-let-lifetime-and-drop.rs:46:28 | LL | super let b = &DropMe(&mut x); | -------------- @@ -26,7 +26,7 @@ LL | } | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:64:32 + --> $DIR/super-let-lifetime-and-drop.rs:64:32 | LL | super let b = identity(&DropMe(&mut x)); | -------------- @@ -40,7 +40,7 @@ LL | }; | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:87:36 + --> $DIR/super-let-lifetime-and-drop.rs:87:36 | LL | super let b = identity(&DropMe(&mut x)); | -------------- @@ -55,7 +55,7 @@ LL | )); | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:107:28 + --> $DIR/super-let-lifetime-and-drop.rs:107:28 | LL | super let b = DropMe(&mut x); | ------ `x` is borrowed here @@ -67,7 +67,7 @@ LL | } | - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:125:28 + --> $DIR/super-let-lifetime-and-drop.rs:125:28 | LL | super let b = DropMe(&mut x); | ------ `x` is borrowed here @@ -79,7 +79,7 @@ LL | } | - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:143:28 + --> $DIR/super-let-lifetime-and-drop.rs:143:28 | LL | super let b = DropMe(&mut x); | ------ `x` is borrowed here @@ -91,7 +91,7 @@ LL | } | - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:159:28 + --> $DIR/super-let-lifetime-and-drop.rs:159:28 | LL | b = DropMe(&mut x); | ------ `x` is borrowed here @@ -102,7 +102,7 @@ LL | drop(a); | - borrow later used here error[E0716]: temporary value dropped while borrowed - --> $DIR/super-let.rs:172:33 + --> $DIR/super-let-lifetime-and-drop.rs:172:33 | LL | #[cfg(borrowck)] { a = &String::from("asdf"); }; | ^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement @@ -115,7 +115,7 @@ LL | let _ = a; = note: consider using a `let` binding to create a longer lived value error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:206:28 + --> $DIR/super-let-lifetime-and-drop.rs:206:28 | LL | super let d = &DropMe(&mut x); | -------------- @@ -130,7 +130,7 @@ LL | } | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:227:32 + --> $DIR/super-let-lifetime-and-drop.rs:227:32 | LL | super let d = identity(&DropMe(&mut x)); | -------------- @@ -145,7 +145,7 @@ LL | }; | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:246:28 + --> $DIR/super-let-lifetime-and-drop.rs:246:28 | LL | super let b = DropMe(&mut x); | ------ `x` is borrowed here @@ -157,7 +157,7 @@ LL | } | - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/super-let.rs:263:28 + --> $DIR/super-let-lifetime-and-drop.rs:263:28 | LL | let dropme = Some(DropMe(&mut x)); | ------ `x` is borrowed here diff --git a/tests/ui/super-let.rs b/tests/ui/borrowck/super-let-lifetime-and-drop.rs index 380470f792f..380470f792f 100644 --- a/tests/ui/super-let.rs +++ b/tests/ui/borrowck/super-let-lifetime-and-drop.rs diff --git a/tests/ui/tag-variant-cast-non-nullary.fixed b/tests/ui/cast/cast-enum-to-primitive-error.fixed index 7e22116b955..4d447c81ac9 100644 --- a/tests/ui/tag-variant-cast-non-nullary.fixed +++ b/tests/ui/cast/cast-enum-to-primitive-error.fixed @@ -1,5 +1,10 @@ +//! This test verifies that a direct non-primitive cast from an enum to an integer type +//! is correctly disallowed, even when a `From` implementation exists for that enum. + //@ run-rustfix + #![allow(dead_code, unused_variables)] + enum NonNullary { Nullary, Other(isize), @@ -16,5 +21,7 @@ impl From<NonNullary> for isize { fn main() { let v = NonNullary::Nullary; - let val = isize::from(v); //~ ERROR non-primitive cast: `NonNullary` as `isize` [E0605] + let val = isize::from(v); + //~^ ERROR non-primitive cast: `NonNullary` as `isize` [E0605] + //~| HELP consider using the `From` trait instead } diff --git a/tests/ui/tag-variant-cast-non-nullary.rs b/tests/ui/cast/cast-enum-to-primitive-error.rs index 1a64cf1933d..fdbe63b9bc7 100644 --- a/tests/ui/tag-variant-cast-non-nullary.rs +++ b/tests/ui/cast/cast-enum-to-primitive-error.rs @@ -1,5 +1,10 @@ +//! This test verifies that a direct non-primitive cast from an enum to an integer type +//! is correctly disallowed, even when a `From` implementation exists for that enum. + //@ run-rustfix + #![allow(dead_code, unused_variables)] + enum NonNullary { Nullary, Other(isize), @@ -16,5 +21,7 @@ impl From<NonNullary> for isize { fn main() { let v = NonNullary::Nullary; - let val = v as isize; //~ ERROR non-primitive cast: `NonNullary` as `isize` [E0605] + let val = v as isize; + //~^ ERROR non-primitive cast: `NonNullary` as `isize` [E0605] + //~| HELP consider using the `From` trait instead } diff --git a/tests/ui/tag-variant-cast-non-nullary.stderr b/tests/ui/cast/cast-enum-to-primitive-error.stderr index 8ec1c5f11ec..692e5c19e06 100644 --- a/tests/ui/tag-variant-cast-non-nullary.stderr +++ b/tests/ui/cast/cast-enum-to-primitive-error.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `NonNullary` as `isize` - --> $DIR/tag-variant-cast-non-nullary.rs:19:15 + --> $DIR/cast-enum-to-primitive-error.rs:24:15 | LL | let val = v as isize; | ^^^^^^^^^^ an `as` expression can be used to convert enum types to numeric types only if the enum type is unit-only or field-less diff --git a/tests/ui/trivial_casts-rpass.rs b/tests/ui/cast/coercion-as-explicit-cast.rs index 701e2f6166f..b99f5d93478 100644 --- a/tests/ui/trivial_casts-rpass.rs +++ b/tests/ui/cast/coercion-as-explicit-cast.rs @@ -1,5 +1,7 @@ +//! This test checks that various forms of "trivial" casts and coercions +//! can be explicitly performed using the `as` keyword without compilation errors. + //@ run-pass -// Test that all coercions can actually be done using casts (modulo the lints). #![allow(trivial_casts, trivial_numeric_casts)] diff --git a/tests/ui/trivial_casts-rpass.stderr b/tests/ui/cast/coercion-as-explicit-cast.stderr index 74698b61ab4..d66298c7d44 100644 --- a/tests/ui/trivial_casts-rpass.stderr +++ b/tests/ui/cast/coercion-as-explicit-cast.stderr @@ -1,5 +1,5 @@ warning: method `foo` is never used - --> $DIR/trivial_casts-rpass.rs:7:8 + --> $DIR/coercion-as-explicit-cast.rs:9:8 | LL | trait Foo { | --- method in this trait diff --git a/tests/ui/unused-move-capture.rs b/tests/ui/closures/no-capture-closure-call.rs index 5f42bcbe280..29e5ac635b4 100644 --- a/tests/ui/unused-move-capture.rs +++ b/tests/ui/closures/no-capture-closure-call.rs @@ -1,3 +1,5 @@ +//! Sanity check for no capture closures + //@ run-pass pub fn main() { diff --git a/tests/ui/unknown-llvm-arg.rs b/tests/ui/codegen/llvm-args-invalid-flag.rs index a8fa55a220a..a8fa55a220a 100644 --- a/tests/ui/unknown-llvm-arg.rs +++ b/tests/ui/codegen/llvm-args-invalid-flag.rs diff --git a/tests/ui/unknown-llvm-arg.stderr b/tests/ui/codegen/llvm-args-invalid-flag.stderr index e1d3cfea28f..e1d3cfea28f 100644 --- a/tests/ui/unknown-llvm-arg.stderr +++ b/tests/ui/codegen/llvm-args-invalid-flag.stderr diff --git a/tests/ui/const-generics/cross_crate_complex.rs b/tests/ui/const-generics/cross_crate_complex.rs index d13b69aa0cf..b44d889f5e9 100644 --- a/tests/ui/const-generics/cross_crate_complex.rs +++ b/tests/ui/const-generics/cross_crate_complex.rs @@ -11,6 +11,7 @@ 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/issues/issue-82956.stderr b/tests/ui/const-generics/issues/issue-82956.stderr index 5e380eea81c..fd93e5122a5 100644 --- a/tests/ui/const-generics/issues/issue-82956.stderr +++ b/tests/ui/const-generics/issues/issue-82956.stderr @@ -14,7 +14,7 @@ LL + use std::collections::btree_map::IntoIter; | LL + use std::collections::btree_set::IntoIter; | - and 9 other candidates + = and 9 other candidates error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-90318.rs b/tests/ui/const-generics/issues/issue-90318.rs index dfba90a5575..239171217eb 100644 --- a/tests/ui/const-generics/issues/issue-90318.rs +++ b/tests/ui/const-generics/issues/issue-90318.rs @@ -1,6 +1,6 @@ #![feature(const_type_id)] #![feature(generic_const_exprs)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_cmp)] #![feature(core_intrinsics)] #![allow(incomplete_features)] diff --git a/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr b/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr index 579aff849d6..125c778ef1c 100644 --- a/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr +++ b/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr @@ -1,9 +1,3 @@ -error: malformed `type_const` attribute input - --> $DIR/bad-type_const-syntax.rs:2:5 - | -LL | #[type_const()] - | ^^^^^^^^^^^^^^^ help: must be of the form: `#[type_const]` - error[E0658]: the `#[type_const]` attribute is an experimental feature --> $DIR/bad-type_const-syntax.rs:2:5 | @@ -24,6 +18,15 @@ LL | #[type_const] = help: add `#![feature(min_generic_const_args)]` 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[E0565]: malformed `type_const` attribute input + --> $DIR/bad-type_const-syntax.rs:2:5 + | +LL | #[type_const()] + | ^^^^^^^^^^^^--^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[type_const]` + error: `#[type_const]` must only be applied to trait associated constants --> $DIR/bad-type_const-syntax.rs:11:5 | @@ -32,4 +35,5 @@ LL | #[type_const] error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0565, E0658. +For more information about an error, try `rustc --explain E0565`. diff --git a/tests/ui/consts/const-eval-array-len-in-impl.rs b/tests/ui/consts/const-eval-array-len-in-impl.rs new file mode 100644 index 00000000000..0373274770d --- /dev/null +++ b/tests/ui/consts/const-eval-array-len-in-impl.rs @@ -0,0 +1,15 @@ +//! This checks that compiler correctly evaluate constant array lengths within trait `impl` headers. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/49208>. + +trait Foo { + fn foo(); +} + +impl Foo for [(); 1] { + fn foo() {} +} + +fn main() { + <[(); 0] as Foo>::foo() //~ ERROR E0277 +} diff --git a/tests/ui/unevaluated_fixed_size_array_len.stderr b/tests/ui/consts/const-eval-array-len-in-impl.stderr index 43cc377006e..faff7aa3ff7 100644 --- a/tests/ui/unevaluated_fixed_size_array_len.stderr +++ b/tests/ui/consts/const-eval-array-len-in-impl.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `[(); 0]: Foo` is not satisfied - --> $DIR/unevaluated_fixed_size_array_len.rs:12:6 + --> $DIR/const-eval-array-len-in-impl.rs:14:6 | LL | <[(); 0] as Foo>::foo() | ^^^^^^^ the trait `Foo` is not implemented for `[(); 0]` diff --git a/tests/ui/consts/const_cmp_type_id.rs b/tests/ui/consts/const_cmp_type_id.rs index def615bd92b..db2d50f4d22 100644 --- a/tests/ui/consts/const_cmp_type_id.rs +++ b/tests/ui/consts/const_cmp_type_id.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Znext-solver -#![feature(const_type_id, const_trait_impl)] +#![feature(const_type_id, const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id.rs b/tests/ui/consts/const_transmute_type_id.rs index 56ead6a622b..a2d4cf37830 100644 --- a/tests/ui/consts/const_transmute_type_id.rs +++ b/tests/ui/consts/const_transmute_type_id.rs @@ -1,4 +1,4 @@ -#![feature(const_type_id, const_trait_impl)] +#![feature(const_type_id, const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id2.rs b/tests/ui/consts/const_transmute_type_id2.rs index e29cf8171ac..3ceb2b942b0 100644 --- a/tests/ui/consts/const_transmute_type_id2.rs +++ b/tests/ui/consts/const_transmute_type_id2.rs @@ -1,6 +1,6 @@ //@ normalize-stderr: "0x(ff)+" -> "<u128::MAX>" -#![feature(const_type_id, const_trait_impl)] +#![feature(const_type_id, const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id3.rs b/tests/ui/consts/const_transmute_type_id3.rs index a870d6e7e80..ed5ff769701 100644 --- a/tests/ui/consts/const_transmute_type_id3.rs +++ b/tests/ui/consts/const_transmute_type_id3.rs @@ -1,4 +1,4 @@ -#![feature(const_type_id, const_trait_impl)] +#![feature(const_type_id, const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id4.rs b/tests/ui/consts/const_transmute_type_id4.rs index bc71f961a51..22a607e9e0e 100644 --- a/tests/ui/consts/const_transmute_type_id4.rs +++ b/tests/ui/consts/const_transmute_type_id4.rs @@ -1,4 +1,4 @@ -#![feature(const_type_id, const_trait_impl)] +#![feature(const_type_id, const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/issue-73976-monomorphic.rs b/tests/ui/consts/issue-73976-monomorphic.rs index 3bfdb397afb..5f364cd995e 100644 --- a/tests/ui/consts/issue-73976-monomorphic.rs +++ b/tests/ui/consts/issue-73976-monomorphic.rs @@ -8,6 +8,7 @@ #![feature(const_type_id)] #![feature(const_type_name)] #![feature(const_trait_impl)] +#![feature(const_cmp)] use std::any::{self, TypeId}; diff --git a/tests/ui/consts/issue-90870.rs b/tests/ui/consts/issue-90870.rs index f807ae75ee5..053763b9f89 100644 --- a/tests/ui/consts/issue-90870.rs +++ b/tests/ui/consts/issue-90870.rs @@ -3,9 +3,9 @@ #![allow(dead_code)] const fn f(a: &u8, b: &u8) -> bool { - //~^ HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable - //~| HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable - //~| HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable + //~^ HELP: add `#![feature(const_cmp)]` to the crate attributes to enable + //~| HELP: add `#![feature(const_cmp)]` to the crate attributes to enable + //~| HELP: add `#![feature(const_cmp)]` to the crate attributes to enable a == b //~^ ERROR: cannot call conditionally-const operator in constant functions //~| ERROR: `PartialEq` is not yet stable as a const trait diff --git a/tests/ui/consts/issue-90870.stderr b/tests/ui/consts/issue-90870.stderr index 8d6f21fd82f..60993f25864 100644 --- a/tests/ui/consts/issue-90870.stderr +++ b/tests/ui/consts/issue-90870.stderr @@ -19,9 +19,9 @@ error: `PartialEq` is not yet stable as a const trait LL | a == b | ^^^^^^ | -help: add `#![feature(const_trait_impl)]` to the crate attributes to enable +help: add `#![feature(const_cmp)]` to the crate attributes to enable | -LL + #![feature(const_trait_impl)] +LL + #![feature(const_cmp)] | error[E0658]: cannot call conditionally-const operator in constant functions @@ -45,9 +45,9 @@ error: `PartialEq` is not yet stable as a const trait LL | a == b | ^^^^^^ | -help: add `#![feature(const_trait_impl)]` to the crate attributes to enable +help: add `#![feature(const_cmp)]` to the crate attributes to enable | -LL + #![feature(const_trait_impl)] +LL + #![feature(const_cmp)] | error[E0658]: cannot call conditionally-const operator in constant functions @@ -71,9 +71,9 @@ error: `PartialEq` is not yet stable as a const trait LL | if l == r { | ^^^^^^ | -help: add `#![feature(const_trait_impl)]` to the crate attributes to enable +help: add `#![feature(const_cmp)]` to the crate attributes to enable | -LL + #![feature(const_trait_impl)] +LL + #![feature(const_cmp)] | error: aborting due to 6 previous errors diff --git a/tests/ui/typestate-multi-decl.rs b/tests/ui/destructuring-assignment/let-binding-tuple-destructuring.rs index 3d0e79632bb..f62fae86219 100644 --- a/tests/ui/typestate-multi-decl.rs +++ b/tests/ui/destructuring-assignment/let-binding-tuple-destructuring.rs @@ -1,3 +1,5 @@ +//! Checks basic multiple variable declaration using tuple destructuring in a `let` binding. + //@ run-pass pub fn main() { diff --git a/tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr b/tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr index 32be9db5317..5c0a437aad8 100644 --- a/tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr +++ b/tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr @@ -9,6 +9,7 @@ note: the lint level is defined here | LL | #![deny(unknown_or_malformed_diagnostic_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[deny(unknown_diagnostic_attributes)]` implied by `#[deny(unknown_or_malformed_diagnostic_attributes)]` error: aborting due to 1 previous error diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr index 8a478a5c733..9d1556ee0c1 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr @@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments LL | #[diagnostic::do_not_recommend(not_accepted)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: `#[diagnostic::do_not_recommend]` does not expect any arguments --> $DIR/does_not_acccept_args.rs:15:1 diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr index 8a478a5c733..9d1556ee0c1 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr @@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments LL | #[diagnostic::do_not_recommend(not_accepted)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: `#[diagnostic::do_not_recommend]` does not expect any arguments --> $DIR/does_not_acccept_args.rs:15:1 diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.current.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.current.stderr index e348f0c8902..29ffbb5bf18 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.current.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.current.stderr @@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implement LL | #[diagnostic::do_not_recommend] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(misplaced_diagnostic_attributes)]` on by default warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations --> $DIR/incorrect-locations.rs:11:1 diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.next.stderr index e348f0c8902..29ffbb5bf18 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.next.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.next.stderr @@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implement LL | #[diagnostic::do_not_recommend] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(misplaced_diagnostic_attributes)]` on by default warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations --> $DIR/incorrect-locations.rs:11:1 diff --git a/tests/ui/diagnostic_namespace/multiline_spans.rs b/tests/ui/diagnostic_namespace/multiline_spans.rs index 994dd9fd011..e0876b19df0 100644 --- a/tests/ui/diagnostic_namespace/multiline_spans.rs +++ b/tests/ui/diagnostic_namespace/multiline_spans.rs @@ -5,17 +5,17 @@ #[diagnostic::on_unimplemented(message = "here is a big \ multiline string \ {unknown}")] -//~^ ERROR there is no parameter `unknown` on trait `MultiLine` [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR there is no parameter `unknown` on trait `MultiLine` [malformed_diagnostic_format_literals] pub trait MultiLine {} #[diagnostic::on_unimplemented(message = "here is a big \ multiline string {unknown}")] -//~^ ERROR there is no parameter `unknown` on trait `MultiLine2` [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR there is no parameter `unknown` on trait `MultiLine2` [malformed_diagnostic_format_literals] pub trait MultiLine2 {} #[diagnostic::on_unimplemented(message = "here is a big \ multiline string {unknown}")] -//~^ ERROR there is no parameter `unknown` on trait `MultiLine3` [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR there is no parameter `unknown` on trait `MultiLine3` [malformed_diagnostic_format_literals] pub trait MultiLine3 {} @@ -25,23 +25,23 @@ pub trait MultiLine3 {} \ \ multiline string {unknown}")] -//~^ ERROR there is no parameter `unknown` on trait `MultiLine4` [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR there is no parameter `unknown` on trait `MultiLine4` [malformed_diagnostic_format_literals] pub trait MultiLine4 {} #[diagnostic::on_unimplemented(message = "here is a big \ multiline string \ {Self:+}")] -//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals] pub trait MultiLineFmt {} #[diagnostic::on_unimplemented(message = "here is a big \ multiline string {Self:X}")] -//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals] pub trait MultiLineFmt2 {} #[diagnostic::on_unimplemented(message = "here is a big \ multiline string {Self:#}")] -//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals] pub trait MultiLineFmt3 {} @@ -51,5 +51,5 @@ pub trait MultiLineFmt3 {} \ \ multiline string {Self:?}")] -//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes] +//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals] pub trait MultiLineFmt4 {} diff --git a/tests/ui/diagnostic_namespace/multiline_spans.stderr b/tests/ui/diagnostic_namespace/multiline_spans.stderr index 894bfe3d90a..0e4bb864b96 100644 --- a/tests/ui/diagnostic_namespace/multiline_spans.stderr +++ b/tests/ui/diagnostic_namespace/multiline_spans.stderr @@ -10,6 +10,7 @@ note: the lint level is defined here | LL | #![deny(unknown_or_malformed_diagnostic_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[deny(malformed_diagnostic_format_literals)]` implied by `#[deny(unknown_or_malformed_diagnostic_attributes)]` error: there is no parameter `unknown` on trait `MultiLine2` --> $DIR/multiline_spans.rs:12:60 diff --git a/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr index 753077b365e..4f9b7ba2bcf 100644 --- a/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr +++ b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr @@ -4,7 +4,7 @@ warning: unknown diagnostic attribute LL | #[diagnostic::non_existing_attribute] | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(unknown_diagnostic_attributes)]` on by default warning: unknown diagnostic attribute --> $DIR/non_existing_attributes_accepted.rs:8:15 diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.rs b/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.rs index 4762d9e793f..82c2db7e26d 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.rs +++ b/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.rs @@ -12,8 +12,8 @@ trait ImportantTrait2 {} #[diagnostic::on_unimplemented(message = "Test {1:}")] //~^WARN positional format arguments are not allowed here //~|WARN positional format arguments are not allowed here -//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes] -//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes] +//~|WARN invalid format specifier [malformed_diagnostic_format_literals] +//~|WARN invalid format specifier [malformed_diagnostic_format_literals] trait ImportantTrait3 {} #[diagnostic::on_unimplemented(message = "Test {Self:123}")] @@ -22,13 +22,13 @@ trait ImportantTrait3 {} trait ImportantTrait4 {} #[diagnostic::on_unimplemented(message = "Test {Self:!}")] -//~^WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes] -//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes] +//~^WARN invalid format specifier [malformed_diagnostic_format_literals] +//~|WARN invalid format specifier [malformed_diagnostic_format_literals] trait ImportantTrait5 {} #[diagnostic::on_unimplemented(message = "Test {Self:}")] -//~^WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes] -//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes] +//~^WARN invalid format specifier [malformed_diagnostic_format_literals] +//~|WARN invalid format specifier [malformed_diagnostic_format_literals] trait ImportantTrait6 {} diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.stderr index 2670d0630f7..5002122f8b7 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/broken_format.stderr @@ -4,7 +4,7 @@ warning: unmatched `}` found LL | #[diagnostic::on_unimplemented(message = "{{Test } thing")] | ^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(malformed_diagnostic_format_literals)]` on by default warning: positional format arguments are not allowed here --> $DIR/broken_format.rs:7:49 diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr index 8dace7d9052..42f4bc0d8b0 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr @@ -4,7 +4,7 @@ warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definiti LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(misplaced_diagnostic_attributes)]` on by default warning: malformed `on_unimplemented` attribute --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:6:5 @@ -13,6 +13,7 @@ LL | on(Self = "&str"), | ^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options + = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: malformed `on_unimplemented` attribute --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:12:5 @@ -45,6 +46,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}", | ^^^^^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument + = note: `#[warn(malformed_diagnostic_format_literals)]` on by default warning: there is no parameter `direct` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:33:34 diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr index 80790dc3f79..85d74fb8955 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr @@ -4,7 +4,7 @@ warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definiti LL | #[diagnostic::on_unimplemented(message = "Baz")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(misplaced_diagnostic_attributes)]` on by default warning: malformed `on_unimplemented` attribute --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32 @@ -13,6 +13,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")] | ^^^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options + = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: malformed `on_unimplemented` attribute --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:12:50 @@ -61,6 +62,7 @@ LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")] | ^^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument + = note: `#[warn(malformed_diagnostic_format_literals)]` on by default warning: malformed `on_unimplemented` attribute --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32 diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr index e00846da77b..86fe75a62de 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr @@ -5,7 +5,7 @@ LL | if(Self = "()"), | ^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: `message` is ignored due to previous definition of `message` --> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:10:32 diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.stderr index 5eee6478922..69433f91543 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.stderr @@ -4,7 +4,7 @@ warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definiti LL | #[diagnostic::on_unimplemented(message = "blah", label = "blah", note = "blah")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(misplaced_diagnostic_attributes)]` on by default error[E0277]: the trait bound `{integer}: Alias` is not satisfied --> $DIR/on_impl_trait.rs:16:9 diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/report_warning_on_duplicated_options.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/report_warning_on_duplicated_options.stderr index feafe2cee76..d2e121b61a6 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/report_warning_on_duplicated_options.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/report_warning_on_duplicated_options.stderr @@ -7,7 +7,7 @@ LL | message = "first message", LL | message = "second message", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `message` is already declared here | - = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: `label` is ignored due to previous definition of `label` --> $DIR/report_warning_on_duplicated_options.rs:11:5 diff --git a/tests/ui/diagnostic_namespace/suggest_typos.rs b/tests/ui/diagnostic_namespace/suggest_typos.rs index 8d1dc6f59da..37a1c79bb08 100644 --- a/tests/ui/diagnostic_namespace/suggest_typos.rs +++ b/tests/ui/diagnostic_namespace/suggest_typos.rs @@ -1,5 +1,5 @@ //@ reference: attributes.diagnostic.namespace.unknown-invalid-syntax -#![deny(unknown_or_malformed_diagnostic_attributes)] +#![deny(unknown_diagnostic_attributes)] #[diagnostic::onunimplemented] //~^ERROR unknown diagnostic attribute diff --git a/tests/ui/diagnostic_namespace/suggest_typos.stderr b/tests/ui/diagnostic_namespace/suggest_typos.stderr index 1f19fd4bbcf..c1177945ea6 100644 --- a/tests/ui/diagnostic_namespace/suggest_typos.stderr +++ b/tests/ui/diagnostic_namespace/suggest_typos.stderr @@ -7,8 +7,8 @@ LL | #[diagnostic::onunimplemented] note: the lint level is defined here --> $DIR/suggest_typos.rs:2:9 | -LL | #![deny(unknown_or_malformed_diagnostic_attributes)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(unknown_diagnostic_attributes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: an attribute with a similar name exists | LL | #[diagnostic::on_unimplemented] diff --git a/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr b/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr index 927f9e842e6..12965800a02 100644 --- a/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr +++ b/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr @@ -18,7 +18,7 @@ LL + fn setup() -> Determine { Set } LL - fn setup() -> Set { Set } LL + fn setup() -> PutDown { Set } | - and 3 other candidates + = and 3 other candidates error[E0425]: cannot find value `Set` in this scope --> $DIR/issue-56028-there-is-an-enum-variant.rs:9:21 @@ -36,7 +36,7 @@ LL + use Determine::Set; | LL + use PutDown::Set; | - and 3 other candidates + = and 3 other candidates error: aborting due to 2 previous errors diff --git a/tests/ui/drop/box-drop-unused-value-statement-regression.rs b/tests/ui/drop/box-drop-unused-value-statement-regression.rs new file mode 100644 index 00000000000..43865e08444 --- /dev/null +++ b/tests/ui/drop/box-drop-unused-value-statement-regression.rs @@ -0,0 +1,12 @@ +//! Regression test for a crash caused by an "unsused move" +//! (specifically, a variable bound to a `Box` used as a statement) +//! leading to incorrect memory zero-filling after drop. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/3878>. + +//@ run-pass + +pub fn main() { + let y: Box<_> = Box::new(1); + drop(y); +} diff --git a/tests/ui/weird-exprs.rs b/tests/ui/expr/syntax-edge-cases-lint-clean.rs index 7db92d46067..7db92d46067 100644 --- a/tests/ui/weird-exprs.rs +++ b/tests/ui/expr/syntax-edge-cases-lint-clean.rs diff --git a/tests/ui/generic-associated-types/missing-bounds.fixed b/tests/ui/generic-associated-types/missing-bounds.fixed index 703d3c1e0fb..15cdd44d7f1 100644 --- a/tests/ui/generic-associated-types/missing-bounds.fixed +++ b/tests/ui/generic-associated-types/missing-bounds.fixed @@ -1,5 +1,7 @@ //@ run-rustfix +#![allow(dead_code)] + use std::ops::Add; struct A<B>(B); diff --git a/tests/ui/generic-associated-types/missing-bounds.rs b/tests/ui/generic-associated-types/missing-bounds.rs index f40b4228873..dad111c8c15 100644 --- a/tests/ui/generic-associated-types/missing-bounds.rs +++ b/tests/ui/generic-associated-types/missing-bounds.rs @@ -1,5 +1,7 @@ //@ run-rustfix +#![allow(dead_code)] + use std::ops::Add; struct A<B>(B); diff --git a/tests/ui/generic-associated-types/missing-bounds.stderr b/tests/ui/generic-associated-types/missing-bounds.stderr index 13e4d249876..97b88c26e3b 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:37:33 + --> $DIR/missing-bounds.rs:39:33 | LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { | ^^^^^^^^^^^^^^^^^^^^^^ not supported @@ -12,7 +12,7 @@ LL + impl<B: Add> Add for E<B> where B: Add<Output = B> { | error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:11:11 + --> $DIR/missing-bounds.rs:13:11 | LL | impl<B> Add for A<B> where B: Add { | - expected this type parameter @@ -25,14 +25,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:11:9 + --> $DIR/missing-bounds.rs:13:9 | LL | A(self.0 + rhs.0) | ^^--------------^ | | | this argument influences the type of `A` note: tuple struct defined here - --> $DIR/missing-bounds.rs:5:8 + --> $DIR/missing-bounds.rs:7:8 | LL | struct A<B>(B); | ^ @@ -42,7 +42,7 @@ LL | impl<B> Add for A<B> where B: Add<Output = B> { | ++++++++++++ error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:21:14 + --> $DIR/missing-bounds.rs:23:14 | LL | impl<B: Add> Add for C<B> { | - expected this type parameter @@ -55,7 +55,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:15:8 + --> $DIR/missing-bounds.rs:17:8 | LL | struct C<B>(B); | ^ @@ -65,7 +65,7 @@ LL | impl<B: Add<Output = B>> Add for C<B> { | ++++++++++++ error[E0369]: cannot add `B` to `B` - --> $DIR/missing-bounds.rs:31:21 + --> $DIR/missing-bounds.rs:33:21 | LL | Self(self.0 + rhs.0) | ------ ^ ----- B @@ -78,7 +78,7 @@ LL | impl<B: std::ops::Add<Output = B>> Add for D<B> { | +++++++++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:42:14 + --> $DIR/missing-bounds.rs:44:14 | LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { | - expected this type parameter @@ -91,7 +91,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:35:8 + --> $DIR/missing-bounds.rs:37:8 | LL | struct E<B>(B); | ^ diff --git a/tests/ui/generics/generic-enum-errors.rs b/tests/ui/generics/generic-enum-errors.rs new file mode 100644 index 00000000000..111f5635168 --- /dev/null +++ b/tests/ui/generics/generic-enum-errors.rs @@ -0,0 +1,15 @@ +//! This test checks that unused generics are rejected by compiler + +enum Quux<T> { + //~^ ERROR: parameter `T` is never used + Bar, +} + +fn foo(c: Quux) { + //~^ ERROR missing generics for enum `Quux` + assert!((false)); +} + +fn main() { + panic!(); +} diff --git a/tests/ui/tag-type-args.stderr b/tests/ui/generics/generic-enum-errors.stderr index def13832e1a..47a8badbd5d 100644 --- a/tests/ui/tag-type-args.stderr +++ b/tests/ui/generics/generic-enum-errors.stderr @@ -1,26 +1,26 @@ error[E0392]: type parameter `T` is never used - --> $DIR/tag-type-args.rs:1:11 + --> $DIR/generic-enum-errors.rs:3:11 | -LL | enum Quux<T> { Bar } +LL | enum Quux<T> { | ^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead error[E0107]: missing generics for enum `Quux` - --> $DIR/tag-type-args.rs:4:11 + --> $DIR/generic-enum-errors.rs:8:11 | -LL | fn foo(c: Quux) { assert!((false)); } +LL | fn foo(c: Quux) { | ^^^^ expected 1 generic argument | note: enum defined here, with 1 generic parameter: `T` - --> $DIR/tag-type-args.rs:1:6 + --> $DIR/generic-enum-errors.rs:3:6 | -LL | enum Quux<T> { Bar } +LL | enum Quux<T> { | ^^^^ - help: add missing generic argument | -LL | fn foo(c: Quux<T>) { assert!((false)); } +LL | fn foo(c: Quux<T>) { | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/wrong-hashset-issue-42918.rs b/tests/ui/hashmap/hashset-enum-variant.rs index 5795cc527cf..39a59d3a39b 100644 --- a/tests/ui/wrong-hashset-issue-42918.rs +++ b/tests/ui/hashmap/hashset-enum-variant.rs @@ -1,26 +1,27 @@ +//! Check for correct initialization of `HashSet` with enums. This is a regression test for a +//! codegen bug that caused the `HashSet` to appear as if it contained one of each enum variant. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/42918> + //@ run-pass -// -#![allow(dead_code)] //@ compile-flags: -O +#![allow(dead_code)] + use std::collections::HashSet; #[derive(PartialEq, Debug, Hash, Eq, Clone, PartialOrd, Ord)] enum MyEnum { E0, - E1, - E2, E3, E4, - E5, E6, E7, } - fn main() { use MyEnum::*; let s: HashSet<_> = [E4, E1].iter().cloned().collect(); diff --git a/tests/ui/impl-trait/call_method_without_import.no_import.stderr b/tests/ui/impl-trait/call_method_without_import.no_import.stderr index 72982b695bb..e59409ea27e 100644 --- a/tests/ui/impl-trait/call_method_without_import.no_import.stderr +++ b/tests/ui/impl-trait/call_method_without_import.no_import.stderr @@ -30,7 +30,7 @@ LL + use std::fmt::Display; | LL + use std::fmt::LowerExp; | - and 5 other candidates + = and 5 other candidates error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.rs b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.rs index e3dc22c1992..9c9cef24a96 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.rs +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.rs @@ -43,4 +43,17 @@ trait Qux { //~^^^^ ERROR: the name `foo` is defined multiple times } +trait T0<T> { + type Target; +} +trait T1<T> {} + +trait X { + fn a() -> impl T0<(), Target = impl T1<()>>; + fn a() -> impl T0<(), Target = impl T1<()>>; + //~^ ERROR the name `a` is defined multiple times + fn a() -> impl T0<(), Target = impl T1<()>>; + //~^ ERROR the name `a` is defined multiple times +} + fn main() {} diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.stderr b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.stderr index f4e73dc1798..8356f94f2aa 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.stderr +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.stderr @@ -44,6 +44,27 @@ LL | | >; | = note: `foo` must be defined only once in the value namespace of this trait -error: aborting due to 4 previous errors +error[E0428]: the name `a` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn-with-nested.rs:53:5 + | +LL | fn a() -> impl T0<(), Target = impl T1<()>>; + | -------------------------------------------- previous definition of the value `a` here +LL | fn a() -> impl T0<(), Target = impl T1<()>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `a` redefined here + | + = note: `a` must be defined only once in the value namespace of this trait + +error[E0428]: the name `a` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn-with-nested.rs:55:5 + | +LL | fn a() -> impl T0<(), Target = impl T1<()>>; + | -------------------------------------------- previous definition of the value `a` here +... +LL | fn a() -> impl T0<(), Target = impl T1<()>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `a` redefined here + | + = note: `a` must be defined only once in the value namespace of this trait + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/imports/issue-56125.stderr b/tests/ui/imports/issue-56125.stderr index 81336d51df4..371130facf9 100644 --- a/tests/ui/imports/issue-56125.stderr +++ b/tests/ui/imports/issue-56125.stderr @@ -18,7 +18,7 @@ LL + use ::issue_56125::issue_56125; LL - use empty::issue_56125; LL + use ::issue_56125::last_segment::issue_56125; | - and 1 other candidate + = and 1 other candidate error[E0659]: `issue_56125` is ambiguous --> $DIR/issue-56125.rs:6:9 diff --git a/tests/ui/write-fmt-errors.rs b/tests/ui/io-checks/write-macro-error.rs index b48fa3f11cc..857ea0024e1 100644 --- a/tests/ui/write-fmt-errors.rs +++ b/tests/ui/io-checks/write-macro-error.rs @@ -1,3 +1,6 @@ +//! Tests that errors from both the writer (`Write::write`) and formatter (`Display::fmt`) +//! are correctly propagated: writer errors return `Err`, formatter errors cause panics. + //@ run-pass //@ needs-unwind @@ -24,7 +27,9 @@ impl Write for ErrorWriter { Err(Error::new(WRITER_ERROR, "not connected")) } - fn flush(&mut self) -> io::Result<()> { Ok(()) } + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } } fn main() { @@ -37,7 +42,8 @@ fn main() { let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap(); assert!( err.contains("formatting trait implementation returned an error"), - "unexpected panic: {}", err + "unexpected panic: {}", + err ); // Writer error when there's some string before the first `{}` @@ -50,6 +56,7 @@ fn main() { let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap(); assert!( err.contains("formatting trait implementation returned an error"), - "unexpected panic: {}", err + "unexpected panic: {}", + err ); } diff --git a/tests/ui/lang-items/lang-item-unknown-definition-error.rs b/tests/ui/lang-items/lang-item-unknown-definition-error.rs new file mode 100644 index 00000000000..22812128c2d --- /dev/null +++ b/tests/ui/lang-items/lang-item-unknown-definition-error.rs @@ -0,0 +1,12 @@ +//! Checks that compiler prevernt attempting to define an unrecognized or unknown lang item + +#![allow(unused)] +#![feature(lang_items)] + +#[lang = "foo"] +fn bar() -> ! { + //~^^ ERROR definition of an unknown lang item: `foo` + loop {} +} + +fn main() {} diff --git a/tests/ui/unknown-language-item.stderr b/tests/ui/lang-items/lang-item-unknown-definition-error.stderr index 832f1342418..3b939757ac2 100644 --- a/tests/ui/unknown-language-item.stderr +++ b/tests/ui/lang-items/lang-item-unknown-definition-error.stderr @@ -1,5 +1,5 @@ error[E0522]: definition of an unknown lang item: `foo` - --> $DIR/unknown-language-item.rs:4:1 + --> $DIR/lang-item-unknown-definition-error.rs:6:1 | LL | #[lang = "foo"] | ^^^^^^^^^^^^^^^ definition of unknown lang item `foo` diff --git a/tests/ui/type-id-higher-rank-2.rs b/tests/ui/lifetimes/any-lifetime-escape-higher-rank.rs index 7b0c7b53940..f9f38ee532d 100644 --- a/tests/ui/type-id-higher-rank-2.rs +++ b/tests/ui/lifetimes/any-lifetime-escape-higher-rank.rs @@ -1,11 +1,15 @@ +//! Checks that `std::any::Any` cannot be used to circumvent lifetime rules +//! with higher-rank types. + //@ run-pass -// Test that we can't ignore lifetimes by going through Any. use std::any::Any; struct Foo<'a>(&'a str); -fn good(s: &String) -> Foo<'_> { Foo(s) } +fn good(s: &String) -> Foo<'_> { + Foo(s) +} fn bad1(s: String) -> Option<&'static str> { let a: Box<dyn Any> = Box::new(good as fn(&String) -> Foo); @@ -17,7 +21,9 @@ trait AsStr<'a, 'b> { } impl<'a> AsStr<'a, 'a> for String { - fn get(&'a self) -> &'a str { self } + fn get(&'a self) -> &'a str { + self + } } fn bad2(s: String) -> Option<&'static str> { diff --git a/tests/ui/type_length_limit.rs b/tests/ui/limits/type-length-limit-enforcement.rs index 87f5ffd76d7..3b34d6eb5c8 100644 --- a/tests/ui/type_length_limit.rs +++ b/tests/ui/limits/type-length-limit-enforcement.rs @@ -1,17 +1,19 @@ -//@ build-fail +//~ ERROR reached the type-length limit + +//! Checks the enforcement of the type-length limit +//! and its configurability via `#![type_length_limit]`. + //@ compile-flags: -Copt-level=0 -Zenforce-type-length-limit -//~^^ ERROR reached the type-length limit -// Test that the type length limit can be changed. -// The exact type depends on optimizations, so disable them. +//@ build-fail #![allow(dead_code)] -#![type_length_limit="8"] +#![type_length_limit = "8"] macro_rules! link { ($id:ident, $t:ty) => { pub type $id = ($t, $t, $t); - } + }; } link! { A1, B1 } @@ -26,7 +28,7 @@ link! { D, E } link! { E, F } link! { F, G<Option<i32>, Option<i32>> } -pub struct G<T, K>(std::marker::PhantomData::<(T, K)>); +pub struct G<T, K>(std::marker::PhantomData<(T, K)>); fn main() { drop::<Option<A>>(None); diff --git a/tests/ui/type_length_limit.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index 198d133c08c..516230ae832 100644 --- a/tests/ui/type_length_limit.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -1,11 +1,11 @@ error: reached the type-length limit while instantiating `std::mem::drop::<Option<((((..., ..., ...), ..., ...), ..., ...), ..., ...)>>` - --> $DIR/type_length_limit.rs:32:5 + --> $DIR/type-length-limit-enforcement.rs:34:5 | LL | drop::<Option<A>>(None); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a `#![type_length_limit="4010"]` attribute to your crate - = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit.long-type.txt' + = note: the full type name has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type.txt' error: reached the type-length limit while instantiating `<{closure@rt::lang_start<()>::{closure#0}} as FnMut<()>>::call_mut` | diff --git a/tests/ui/lint/dead-code/unused-trait-with-assoc-const.rs b/tests/ui/lint/dead-code/unused-trait-with-assoc-const.rs new file mode 100644 index 00000000000..8259e932c64 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-trait-with-assoc-const.rs @@ -0,0 +1,13 @@ +#![deny(dead_code)] + +trait Tr { //~ ERROR trait `Tr` is never used + const I: Self; +} + +struct Foo; //~ ERROR struct `Foo` is never constructed + +impl Tr for Foo { + const I: Self = Foo; +} + +fn main() {} diff --git a/tests/ui/lint/dead-code/unused-trait-with-assoc-const.stderr b/tests/ui/lint/dead-code/unused-trait-with-assoc-const.stderr new file mode 100644 index 00000000000..ec894210f71 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-trait-with-assoc-const.stderr @@ -0,0 +1,20 @@ +error: trait `Tr` is never used + --> $DIR/unused-trait-with-assoc-const.rs:3:7 + | +LL | trait Tr { + | ^^ + | +note: the lint level is defined here + --> $DIR/unused-trait-with-assoc-const.rs:1:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: struct `Foo` is never constructed + --> $DIR/unused-trait-with-assoc-const.rs:7:8 + | +LL | struct Foo; + | ^^^ + +error: aborting due to 2 previous errors + 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 new file mode 100644 index 00000000000..e8116d83ebf --- /dev/null +++ b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs @@ -0,0 +1,11 @@ +#![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 new file mode 100644 index 00000000000..ab73c640634 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr @@ -0,0 +1,20 @@ +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/use_suggestion_json.stderr b/tests/ui/lint/use_suggestion_json.stderr index 0d4304e2e2e..558c2260fce 100644 --- a/tests/ui/lint/use_suggestion_json.stderr +++ b/tests/ui/lint/use_suggestion_json.stderr @@ -419,7 +419,7 @@ mod foo { \u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m \u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ use std::collections::hash_map::Iter;\u001b[0m \u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m -\u001b[0m and 9 other candidates\u001b[0m +\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0mand 9 other candidates\u001b[0m " } diff --git a/tests/ui/macros/macro-fragment-ident-underscore-error.rs b/tests/ui/macros/macro-fragment-ident-underscore-error.rs new file mode 100644 index 00000000000..882dd167adc --- /dev/null +++ b/tests/ui/macros/macro-fragment-ident-underscore-error.rs @@ -0,0 +1,12 @@ +//! Verifies that the reserved underscore `_` cannot be used as an `ident` fragment specifier +//! within a macro pattern, as it leads to a compilation error. + +macro_rules! identity { + ($i: ident) => { + $i + }; +} + +fn main() { + let identity!(_) = 10; //~ ERROR no rules expected reserved identifier `_` +} diff --git a/tests/ui/underscore-ident-matcher.stderr b/tests/ui/macros/macro-fragment-ident-underscore-error.stderr index 0c3f980cf6c..929e4624e4b 100644 --- a/tests/ui/underscore-ident-matcher.stderr +++ b/tests/ui/macros/macro-fragment-ident-underscore-error.stderr @@ -1,5 +1,5 @@ error: no rules expected reserved identifier `_` - --> $DIR/underscore-ident-matcher.rs:8:19 + --> $DIR/macro-fragment-ident-underscore-error.rs:11:19 | LL | macro_rules! identity { | --------------------- when calling this macro @@ -8,9 +8,9 @@ LL | let identity!(_) = 10; | ^ no rules expected this token in macro call | note: while trying to match meta-variable `$i:ident` - --> $DIR/underscore-ident-matcher.rs:2:6 + --> $DIR/macro-fragment-ident-underscore-error.rs:5:6 | -LL | ($i: ident) => ( +LL | ($i: ident) => { | ^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/marker_trait_attr/marker-attribute-with-values.stderr b/tests/ui/marker_trait_attr/marker-attribute-with-values.stderr index 6f9c9508e7e..9a2e5add37b 100644 --- a/tests/ui/marker_trait_attr/marker-attribute-with-values.stderr +++ b/tests/ui/marker_trait_attr/marker-attribute-with-values.stderr @@ -1,20 +1,30 @@ -error: malformed `marker` attribute input +error[E0565]: malformed `marker` attribute input --> $DIR/marker-attribute-with-values.rs:3:1 | LL | #[marker(always)] - | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[marker]` + | ^^^^^^^^--------^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[marker]` -error: malformed `marker` attribute input +error[E0565]: malformed `marker` attribute input --> $DIR/marker-attribute-with-values.rs:6:1 | LL | #[marker("never")] - | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[marker]` + | ^^^^^^^^---------^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[marker]` -error: malformed `marker` attribute input +error[E0565]: malformed `marker` attribute input --> $DIR/marker-attribute-with-values.rs:9:1 | LL | #[marker(key = "value")] - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[marker]` + | ^^^^^^^^---------------^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[marker]` error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0565`. diff --git a/tests/ui/modules/module-qualified-paths-basic.rs b/tests/ui/modules/module-qualified-paths-basic.rs new file mode 100644 index 00000000000..c02f6060caa --- /dev/null +++ b/tests/ui/modules/module-qualified-paths-basic.rs @@ -0,0 +1,20 @@ +//! Checks that functions from different modules are accessible via their fully-qualified paths. + +//@ run-pass + +mod foo { + pub fn x() -> isize { + return 1; + } +} + +mod bar { + pub fn y() -> isize { + return 1; + } +} + +pub fn main() { + foo::x(); + bar::y(); +} diff --git a/tests/ui/modules/module-super-access.rs b/tests/ui/modules/module-super-access.rs new file mode 100644 index 00000000000..8acba607f6c --- /dev/null +++ b/tests/ui/modules/module-super-access.rs @@ -0,0 +1,16 @@ +//! Check path resolution using `super` + +//@ run-pass + +#![allow(dead_code)] + +pub mod a { + pub fn f() {} + pub mod b { + fn g() { + super::f(); // Accessing `f` from module `a` (parent of `b`) + } + } +} + +pub fn main() {} diff --git a/tests/ui/use-nested-groups.rs b/tests/ui/modules/module-use-nested-groups.rs index c5d66a86935..84d1f9141a8 100644 --- a/tests/ui/use-nested-groups.rs +++ b/tests/ui/modules/module-use-nested-groups.rs @@ -1,3 +1,5 @@ +//! Checks complex `use` syntax and availability of types across nested modules. + //@ run-pass mod a { diff --git a/tests/ui/modules/primitive-type-module-deprecated-paths.rs b/tests/ui/modules/primitive-type-module-deprecated-paths.rs new file mode 100644 index 00000000000..5c9d2a616b3 --- /dev/null +++ b/tests/ui/modules/primitive-type-module-deprecated-paths.rs @@ -0,0 +1,13 @@ +//! Make sure the module level constants are still there and accessible even after +//! the corresponding associated constants have been added, and later stabilized. + +//@ run-pass + +#![allow(deprecated, deprecated_in_future)] +use std::{f32, u16}; + +fn main() { + let _ = u16::MAX; + let _ = f32::EPSILON; + let _ = std::f64::MANTISSA_DIGITS; +} diff --git a/tests/ui/modules/super-at-crate-root.rs b/tests/ui/modules/super-at-crate-root.rs new file mode 100644 index 00000000000..d605dc0cccb --- /dev/null +++ b/tests/ui/modules/super-at-crate-root.rs @@ -0,0 +1,6 @@ +//! Check that `super` keyword used at the crate root (top-level) results in a compilation error +//! as there is no parent module to resolve. + +use super::f; //~ ERROR there are too many leading `super` keywords + +fn main() {} diff --git a/tests/ui/super-at-top-level.stderr b/tests/ui/modules/super-at-crate-root.stderr index 4dce81fbef4..02798708864 100644 --- a/tests/ui/super-at-top-level.stderr +++ b/tests/ui/modules/super-at-crate-root.stderr @@ -1,5 +1,5 @@ error[E0433]: failed to resolve: there are too many leading `super` keywords - --> $DIR/super-at-top-level.rs:1:5 + --> $DIR/super-at-crate-root.rs:4:5 | LL | use super::f; | ^^^^^ there are too many leading `super` keywords diff --git a/tests/ui/use-keyword-2.rs b/tests/ui/modules/use-keyword-reexport-type-alias.rs index 4f3d1ee500d..c62bd9687ae 100644 --- a/tests/ui/use-keyword-2.rs +++ b/tests/ui/modules/use-keyword-reexport-type-alias.rs @@ -1,18 +1,20 @@ +//! Checks module re-exports, aliasing with `pub use`, +//! and calling private methods via `Self` in an impl block. + //@ run-pass #![allow(unused_variables)] pub struct A; mod test { - pub use super :: A; - - pub use self :: A as B; + pub use self::A as B; + pub use super::A; } impl A { fn f() {} fn g() { - Self :: f() + Self::f() } } diff --git a/tests/ui/namespace/struct-type-and-function-name-coexistence.rs b/tests/ui/namespace/struct-type-and-function-name-coexistence.rs new file mode 100644 index 00000000000..8d5ab3781b5 --- /dev/null +++ b/tests/ui/namespace/struct-type-and-function-name-coexistence.rs @@ -0,0 +1,14 @@ +//@ run-pass + +struct A { + a: isize, +} + +fn a(a: A) -> isize { + return a.a; +} + +pub fn main() { + let x: A = A { a: 1 }; + assert_eq!(a(x), 1); +} diff --git a/tests/ui/unsigned-literal-negation.rs b/tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.rs index 943c7f79742..4325c8b111b 100644 --- a/tests/ui/unsigned-literal-negation.rs +++ b/tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.rs @@ -1,3 +1,5 @@ +//! This test ensures that the unary negation operator (`-`) cannot be applied to unsigned ints + fn main() { let x = -1 as usize; //~ ERROR: cannot apply unary operator `-` let x = (-1) as usize; //~ ERROR: cannot apply unary operator `-` diff --git a/tests/ui/unsigned-literal-negation.stderr b/tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.stderr index 0bedbc1accd..4ce870ded9f 100644 --- a/tests/ui/unsigned-literal-negation.stderr +++ b/tests/ui/numbers-arithmetic/unary-negation-unsigned-integer-error.stderr @@ -1,5 +1,5 @@ error[E0600]: cannot apply unary operator `-` to type `usize` - --> $DIR/unsigned-literal-negation.rs:2:13 + --> $DIR/unary-negation-unsigned-integer-error.rs:4:13 | LL | let x = -1 as usize; | ^^ cannot apply unary operator `-` @@ -12,7 +12,7 @@ LL + let x = usize::MAX; | error[E0600]: cannot apply unary operator `-` to type `usize` - --> $DIR/unsigned-literal-negation.rs:3:13 + --> $DIR/unary-negation-unsigned-integer-error.rs:5:13 | LL | let x = (-1) as usize; | ^^^^ cannot apply unary operator `-` @@ -25,7 +25,7 @@ LL + let x = usize::MAX; | error[E0600]: cannot apply unary operator `-` to type `u32` - --> $DIR/unsigned-literal-negation.rs:4:18 + --> $DIR/unary-negation-unsigned-integer-error.rs:6:18 | LL | let x: u32 = -1; | ^^ cannot apply unary operator `-` diff --git a/tests/ui/unwind-no-uwtable.rs b/tests/ui/panics/unwind-force-no-unwind-tables.rs index fb8082e3188..2226e4dd03e 100644 --- a/tests/ui/unwind-no-uwtable.rs +++ b/tests/ui/panics/unwind-force-no-unwind-tables.rs @@ -1,3 +1,7 @@ +//! This test checks that Rust's unwinding mechanism correctly executes `Drop` +//! implementations during stack unwinding, even when unwind tables (`uwtable`) +//! are explicitly disabled via `-C force-unwind-tables=n`. + //@ run-pass //@ needs-unwind //@ ignore-windows target requires uwtable @@ -26,9 +30,12 @@ fn increase(count: &mut u8) { fn main() { let mut count = 0; - assert!(panic::catch_unwind(AssertUnwindSafe( - #[inline(never)] - || increase(&mut count) - )).is_err()); + assert!( + panic::catch_unwind(AssertUnwindSafe( + #[inline(never)] + || increase(&mut count) + )) + .is_err() + ); assert_eq!(count, 1); } diff --git a/tests/ui/parser/integer-literal-method-call-underscore.rs b/tests/ui/parser/integer-literal-method-call-underscore.rs new file mode 100644 index 00000000000..9e4abf28cba --- /dev/null +++ b/tests/ui/parser/integer-literal-method-call-underscore.rs @@ -0,0 +1,15 @@ +//! Checks that methods with names starting with an underscore (`_`) can be +//! successfully called directly on integer literals, confirming the correct +//! parsing of such expressions where the underscore is part of the method identifier. + +//@ run-pass + +trait Tr: Sized { + fn _method_on_numbers(self) {} +} + +impl Tr for i32 {} + +fn main() { + 42._method_on_numbers(); +} diff --git a/tests/ui/trailing-comma.rs b/tests/ui/parser/syntactic-trailing-commas.rs index 53b76fb6037..ba688dffb3c 100644 --- a/tests/ui/trailing-comma.rs +++ b/tests/ui/parser/syntactic-trailing-commas.rs @@ -1,3 +1,11 @@ +//! Checks trailing commas are accepted in various places: +//! - Generic parameters in function and struct definitions. +//! - Function and method arguments. +//! - Tuple and array literal expressions. +//! - Tuple and array destructuring patterns, including those with `..`. +//! - Enum variant declarations. +//! - Attributes. + //@ run-pass fn f<T,>(_: T,) {} diff --git a/tests/ui/pattern/issue-22546.rs b/tests/ui/pattern/issue-22546.rs index 81908017b4e..cf128d185df 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 { //~ WARN trait `Tr` is never used +trait Tr { type U; } diff --git a/tests/ui/pattern/issue-22546.stderr b/tests/ui/pattern/issue-22546.stderr deleted file mode 100644 index e067a95e422..00000000000 --- a/tests/ui/pattern/issue-22546.stderr +++ /dev/null @@ -1,10 +0,0 @@ -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/privacy/suggest-box-new.stderr b/tests/ui/privacy/suggest-box-new.stderr index b651348de29..6c47b52c9de 100644 --- a/tests/ui/privacy/suggest-box-new.stderr +++ b/tests/ui/privacy/suggest-box-new.stderr @@ -63,7 +63,7 @@ LL - x: (), LL - })), LL + wtf: Some(Box::new_in(_, _)), | - and 12 other candidates + = and 12 other candidates help: consider using the `Default` trait | LL - wtf: Some(Box(U { @@ -118,7 +118,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); | - and 12 other candidates + = and 12 other candidates help: consider using the `Default` trait | LL - let _ = Box {}; diff --git a/tests/ui/wait-forked-but-failed-child.rs b/tests/ui/process/process-spawn-failure.rs index 4a7f2bee9d9..0950b044c97 100644 --- a/tests/ui/wait-forked-but-failed-child.rs +++ b/tests/ui/process/process-spawn-failure.rs @@ -1,3 +1,9 @@ +//! Tests that repeatedly spawning a failing command does not create zombie processes. +//! Spawns a deliberately invalid command multiple times, verifies each spawn fails, +//! then uses `ps` (on Unix) to detect any leftover zombie (defunct) child processes. +//! Checks Rust's process spawning cleans up resources properly. +//! Skipped on platforms without `ps` utility. + //@ run-pass //@ needs-subprocess //@ ignore-vxworks no 'ps' @@ -36,35 +42,42 @@ fn find_zombies() { // the PPID column contains a "-" for the respective process. // Filter out any lines that have a "-" as the PPID as the PPID is // expected to be an integer. - let filtered_ps: Vec<_> = ps_output - .lines() - .filter(|line| line.split_whitespace().nth(1) != Some("-")) - .collect(); + let filtered_ps: Vec<_> = + ps_output.lines().filter(|line| line.split_whitespace().nth(1) != Some("-")).collect(); for (line_no, line) in filtered_ps.into_iter().enumerate() { - if 0 < line_no && 0 < line.len() && - my_pid == line.split(' ').filter(|w| 0 < w.len()).nth(1) - .expect("1st column should be PPID") - .parse().ok() - .expect("PPID string into integer") && - line.contains("defunct") { + if 0 < line_no + && 0 < line.len() + && my_pid + == line + .split(' ') + .filter(|w| 0 < w.len()) + .nth(1) + .expect("1st column should be PPID") + .parse() + .ok() + .expect("PPID string into integer") + && line.contains("defunct") + { panic!("Zombie child {}", line); } } } #[cfg(windows)] -fn find_zombies() { } +fn find_zombies() {} fn main() { let too_long = format!("/NoSuchCommand{:0300}", 0u8); - let _failures = (0..100).map(|_| { - let mut cmd = Command::new(&too_long); - let failed = cmd.spawn(); - assert!(failed.is_err(), "Make sure the command fails to spawn(): {:?}", cmd); - failed - }).collect::<Vec<_>>(); + let _failures = (0..100) + .map(|_| { + let mut cmd = Command::new(&too_long); + let failed = cmd.spawn(); + assert!(failed.is_err(), "Make sure the command fails to spawn(): {:?}", cmd); + failed + }) + .collect::<Vec<_>>(); find_zombies(); // then _failures goes out of scope diff --git a/tests/ui/process/windows-exit-code-still-active.rs b/tests/ui/process/windows-exit-code-still-active.rs new file mode 100644 index 00000000000..e661a4f6adc --- /dev/null +++ b/tests/ui/process/windows-exit-code-still-active.rs @@ -0,0 +1,26 @@ +//! On Windows the GetExitCodeProcess API is used to get the exit code of a +//! process, but it's easy to mistake a process exiting with the code 259 as +//! "still running" because this is the value of the STILL_ACTIVE constant. Make +//! sure we handle this case in the standard library and correctly report the +//! status. +//! +//! Note that this is disabled on unix as processes exiting with 259 will have +//! their exit status truncated to 3 (only the lower 8 bits are used). + +//@ run-pass + +#[cfg(windows)] +fn main() { + use std::env; + use std::process::{self, Command}; + + if env::args().len() == 1 { + let status = Command::new(env::current_exe().unwrap()).arg("foo").status().unwrap(); + assert_eq!(status.code(), Some(259)); + } else { + process::exit(259); + } +} + +#[cfg(not(windows))] +fn main() {} diff --git a/tests/ui/ptr_ops/ptr-swap-basic.rs b/tests/ui/ptr_ops/ptr-swap-basic.rs new file mode 100644 index 00000000000..ce230feeb32 --- /dev/null +++ b/tests/ui/ptr_ops/ptr-swap-basic.rs @@ -0,0 +1,14 @@ +//! Check the basic functionality of `std::mem::swap` to ensure it correctly +//! exchanges the values of two mutable variables. + +//@ run-pass + +use std::mem::swap; + +pub fn main() { + let mut x = 3; + let mut y = 7; + swap(&mut x, &mut y); + assert_eq!(x, 7); + assert_eq!(y, 3); +} diff --git a/tests/ui/swap-overlapping.rs b/tests/ui/ptr_ops/ptr-swap-overlapping-regions.rs index 38d5a8109d1..8f05e937d59 100644 --- a/tests/ui/swap-overlapping.rs +++ b/tests/ui/ptr_ops/ptr-swap-overlapping-regions.rs @@ -1,17 +1,17 @@ +//! Check that `std::ptr::swap` behaves correctly when the source and destination +//! pointers refer to the same memory location, avoiding issues like overlapping `memcpy`. +//! +//! Regression test: <https://github.com/rust-lang/rust/issues/5041> + //@ run-pass #![allow(dead_code)] -// Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same - use std::ptr; pub fn main() { let mut test = TestDescAndFn { - desc: TestDesc { - name: TestName::DynTestName("test".to_string()), - should_fail: false - }, + desc: TestDesc { name: TestName::DynTestName("test".to_string()), should_fail: false }, testfn: TestFn::DynTestFn(22), }; do_swap(&mut test); @@ -24,7 +24,7 @@ fn do_swap(test: &mut TestDescAndFn) { } pub enum TestName { - DynTestName(String) + DynTestName(String), } pub enum TestFn { @@ -34,7 +34,7 @@ pub enum TestFn { pub struct TestDesc { name: TestName, - should_fail: bool + should_fail: bool, } pub struct TestDescAndFn { diff --git a/tests/ui/ptr_ops/ptr-write-bool-representation.rs b/tests/ui/ptr_ops/ptr-write-bool-representation.rs new file mode 100644 index 00000000000..3dfc3e51ab2 --- /dev/null +++ b/tests/ui/ptr_ops/ptr-write-bool-representation.rs @@ -0,0 +1,18 @@ +//! Validates the correct behavior of writing a `bool` value using `std::ptr::write`. +//! +//! This test addresses historical concerns regarding the internal representation of `bool` +//! (e.g., as `i1` in LLVM versus its byte-aligned memory layout) and checks that +//! `ptr::write` correctly handles this type without issues, confirming its memory +//! behavior is as expected. + +//@ run-pass + +use std::ptr; + +pub fn main() { + unsafe { + let mut x: bool = false; + // this line breaks it + ptr::write(&mut x, false); + } +} diff --git a/tests/ui/ptr_ops/raw-pointer-type-basic.rs b/tests/ui/ptr_ops/raw-pointer-type-basic.rs new file mode 100644 index 00000000000..349e8e67909 --- /dev/null +++ b/tests/ui/ptr_ops/raw-pointer-type-basic.rs @@ -0,0 +1,18 @@ +//! Checks the basic usage of raw pointers (`*const isize`) as function argument and return types. + +//@ run-pass + +#![allow(dead_code)] + +fn f(a: *const isize) -> *const isize { + return a; +} + +fn g(a: *const isize) -> *const isize { + let b = f(a); + return b; +} + +pub fn main() { + return; +} diff --git a/tests/ui/reachable/diverging-expressions-unreachable-code.rs b/tests/ui/reachable/diverging-expressions-unreachable-code.rs new file mode 100644 index 00000000000..bb56987775f --- /dev/null +++ b/tests/ui/reachable/diverging-expressions-unreachable-code.rs @@ -0,0 +1,19 @@ +//@ run-pass + +#![allow(unused_must_use)] +#![allow(unreachable_code)] + +fn _id(x: bool) -> bool { + x +} + +fn _call_id() { + let _c = panic!(); + _id(_c); +} + +fn _call_id_3() { + _id(return) && _id(return); +} + +pub fn main() {} diff --git a/tests/ui/unreachable-code.rs b/tests/ui/reachable/unreachable-code-diverging-expressions.rs index 0c46a38d73f..00676418002 100644 --- a/tests/ui/unreachable-code.rs +++ b/tests/ui/reachable/unreachable-code-diverging-expressions.rs @@ -26,9 +26,13 @@ fn call_id_3() { fn ret_guard() { match 2 { - x if (return) => { x; } - x if let true = return => { x; } - _ => {} + x if (return) => { + x; + } + x if let true = return => { + x; + } + _ => {} } } diff --git a/tests/ui/recursion/recursion-tail-call-no-arg-leak.rs b/tests/ui/recursion/recursion-tail-call-no-arg-leak.rs new file mode 100644 index 00000000000..fe10b890700 --- /dev/null +++ b/tests/ui/recursion/recursion-tail-call-no-arg-leak.rs @@ -0,0 +1,15 @@ +//! This test verifies that tail call optimization does not lead to argument slot leaks. +//! +//! Regression test for: <https://github.com/rust-lang/rust/issues/160> + +//@ run-pass + +fn inner(dummy: String, b: bool) { + if b { + return inner(dummy, false); + } +} + +pub fn main() { + inner("hi".to_string(), true); +} diff --git a/tests/ui/recursion/recursion-tail-cps.rs b/tests/ui/recursion/recursion-tail-cps.rs new file mode 100644 index 00000000000..9014be0ce98 --- /dev/null +++ b/tests/ui/recursion/recursion-tail-cps.rs @@ -0,0 +1,34 @@ +//! Verify that mutually recursive functions use CPS to avoid overflowing the stack. + +//@ run-pass + +fn checktrue(rs: bool) -> bool { + assert!(rs); + return true; +} + +pub fn main() { + let k = checktrue; + evenk(42, k); + oddk(45, k); +} + +fn evenk(n: isize, k: fn(bool) -> bool) -> bool { + println!("evenk"); + println!("{}", n); + if n == 0 { + return k(true); + } else { + return oddk(n - 1, k); + } +} + +fn oddk(n: isize, k: fn(bool) -> bool) -> bool { + println!("oddk"); + println!("{}", n); + if n == 0 { + return k(false); + } else { + return evenk(n - 1, k); + } +} diff --git a/tests/ui/rust-2018/issue-52202-use-suggestions.stderr b/tests/ui/rust-2018/issue-52202-use-suggestions.stderr index ee1a336ea98..0eb1d46637b 100644 --- a/tests/ui/rust-2018/issue-52202-use-suggestions.stderr +++ b/tests/ui/rust-2018/issue-52202-use-suggestions.stderr @@ -14,7 +14,7 @@ LL + use std::collections::hash_map::Drain; | LL + use std::collections::hash_set::Drain; | - and 3 other candidates + = and 3 other candidates error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/multi-suggestion.ascii.stderr b/tests/ui/suggestions/multi-suggestion.ascii.stderr new file mode 100644 index 00000000000..f2a146fbd52 --- /dev/null +++ b/tests/ui/suggestions/multi-suggestion.ascii.stderr @@ -0,0 +1,130 @@ +error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` + --> $DIR/multi-suggestion.rs:17:13 + | +LL | let _ = std::collections::HashMap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL + | + = note: `std::collections::HashMap` defined here + | +help: you might have meant to use an associated function to build this type + | +LL | let _ = std::collections::HashMap::new(); + | +++++ +LL - let _ = std::collections::HashMap(); +LL + let _ = std::collections::HashMap::with_capacity(_); + | +LL - let _ = std::collections::HashMap(); +LL + let _ = std::collections::HashMap::with_hasher(_); + | +LL - let _ = std::collections::HashMap(); +LL + let _ = std::collections::HashMap::with_capacity_and_hasher(_, _); + | +help: consider using the `Default` trait + | +LL | let _ = <std::collections::HashMap as std::default::Default>::default(); + | + ++++++++++++++++++++++++++++++++++ + +error[E0423]: cannot initialize a tuple struct which contains private fields + --> $DIR/multi-suggestion.rs:11:19 + | +LL | wtf: Some(Box(U { + | ^^^ + | +note: constructor is not visible here due to private fields + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + | + = note: private field + | + = note: private field +help: you might have meant to use an associated function to build this type + | +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new(_)), + | +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new_uninit()), + | +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new_zeroed()), + | +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new_in(_, _)), + | + = and 12 other candidates +help: consider using the `Default` trait + | +LL - wtf: Some(Box(U { +LL + wtf: Some(<Box as std::default::Default>::default()), + | + +error: cannot construct `HashMap<_, _, _>` with struct literal syntax due to private fields + --> $DIR/multi-suggestion.rs:19:13 + | +LL | let _ = std::collections::HashMap {}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: private field `base` that was not provided +help: you might have meant to use an associated function to build this type + | +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::new(); + | +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::with_capacity(_); + | +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::with_hasher(_); + | +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::with_capacity_and_hasher(_, _); + | +help: consider using the `Default` trait + | +LL - let _ = std::collections::HashMap {}; +LL + let _ = <std::collections::HashMap as std::default::Default>::default(); + | + +error: cannot construct `Box<_, _>` with struct literal syntax due to private fields + --> $DIR/multi-suggestion.rs:21:13 + | +LL | let _ = Box {}; + | ^^^ + | + = note: private fields `0` and `1` that were not provided +help: you might have meant to use an associated function to build this type + | +LL - let _ = Box {}; +LL + let _ = Box::new(_); + | +LL - let _ = Box {}; +LL + let _ = Box::new_uninit(); + | +LL - let _ = Box {}; +LL + let _ = Box::new_zeroed(); + | +LL - let _ = Box {}; +LL + let _ = Box::new_in(_, _); + | + = and 12 other candidates +help: consider using the `Default` trait + | +LL - let _ = Box {}; +LL + let _ = <Box as std::default::Default>::default(); + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/suggestions/multi-suggestion.rs b/tests/ui/suggestions/multi-suggestion.rs new file mode 100644 index 00000000000..99d2407aa21 --- /dev/null +++ b/tests/ui/suggestions/multi-suggestion.rs @@ -0,0 +1,22 @@ +//@ revisions: ascii unicode +//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode + +#![allow(dead_code)] +struct U <T> { + wtf: Option<Box<U<T>>>, + x: T, +} +fn main() { + U { + wtf: Some(Box(U { //[ascii]~ ERROR cannot initialize a tuple struct which contains private fields + wtf: None, + x: (), + })), + x: () + }; + let _ = std::collections::HashMap(); + //[ascii]~^ ERROR expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` + let _ = std::collections::HashMap {}; + //[ascii]~^ ERROR cannot construct `HashMap<_, _, _>` with struct literal syntax due to private fields + let _ = Box {}; //[ascii]~ ERROR cannot construct `Box<_, _>` with struct literal syntax due to private fields +} diff --git a/tests/ui/suggestions/multi-suggestion.unicode.stderr b/tests/ui/suggestions/multi-suggestion.unicode.stderr new file mode 100644 index 00000000000..69df481579b --- /dev/null +++ b/tests/ui/suggestions/multi-suggestion.unicode.stderr @@ -0,0 +1,130 @@ +error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` + ╭▸ $DIR/multi-suggestion.rs:17:13 + │ +LL │ let _ = std::collections::HashMap(); + │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL + │ + ╰ note: `std::collections::HashMap` defined here + ╰╴ +help: you might have meant to use an associated function to build this type + ╭╴ +LL │ let _ = std::collections::HashMap::new(); + ├╴ +++++ +LL - let _ = std::collections::HashMap(); +LL + let _ = std::collections::HashMap::with_capacity(_); + ├╴ +LL - let _ = std::collections::HashMap(); +LL + let _ = std::collections::HashMap::with_hasher(_); + ├╴ +LL - let _ = std::collections::HashMap(); +LL + let _ = std::collections::HashMap::with_capacity_and_hasher(_, _); + ╰╴ +help: consider using the `Default` trait + ╭╴ +LL │ let _ = <std::collections::HashMap as std::default::Default>::default(); + ╰╴ + ++++++++++++++++++++++++++++++++++ + +error[E0423]: cannot initialize a tuple struct which contains private fields + ╭▸ $DIR/multi-suggestion.rs:11:19 + │ +LL │ wtf: Some(Box(U { + │ ━━━ + ╰╴ +note: constructor is not visible here due to private fields + ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL + │ + ╰ note: private field + │ + ╰ note: private field +help: you might have meant to use an associated function to build this type + ╭╴ +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new(_)), + ├╴ +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new_uninit()), + ├╴ +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new_zeroed()), + ├╴ +LL - wtf: Some(Box(U { +LL - wtf: None, +LL - x: (), +LL - })), +LL + wtf: Some(Box::new_in(_, _)), + │ + ╰ and 12 other candidates +help: consider using the `Default` trait + ╭╴ +LL - wtf: Some(Box(U { +LL + wtf: Some(<Box as std::default::Default>::default()), + ╰╴ + +error: cannot construct `HashMap<_, _, _>` with struct literal syntax due to private fields + ╭▸ $DIR/multi-suggestion.rs:19:13 + │ +LL │ let _ = std::collections::HashMap {}; + │ ━━━━━━━━━━━━━━━━━━━━━━━━━ + │ + ╰ note: private field `base` that was not provided +help: you might have meant to use an associated function to build this type + ╭╴ +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::new(); + ├╴ +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::with_capacity(_); + ├╴ +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::with_hasher(_); + ├╴ +LL - let _ = std::collections::HashMap {}; +LL + let _ = std::collections::HashMap::with_capacity_and_hasher(_, _); + ╰╴ +help: consider using the `Default` trait + ╭╴ +LL - let _ = std::collections::HashMap {}; +LL + let _ = <std::collections::HashMap as std::default::Default>::default(); + ╰╴ + +error: cannot construct `Box<_, _>` with struct literal syntax due to private fields + ╭▸ $DIR/multi-suggestion.rs:21:13 + │ +LL │ let _ = Box {}; + │ ━━━ + │ + ╰ note: private fields `0` and `1` that were not provided +help: you might have meant to use an associated function to build this type + ╭╴ +LL - let _ = Box {}; +LL + let _ = Box::new(_); + ├╴ +LL - let _ = Box {}; +LL + let _ = Box::new_uninit(); + ├╴ +LL - let _ = Box {}; +LL + let _ = Box::new_zeroed(); + ├╴ +LL - let _ = Box {}; +LL + let _ = Box::new_in(_, _); + │ + ╰ and 12 other candidates +help: consider using the `Default` trait + ╭╴ +LL - let _ = Box {}; +LL + let _ = <Box as std::default::Default>::default(); + ╰╴ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/suggestions/too-many-field-suggestions.stderr b/tests/ui/suggestions/too-many-field-suggestions.stderr index ac5c8cb60cc..0cb0c8bec07 100644 --- a/tests/ui/suggestions/too-many-field-suggestions.stderr +++ b/tests/ui/suggestions/too-many-field-suggestions.stderr @@ -17,7 +17,7 @@ LL | t.a2.bar(); | +++ LL | t.a3.bar(); | +++ - and 6 other candidates + = and 6 other candidates error[E0609]: no field `field` on type `Thing` --> $DIR/too-many-field-suggestions.rs:26:7 @@ -35,7 +35,7 @@ LL | t.a2.field; | +++ LL | t.a3.field; | +++ - and 6 other candidates + = and 6 other candidates error: aborting due to 2 previous errors diff --git a/tests/ui/super-at-top-level.rs b/tests/ui/super-at-top-level.rs deleted file mode 100644 index e4d587bc9ef..00000000000 --- a/tests/ui/super-at-top-level.rs +++ /dev/null @@ -1,4 +0,0 @@ -use super::f; //~ ERROR there are too many leading `super` keywords - -fn main() { -} diff --git a/tests/ui/super.rs b/tests/ui/super.rs deleted file mode 100644 index 69aff4f98e0..00000000000 --- a/tests/ui/super.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - -pub mod a { - pub fn f() {} - pub mod b { - fn g() { - super::f(); - } - } -} - -pub fn main() { -} diff --git a/tests/ui/svh-add-nothing.rs b/tests/ui/svh-add-nothing.rs deleted file mode 100644 index 6e4b9fa7f4c..00000000000 --- a/tests/ui/svh-add-nothing.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass -// note that these aux-build directives must be in this order -//@ aux-build:svh-a-base.rs -//@ aux-build:svh-b.rs -//@ aux-build:svh-a-base.rs - - -extern crate a; -extern crate b; - -fn main() { - b::foo() -} diff --git a/tests/ui/svh/svh-no-api-change-no-recompile.rs b/tests/ui/svh/svh-no-api-change-no-recompile.rs new file mode 100644 index 00000000000..d4b8ac77444 --- /dev/null +++ b/tests/ui/svh/svh-no-api-change-no-recompile.rs @@ -0,0 +1,20 @@ +//! This test verifies that the Signature Version Hash (SVH) system correctly identifies +//! when changes to an auxiliary crate do not affect its public API. +//! +//! Specifically, it checks that adding non-public items to a crate does not alter +//! its SVH, preventing unnecessary recompilations of dependent crates. + +//@ run-pass + +// Note that these aux-build directives must be in this order + +//@ aux-build:svh-a-base.rs +//@ aux-build:svh-b.rs +//@ aux-build:svh-a-base.rs + +extern crate a; +extern crate b; + +fn main() { + b::foo() +} diff --git a/tests/ui/swap-1.rs b/tests/ui/swap-1.rs deleted file mode 100644 index b104c3ade42..00000000000 --- a/tests/ui/swap-1.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -use std::mem::swap; - -pub fn main() { - let mut x = 3; let mut y = 7; - swap(&mut x, &mut y); - assert_eq!(x, 7); - assert_eq!(y, 3); -} diff --git a/tests/ui/switched-expectations.rs b/tests/ui/switched-expectations.rs deleted file mode 100644 index c5bc84de54c..00000000000 --- a/tests/ui/switched-expectations.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let var = 10i32; - let ref string: String = var; //~ ERROR mismatched types [E0308] -} diff --git a/tests/ui/tag-type-args.rs b/tests/ui/tag-type-args.rs deleted file mode 100644 index 75a54927443..00000000000 --- a/tests/ui/tag-type-args.rs +++ /dev/null @@ -1,6 +0,0 @@ -enum Quux<T> { Bar } -//~^ ERROR: parameter `T` is never used - -fn foo(c: Quux) { assert!((false)); } //~ ERROR missing generics for enum `Quux` - -fn main() { panic!(); } diff --git a/tests/ui/tail-call-arg-leak.rs b/tests/ui/tail-call-arg-leak.rs deleted file mode 100644 index 234924307c3..00000000000 --- a/tests/ui/tail-call-arg-leak.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -// use of tail calls causes arg slot leaks, issue #160. - -fn inner(dummy: String, b: bool) { if b { return inner(dummy, false); } } - -pub fn main() { - inner("hi".to_string(), true); -} diff --git a/tests/ui/tail-cps.rs b/tests/ui/tail-cps.rs deleted file mode 100644 index fe99dadf795..00000000000 --- a/tests/ui/tail-cps.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass - -fn checktrue(rs: bool) -> bool { assert!(rs); return true; } - -pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); } - -fn evenk(n: isize, k: fn(bool) -> bool) -> bool { - println!("evenk"); - println!("{}", n); - if n == 0 { return k(true); } else { return oddk(n - 1, k); } -} - -fn oddk(n: isize, k: fn(bool) -> bool) -> bool { - println!("oddk"); - println!("{}", n); - if n == 0 { return k(false); } else { return evenk(n - 1, k); } -} diff --git a/tests/ui/tail-typeck.rs b/tests/ui/tail-typeck.rs deleted file mode 100644 index 1deb43c9496..00000000000 --- a/tests/ui/tail-typeck.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn f() -> isize { return g(); } //~ ERROR mismatched types - -fn g() -> usize { return 0; } - -fn main() { let y = f(); } diff --git a/tests/ui/tail-typeck.stderr b/tests/ui/tail-typeck.stderr deleted file mode 100644 index 3cfbfa0fb56..00000000000 --- a/tests/ui/tail-typeck.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/tail-typeck.rs:1:26 - | -LL | fn f() -> isize { return g(); } - | ----- ^^^ expected `isize`, found `usize` - | | - | expected `isize` because of return type - | -help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit - | -LL | fn f() -> isize { return g().try_into().unwrap(); } - | ++++++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/trait-method-number-parameters.rs b/tests/ui/trait-method-number-parameters.rs deleted file mode 100644 index 719005d6643..00000000000 --- a/tests/ui/trait-method-number-parameters.rs +++ /dev/null @@ -1,13 +0,0 @@ -trait Foo { - fn foo(&mut self, x: i32, y: i32) -> i32; -} - -impl Foo for i32 { - fn foo( - &mut self, //~ ERROR - x: i32, - ) { - } -} - -fn main() {} diff --git a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs index d66a11490c5..2d9c2ca0861 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl, const_ops)] +#![feature(const_trait_impl, const_ops, const_cmp)] //@ check-pass struct Int(i32); diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.rs b/tests/ui/traits/const-traits/call-generic-in-impl.rs index f38590fa3c0..72fc80c50e0 100644 --- a/tests/ui/traits/const-traits/call-generic-in-impl.rs +++ b/tests/ui/traits/const-traits/call-generic-in-impl.rs @@ -1,5 +1,5 @@ //@ check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_cmp)] #[const_trait] trait MyPartialEq { diff --git a/tests/ui/traits/const-traits/call-generic-method-chain.rs b/tests/ui/traits/const-traits/call-generic-method-chain.rs index 1ad71c424a3..db053b48079 100644 --- a/tests/ui/traits/const-traits/call-generic-method-chain.rs +++ b/tests/ui/traits/const-traits/call-generic-method-chain.rs @@ -3,7 +3,7 @@ //@ compile-flags: -Znext-solver //@ check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_cmp)] struct S; diff --git a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs index 58f293b5ac5..5913cbf8a21 100644 --- a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs +++ b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Znext-solver //@ check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_cmp)] struct S; diff --git a/tests/ui/traits/const-traits/call-generic-method-fail.rs b/tests/ui/traits/const-traits/call-generic-method-fail.rs index 4528f3b122f..6744176d40a 100644 --- a/tests/ui/traits/const-traits/call-generic-method-fail.rs +++ b/tests/ui/traits/const-traits/call-generic-method-fail.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Znext-solver -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_cmp)] pub const fn equals_self<T: PartialEq>(t: &T) -> bool { *t == *t diff --git a/tests/ui/traits/const-traits/call-generic-method-pass.rs b/tests/ui/traits/const-traits/call-generic-method-pass.rs index aa52a7b9e47..01c5860c8ec 100644 --- a/tests/ui/traits/const-traits/call-generic-method-pass.rs +++ b/tests/ui/traits/const-traits/call-generic-method-pass.rs @@ -3,7 +3,7 @@ //@ compile-flags: -Znext-solver //@ check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_cmp)] struct S; diff --git a/tests/ui/traits/const-traits/const-drop.rs b/tests/ui/traits/const-traits/const-drop.rs index 5df3a77f73a..dc985a8f620 100644 --- a/tests/ui/traits/const-traits/const-drop.rs +++ b/tests/ui/traits/const-traits/const-drop.rs @@ -17,12 +17,10 @@ impl<'a> const Drop for S<'a> { } const fn a<T: [const] Destruct>(_: T) {} -//FIXME ~^ ERROR destructor of const fn b() -> u8 { let mut c = 0; let _ = S(&mut c); - //FIXME ~^ ERROR destructor of a(S(&mut c)); c } diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs index b39f97b5938..bbc0faee10f 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs +++ b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs @@ -1,7 +1,7 @@ //@ check-pass #![feature(derive_const)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_cmp)] #[derive_const(PartialEq)] pub struct Reverse<T>(T); diff --git a/tests/ui/traits/const-traits/issue-102985.rs b/tests/ui/traits/const-traits/issue-102985.rs index e5394ddd688..ebab6566d4b 100644 --- a/tests/ui/traits/const-traits/issue-102985.rs +++ b/tests/ui/traits/const-traits/issue-102985.rs @@ -1,12 +1,9 @@ -//@ known-bug: #110395 #![feature(const_trait_impl)] struct Bug { inner: [(); match || 1 { n => n(), - //FIXME ~^ ERROR the trait bound - //FIXME ~| ERROR the trait bound - //FIXME ~| ERROR cannot call non-const closure in constants + //~^ ERROR cannot call non-const closure in constants }], } diff --git a/tests/ui/traits/const-traits/issue-102985.stderr b/tests/ui/traits/const-traits/issue-102985.stderr index 7c5c5acf207..8588dc17e70 100644 --- a/tests/ui/traits/const-traits/issue-102985.stderr +++ b/tests/ui/traits/const-traits/issue-102985.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot call non-const closure in constants - --> $DIR/issue-102985.rs:6:14 + --> $DIR/issue-102985.rs:5:14 | LL | n => n(), | ^^^ diff --git a/tests/ui/traits/const-traits/issue-88155.rs b/tests/ui/traits/const-traits/issue-88155.rs index a26128a6ecc..a642e1101c7 100644 --- a/tests/ui/traits/const-traits/issue-88155.rs +++ b/tests/ui/traits/const-traits/issue-88155.rs @@ -1,5 +1,3 @@ -//@ known-bug: #110395 - #![feature(const_trait_impl)] pub trait A { @@ -8,8 +6,7 @@ pub trait A { pub const fn foo<T: A>() -> bool { T::assoc() - //FIXME ~^ ERROR the trait bound - //FIXME ~| ERROR cannot call non-const function + //~^ ERROR cannot call non-const associated function } fn main() {} diff --git a/tests/ui/traits/const-traits/issue-88155.stderr b/tests/ui/traits/const-traits/issue-88155.stderr index 2e140ac9ff6..96a3c4187f5 100644 --- a/tests/ui/traits/const-traits/issue-88155.stderr +++ b/tests/ui/traits/const-traits/issue-88155.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot call non-const associated function `<T as A>::assoc` in constant functions - --> $DIR/issue-88155.rs:10:5 + --> $DIR/issue-88155.rs:8:5 | LL | T::assoc() | ^^^^^^^^^^ diff --git a/tests/ui/traits/trait-method-signature-mismatch.rs b/tests/ui/traits/trait-method-signature-mismatch.rs new file mode 100644 index 00000000000..118aff69e4e --- /dev/null +++ b/tests/ui/traits/trait-method-signature-mismatch.rs @@ -0,0 +1,18 @@ +//! This test verifies that implementing a trait method with a signature that does not +//! exactly match its declaration in the trait results in a compilation error. +//! Specifically, it checks for errors when the number of parameters or the return type +//! in the `impl` differs from the trait definition. + +trait Foo { + fn foo(&mut self, x: i32, y: i32) -> i32; +} + +impl Foo for i32 { + fn foo( + &mut self, //~ ERROR method `foo` has 2 parameters but the declaration + x: i32, + ) { + } +} + +fn main() {} diff --git a/tests/ui/trait-method-number-parameters.stderr b/tests/ui/traits/trait-method-signature-mismatch.stderr index cf9b4f2ae79..c7a77aa7aba 100644 --- a/tests/ui/trait-method-number-parameters.stderr +++ b/tests/ui/traits/trait-method-signature-mismatch.stderr @@ -1,5 +1,5 @@ error[E0050]: method `foo` has 2 parameters but the declaration in trait `Foo::foo` has 3 - --> $DIR/trait-method-number-parameters.rs:7:9 + --> $DIR/trait-method-signature-mismatch.rs:12:9 | LL | fn foo(&mut self, x: i32, y: i32) -> i32; | ------------------------- trait requires 3 parameters diff --git a/tests/ui/traits/tryfrominterror-result-comparison.rs b/tests/ui/traits/tryfrominterror-result-comparison.rs new file mode 100644 index 00000000000..8a2741e9058 --- /dev/null +++ b/tests/ui/traits/tryfrominterror-result-comparison.rs @@ -0,0 +1,19 @@ +//! This test verifies that `std::num::TryFromIntError` correctly implements `PartialEq`, +//! allowing `Result<T, TryFromIntError>` values to be compared for equality using `==`. +//! It specifically checks a successful numeric conversion scenario where the `Result::Ok` +//! variant is compared, ensuring that the comparison yields the expected boolean result. + +//@ run-pass + +#![allow(unused_must_use)] // Allow ignoring the result of the comparison for the test's purpose + +use std::convert::TryFrom; +use std::num::TryFromIntError; + +fn main() { + let x: u32 = 125; + // Attempt to convert u32 to u8, which should succeed as 125 fits in u8. + let y: Result<u8, TryFromIntError> = u8::try_from(x); + // Verify that the Result can be correctly compared with an Ok value. + y == Ok(125); +} diff --git a/tests/ui/virtual-call-attrs-issue-137646.rs b/tests/ui/traits/virtual-call-parameter-handling.rs index e80bd5768a4..71ed459d15a 100644 --- a/tests/ui/virtual-call-attrs-issue-137646.rs +++ b/tests/ui/traits/virtual-call-parameter-handling.rs @@ -1,5 +1,7 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/137646. -//! The parameter value at all calls to `check` should be `(1, 1, 1)`. +//! This test checks the correct parameter handling during virtual method calls +//! through a `dyn Trait` object. +//! +//! Regression test for: <https://github.com/rust-lang/rust/issues/137646> //@ run-pass diff --git a/tests/ui/transmute-non-immediate-to-immediate.rs b/tests/ui/transmute-non-immediate-to-immediate.rs deleted file mode 100644 index d99bbcc600f..00000000000 --- a/tests/ui/transmute-non-immediate-to-immediate.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -// Issue #7988 -// Transmuting non-immediate type to immediate type - - -pub fn main() { - unsafe { - ::std::mem::transmute::<[isize; 1],isize>([1]) - }; -} diff --git a/tests/ui/transmute/transmute-array-to-scalar.rs b/tests/ui/transmute/transmute-array-to-scalar.rs new file mode 100644 index 00000000000..cd6dbb040c8 --- /dev/null +++ b/tests/ui/transmute/transmute-array-to-scalar.rs @@ -0,0 +1,14 @@ +//! Verify transmuting from a single-element array to a scalar is allowed. +//! +//! Regression test: <https://github.com/rust-lang/rust/issues/7988> + +//@ run-pass + +pub fn main() { + unsafe { + // Transmute a single-element array `[1]` (which might be treated as a "non-immediate" type) + // to a scalar `isize` (an "immediate" type). + // This is safe because `[isize; 1]` and `isize` have the same size and alignment. + ::std::mem::transmute::<[isize; 1], isize>([1]); + } +} diff --git a/tests/ui/transmute-equal-assoc-types.rs b/tests/ui/transmute/transmute-same-associated-type.rs index 526f4ebbffa..8bc452c6df4 100644 --- a/tests/ui/transmute-equal-assoc-types.rs +++ b/tests/ui/transmute/transmute-same-associated-type.rs @@ -1,3 +1,5 @@ +//! Verify transmuting is allowed when `Src` and `Dst` are the same associated type. + //@ check-pass trait Foo { diff --git a/tests/ui/try-from-int-error-partial-eq.rs b/tests/ui/try-from-int-error-partial-eq.rs deleted file mode 100644 index 66a78b3f842..00000000000 --- a/tests/ui/try-from-int-error-partial-eq.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass - -#![allow(unused_must_use)] - -use std::convert::TryFrom; -use std::num::TryFromIntError; - -fn main() { - let x: u32 = 125; - let y: Result<u8, TryFromIntError> = u8::try_from(x); - y == Ok(125); -} diff --git a/tests/ui/try-operator-hygiene.rs b/tests/ui/try-operator-hygiene.rs deleted file mode 100644 index 20538e094c6..00000000000 --- a/tests/ui/try-operator-hygiene.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ run-pass - -#![allow(non_upper_case_globals)] -#![allow(dead_code)] -// `expr?` expands to: -// -// match expr { -// Ok(val) => val, -// Err(err) => return Err(From::from(err)), -// } -// -// This test verifies that the expansion is hygienic, i.e., it's not affected by other `val` and -// `err` bindings that may be in scope. - -use std::num::ParseIntError; - -fn main() { - assert_eq!(parse(), Ok(1)); -} - -fn parse() -> Result<i32, ParseIntError> { - const val: char = 'a'; - const err: char = 'b'; - - Ok("1".parse::<i32>()?) -} diff --git a/tests/ui/try-trait/try-operator-expansion-hygiene.rs b/tests/ui/try-trait/try-operator-expansion-hygiene.rs new file mode 100644 index 00000000000..b6f4e533d8d --- /dev/null +++ b/tests/ui/try-trait/try-operator-expansion-hygiene.rs @@ -0,0 +1,24 @@ +//! This test verifies that the `?` operator expansion is hygienic, +//! i.e., it's not affected by other `val` and `err` bindings that may be in scope. +//! +//! Note: Prior to the Try trait stabilization, `expr?` expanded to a match +//! with `val` and `err` bindings. The current implementation uses Try::branch() +//! but this test remains relevant for hygiene verification. + +//@ run-pass + +#![allow(non_upper_case_globals)] +#![allow(dead_code)] + +use std::num::ParseIntError; + +fn main() { + assert_eq!(parse(), Ok(1)); +} + +fn parse() -> Result<i32, ParseIntError> { + const val: char = 'a'; + const err: char = 'b'; + + Ok("1".parse::<i32>()?) +} diff --git a/tests/ui/try-operator.rs b/tests/ui/try-trait/try-operator-various-contexts.rs index b9978204557..41c3679c96f 100644 --- a/tests/ui/try-operator.rs +++ b/tests/ui/try-trait/try-operator-various-contexts.rs @@ -1,9 +1,11 @@ +//! Checks the functionality of the `?` operator in various syntactic contexts. + //@ run-pass #![allow(dead_code)] use std::fs::File; -use std::io::{Read, self}; +use std::io::{self, Read}; use std::num::ParseIntError; use std::str::FromStr; @@ -35,7 +37,9 @@ fn on_path() -> Result<i32, ParseIntError> { fn on_macro() -> Result<i32, ParseIntError> { macro_rules! id { - ($e:expr) => { $e } + ($e:expr) => { + $e + }; } Ok(id!("7".parse::<i32>())?) @@ -50,11 +54,14 @@ fn on_parens() -> Result<i32, ParseIntError> { fn on_block() -> Result<i32, ParseIntError> { let x = "9".parse::<i32>(); - Ok({x}?) + Ok({ x }?) } fn on_field() -> Result<i32, ParseIntError> { - struct Pair<A, B> { a: A, b: B } + struct Pair<A, B> { + a: A, + b: B, + } let x = Pair { a: "10".parse::<i32>(), b: 0 }; @@ -89,7 +96,9 @@ fn on_index() -> Result<i32, ParseIntError> { } fn on_args() -> Result<i32, ParseIntError> { - fn sub(x: i32, y: i32) -> i32 { x - y } + fn sub(x: i32, y: i32) -> i32 { + x - y + } let x = "20".parse(); let y = "21".parse(); @@ -98,19 +107,11 @@ fn on_args() -> Result<i32, ParseIntError> { } fn on_if() -> Result<i32, ParseIntError> { - Ok(if true { - "22".parse::<i32>() - } else { - "23".parse::<i32>() - }?) + Ok(if true { "22".parse::<i32>() } else { "23".parse::<i32>() }?) } fn on_if_let() -> Result<i32, ParseIntError> { - Ok(if let Ok(..) = "24".parse::<i32>() { - "25".parse::<i32>() - } else { - "26".parse::<i32>() - }?) + Ok(if let Ok(..) = "24".parse::<i32>() { "25".parse::<i32>() } else { "26".parse::<i32>() }?) } fn on_match() -> Result<i32, ParseIntError> { @@ -121,7 +122,9 @@ fn on_match() -> Result<i32, ParseIntError> { } fn tight_binding() -> Result<bool, ()> { - fn ok<T>(x: T) -> Result<T, ()> { Ok(x) } + fn ok<T>(x: T) -> Result<T, ()> { + Ok(x) + } let x = ok(true); Ok(!x?) diff --git a/tests/ui/tydesc-name.rs b/tests/ui/tydesc-name.rs deleted file mode 100644 index 068a42606c2..00000000000 --- a/tests/ui/tydesc-name.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - -use std::any::type_name; - -struct Foo<T> { - x: T -} - -pub fn main() { - assert_eq!(type_name::<isize>(), "isize"); - assert_eq!(type_name::<Foo<usize>>(), "tydesc_name::Foo<usize>"); -} diff --git a/tests/ui/type-inference/type-inference-none-in-generic-ref.rs b/tests/ui/type-inference/type-inference-none-in-generic-ref.rs new file mode 100644 index 00000000000..9c1b7c19e3d --- /dev/null +++ b/tests/ui/type-inference/type-inference-none-in-generic-ref.rs @@ -0,0 +1,9 @@ +//! Checks that unconstrained `None` is rejected through references and generics + +struct S<'a, T: 'a> { + o: &'a Option<T>, +} + +fn main() { + S { o: &None }; //~ ERROR type annotations needed [E0282] +} diff --git a/tests/ui/unconstrained-ref.stderr b/tests/ui/type-inference/type-inference-none-in-generic-ref.stderr index 72fd0202f4e..d671c189b37 100644 --- a/tests/ui/unconstrained-ref.stderr +++ b/tests/ui/type-inference/type-inference-none-in-generic-ref.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/unconstrained-ref.rs:6:5 + --> $DIR/type-inference-none-in-generic-ref.rs:8:5 | LL | S { o: &None }; | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `S` diff --git a/tests/ui/type-inference/type-inference-unconstrained-none.rs b/tests/ui/type-inference/type-inference-unconstrained-none.rs new file mode 100644 index 00000000000..38a506763c7 --- /dev/null +++ b/tests/ui/type-inference/type-inference-unconstrained-none.rs @@ -0,0 +1,5 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/5062>. + +fn main() { + None; //~ ERROR type annotations needed [E0282] +} diff --git a/tests/ui/unconstrained-none.stderr b/tests/ui/type-inference/type-inference-unconstrained-none.stderr index 4af6f412e5b..80572b845e8 100644 --- a/tests/ui/unconstrained-none.stderr +++ b/tests/ui/type-inference/type-inference-unconstrained-none.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/unconstrained-none.rs:4:5 + --> $DIR/type-inference-unconstrained-none.rs:4:5 | LL | None; | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` diff --git a/tests/ui/type-namespace.rs b/tests/ui/type-namespace.rs deleted file mode 100644 index 31dc684a214..00000000000 --- a/tests/ui/type-namespace.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -struct A { a: isize } - -fn a(a: A) -> isize { return a.a; } - -pub fn main() { let x: A = A {a: 1}; assert_eq!(a(x), 1); } diff --git a/tests/ui/type-ptr.rs b/tests/ui/type-ptr.rs deleted file mode 100644 index 5c8ed344ab3..00000000000 --- a/tests/ui/type-ptr.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - -fn f(a: *const isize) -> *const isize { return a; } - -fn g(a: *const isize) -> *const isize { let b = f(a); return b; } - -pub fn main() { return; } diff --git a/tests/ui/type-use-i1-versus-i8.rs b/tests/ui/type-use-i1-versus-i8.rs deleted file mode 100644 index 4eb25329223..00000000000 --- a/tests/ui/type-use-i1-versus-i8.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass - -use std::ptr; - -pub fn main() { - unsafe { - let mut x: bool = false; - // this line breaks it - ptr::write(&mut x, false); - } -} diff --git a/tests/ui/auxiliary/typeid-intrinsic-aux1.rs b/tests/ui/type/auxiliary/typeid-consistency-aux1.rs index a028008c6ae..a028008c6ae 100644 --- a/tests/ui/auxiliary/typeid-intrinsic-aux1.rs +++ b/tests/ui/type/auxiliary/typeid-consistency-aux1.rs diff --git a/tests/ui/auxiliary/typeid-intrinsic-aux2.rs b/tests/ui/type/auxiliary/typeid-consistency-aux2.rs index a028008c6ae..a028008c6ae 100644 --- a/tests/ui/auxiliary/typeid-intrinsic-aux2.rs +++ b/tests/ui/type/auxiliary/typeid-consistency-aux2.rs diff --git a/tests/ui/type/type-name-basic.rs b/tests/ui/type/type-name-basic.rs new file mode 100644 index 00000000000..9381cb82578 --- /dev/null +++ b/tests/ui/type/type-name-basic.rs @@ -0,0 +1,17 @@ +//! Checks the basic functionality of `std::any::type_name` for primitive types +//! and simple generic structs. + +//@ run-pass + +#![allow(dead_code)] + +use std::any::type_name; + +struct Foo<T> { + x: T, +} + +pub fn main() { + assert_eq!(type_name::<isize>(), "isize"); + assert_eq!(type_name::<Foo<usize>>(), "type_name_basic::Foo<usize>"); +} diff --git a/tests/ui/typeid-intrinsic.rs b/tests/ui/type/typeid-consistency.rs index 7c4fb3f95a9..67ee1b6d839 100644 --- a/tests/ui/typeid-intrinsic.rs +++ b/tests/ui/type/typeid-consistency.rs @@ -1,16 +1,18 @@ +//! Checks the correctness and consistency of `std::any::TypeId::of`. + //@ run-pass #![allow(deprecated)] -//@ aux-build:typeid-intrinsic-aux1.rs -//@ aux-build:typeid-intrinsic-aux2.rs - #![feature(core_intrinsics)] -extern crate typeid_intrinsic_aux1 as other1; -extern crate typeid_intrinsic_aux2 as other2; +//@ aux-build:typeid-consistency-aux1.rs +//@ aux-build:typeid-consistency-aux2.rs + +extern crate typeid_consistency_aux1 as other1; +extern crate typeid_consistency_aux2 as other2; -use std::hash::{SipHasher, Hasher, Hash}; use std::any::TypeId; +use std::hash::{Hash, Hasher, SipHasher}; struct A; struct Test; @@ -34,7 +36,7 @@ pub fn main() { assert_eq!(TypeId::of::<other2::F>(), other2::id_F()); assert_eq!(TypeId::of::<other2::G>(), other2::id_G()); assert_eq!(TypeId::of::<other2::H>(), other2::id_H()); - assert_eq!(TypeId::of::<other1::I>(), other2::id_I()); + assert_eq!(TypeId::of::<other2::I>(), other2::id_I()); assert_eq!(other1::id_F(), other2::id_F()); assert_eq!(other1::id_G(), other2::id_G()); @@ -49,10 +51,8 @@ pub fn main() { assert_eq!(other2::foo::<A>(), other1::foo::<A>()); // sanity test of TypeId - let (a, b, c) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(), - TypeId::of::<Test>()); - let (d, e, f) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(), - TypeId::of::<Test>()); + let (a, b, c) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(), TypeId::of::<Test>()); + let (d, e, f) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(), TypeId::of::<Test>()); assert!(a != b); assert!(a != c); @@ -82,10 +82,7 @@ pub fn main() { assert_ne!(TypeId::of::<other1::I32Iterator>(), TypeId::of::<other1::U32Iterator>()); // Check fn pointer against collisions - assert_ne!( - TypeId::of::<fn(fn(A) -> A) -> A>(), - TypeId::of::<fn(fn() -> A, A) -> A>() - ); + assert_ne!(TypeId::of::<fn(fn(A) -> A) -> A>(), TypeId::of::<fn(fn() -> A, A) -> A>()); assert_ne!( TypeId::of::<for<'a> fn(&'a i32) -> &'a i32>(), TypeId::of::<for<'a> fn(&'a i32) -> &'static i32>() diff --git a/tests/ui/type/unit-type-basic-usages.rs b/tests/ui/type/unit-type-basic-usages.rs new file mode 100644 index 00000000000..c3ee8067f59 --- /dev/null +++ b/tests/ui/type/unit-type-basic-usages.rs @@ -0,0 +1,14 @@ +//! Checks the basic usage of unit type + +//@ run-pass + +fn f(u: ()) { + u +} + +pub fn main() { + let u1: () = (); + let mut _u2: () = f(u1); + _u2 = (); + () +} diff --git a/tests/ui/usize-generic-argument-parent.rs b/tests/ui/type/usize-no-generic-arguments.rs index 4ab80d944a5..d4d1eea757c 100644 --- a/tests/ui/usize-generic-argument-parent.rs +++ b/tests/ui/type/usize-no-generic-arguments.rs @@ -1,3 +1,5 @@ +//! Sanity test that primitives cannot have const generics. + fn foo() { let x: usize<foo>; //~ ERROR const arguments are not allowed on builtin type `usize` } diff --git a/tests/ui/usize-generic-argument-parent.stderr b/tests/ui/type/usize-no-generic-arguments.stderr index 9c081a287ed..f1f3456461f 100644 --- a/tests/ui/usize-generic-argument-parent.stderr +++ b/tests/ui/type/usize-no-generic-arguments.stderr @@ -1,5 +1,5 @@ error[E0109]: const arguments are not allowed on builtin type `usize` - --> $DIR/usize-generic-argument-parent.rs:2:18 + --> $DIR/usize-no-generic-arguments.rs:4:18 | LL | let x: usize<foo>; | ----- ^^^ const argument not allowed diff --git a/tests/ui/typeck/mismatched-types-ref-binding.rs b/tests/ui/typeck/mismatched-types-ref-binding.rs new file mode 100644 index 00000000000..baf9056dfeb --- /dev/null +++ b/tests/ui/typeck/mismatched-types-ref-binding.rs @@ -0,0 +1,8 @@ +//! Check that a `mismatched types` error (E0308) is correctly reported when attempting to +//! bind a reference to an `i32` to a reference to a `String`. +//! Ensure `ref` bindings report a mismatched type error. + +fn main() { + let var = 10i32; + let ref string: String = var; //~ ERROR mismatched types [E0308] +} diff --git a/tests/ui/switched-expectations.stderr b/tests/ui/typeck/mismatched-types-ref-binding.stderr index e235c2da1f7..c08e5d2a60b 100644 --- a/tests/ui/switched-expectations.stderr +++ b/tests/ui/typeck/mismatched-types-ref-binding.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/switched-expectations.rs:3:30 + --> $DIR/mismatched-types-ref-binding.rs:7:30 | LL | let ref string: String = var; | ^^^ expected `String`, found `i32` diff --git a/tests/ui/typeck/tail-return-type-mismatch.rs b/tests/ui/typeck/tail-return-type-mismatch.rs new file mode 100644 index 00000000000..fa0d205ad82 --- /dev/null +++ b/tests/ui/typeck/tail-return-type-mismatch.rs @@ -0,0 +1,14 @@ +//! Test for type mismatch error when returning `usize` from `isize` function. + +fn f() -> isize { + return g(); + //~^ ERROR mismatched types [E0308] +} + +fn g() -> usize { + return 0; +} + +fn main() { + let y = f(); +} diff --git a/tests/ui/typeck/tail-return-type-mismatch.stderr b/tests/ui/typeck/tail-return-type-mismatch.stderr new file mode 100644 index 00000000000..36da65d0304 --- /dev/null +++ b/tests/ui/typeck/tail-return-type-mismatch.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/tail-return-type-mismatch.rs:4:12 + | +LL | fn f() -> isize { + | ----- expected `isize` because of return type +LL | return g(); + | ^^^ expected `isize`, found `usize` + | +help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit + | +LL | return g().try_into().unwrap(); + | ++++++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/unconstrained-none.rs b/tests/ui/unconstrained-none.rs deleted file mode 100644 index e180b3163d4..00000000000 --- a/tests/ui/unconstrained-none.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Issue #5062 - -fn main() { - None; //~ ERROR type annotations needed [E0282] -} diff --git a/tests/ui/unconstrained-ref.rs b/tests/ui/unconstrained-ref.rs deleted file mode 100644 index 473ca954b23..00000000000 --- a/tests/ui/unconstrained-ref.rs +++ /dev/null @@ -1,7 +0,0 @@ -struct S<'a, T:'a> { - o: &'a Option<T> -} - -fn main() { - S { o: &None }; //~ ERROR type annotations needed [E0282] -} diff --git a/tests/ui/underscore-ident-matcher.rs b/tests/ui/underscore-ident-matcher.rs deleted file mode 100644 index 77ec70d43d5..00000000000 --- a/tests/ui/underscore-ident-matcher.rs +++ /dev/null @@ -1,9 +0,0 @@ -macro_rules! identity { - ($i: ident) => ( - $i - ) -} - -fn main() { - let identity!(_) = 10; //~ ERROR no rules expected reserved identifier `_` -} diff --git a/tests/ui/underscore-lifetimes.rs b/tests/ui/underscore-lifetime/basic-underscore-lifetime-elision.rs index a372851f9cf..a2e3c8e26d4 100644 --- a/tests/ui/underscore-lifetimes.rs +++ b/tests/ui/underscore-lifetime/basic-underscore-lifetime-elision.rs @@ -1,6 +1,9 @@ +//! Checks the correct usage and behavior of the anonymous lifetime `'_` (underscore lifetime) + //@ run-pass #![allow(dead_code, mismatched_lifetime_syntaxes)] + struct Foo<'a>(&'a u8); fn foo(x: &u8) -> Foo<'_> { @@ -31,8 +34,5 @@ fn main() { let _ = foo2(x); let _ = foo3(x); foo4(Foo(x)); - let _ = foo5(Foo2 { - a: x, - b: &6, - }); + let _ = foo5(Foo2 { a: x, b: &6 }); } diff --git a/tests/ui/underscore-method-after-integer.rs b/tests/ui/underscore-method-after-integer.rs deleted file mode 100644 index d9eb21894e8..00000000000 --- a/tests/ui/underscore-method-after-integer.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass - -trait Tr : Sized { - fn _method_on_numbers(self) {} -} - -impl Tr for i32 {} - -fn main() { - 42._method_on_numbers(); -} diff --git a/tests/ui/unevaluated_fixed_size_array_len.rs b/tests/ui/unevaluated_fixed_size_array_len.rs deleted file mode 100644 index 6c545913dd9..00000000000 --- a/tests/ui/unevaluated_fixed_size_array_len.rs +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/rust-lang/rust/issues/49208 - -trait Foo { - fn foo(); -} - -impl Foo for [(); 1] { - fn foo() {} -} - -fn main() { - <[(); 0] as Foo>::foo() //~ ERROR E0277 -} diff --git a/tests/ui/unit.rs b/tests/ui/unit.rs deleted file mode 100644 index 04404fc3f5e..00000000000 --- a/tests/ui/unit.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass - -#![allow(unused_assignments)] -#![allow(unknown_lints)] - -#![allow(unused_variables)] -#![allow(dead_assignment)] - -fn f(u: ()) { return u; } - -pub fn main() { - let u1: () = (); - let mut u2: () = f(u1); - u2 = (); - return (); -} diff --git a/tests/ui/unknown-language-item.rs b/tests/ui/unknown-language-item.rs deleted file mode 100644 index ce206d20358..00000000000 --- a/tests/ui/unknown-language-item.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![allow(unused)] -#![feature(lang_items)] - -#[lang = "foo"] -fn bar() -> ! { -//~^^ ERROR definition of an unknown lang item: `foo` - loop {} -} - -fn main() {} diff --git a/tests/ui/unnamed_argument_mode.rs b/tests/ui/unnamed_argument_mode.rs deleted file mode 100644 index 2014e0d23d8..00000000000 --- a/tests/ui/unnamed_argument_mode.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -fn good(_a: &isize) { -} - -// unnamed argument &isize is now parse x: &isize - -fn called<F>(_f: F) where F: FnOnce(&isize) { -} - -pub fn main() { - called(good); -} diff --git a/tests/ui/unpretty/frontmatter.rs b/tests/ui/unpretty/frontmatter.rs new file mode 100644 index 00000000000..1971808e2a8 --- /dev/null +++ b/tests/ui/unpretty/frontmatter.rs @@ -0,0 +1,10 @@ +--- +--- + +//@ compile-flags: -Zunpretty=normal +//@ check-pass + +#![feature(frontmatter)] + +fn main() { +} diff --git a/tests/ui/unpretty/frontmatter.stdout b/tests/ui/unpretty/frontmatter.stdout new file mode 100644 index 00000000000..2ccbb1b2582 --- /dev/null +++ b/tests/ui/unpretty/frontmatter.stdout @@ -0,0 +1,9 @@ +--- +--- + +//@ compile-flags: -Zunpretty=normal +//@ check-pass + +#![feature(frontmatter)] + +fn main() {} diff --git a/tests/ui/unreachable-code-1.rs b/tests/ui/unreachable-code-1.rs deleted file mode 100644 index 9c5f7c8f451..00000000000 --- a/tests/ui/unreachable-code-1.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass - -#![allow(unused_must_use)] -#![allow(unreachable_code)] - -#![allow(unused_variables)] -#![allow(dead_code)] - -fn id(x: bool) -> bool { x } - -fn call_id() { - let c = panic!(); - id(c); -} - -fn call_id_3() { id(return) && id(return); } - -pub fn main() { -} diff --git a/tests/ui/uninit-empty-types.rs b/tests/ui/unsafe/maybe-uninit-zero-sized-types.rs index 82474d873b7..e587ca554fe 100644 --- a/tests/ui/uninit-empty-types.rs +++ b/tests/ui/unsafe/maybe-uninit-zero-sized-types.rs @@ -1,6 +1,9 @@ -//@ build-pass -// Test the uninit() construct returning various empty types. +//! This test checks that ZSTs can be safely initialized from +//! `MaybeUninit::uninit().assume_init()` and `std::mem::uninitialized()` +//! (which is deprecated). This is safe because ZSTs inherently +//! require no actual memory initialization, as they occupy no memory. +//@ build-pass use std::mem::MaybeUninit; diff --git a/tests/ui/unsized-locals/unsized-exprs-rpass.rs b/tests/ui/unsized-locals/unsized-exprs-rpass.rs index 54ecd000343..ce31bd63f7c 100644 --- a/tests/ui/unsized-locals/unsized-exprs-rpass.rs +++ b/tests/ui/unsized-locals/unsized-exprs-rpass.rs @@ -18,11 +18,6 @@ impl std::ops::Add<i32> for A<[u8]> { } fn main() { - udrop::<[u8]>(loop { - break *foo(); - }); - udrop::<[u8]>(if true { *foo() } else { *foo() }); - udrop::<[u8]>({ *foo() }); udrop::<[u8]>((*foo())); *afoo() + 42; udrop as fn([u8]); diff --git a/tests/ui/unsized-locals/unsized-exprs.stderr b/tests/ui/unsized-locals/unsized-exprs.stderr index 1b61254870f..0455edbe8e7 100644 --- a/tests/ui/unsized-locals/unsized-exprs.stderr +++ b/tests/ui/unsized-locals/unsized-exprs.stderr @@ -10,7 +10,11 @@ note: required because it appears within the type `A<[u8]>` | LL | struct A<X: ?Sized>(X); | ^ - = note: structs must have a statically known size to be initialized +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-exprs.rs:19:22 + | +LL | udrop::<A<[u8]>>(A { 0: *foo() }); + | ^^^^^^^^^^^^^^^ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/unsized-exprs.rs:21:22 @@ -24,7 +28,11 @@ note: required because it appears within the type `A<[u8]>` | LL | struct A<X: ?Sized>(X); | ^ - = note: the return type of a function must have a statically known size +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-exprs.rs:21:22 + | +LL | udrop::<A<[u8]>>(A(*foo())); + | ^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/unsized-locals/unsized-non-place-exprs.rs b/tests/ui/unsized-locals/unsized-non-place-exprs.rs new file mode 100644 index 00000000000..d724fcf81a4 --- /dev/null +++ b/tests/ui/unsized-locals/unsized-non-place-exprs.rs @@ -0,0 +1,27 @@ +//! `#![feature(unsized_fn_params)]` lets you use unsized function parameters. In particular this +//! is load bearing for `Box<dyn FnOnce()>: FnOnce()`. To do that, borrowck relaxes the requirement +//! that certain places must be `Sized`. But in #142911 we removed alloca support, so these +//! arguments cannot be put in temporaries (or ICE at codegen) That means when `unsized_fn_params` +//! is enabled, we must explicitly check that unsized function arguments are place expressions. +//! +//! Also see tests/ui/unsized_locals/unsized-exprs-rpass.rs + +#![feature(unsized_fn_params)] + +fn foo() -> Box<[u8]> { + Box::new(*b"foo") +} + +fn udrop<T: ?Sized>(_x: T) {} + +fn main(){ + // NB The ordering of the following operations matters, otherwise errors get swallowed somehow. + + udrop::<[u8]>(if true { *foo() } else { *foo() }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time + udrop::<[u8]>({ *foo() }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time + udrop(match foo() { x => *x }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time + udrop::<[u8]>({ loop { break *foo(); } }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time + + { *foo() }; //~ERROR the size for values of type `[u8]` cannot be known at compilation time + { loop { break *foo(); } }; //~ERROR the size for values of type `[u8]` cannot be known at compilation time +} diff --git a/tests/ui/unsized-locals/unsized-non-place-exprs.stderr b/tests/ui/unsized-locals/unsized-non-place-exprs.stderr new file mode 100644 index 00000000000..f9507e9a888 --- /dev/null +++ b/tests/ui/unsized-locals/unsized-non-place-exprs.stderr @@ -0,0 +1,81 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-non-place-exprs.rs:20:19 + | +LL | udrop::<[u8]>(if true { *foo() } else { *foo() }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-non-place-exprs.rs:20:19 + | +LL | udrop::<[u8]>(if true { *foo() } else { *foo() }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-non-place-exprs.rs:21:19 + | +LL | udrop::<[u8]>({ *foo() }); + | ^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-non-place-exprs.rs:21:19 + | +LL | udrop::<[u8]>({ *foo() }); + | ^^^^^^^^^^ + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-non-place-exprs.rs:22:11 + | +LL | udrop(match foo() { x => *x }); + | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-non-place-exprs.rs:22:11 + | +LL | udrop(match foo() { x => *x }); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-non-place-exprs.rs:23:19 + | +LL | udrop::<[u8]>({ loop { break *foo(); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-non-place-exprs.rs:23:19 + | +LL | udrop::<[u8]>({ loop { break *foo(); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-non-place-exprs.rs:25:5 + | +LL | { *foo() }; + | ^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-non-place-exprs.rs:25:5 + | +LL | { *foo() }; + | ^^^^^^^^^^ + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-non-place-exprs.rs:26:5 + | +LL | { loop { break *foo(); } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: unsized values must be place expressions and cannot be put in temporaries + --> $DIR/unsized-non-place-exprs.rs:26:5 + | +LL | { loop { break *foo(); } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unused-move.rs b/tests/ui/unused-move.rs deleted file mode 100644 index 3d5eff2c48d..00000000000 --- a/tests/ui/unused-move.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass -// Issue #3878 -// Issue Name: Unused move causes a crash -// Abstract: zero-fill to block after drop - - -#![allow(path_statements)] - -pub fn main() { - let y: Box<_> = Box::new(1); - y; -} diff --git a/tests/ui/use-import-export.rs b/tests/ui/use-import-export.rs deleted file mode 100644 index d948ffc1520..00000000000 --- a/tests/ui/use-import-export.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass - -mod foo { - pub fn x() -> isize { return 1; } -} - -mod bar { - pub fn y() -> isize { return 1; } -} - -pub fn main() { foo::x(); bar::y(); } diff --git a/tests/ui/use-module-level-int-consts.rs b/tests/ui/use-module-level-int-consts.rs deleted file mode 100644 index 6e8c7053c57..00000000000 --- a/tests/ui/use-module-level-int-consts.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass - -// Make sure the module level constants are still there and accessible even after -// the corresponding associated constants have been added, and later stabilized. -#![allow(deprecated, deprecated_in_future)] -use std::{u16, f32}; - -fn main() { - let _ = u16::MAX; - let _ = f32::EPSILON; - let _ = std::f64::MANTISSA_DIGITS; -} diff --git a/tests/ui/walk-struct-literal-with.rs b/tests/ui/walk-struct-literal-with.rs deleted file mode 100644 index ee1a77eb9a4..00000000000 --- a/tests/ui/walk-struct-literal-with.rs +++ /dev/null @@ -1,17 +0,0 @@ -struct Mine{ - test: String, - other_val: isize -} - -impl Mine{ - fn make_string_bar(mut self) -> Mine{ - self.test = "Bar".to_string(); - self - } -} - -fn main(){ - let start = Mine{test:"Foo".to_string(), other_val:0}; - let end = Mine{other_val:1, ..start.make_string_bar()}; - println!("{}", start.test); //~ ERROR borrow of moved value: `start` -} diff --git a/tests/ui/weak-new-uninhabited-issue-48493.rs b/tests/ui/weak-new-uninhabited-issue-48493.rs deleted file mode 100644 index ce7d5786b41..00000000000 --- a/tests/ui/weak-new-uninhabited-issue-48493.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -fn main() { - enum Void {} - let _ = std::rc::Weak::<Void>::new(); - let _ = std::sync::Weak::<Void>::new(); -} diff --git a/tests/ui/weird-exit-code.rs b/tests/ui/weird-exit-code.rs deleted file mode 100644 index e016343f8ba..00000000000 --- a/tests/ui/weird-exit-code.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ run-pass -// On Windows the GetExitCodeProcess API is used to get the exit code of a -// process, but it's easy to mistake a process exiting with the code 259 as -// "still running" because this is the value of the STILL_ACTIVE constant. Make -// sure we handle this case in the standard library and correctly report the -// status. -// -// Note that this is disabled on unix as processes exiting with 259 will have -// their exit status truncated to 3 (only the lower 8 bits are used). - -#[cfg(windows)] -fn main() { - use std::process::{self, Command}; - use std::env; - - if env::args().len() == 1 { - let status = Command::new(env::current_exe().unwrap()) - .arg("foo") - .status() - .unwrap(); - assert_eq!(status.code(), Some(259)); - } else { - process::exit(259); - } -} - -#[cfg(not(windows))] -fn main() {} |
