summaryrefslogtreecommitdiffstats
path: root/src/test/ui/lint/unused
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
commit17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch)
tree3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /src/test/ui/lint/unused
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-upstream/1.65.0+dfsg1.tar.xz
rustc-upstream/1.65.0+dfsg1.zip
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/test/ui/lint/unused/issue-54180-unused-ref-field.stderr12
-rw-r--r--src/test/ui/lint/unused/lint-unused-variables.stderr28
-rw-r--r--src/test/ui/lint/unused/unused_attributes-must_use.rs6
-rw-r--r--src/test/ui/lint/unused/unused_attributes-must_use.stderr14
-rw-r--r--src/test/ui/lint/unused_labels.rs1
-rw-r--r--src/test/ui/lint/unused_labels.stderr20
-rw-r--r--src/test/ui/lint/unused_parens_multibyte_recovery.rs11
-rw-r--r--src/test/ui/lint/unused_parens_multibyte_recovery.stderr43
8 files changed, 103 insertions, 32 deletions
diff --git a/src/test/ui/lint/unused/issue-54180-unused-ref-field.stderr b/src/test/ui/lint/unused/issue-54180-unused-ref-field.stderr
index c501aa25f..f2e616899 100644
--- a/src/test/ui/lint/unused/issue-54180-unused-ref-field.stderr
+++ b/src/test/ui/lint/unused/issue-54180-unused-ref-field.stderr
@@ -11,12 +11,6 @@ LL | #![deny(unused)]
| ^^^^^^
= note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
-error: unused variable: `x`
- --> $DIR/issue-54180-unused-ref-field.rs:29:45
- |
-LL | let _: i32 = points.iter().map(|Point { x, y }| y).sum();
- | ^ help: try ignoring the field: `x: _`
-
error: unused variable: `f1`
--> $DIR/issue-54180-unused-ref-field.rs:26:13
|
@@ -29,5 +23,11 @@ error: unused variable: `x`
LL | Point { y, ref mut x } => y,
| ^^^^^^^^^ help: try ignoring the field: `x: _`
+error: unused variable: `x`
+ --> $DIR/issue-54180-unused-ref-field.rs:29:45
+ |
+LL | let _: i32 = points.iter().map(|Point { x, y }| y).sum();
+ | ^ help: try ignoring the field: `x: _`
+
error: aborting due to 4 previous errors
diff --git a/src/test/ui/lint/unused/lint-unused-variables.stderr b/src/test/ui/lint/unused/lint-unused-variables.stderr
index d6e684e83..fd9a5bcbf 100644
--- a/src/test/ui/lint/unused/lint-unused-variables.stderr
+++ b/src/test/ui/lint/unused/lint-unused-variables.stderr
@@ -17,55 +17,55 @@ LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
- --> $DIR/lint-unused-variables.rs:68:9
+ --> $DIR/lint-unused-variables.rs:22:9
|
LL | a: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:74:9
+ --> $DIR/lint-unused-variables.rs:29:9
|
LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:42:9
+ --> $DIR/lint-unused-variables.rs:34:9
|
LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:47:9
+ --> $DIR/lint-unused-variables.rs:42:9
|
LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
-error: unused variable: `a`
- --> $DIR/lint-unused-variables.rs:22:9
- |
-LL | a: i32,
- | ^ help: if this is intentional, prefix it with an underscore: `_a`
-
error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:29:9
+ --> $DIR/lint-unused-variables.rs:47:9
|
LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:34:9
+ --> $DIR/lint-unused-variables.rs:55:9
|
LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:55:9
+ --> $DIR/lint-unused-variables.rs:60:9
|
LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
+error: unused variable: `a`
+ --> $DIR/lint-unused-variables.rs:68:9
+ |
+LL | a: i32,
+ | ^ help: if this is intentional, prefix it with an underscore: `_a`
+
error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:60:9
+ --> $DIR/lint-unused-variables.rs:74:9
|
LL | b: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_b`
diff --git a/src/test/ui/lint/unused/unused_attributes-must_use.rs b/src/test/ui/lint/unused/unused_attributes-must_use.rs
index 1c4abb949..51f868706 100644
--- a/src/test/ui/lint/unused/unused_attributes-must_use.rs
+++ b/src/test/ui/lint/unused/unused_attributes-must_use.rs
@@ -122,4 +122,10 @@ fn main() {
Some(res) => res,
None => 0,
};
+
+ struct PatternField {
+ foo: i32,
+ }
+ let s = PatternField { #[must_use] foo: 123 }; //~ ERROR `#[must_use]` has no effect
+ let PatternField { #[must_use] foo } = s; //~ ERROR `#[must_use]` has no effect
}
diff --git a/src/test/ui/lint/unused/unused_attributes-must_use.stderr b/src/test/ui/lint/unused/unused_attributes-must_use.stderr
index 317d81c59..dd112c23e 100644
--- a/src/test/ui/lint/unused/unused_attributes-must_use.stderr
+++ b/src/test/ui/lint/unused/unused_attributes-must_use.stderr
@@ -105,6 +105,18 @@ error: `#[must_use]` has no effect when applied to an match arm
LL | #[must_use]
| ^^^^^^^^^^^
+error: `#[must_use]` has no effect when applied to a struct field
+ --> $DIR/unused_attributes-must_use.rs:129:28
+ |
+LL | let s = PatternField { #[must_use] foo: 123 };
+ | ^^^^^^^^^^^
+
+error: `#[must_use]` has no effect when applied to a pattern field
+ --> $DIR/unused_attributes-must_use.rs:130:24
+ |
+LL | let PatternField { #[must_use] foo } = s;
+ | ^^^^^^^^^^^
+
error: `#[must_use]` has no effect when applied to an associated const
--> $DIR/unused_attributes-must_use.rs:68:5
|
@@ -171,5 +183,5 @@ error: unused return value of `Use::get_four` that must be used
LL | ().get_four();
| ^^^^^^^^^^^^^^
-error: aborting due to 26 previous errors
+error: aborting due to 28 previous errors
diff --git a/src/test/ui/lint/unused_labels.rs b/src/test/ui/lint/unused_labels.rs
index 8a3568f65..87a5392fd 100644
--- a/src/test/ui/lint/unused_labels.rs
+++ b/src/test/ui/lint/unused_labels.rs
@@ -4,7 +4,6 @@
// check-pass
-#![feature(label_break_value)]
#![warn(unused_labels)]
fn main() {
diff --git a/src/test/ui/lint/unused_labels.stderr b/src/test/ui/lint/unused_labels.stderr
index 85adc9ab3..846da792b 100644
--- a/src/test/ui/lint/unused_labels.stderr
+++ b/src/test/ui/lint/unused_labels.stderr
@@ -1,5 +1,5 @@
warning: label name `'many_used_shadowed` shadows a label name that is already in scope
- --> $DIR/unused_labels.rs:62:9
+ --> $DIR/unused_labels.rs:61:9
|
LL | 'many_used_shadowed: for _ in 0..10 {
| ------------------- first declared here
@@ -8,55 +8,55 @@ LL | 'many_used_shadowed: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^ label `'many_used_shadowed` already in scope
warning: unused label
- --> $DIR/unused_labels.rs:11:5
+ --> $DIR/unused_labels.rs:10:5
|
LL | 'unused_while_label: while 0 == 0 {
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/unused_labels.rs:8:9
+ --> $DIR/unused_labels.rs:7:9
|
LL | #![warn(unused_labels)]
| ^^^^^^^^^^^^^
warning: unused label
- --> $DIR/unused_labels.rs:16:5
+ --> $DIR/unused_labels.rs:15:5
|
LL | 'unused_while_let_label: while let Some(_) = opt {
| ^^^^^^^^^^^^^^^^^^^^^^^
warning: unused label
- --> $DIR/unused_labels.rs:20:5
+ --> $DIR/unused_labels.rs:19:5
|
LL | 'unused_for_label: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^
warning: unused label
- --> $DIR/unused_labels.rs:36:9
+ --> $DIR/unused_labels.rs:35:9
|
LL | 'unused_loop_label_inner_2: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused label
- --> $DIR/unused_labels.rs:42:5
+ --> $DIR/unused_labels.rs:41:5
|
LL | 'unused_loop_label_outer_3: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused label
- --> $DIR/unused_labels.rs:60:5
+ --> $DIR/unused_labels.rs:59:5
|
LL | 'many_used_shadowed: for _ in 0..10 {
| ^^^^^^^^^^^^^^^^^^^
warning: unused label
- --> $DIR/unused_labels.rs:72:5
+ --> $DIR/unused_labels.rs:71:5
|
LL | 'unused_loop_label: loop {
| ^^^^^^^^^^^^^^^^^^
warning: unused label
- --> $DIR/unused_labels.rs:78:5
+ --> $DIR/unused_labels.rs:77:5
|
LL | 'unused_block_label: {
| ^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/lint/unused_parens_multibyte_recovery.rs b/src/test/ui/lint/unused_parens_multibyte_recovery.rs
new file mode 100644
index 000000000..8fcfae22a
--- /dev/null
+++ b/src/test/ui/lint/unused_parens_multibyte_recovery.rs
@@ -0,0 +1,11 @@
+// ignore-tidy-trailing-newlines
+//
+// error-pattern: this file contains an unclosed delimiter
+// error-pattern: this file contains an unclosed delimiter
+// error-pattern: this file contains an unclosed delimiter
+// error-pattern: format argument must be a string literal
+//
+// Verify that unused parens lint does not try to create a span
+// which points in the middle of a multibyte character.
+
+fn f(){(print!(á \ No newline at end of file
diff --git a/src/test/ui/lint/unused_parens_multibyte_recovery.stderr b/src/test/ui/lint/unused_parens_multibyte_recovery.stderr
new file mode 100644
index 000000000..a0302b17e
--- /dev/null
+++ b/src/test/ui/lint/unused_parens_multibyte_recovery.stderr
@@ -0,0 +1,43 @@
+error: this file contains an unclosed delimiter
+ --> $DIR/unused_parens_multibyte_recovery.rs:11:17
+ |
+LL | fn f(){(print!(á
+ | -- - ^
+ | || |
+ | || unclosed delimiter
+ | |unclosed delimiter
+ | unclosed delimiter
+
+error: this file contains an unclosed delimiter
+ --> $DIR/unused_parens_multibyte_recovery.rs:11:17
+ |
+LL | fn f(){(print!(á
+ | -- - ^
+ | || |
+ | || unclosed delimiter
+ | |unclosed delimiter
+ | unclosed delimiter
+
+error: this file contains an unclosed delimiter
+ --> $DIR/unused_parens_multibyte_recovery.rs:11:17
+ |
+LL | fn f(){(print!(á
+ | -- - ^
+ | || |
+ | || unclosed delimiter
+ | |unclosed delimiter
+ | unclosed delimiter
+
+error: format argument must be a string literal
+ --> $DIR/unused_parens_multibyte_recovery.rs:11:16
+ |
+LL | fn f(){(print!(á
+ | ^
+ |
+help: you might be missing a string literal to format with
+ |
+LL | fn f(){(print!("{}", á
+ | +++++
+
+error: aborting due to 4 previous errors
+