diff options
Diffstat (limited to 'tests/ui/lint/rfc-2383-lint-reason')
3 files changed, 38 insertions, 30 deletions
diff --git a/tests/ui/lint/rfc-2383-lint-reason/expect_unused_inside_impl_block.rs b/tests/ui/lint/rfc-2383-lint-reason/expect_unused_inside_impl_block.rs new file mode 100644 index 000000000..1e2ff12a2 --- /dev/null +++ b/tests/ui/lint/rfc-2383-lint-reason/expect_unused_inside_impl_block.rs @@ -0,0 +1,30 @@ +// check-pass +// incremental + +#![feature(lint_reasons)] +#![warn(unused)] + +struct OneUnused; +struct TwoUnused; + +impl OneUnused { + #[expect(unused)] + fn unused() {} +} + +impl TwoUnused { + #[expect(unused)] + fn unused1(){} + + // This unused method has `#[expect(unused)]`, so the compiler should not emit a warning. + // This ui test was added after a regression in the compiler where it did not recognize multiple + // `#[expect(unused)]` annotations inside of impl blocks. + // issue 114416 + #[expect(unused)] + fn unused2(){} +} + +fn main() { + let _ = OneUnused; + let _ = TwoUnused; +} diff --git a/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.rs b/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.rs index 479ee198e..77cb5e88b 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.rs +++ b/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.rs @@ -1,24 +1,20 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes + #![feature(lint_reasons)] #[forbid(unused_variables)] //~^ NOTE `forbid` level set here -//~| NOTE `forbid` level set here #[expect(unused_variables)] //~^ ERROR incompatible with previous forbid [E0453] //~| NOTE overruled by previous forbid -//~| ERROR incompatible with previous forbid [E0453] -//~| NOTE overruled by previous forbid fn expect_forbidden_lint_1() {} #[forbid(while_true)] //~^ NOTE `forbid` level set here -//~| NOTE `forbid` level set here //~| NOTE the lint level is defined here #[expect(while_true)] //~^ ERROR incompatible with previous forbid [E0453] //~| NOTE overruled by previous forbid -//~| ERROR incompatible with previous forbid [E0453] -//~| NOTE overruled by previous forbid fn expect_forbidden_lint_2() { // This while loop will produce a `while_true` lint as the lint level // at this node is still `forbid` and the `while_true` check happens diff --git a/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.stderr b/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.stderr index a8116e934..0f42ffbde 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.stderr +++ b/tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.stderr @@ -1,32 +1,14 @@ error[E0453]: expect(unused_variables) incompatible with previous forbid - --> $DIR/expect_with_forbid.rs:6:10 + --> $DIR/expect_with_forbid.rs:7:10 | LL | #[forbid(unused_variables)] | ---------------- `forbid` level set here -... -LL | #[expect(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - -error[E0453]: expect(while_true) incompatible with previous forbid - --> $DIR/expect_with_forbid.rs:17:10 - | -LL | #[forbid(while_true)] - | ---------- `forbid` level set here -... -LL | #[expect(while_true)] - | ^^^^^^^^^^ overruled by previous forbid - -error[E0453]: expect(unused_variables) incompatible with previous forbid - --> $DIR/expect_with_forbid.rs:6:10 - | -LL | #[forbid(unused_variables)] - | ---------------- `forbid` level set here -... +LL | LL | #[expect(unused_variables)] | ^^^^^^^^^^^^^^^^ overruled by previous forbid error[E0453]: expect(while_true) incompatible with previous forbid - --> $DIR/expect_with_forbid.rs:17:10 + --> $DIR/expect_with_forbid.rs:15:10 | LL | #[forbid(while_true)] | ---------- `forbid` level set here @@ -35,17 +17,17 @@ LL | #[expect(while_true)] | ^^^^^^^^^^ overruled by previous forbid error: denote infinite loops with `loop { ... }` - --> $DIR/expect_with_forbid.rs:26:5 + --> $DIR/expect_with_forbid.rs:22:5 | LL | while true {} | ^^^^^^^^^^ help: use `loop` | note: the lint level is defined here - --> $DIR/expect_with_forbid.rs:13:10 + --> $DIR/expect_with_forbid.rs:12:10 | LL | #[forbid(while_true)] | ^^^^^^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0453`. |