diff options
Diffstat (limited to 'tests')
106 files changed, 664 insertions, 449 deletions
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/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/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/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/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/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-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_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/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/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/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/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/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-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/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/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/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/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/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/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/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`. |
