summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/rfc-2383-lint-reason
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/lint/rfc-2383-lint-reason
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/lint/rfc-2383-lint-reason')
-rw-r--r--tests/ui/lint/rfc-2383-lint-reason/expect_unused_inside_impl_block.rs30
-rw-r--r--tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.rs8
-rw-r--r--tests/ui/lint/rfc-2383-lint-reason/expect_with_forbid.stderr30
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`.