summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/unused
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/ui/lint/unused
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/lint/unused')
-rw-r--r--tests/ui/lint/unused/assoc-types.assoc_ty.stderr15
-rw-r--r--tests/ui/lint/unused/assoc-types.rpitit.stderr15
-rw-r--r--tests/ui/lint/unused/assoc-types.rs23
-rw-r--r--tests/ui/lint/unused/issue-105061.stderr2
-rw-r--r--tests/ui/lint/unused/issue-30730.stderr2
-rw-r--r--tests/ui/lint/unused/issue-46576.stderr2
-rw-r--r--tests/ui/lint/unused/issue-59896.stderr2
-rw-r--r--tests/ui/lint/unused/issue-85913.stderr2
-rw-r--r--tests/ui/lint/unused/lint-unused-mut-variables.stderr2
-rw-r--r--tests/ui/lint/unused/must_use-pin.rs45
-rw-r--r--tests/ui/lint/unused/must_use-pin.stderr20
-rw-r--r--tests/ui/lint/unused/unused-macro-rules-malformed-rule.stderr2
-rw-r--r--tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr2
-rw-r--r--tests/ui/lint/unused/unused-macro-with-follow-violation.stderr2
-rw-r--r--tests/ui/lint/unused/unused-mut-warning-captured-var.stderr2
-rw-r--r--tests/ui/lint/unused/unused-supertrait.stderr2
16 files changed, 129 insertions, 11 deletions
diff --git a/tests/ui/lint/unused/assoc-types.assoc_ty.stderr b/tests/ui/lint/unused/assoc-types.assoc_ty.stderr
new file mode 100644
index 000000000..190c4ef0c
--- /dev/null
+++ b/tests/ui/lint/unused/assoc-types.assoc_ty.stderr
@@ -0,0 +1,15 @@
+error: unused implementer of `Future` that must be used
+ --> $DIR/assoc-types.rs:19:5
+ |
+LL | T::foo();
+ | ^^^^^^^^
+ |
+ = note: futures do nothing unless you `.await` or poll them
+note: the lint level is defined here
+ --> $DIR/assoc-types.rs:4:9
+ |
+LL | #![deny(unused_must_use)]
+ | ^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/lint/unused/assoc-types.rpitit.stderr b/tests/ui/lint/unused/assoc-types.rpitit.stderr
new file mode 100644
index 000000000..190c4ef0c
--- /dev/null
+++ b/tests/ui/lint/unused/assoc-types.rpitit.stderr
@@ -0,0 +1,15 @@
+error: unused implementer of `Future` that must be used
+ --> $DIR/assoc-types.rs:19:5
+ |
+LL | T::foo();
+ | ^^^^^^^^
+ |
+ = note: futures do nothing unless you `.await` or poll them
+note: the lint level is defined here
+ --> $DIR/assoc-types.rs:4:9
+ |
+LL | #![deny(unused_must_use)]
+ | ^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/lint/unused/assoc-types.rs b/tests/ui/lint/unused/assoc-types.rs
new file mode 100644
index 000000000..cebb9b409
--- /dev/null
+++ b/tests/ui/lint/unused/assoc-types.rs
@@ -0,0 +1,23 @@
+// edition: 2021
+// revisions: rpitit assoc_ty
+
+#![deny(unused_must_use)]
+
+use std::future::Future;
+
+pub trait Tr {
+ type Fut: Future<Output = ()>;
+
+ #[cfg(rpitit)]
+ fn foo() -> impl Future<Output = ()>;
+
+ #[cfg(assoc_ty)]
+ fn foo() -> Self::Fut;
+}
+
+pub async fn bar<T: Tr>() {
+ T::foo();
+ //~^ ERROR unused implementer of `Future` that must be used
+}
+
+fn main() {}
diff --git a/tests/ui/lint/unused/issue-105061.stderr b/tests/ui/lint/unused/issue-105061.stderr
index f07aa2012..b41f14d82 100644
--- a/tests/ui/lint/unused/issue-105061.stderr
+++ b/tests/ui/lint/unused/issue-105061.stderr
@@ -16,5 +16,5 @@ LL - ((for<'a> fn(Inv<'a>)),): Trait,
LL + (for<'a> fn(Inv<'a>),): Trait,
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/issue-30730.stderr b/tests/ui/lint/unused/issue-30730.stderr
index b299e99a3..c815045df 100644
--- a/tests/ui/lint/unused/issue-30730.stderr
+++ b/tests/ui/lint/unused/issue-30730.stderr
@@ -11,5 +11,5 @@ LL | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(unused_imports)]` implied by `#[deny(warnings)]`
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/issue-46576.stderr b/tests/ui/lint/unused/issue-46576.stderr
index 6f4d97068..44e4fb582 100644
--- a/tests/ui/lint/unused/issue-46576.stderr
+++ b/tests/ui/lint/unused/issue-46576.stderr
@@ -10,5 +10,5 @@ note: the lint level is defined here
LL | #![deny(unused_imports)]
| ^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/issue-59896.stderr b/tests/ui/lint/unused/issue-59896.stderr
index 95b7938ae..3e8298c6b 100644
--- a/tests/ui/lint/unused/issue-59896.stderr
+++ b/tests/ui/lint/unused/issue-59896.stderr
@@ -13,5 +13,5 @@ note: the lint level is defined here
LL | #![deny(unused_imports)]
| ^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/issue-85913.stderr b/tests/ui/lint/unused/issue-85913.stderr
index 8234ed3b1..b69ac3d97 100644
--- a/tests/ui/lint/unused/issue-85913.stderr
+++ b/tests/ui/lint/unused/issue-85913.stderr
@@ -14,5 +14,5 @@ help: use `let _ = ...` to ignore the resulting value
LL | let _ = function() && return 1;
| +++++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/lint-unused-mut-variables.stderr b/tests/ui/lint/unused/lint-unused-mut-variables.stderr
index 5f66c0315..dcda1e530 100644
--- a/tests/ui/lint/unused/lint-unused-mut-variables.stderr
+++ b/tests/ui/lint/unused/lint-unused-mut-variables.stderr
@@ -226,5 +226,5 @@ LL | fn write_through_reference(mut arg: &mut Arg) {
| |
| help: remove this `mut`
-error: aborting due to previous error; 26 warnings emitted
+error: aborting due to 1 previous error; 26 warnings emitted
diff --git a/tests/ui/lint/unused/must_use-pin.rs b/tests/ui/lint/unused/must_use-pin.rs
new file mode 100644
index 000000000..b08515428
--- /dev/null
+++ b/tests/ui/lint/unused/must_use-pin.rs
@@ -0,0 +1,45 @@
+#![deny(unused_must_use)]
+
+use std::{ops::Deref, pin::Pin};
+
+#[must_use]
+struct MustUse;
+
+#[must_use]
+struct MustUsePtr<'a, T>(&'a T);
+
+impl<'a, T> Deref for MustUsePtr<'a, T> {
+ type Target = T;
+
+ fn deref(&self) -> &Self::Target {
+ self.0
+ }
+}
+
+fn pin_ref() -> Pin<&'static ()> {
+ Pin::new(&())
+}
+
+fn pin_ref_mut() -> Pin<&'static mut ()> {
+ Pin::new(unimplemented!())
+}
+
+fn pin_must_use_ptr() -> Pin<MustUsePtr<'static, ()>> {
+ Pin::new(MustUsePtr(&()))
+}
+
+fn pin_box() -> Pin<Box<()>> {
+ Box::pin(())
+}
+
+fn pin_box_must_use() -> Pin<Box<MustUse>> {
+ Box::pin(MustUse)
+}
+
+fn main() {
+ pin_ref();
+ pin_ref_mut();
+ pin_must_use_ptr(); //~ ERROR unused pinned `MustUsePtr` that must be used
+ pin_box();
+ pin_box_must_use(); //~ ERROR unused pinned boxed `MustUse` that must be used
+}
diff --git a/tests/ui/lint/unused/must_use-pin.stderr b/tests/ui/lint/unused/must_use-pin.stderr
new file mode 100644
index 000000000..c04f8fef4
--- /dev/null
+++ b/tests/ui/lint/unused/must_use-pin.stderr
@@ -0,0 +1,20 @@
+error: unused pinned `MustUsePtr` that must be used
+ --> $DIR/must_use-pin.rs:42:5
+ |
+LL | pin_must_use_ptr();
+ | ^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/must_use-pin.rs:1:9
+ |
+LL | #![deny(unused_must_use)]
+ | ^^^^^^^^^^^^^^^
+
+error: unused pinned boxed `MustUse` that must be used
+ --> $DIR/must_use-pin.rs:44:5
+ |
+LL | pin_box_must_use();
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/unused/unused-macro-rules-malformed-rule.stderr b/tests/ui/lint/unused/unused-macro-rules-malformed-rule.stderr
index 797c86710..76b2a0556 100644
--- a/tests/ui/lint/unused/unused-macro-rules-malformed-rule.stderr
+++ b/tests/ui/lint/unused/unused-macro-rules-malformed-rule.stderr
@@ -4,5 +4,5 @@ error: macro rhs must be delimited
LL | () => 0;
| ^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr b/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr
index 6edf0a2cf..f027e169b 100644
--- a/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr
+++ b/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr
@@ -6,5 +6,5 @@ LL | ($wrong:t_ty) => ()
|
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/unused-macro-with-follow-violation.stderr b/tests/ui/lint/unused/unused-macro-with-follow-violation.stderr
index 5eced4f06..a8a41e081 100644
--- a/tests/ui/lint/unused/unused-macro-with-follow-violation.stderr
+++ b/tests/ui/lint/unused/unused-macro-with-follow-violation.stderr
@@ -6,5 +6,5 @@ LL | ($e:expr +) => ()
|
= note: allowed there are: `=>`, `,` or `;`
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/unused-mut-warning-captured-var.stderr b/tests/ui/lint/unused/unused-mut-warning-captured-var.stderr
index 20aeedcc2..d4fa96c10 100644
--- a/tests/ui/lint/unused/unused-mut-warning-captured-var.stderr
+++ b/tests/ui/lint/unused/unused-mut-warning-captured-var.stderr
@@ -12,5 +12,5 @@ note: the lint level is defined here
LL | #![forbid(unused_mut)]
| ^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/lint/unused/unused-supertrait.stderr b/tests/ui/lint/unused/unused-supertrait.stderr
index cb45add9c..c7ccf30ea 100644
--- a/tests/ui/lint/unused/unused-supertrait.stderr
+++ b/tests/ui/lint/unused/unused-supertrait.stderr
@@ -11,5 +11,5 @@ note: the lint level is defined here
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error