summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/lint')
-rw-r--r--tests/ui/lint/auxiliary/missing_docs.rs1
-rw-r--r--tests/ui/lint/dead-code/closure-bang.rs4
-rw-r--r--tests/ui/lint/dead-code/closure-bang.stderr17
-rw-r--r--tests/ui/lint/dead-code/offset-of-correct-param-env.rs42
-rw-r--r--tests/ui/lint/dead-code/offset-of.rs44
-rw-r--r--tests/ui/lint/dead-code/offset-of.stderr50
-rw-r--r--tests/ui/lint/dropping_copy_types.rs98
-rw-r--r--tests/ui/lint/dropping_copy_types.stderr108
-rw-r--r--tests/ui/lint/dropping_references.rs118
-rw-r--r--tests/ui/lint/dropping_references.stderr127
-rw-r--r--tests/ui/lint/forgetting_copy_types.rs56
-rw-r--r--tests/ui/lint/forgetting_copy_types.stderr88
-rw-r--r--tests/ui/lint/forgetting_references.rs39
-rw-r--r--tests/ui/lint/forgetting_references.stderr97
-rw-r--r--tests/ui/lint/internal/trivial-diagnostics.rs8
-rw-r--r--tests/ui/lint/internal/trivial-diagnostics.stderr15
-rw-r--r--tests/ui/lint/invalid_value-polymorphic.rs2
-rw-r--r--tests/ui/lint/issue-110573.rs12
-rw-r--r--tests/ui/lint/issue-111359.rs27
-rw-r--r--tests/ui/lint/issue-111359.stderr26
-rw-r--r--tests/ui/lint/issue-112489.rs17
-rw-r--r--tests/ui/lint/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs16
-rw-r--r--tests/ui/lint/lint-attr-everywhere-early.rs8
-rw-r--r--tests/ui/lint/lint-attr-everywhere-early.stderr48
-rw-r--r--tests/ui/lint/lint-attr-everywhere-late.rs5
-rw-r--r--tests/ui/lint/lint-attr-everywhere-late.stderr56
-rw-r--r--tests/ui/lint/lint-match-arms-2.rs24
-rw-r--r--tests/ui/lint/lint-match-arms-2.stderr29
-rw-r--r--tests/ui/lint/lint-missing-doc.rs7
-rw-r--r--tests/ui/lint/lint-missing-doc.stderr58
-rw-r--r--tests/ui/lint/lint-non-uppercase-trait-assoc-const.rs15
-rw-r--r--tests/ui/lint/lint-non-uppercase-trait-assoc-const.stderr14
-rw-r--r--tests/ui/lint/lint-uppercase-variables.stderr12
-rw-r--r--tests/ui/lint/must_not_suspend/boxed.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr4
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.stderr19
-rw-r--r--tests/ui/lint/must_not_suspend/mutex.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr4
-rw-r--r--tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr4
-rw-r--r--tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr4
-rw-r--r--tests/ui/lint/must_not_suspend/trait.stderr37
-rw-r--r--tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/unit.stderr26
-rw-r--r--tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr2
-rw-r--r--tests/ui/lint/must_not_suspend/warn.stderr26
-rw-r--r--tests/ui/lint/noop-method-call.rs8
-rw-r--r--tests/ui/lint/noop-method-call.stderr26
-rw-r--r--tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr24
-rw-r--r--tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr12
-rw-r--r--tests/ui/lint/rfc-2383-lint-reason/root-attribute-confusion.rs7
-rw-r--r--tests/ui/lint/suspicious-double-ref-op.rs30
-rw-r--r--tests/ui/lint/suspicious-double-ref-op.stderr35
-rw-r--r--tests/ui/lint/unaligned_references.stderr30
-rw-r--r--tests/ui/lint/unaligned_references_external_macro.stderr3
-rw-r--r--tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed19
-rw-r--r--tests/ui/lint/unused/issue-54538-unused-parens-lint.rs19
-rw-r--r--tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr62
-rw-r--r--tests/ui/lint/unused/lint-unused-mut-variables.rs8
-rw-r--r--tests/ui/lint/unused/lint-unused-mut-variables.stderr10
-rw-r--r--tests/ui/lint/unused/lint-unused-variables.stderr12
70 files changed, 1474 insertions, 271 deletions
diff --git a/tests/ui/lint/auxiliary/missing_docs.rs b/tests/ui/lint/auxiliary/missing_docs.rs
new file mode 100644
index 000000000..4a835673a
--- /dev/null
+++ b/tests/ui/lint/auxiliary/missing_docs.rs
@@ -0,0 +1 @@
+pub struct Foo;
diff --git a/tests/ui/lint/dead-code/closure-bang.rs b/tests/ui/lint/dead-code/closure-bang.rs
index 8e8636b11..bca131a15 100644
--- a/tests/ui/lint/dead-code/closure-bang.rs
+++ b/tests/ui/lint/dead-code/closure-bang.rs
@@ -1,9 +1,7 @@
-// ignore-test FIXME(#20574)
-
#![deny(unreachable_code)]
fn main() {
- let x = || panic!();
+ let x = || -> ! { panic!() };
x();
println!("Foo bar"); //~ ERROR: unreachable statement
}
diff --git a/tests/ui/lint/dead-code/closure-bang.stderr b/tests/ui/lint/dead-code/closure-bang.stderr
new file mode 100644
index 000000000..119ce11e3
--- /dev/null
+++ b/tests/ui/lint/dead-code/closure-bang.stderr
@@ -0,0 +1,17 @@
+error: unreachable statement
+ --> $DIR/closure-bang.rs:6:5
+ |
+LL | x();
+ | --- any code following this expression is unreachable
+LL | println!("Foo bar");
+ | ^^^^^^^^^^^^^^^^^^^ unreachable statement
+ |
+note: the lint level is defined here
+ --> $DIR/closure-bang.rs:1:9
+ |
+LL | #![deny(unreachable_code)]
+ | ^^^^^^^^^^^^^^^^
+ = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lint/dead-code/offset-of-correct-param-env.rs b/tests/ui/lint/dead-code/offset-of-correct-param-env.rs
new file mode 100644
index 000000000..2c6fcef25
--- /dev/null
+++ b/tests/ui/lint/dead-code/offset-of-correct-param-env.rs
@@ -0,0 +1,42 @@
+// check-pass
+
+#![feature(offset_of)]
+#![deny(dead_code)]
+
+// This struct contains a projection that can only be normalized after getting the field type.
+struct A<T: Project> {
+ a: <T as Project>::EquateParamTo,
+}
+
+// This is the inner struct that we want to get.
+struct MyFieldIsNotDead {
+ not_dead: u8,
+}
+
+// These are some helpers.
+// Inside the param env of `test`, we want to make it so that it considers T=MyFieldIsNotDead.
+struct GenericIsEqual<T>(T);
+trait Project {
+ type EquateParamTo;
+}
+impl<T> Project for GenericIsEqual<T> {
+ type EquateParamTo = T;
+}
+
+fn test<T>() -> usize
+where
+ GenericIsEqual<T>: Project<EquateParamTo = MyFieldIsNotDead>,
+{
+ // The first field of the A that we construct here is
+ // `<GenericIsEqual<T>> as Project>::EquateParamTo`.
+ // Typeck normalizes this and figures that the not_dead field is totally fine and accessible.
+ // But importantly, the normalization ends up with T, which, as we've declared in our param
+ // env is MyFieldDead. When we're in the param env of the `a` field, the where bound above
+ // is not in scope, so we don't know what T is - it's generic.
+ // If we use the wrong param env, the lint will ICE.
+ std::mem::offset_of!(A<GenericIsEqual<T>>, a.not_dead)
+}
+
+fn main() {
+ test::<MyFieldIsNotDead>();
+}
diff --git a/tests/ui/lint/dead-code/offset-of.rs b/tests/ui/lint/dead-code/offset-of.rs
new file mode 100644
index 000000000..da91de386
--- /dev/null
+++ b/tests/ui/lint/dead-code/offset-of.rs
@@ -0,0 +1,44 @@
+#![feature(offset_of)]
+#![deny(dead_code)]
+
+use std::mem::offset_of;
+
+struct Alpha {
+ a: (),
+ b: (), //~ ERROR field `b` is never read
+ c: Beta,
+}
+
+struct Beta {
+ a: (), //~ ERROR field `a` is never read
+ b: (),
+}
+
+struct Gamma {
+ a: (), //~ ERROR field `a` is never read
+ b: (),
+}
+
+struct Delta {
+ a: (),
+ b: (), //~ ERROR field `b` is never read
+}
+
+trait Trait {
+ type Assoc;
+}
+impl Trait for () {
+ type Assoc = Delta;
+}
+
+struct Project<T: Trait> {
+ a: u8, //~ ERROR field `a` is never read
+ b: <T as Trait>::Assoc,
+}
+
+fn main() {
+ offset_of!(Alpha, a);
+ offset_of!(Alpha, c.b);
+ offset_of!((Gamma,), 0.b);
+ offset_of!(Project::<()>, b.a);
+}
diff --git a/tests/ui/lint/dead-code/offset-of.stderr b/tests/ui/lint/dead-code/offset-of.stderr
new file mode 100644
index 000000000..ed2916461
--- /dev/null
+++ b/tests/ui/lint/dead-code/offset-of.stderr
@@ -0,0 +1,50 @@
+error: field `b` is never read
+ --> $DIR/offset-of.rs:8:5
+ |
+LL | struct Alpha {
+ | ----- field in this struct
+LL | a: (),
+LL | b: (),
+ | ^
+ |
+note: the lint level is defined here
+ --> $DIR/offset-of.rs:2:9
+ |
+LL | #![deny(dead_code)]
+ | ^^^^^^^^^
+
+error: field `a` is never read
+ --> $DIR/offset-of.rs:13:5
+ |
+LL | struct Beta {
+ | ---- field in this struct
+LL | a: (),
+ | ^
+
+error: field `a` is never read
+ --> $DIR/offset-of.rs:18:5
+ |
+LL | struct Gamma {
+ | ----- field in this struct
+LL | a: (),
+ | ^
+
+error: field `b` is never read
+ --> $DIR/offset-of.rs:24:5
+ |
+LL | struct Delta {
+ | ----- field in this struct
+LL | a: (),
+LL | b: (),
+ | ^
+
+error: field `a` is never read
+ --> $DIR/offset-of.rs:35:5
+ |
+LL | struct Project<T: Trait> {
+ | ------- field in this struct
+LL | a: u8,
+ | ^
+
+error: aborting due to 5 previous errors
+
diff --git a/tests/ui/lint/dropping_copy_types.rs b/tests/ui/lint/dropping_copy_types.rs
new file mode 100644
index 000000000..2412222d6
--- /dev/null
+++ b/tests/ui/lint/dropping_copy_types.rs
@@ -0,0 +1,98 @@
+// check-pass
+
+#![warn(dropping_copy_types)]
+
+use std::mem::drop;
+use std::vec::Vec;
+
+#[derive(Copy, Clone)]
+struct SomeStruct;
+
+struct AnotherStruct {
+ x: u8,
+ y: u8,
+ z: Vec<u8>,
+}
+
+impl Clone for AnotherStruct {
+ fn clone(&self) -> AnotherStruct {
+ AnotherStruct {
+ x: self.x,
+ y: self.y,
+ z: self.z.clone(),
+ }
+ }
+}
+
+fn main() {
+ let s1 = SomeStruct {};
+ let s2 = s1;
+ let s3 = &s1;
+ let mut s4 = s1;
+ let ref s5 = s1;
+
+ drop(s1); //~ WARN calls to `std::mem::drop`
+ drop(s2); //~ WARN calls to `std::mem::drop`
+ drop(s3); //~ WARN calls to `std::mem::drop`
+ drop(s4); //~ WARN calls to `std::mem::drop`
+ drop(s5); //~ WARN calls to `std::mem::drop`
+
+ let a1 = AnotherStruct {
+ x: 255,
+ y: 0,
+ z: vec![1, 2, 3],
+ };
+ let a2 = &a1;
+ let mut a3 = a1.clone();
+ let ref a4 = a1;
+ let a5 = a1.clone();
+
+ drop(a2); //~ WARN calls to `std::mem::drop`
+ drop(a3);
+ drop(a4); //~ WARN calls to `std::mem::drop`
+ drop(a5);
+}
+
+#[allow(unused)]
+#[allow(clippy::unit_cmp)]
+fn issue9482(x: u8) {
+ fn println_and<T>(t: T) -> T {
+ println!("foo");
+ t
+ }
+
+ match x {
+ // Don't lint (copy type), we only care about side-effects
+ 0 => drop(println_and(12)),
+ // Don't lint (no copy type), we only care about side-effects
+ 1 => drop(println_and(String::new())),
+ 2 => {
+ // Lint, even if we only care about the side-effect, it's already in a block
+ drop(println_and(13)); //~ WARN calls to `std::mem::drop`
+ },
+ // Lint, idiomatic use is only in body of `Arm`
+ 3 if drop(println_and(14)) == () => (), //~ WARN calls to `std::mem::drop`
+ // Lint, not a fn/method call
+ 4 => drop(2),//~ WARN calls to `std::mem::drop`
+ _ => (),
+ }
+}
+
+fn issue112653() {
+ fn foo() -> Result<u8, ()> {
+ println!("doing foo");
+ Ok(0) // result is not always useful, the side-effect matters
+ }
+ fn bar() {
+ println!("doing bar");
+ }
+
+ fn stuff() -> Result<(), ()> {
+ match 42 {
+ 0 => drop(foo()?), // drop is needed because we only care about side-effects
+ 1 => bar(),
+ _ => (), // doing nothing (no side-effects needed here)
+ }
+ Ok(())
+ }
+}
diff --git a/tests/ui/lint/dropping_copy_types.stderr b/tests/ui/lint/dropping_copy_types.stderr
new file mode 100644
index 000000000..b6291aa5e
--- /dev/null
+++ b/tests/ui/lint/dropping_copy_types.stderr
@@ -0,0 +1,108 @@
+warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing
+ --> $DIR/dropping_copy_types.rs:34:5
+ |
+LL | drop(s1);
+ | ^^^^^--^
+ | |
+ | argument has type `SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+note: the lint level is defined here
+ --> $DIR/dropping_copy_types.rs:3:9
+ |
+LL | #![warn(dropping_copy_types)]
+ | ^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing
+ --> $DIR/dropping_copy_types.rs:35:5
+ |
+LL | drop(s2);
+ | ^^^^^--^
+ | |
+ | argument has type `SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_copy_types.rs:36:5
+ |
+LL | drop(s3);
+ | ^^^^^--^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+ = note: `#[warn(dropping_references)]` on by default
+
+warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing
+ --> $DIR/dropping_copy_types.rs:37:5
+ |
+LL | drop(s4);
+ | ^^^^^--^
+ | |
+ | argument has type `SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_copy_types.rs:38:5
+ |
+LL | drop(s5);
+ | ^^^^^--^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_copy_types.rs:50:5
+ |
+LL | drop(a2);
+ | ^^^^^--^
+ | |
+ | argument has type `&AnotherStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_copy_types.rs:52:5
+ |
+LL | drop(a4);
+ | ^^^^^--^
+ | |
+ | argument has type `&AnotherStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing
+ --> $DIR/dropping_copy_types.rs:71:13
+ |
+LL | drop(println_and(13));
+ | ^^^^^---------------^
+ | |
+ | argument has type `i32`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing
+ --> $DIR/dropping_copy_types.rs:74:14
+ |
+LL | 3 if drop(println_and(14)) == () => (),
+ | ^^^^^---------------^
+ | |
+ | argument has type `i32`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing
+ --> $DIR/dropping_copy_types.rs:76:14
+ |
+LL | 4 => drop(2),
+ | ^^^^^-^
+ | |
+ | argument has type `i32`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: 10 warnings emitted
+
diff --git a/tests/ui/lint/dropping_references.rs b/tests/ui/lint/dropping_references.rs
new file mode 100644
index 000000000..bb02cb75a
--- /dev/null
+++ b/tests/ui/lint/dropping_references.rs
@@ -0,0 +1,118 @@
+// check-pass
+
+#![warn(dropping_references)]
+
+struct SomeStruct;
+
+fn main() {
+ drop(&SomeStruct); //~ WARN calls to `std::mem::drop`
+
+ let mut owned1 = SomeStruct;
+ drop(&owned1); //~ WARN calls to `std::mem::drop`
+ drop(&&owned1); //~ WARN calls to `std::mem::drop`
+ drop(&mut owned1); //~ WARN calls to `std::mem::drop`
+ drop(owned1);
+
+ let reference1 = &SomeStruct;
+ drop(reference1); //~ WARN calls to `std::mem::drop`
+
+ let reference2 = &mut SomeStruct;
+ drop(reference2); //~ WARN calls to `std::mem::drop`
+
+ let ref reference3 = SomeStruct;
+ drop(reference3); //~ WARN calls to `std::mem::drop`
+}
+
+#[allow(dead_code)]
+fn test_generic_fn_drop<T>(val: T) {
+ drop(&val); //~ WARN calls to `std::mem::drop`
+ drop(val);
+}
+
+#[allow(dead_code)]
+fn test_similarly_named_function() {
+ fn drop<T>(_val: T) {}
+ drop(&SomeStruct); //OK; call to unrelated function which happens to have the same name
+ std::mem::drop(&SomeStruct); //~ WARN calls to `std::mem::drop`
+}
+
+#[derive(Copy, Clone)]
+pub struct Error;
+fn produce_half_owl_error() -> Result<(), Error> {
+ Ok(())
+}
+
+fn produce_half_owl_ok() -> Result<bool, ()> {
+ Ok(true)
+}
+
+#[allow(dead_code)]
+fn test_owl_result() -> Result<(), ()> {
+ produce_half_owl_error().map_err(|_| ())?;
+ produce_half_owl_ok().map(|_| ())?;
+ // the following should not be linted,
+ // we should not force users to use toilet closures
+ // to produce owl results when drop is more convenient
+ produce_half_owl_error().map_err(drop)?;
+ produce_half_owl_ok().map_err(drop)?;
+ Ok(())
+}
+
+#[allow(dead_code)]
+fn test_owl_result_2() -> Result<u8, ()> {
+ produce_half_owl_error().map_err(|_| ())?;
+ produce_half_owl_ok().map(|_| ())?;
+ // the following should not be linted,
+ // we should not force users to use toilet closures
+ // to produce owl results when drop is more convenient
+ produce_half_owl_error().map_err(drop)?;
+ produce_half_owl_ok().map(drop)?;
+ Ok(1)
+}
+
+#[allow(unused)]
+#[allow(clippy::unit_cmp)]
+fn issue10122(x: u8) {
+ // This is a function which returns a reference and has a side-effect, which means
+ // that calling drop() on the function is considered an idiomatic way of achieving
+ // the side-effect in a match arm.
+ fn println_and<T>(t: &T) -> &T {
+ println!("foo");
+ t
+ }
+
+ match x {
+ // Don't lint (copy type), we only care about side-effects
+ 0 => drop(println_and(&12)),
+ // Don't lint (no copy type), we only care about side-effects
+ 1 => drop(println_and(&String::new())),
+ 2 => {
+ // Lint, even if we only care about the side-effect, it's already in a block
+ drop(println_and(&13)); //~ WARN calls to `std::mem::drop`
+ },
+ // Lint, idiomatic use is only in body of `Arm`
+ 3 if drop(println_and(&14)) == () => (), //~ WARN calls to `std::mem::drop`
+ // Lint, not a fn/method call
+ 4 => drop(&2), //~ WARN calls to `std::mem::drop`
+ _ => (),
+ }
+}
+
+fn issue112653() {
+ fn foo() -> Result<&'static u8, ()> {
+ println!("doing foo");
+ Ok(&0) // result is not always useful, the side-effect matters
+ }
+ fn bar() {
+ println!("doing bar");
+ }
+
+ fn stuff() -> Result<(), ()> {
+ match 42 {
+ 0 => drop(foo()?), // drop is needed because we only care about side-effects
+ 1 => bar(),
+ _ => (), // doing nothing (no side-effects needed here)
+ }
+ Ok(())
+ }
+}
diff --git a/tests/ui/lint/dropping_references.stderr b/tests/ui/lint/dropping_references.stderr
new file mode 100644
index 000000000..7e25a4621
--- /dev/null
+++ b/tests/ui/lint/dropping_references.stderr
@@ -0,0 +1,127 @@
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:8:5
+ |
+LL | drop(&SomeStruct);
+ | ^^^^^-----------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+note: the lint level is defined here
+ --> $DIR/dropping_references.rs:3:9
+ |
+LL | #![warn(dropping_references)]
+ | ^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:11:5
+ |
+LL | drop(&owned1);
+ | ^^^^^-------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:12:5
+ |
+LL | drop(&&owned1);
+ | ^^^^^--------^
+ | |
+ | argument has type `&&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:13:5
+ |
+LL | drop(&mut owned1);
+ | ^^^^^-----------^
+ | |
+ | argument has type `&mut SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:17:5
+ |
+LL | drop(reference1);
+ | ^^^^^----------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:20:5
+ |
+LL | drop(reference2);
+ | ^^^^^----------^
+ | |
+ | argument has type `&mut SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:23:5
+ |
+LL | drop(reference3);
+ | ^^^^^----------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:28:5
+ |
+LL | drop(&val);
+ | ^^^^^----^
+ | |
+ | argument has type `&T`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:36:5
+ |
+LL | std::mem::drop(&SomeStruct);
+ | ^^^^^^^^^^^^^^^-----------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:91:13
+ |
+LL | drop(println_and(&13));
+ | ^^^^^----------------^
+ | |
+ | argument has type `&i32`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:94:14
+ |
+LL | 3 if drop(println_and(&14)) == () => (),
+ | ^^^^^----------------^
+ | |
+ | argument has type `&i32`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
+ --> $DIR/dropping_references.rs:96:14
+ |
+LL | 4 => drop(&2),
+ | ^^^^^--^
+ | |
+ | argument has type `&i32`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: 12 warnings emitted
+
diff --git a/tests/ui/lint/forgetting_copy_types.rs b/tests/ui/lint/forgetting_copy_types.rs
new file mode 100644
index 000000000..224c7bcd5
--- /dev/null
+++ b/tests/ui/lint/forgetting_copy_types.rs
@@ -0,0 +1,56 @@
+// check-pass
+
+#![warn(forgetting_copy_types)]
+
+use std::mem::forget;
+use std::vec::Vec;
+
+#[derive(Copy, Clone)]
+struct SomeStruct;
+
+struct AnotherStruct {
+ x: u8,
+ y: u8,
+ z: Vec<u8>,
+}
+
+impl Clone for AnotherStruct {
+ fn clone(&self) -> AnotherStruct {
+ AnotherStruct {
+ x: self.x,
+ y: self.y,
+ z: self.z.clone(),
+ }
+ }
+}
+
+fn main() {
+ let s1 = SomeStruct {};
+ let s2 = s1;
+ let s3 = &s1;
+ let mut s4 = s1;
+ let ref s5 = s1;
+
+ forget(s1); //~ WARN calls to `std::mem::forget`
+ forget(s2); //~ WARN calls to `std::mem::forget`
+ forget(s3); //~ WARN calls to `std::mem::forget`
+ forget(s4); //~ WARN calls to `std::mem::forget`
+ forget(s5); //~ WARN calls to `std::mem::forget`
+
+ let a1 = AnotherStruct {
+ x: 255,
+ y: 0,
+ z: vec![1, 2, 3],
+ };
+ let a2 = &a1;
+ let mut a3 = a1.clone();
+ let ref a4 = a1;
+ let a5 = a1.clone();
+
+ forget(a2); //~ WARN calls to `std::mem::forget`
+ let a3 = &a1;
+ forget(a3); //~ WARN calls to `std::mem::forget`
+ forget(a4); //~ WARN calls to `std::mem::forget`
+ let a5 = a1.clone();
+ forget(a5);
+}
diff --git a/tests/ui/lint/forgetting_copy_types.stderr b/tests/ui/lint/forgetting_copy_types.stderr
new file mode 100644
index 000000000..36d1ef5c5
--- /dev/null
+++ b/tests/ui/lint/forgetting_copy_types.stderr
@@ -0,0 +1,88 @@
+warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing
+ --> $DIR/forgetting_copy_types.rs:34:5
+ |
+LL | forget(s1);
+ | ^^^^^^^--^
+ | |
+ | argument has type `SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+note: the lint level is defined here
+ --> $DIR/forgetting_copy_types.rs:3:9
+ |
+LL | #![warn(forgetting_copy_types)]
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing
+ --> $DIR/forgetting_copy_types.rs:35:5
+ |
+LL | forget(s2);
+ | ^^^^^^^--^
+ | |
+ | argument has type `SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_copy_types.rs:36:5
+ |
+LL | forget(s3);
+ | ^^^^^^^--^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+ = note: `#[warn(forgetting_references)]` on by default
+
+warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing
+ --> $DIR/forgetting_copy_types.rs:37:5
+ |
+LL | forget(s4);
+ | ^^^^^^^--^
+ | |
+ | argument has type `SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_copy_types.rs:38:5
+ |
+LL | forget(s5);
+ | ^^^^^^^--^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_copy_types.rs:50:5
+ |
+LL | forget(a2);
+ | ^^^^^^^--^
+ | |
+ | argument has type `&AnotherStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_copy_types.rs:52:5
+ |
+LL | forget(a3);
+ | ^^^^^^^--^
+ | |
+ | argument has type `&AnotherStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_copy_types.rs:53:5
+ |
+LL | forget(a4);
+ | ^^^^^^^--^
+ | |
+ | argument has type `&AnotherStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: 8 warnings emitted
+
diff --git a/tests/ui/lint/forgetting_references.rs b/tests/ui/lint/forgetting_references.rs
new file mode 100644
index 000000000..bd51e9800
--- /dev/null
+++ b/tests/ui/lint/forgetting_references.rs
@@ -0,0 +1,39 @@
+// check-pass
+
+#![warn(forgetting_references)]
+
+use std::mem::forget;
+
+struct SomeStruct;
+
+fn main() {
+ forget(&SomeStruct); //~ WARN calls to `std::mem::forget`
+
+ let mut owned = SomeStruct;
+ forget(&owned); //~ WARN calls to `std::mem::forget`
+ forget(&&owned); //~ WARN calls to `std::mem::forget`
+ forget(&mut owned); //~ WARN calls to `std::mem::forget`
+ forget(owned);
+
+ let reference1 = &SomeStruct;
+ forget(&*reference1); //~ WARN calls to `std::mem::forget`
+
+ let reference2 = &mut SomeStruct;
+ forget(reference2); //~ WARN calls to `std::mem::forget`
+
+ let ref reference3 = SomeStruct;
+ forget(reference3); //~ WARN calls to `std::mem::forget`
+}
+
+#[allow(dead_code)]
+fn test_generic_fn_forget<T>(val: T) {
+ forget(&val); //~ WARN calls to `std::mem::forget`
+ forget(val);
+}
+
+#[allow(dead_code)]
+fn test_similarly_named_function() {
+ fn forget<T>(_val: T) {}
+ forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name
+ std::mem::forget(&SomeStruct); //~ WARN calls to `std::mem::forget`
+}
diff --git a/tests/ui/lint/forgetting_references.stderr b/tests/ui/lint/forgetting_references.stderr
new file mode 100644
index 000000000..5624b6907
--- /dev/null
+++ b/tests/ui/lint/forgetting_references.stderr
@@ -0,0 +1,97 @@
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:10:5
+ |
+LL | forget(&SomeStruct);
+ | ^^^^^^^-----------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+note: the lint level is defined here
+ --> $DIR/forgetting_references.rs:3:9
+ |
+LL | #![warn(forgetting_references)]
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:13:5
+ |
+LL | forget(&owned);
+ | ^^^^^^^------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:14:5
+ |
+LL | forget(&&owned);
+ | ^^^^^^^-------^
+ | |
+ | argument has type `&&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:15:5
+ |
+LL | forget(&mut owned);
+ | ^^^^^^^----------^
+ | |
+ | argument has type `&mut SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:19:5
+ |
+LL | forget(&*reference1);
+ | ^^^^^^^------------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:22:5
+ |
+LL | forget(reference2);
+ | ^^^^^^^----------^
+ | |
+ | argument has type `&mut SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:25:5
+ |
+LL | forget(reference3);
+ | ^^^^^^^----------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:30:5
+ |
+LL | forget(&val);
+ | ^^^^^^^----^
+ | |
+ | argument has type `&T`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
+ --> $DIR/forgetting_references.rs:38:5
+ |
+LL | std::mem::forget(&SomeStruct);
+ | ^^^^^^^^^^^^^^^^^-----------^
+ | |
+ | argument has type `&SomeStruct`
+ |
+ = note: use `let _ = ...` to ignore the expression or result
+
+warning: 9 warnings emitted
+
diff --git a/tests/ui/lint/internal/trivial-diagnostics.rs b/tests/ui/lint/internal/trivial-diagnostics.rs
new file mode 100644
index 000000000..e536e1164
--- /dev/null
+++ b/tests/ui/lint/internal/trivial-diagnostics.rs
@@ -0,0 +1,8 @@
+// compile-flags: -Zunstable-options
+
+pub fn issue_111280() {
+ struct_span_err(msg).emit(); //~ ERROR cannot find value `msg`
+ //~^ ERROR cannot find function `struct_span_err`
+}
+
+fn main() {}
diff --git a/tests/ui/lint/internal/trivial-diagnostics.stderr b/tests/ui/lint/internal/trivial-diagnostics.stderr
new file mode 100644
index 000000000..d47a7dae0
--- /dev/null
+++ b/tests/ui/lint/internal/trivial-diagnostics.stderr
@@ -0,0 +1,15 @@
+error[E0425]: cannot find value `msg` in this scope
+ --> $DIR/trivial-diagnostics.rs:4:21
+ |
+LL | struct_span_err(msg).emit();
+ | ^^^ not found in this scope
+
+error[E0425]: cannot find function `struct_span_err` in this scope
+ --> $DIR/trivial-diagnostics.rs:4:5
+ |
+LL | struct_span_err(msg).emit();
+ | ^^^^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/lint/invalid_value-polymorphic.rs b/tests/ui/lint/invalid_value-polymorphic.rs
index 055173e98..98f82b792 100644
--- a/tests/ui/lint/invalid_value-polymorphic.rs
+++ b/tests/ui/lint/invalid_value-polymorphic.rs
@@ -1,4 +1,4 @@
-// compile-flags: --crate-type=lib -Zmir-enable-passes=+InstCombine
+// compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify
// build-pass
#![feature(core_intrinsics)]
diff --git a/tests/ui/lint/issue-110573.rs b/tests/ui/lint/issue-110573.rs
new file mode 100644
index 000000000..d9f0868b7
--- /dev/null
+++ b/tests/ui/lint/issue-110573.rs
@@ -0,0 +1,12 @@
+// check-pass
+
+#![deny(warnings)]
+
+pub struct Struct;
+
+impl Struct {
+ #[allow(non_upper_case_globals)]
+ pub const Const: () = ();
+}
+
+fn main() {}
diff --git a/tests/ui/lint/issue-111359.rs b/tests/ui/lint/issue-111359.rs
new file mode 100644
index 000000000..e390c3fc5
--- /dev/null
+++ b/tests/ui/lint/issue-111359.rs
@@ -0,0 +1,27 @@
+#[deny(missing_debug_implementations)]
+#[deny(missing_copy_implementations)]
+
+mod priv_mod {
+ use std::convert::TryFrom;
+
+ pub struct BarPub;
+ //~^ ERROR type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
+ //~| ERROR type could implement `Copy`; consider adding `impl Copy`
+ struct BarPriv;
+
+ impl<'a> TryFrom<BarPriv> for u8 {
+ type Error = ();
+ fn try_from(o: BarPriv) -> Result<Self, ()> {
+ unimplemented!()
+ }
+ }
+
+ impl<'a> TryFrom<BarPub> for u8 {
+ type Error = ();
+ fn try_from(o: BarPub) -> Result<Self, ()> {
+ unimplemented!()
+ }
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/lint/issue-111359.stderr b/tests/ui/lint/issue-111359.stderr
new file mode 100644
index 000000000..2296d8413
--- /dev/null
+++ b/tests/ui/lint/issue-111359.stderr
@@ -0,0 +1,26 @@
+error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
+ --> $DIR/issue-111359.rs:7:5
+ |
+LL | pub struct BarPub;
+ | ^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/issue-111359.rs:1:8
+ |
+LL | #[deny(missing_debug_implementations)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: type could implement `Copy`; consider adding `impl Copy`
+ --> $DIR/issue-111359.rs:7:5
+ |
+LL | pub struct BarPub;
+ | ^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/issue-111359.rs:2:8
+ |
+LL | #[deny(missing_copy_implementations)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/issue-112489.rs b/tests/ui/lint/issue-112489.rs
new file mode 100644
index 000000000..559edf0e4
--- /dev/null
+++ b/tests/ui/lint/issue-112489.rs
@@ -0,0 +1,17 @@
+// check-pass
+use std::borrow::Borrow;
+
+struct S;
+
+trait T: Sized {
+ fn foo(self) {}
+}
+
+impl T for S {}
+impl T for &S {}
+
+fn main() {
+ let s = S;
+ s.borrow().foo();
+ s.foo();
+}
diff --git a/tests/ui/lint/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs b/tests/ui/lint/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs
new file mode 100644
index 000000000..f30d7e2ed
--- /dev/null
+++ b/tests/ui/lint/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs
@@ -0,0 +1,16 @@
+// run-pass
+#![allow(unused_variables)]
+#![deny(non_shorthand_field_patterns)]
+
+pub struct Value<A> { pub value: A }
+
+#[macro_export]
+macro_rules! pat {
+ ($a:pat) => {
+ Value { value: $a }
+ };
+}
+
+fn main() {
+ let pat!(value) = Value { value: () };
+}
diff --git a/tests/ui/lint/lint-attr-everywhere-early.rs b/tests/ui/lint/lint-attr-everywhere-early.rs
index fd0c4b43e..0c820ef9a 100644
--- a/tests/ui/lint/lint-attr-everywhere-early.rs
+++ b/tests/ui/lint/lint-attr-everywhere-early.rs
@@ -134,6 +134,14 @@ fn expressions() {
}
}
+ match f {
+ #[deny(ellipsis_inclusive_range_patterns)]
+ Match{f1: 0...100} => {}
+ //~^ ERROR range patterns are deprecated
+ //~| WARNING this is accepted in the current edition
+ _ => {}
+ }
+
// Statement Block
{
#![deny(unsafe_code)]
diff --git a/tests/ui/lint/lint-attr-everywhere-early.stderr b/tests/ui/lint/lint-attr-everywhere-early.stderr
index d6c6d5fae..fac0eb4fa 100644
--- a/tests/ui/lint/lint-attr-everywhere-early.stderr
+++ b/tests/ui/lint/lint-attr-everywhere-early.stderr
@@ -384,92 +384,106 @@ note: the lint level is defined here
LL | #[deny(while_true)]
| ^^^^^^^^^^
+error: `...` range patterns are deprecated
+ --> $DIR/lint-attr-everywhere-early.rs:139:20
+ |
+LL | Match{f1: 0...100} => {}
+ | ^^^ help: use `..=` for an inclusive range
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+note: the lint level is defined here
+ --> $DIR/lint-attr-everywhere-early.rs:138:16
+ |
+LL | #[deny(ellipsis_inclusive_range_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
error: usage of an `unsafe` block
- --> $DIR/lint-attr-everywhere-early.rs:140:9
+ --> $DIR/lint-attr-everywhere-early.rs:148:9
|
LL | unsafe {}
| ^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:139:17
+ --> $DIR/lint-attr-everywhere-early.rs:147:17
|
LL | #![deny(unsafe_code)]
| ^^^^^^^^^^^
error: usage of an `unsafe` block
- --> $DIR/lint-attr-everywhere-early.rs:144:9
+ --> $DIR/lint-attr-everywhere-early.rs:152:9
|
LL | unsafe {}
| ^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:143:16
+ --> $DIR/lint-attr-everywhere-early.rs:151:16
|
LL | #[deny(unsafe_code)]
| ^^^^^^^^^^^
error: usage of an `unsafe` block
- --> $DIR/lint-attr-everywhere-early.rs:149:5
+ --> $DIR/lint-attr-everywhere-early.rs:157:5
|
LL | unsafe {};
| ^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:148:12
+ --> $DIR/lint-attr-everywhere-early.rs:156:12
|
LL | #[deny(unsafe_code)]
| ^^^^^^^^^^^
error: usage of an `unsafe` block
- --> $DIR/lint-attr-everywhere-early.rs:151:27
+ --> $DIR/lint-attr-everywhere-early.rs:159:27
|
LL | [#[deny(unsafe_code)] unsafe {123}];
| ^^^^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:151:13
+ --> $DIR/lint-attr-everywhere-early.rs:159:13
|
LL | [#[deny(unsafe_code)] unsafe {123}];
| ^^^^^^^^^^^
error: usage of an `unsafe` block
- --> $DIR/lint-attr-everywhere-early.rs:152:27
+ --> $DIR/lint-attr-everywhere-early.rs:160:27
|
LL | (#[deny(unsafe_code)] unsafe {123},);
| ^^^^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:152:13
+ --> $DIR/lint-attr-everywhere-early.rs:160:13
|
LL | (#[deny(unsafe_code)] unsafe {123},);
| ^^^^^^^^^^^
error: usage of an `unsafe` block
- --> $DIR/lint-attr-everywhere-early.rs:154:31
+ --> $DIR/lint-attr-everywhere-early.rs:162:31
|
LL | call(#[deny(unsafe_code)] unsafe {123});
| ^^^^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:154:17
+ --> $DIR/lint-attr-everywhere-early.rs:162:17
|
LL | call(#[deny(unsafe_code)] unsafe {123});
| ^^^^^^^^^^^
error: usage of an `unsafe` block
- --> $DIR/lint-attr-everywhere-early.rs:156:38
+ --> $DIR/lint-attr-everywhere-early.rs:164:38
|
LL | TupleStruct(#[deny(unsafe_code)] unsafe {123});
| ^^^^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:156:24
+ --> $DIR/lint-attr-everywhere-early.rs:164:24
|
LL | TupleStruct(#[deny(unsafe_code)] unsafe {123});
| ^^^^^^^^^^^
error: `...` range patterns are deprecated
- --> $DIR/lint-attr-everywhere-early.rs:167:18
+ --> $DIR/lint-attr-everywhere-early.rs:175:18
|
LL | f1: 0...100,
| ^^^ help: use `..=` for an inclusive range
@@ -477,10 +491,10 @@ LL | f1: 0...100,
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-early.rs:166:20
+ --> $DIR/lint-attr-everywhere-early.rs:174:20
|
LL | #[deny(ellipsis_inclusive_range_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 36 previous errors
+error: aborting due to 37 previous errors
diff --git a/tests/ui/lint/lint-attr-everywhere-late.rs b/tests/ui/lint/lint-attr-everywhere-late.rs
index 1055157d6..a24355bab 100644
--- a/tests/ui/lint/lint-attr-everywhere-late.rs
+++ b/tests/ui/lint/lint-attr-everywhere-late.rs
@@ -162,6 +162,11 @@ fn expressions() {
}
}
+ match 123 {
+ #[deny(non_snake_case)]
+ ARM_VAR => {} //~ ERROR variable `ARM_VAR` should have a snake case name
+ }
+
// Statement Block
{
#![deny(enum_intrinsics_non_enums)]
diff --git a/tests/ui/lint/lint-attr-everywhere-late.stderr b/tests/ui/lint/lint-attr-everywhere-late.stderr
index a69c2e0ef..9587556b0 100644
--- a/tests/ui/lint/lint-attr-everywhere-late.stderr
+++ b/tests/ui/lint/lint-attr-everywhere-late.stderr
@@ -305,124 +305,136 @@ note: the lint level is defined here
LL | #[deny(enum_intrinsics_non_enums)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
+error: variable `ARM_VAR` should have a snake case name
+ --> $DIR/lint-attr-everywhere-late.rs:167:9
+ |
+LL | ARM_VAR => {}
+ | ^^^^^^^ help: convert the identifier to snake case: `arm_var`
+ |
+note: the lint level is defined here
+ --> $DIR/lint-attr-everywhere-late.rs:166:16
+ |
+LL | #[deny(non_snake_case)]
+ | ^^^^^^^^^^^^^^
+
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
- --> $DIR/lint-attr-everywhere-late.rs:168:9
+ --> $DIR/lint-attr-everywhere-late.rs:173:9
|
LL | discriminant::<i32>(&123);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
- --> $DIR/lint-attr-everywhere-late.rs:168:29
+ --> $DIR/lint-attr-everywhere-late.rs:173:29
|
LL | discriminant::<i32>(&123);
| ^^^^
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-late.rs:167:17
+ --> $DIR/lint-attr-everywhere-late.rs:172:17
|
LL | #![deny(enum_intrinsics_non_enums)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
- --> $DIR/lint-attr-everywhere-late.rs:172:9
+ --> $DIR/lint-attr-everywhere-late.rs:177:9
|
LL | discriminant::<i32>(&123);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
- --> $DIR/lint-attr-everywhere-late.rs:172:29
+ --> $DIR/lint-attr-everywhere-late.rs:177:29
|
LL | discriminant::<i32>(&123);
| ^^^^
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-late.rs:171:16
+ --> $DIR/lint-attr-everywhere-late.rs:176:16
|
LL | #[deny(enum_intrinsics_non_enums)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
- --> $DIR/lint-attr-everywhere-late.rs:177:5
+ --> $DIR/lint-attr-everywhere-late.rs:182:5
|
LL | discriminant::<i32>(&123);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
- --> $DIR/lint-attr-everywhere-late.rs:177:25
+ --> $DIR/lint-attr-everywhere-late.rs:182:25
|
LL | discriminant::<i32>(&123);
| ^^^^
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-late.rs:176:12
+ --> $DIR/lint-attr-everywhere-late.rs:181:12
|
LL | #[deny(enum_intrinsics_non_enums)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
- --> $DIR/lint-attr-everywhere-late.rs:179:41
+ --> $DIR/lint-attr-everywhere-late.rs:184:41
|
LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)];
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
- --> $DIR/lint-attr-everywhere-late.rs:179:61
+ --> $DIR/lint-attr-everywhere-late.rs:184:61
|
LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)];
| ^^^^
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-late.rs:179:13
+ --> $DIR/lint-attr-everywhere-late.rs:184:13
|
LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)];
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
- --> $DIR/lint-attr-everywhere-late.rs:180:41
+ --> $DIR/lint-attr-everywhere-late.rs:185:41
|
LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
- --> $DIR/lint-attr-everywhere-late.rs:180:61
+ --> $DIR/lint-attr-everywhere-late.rs:185:61
|
LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),);
| ^^^^
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-late.rs:180:13
+ --> $DIR/lint-attr-everywhere-late.rs:185:13
|
LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
- --> $DIR/lint-attr-everywhere-late.rs:182:45
+ --> $DIR/lint-attr-everywhere-late.rs:187:45
|
LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
- --> $DIR/lint-attr-everywhere-late.rs:182:65
+ --> $DIR/lint-attr-everywhere-late.rs:187:65
|
LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
| ^^^^
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-late.rs:182:17
+ --> $DIR/lint-attr-everywhere-late.rs:187:17
|
LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
- --> $DIR/lint-attr-everywhere-late.rs:184:52
+ --> $DIR/lint-attr-everywhere-late.rs:189:52
|
LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
- --> $DIR/lint-attr-everywhere-late.rs:184:72
+ --> $DIR/lint-attr-everywhere-late.rs:189:72
|
LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
| ^^^^
note: the lint level is defined here
- --> $DIR/lint-attr-everywhere-late.rs:184:24
+ --> $DIR/lint-attr-everywhere-late.rs:189:24
|
LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123));
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 31 previous errors
+error: aborting due to 32 previous errors
diff --git a/tests/ui/lint/lint-match-arms-2.rs b/tests/ui/lint/lint-match-arms-2.rs
new file mode 100644
index 000000000..0c1146339
--- /dev/null
+++ b/tests/ui/lint/lint-match-arms-2.rs
@@ -0,0 +1,24 @@
+#![feature(if_let_guard)]
+#![allow(unused, non_snake_case)]
+
+enum E {
+ A,
+}
+
+#[allow(bindings_with_variant_name, irrefutable_let_patterns)]
+fn foo() {
+ match E::A {
+ #[deny(bindings_with_variant_name)]
+ A => {}
+ //~^ ERROR pattern binding `A` is named the same as one of the variants of the type `E`
+ }
+
+ match &E::A {
+ #[deny(irrefutable_let_patterns)]
+ a if let b = a => {}
+ //~^ ERROR irrefutable `if let` guard pattern
+ _ => {}
+ }
+}
+
+fn main() { }
diff --git a/tests/ui/lint/lint-match-arms-2.stderr b/tests/ui/lint/lint-match-arms-2.stderr
new file mode 100644
index 000000000..062d5c12e
--- /dev/null
+++ b/tests/ui/lint/lint-match-arms-2.stderr
@@ -0,0 +1,29 @@
+error[E0170]: pattern binding `A` is named the same as one of the variants of the type `E`
+ --> $DIR/lint-match-arms-2.rs:12:9
+ |
+LL | A => {}
+ | ^ help: to match on the variant, qualify the path: `E::A`
+ |
+note: the lint level is defined here
+ --> $DIR/lint-match-arms-2.rs:11:16
+ |
+LL | #[deny(bindings_with_variant_name)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: irrefutable `if let` guard pattern
+ --> $DIR/lint-match-arms-2.rs:18:18
+ |
+LL | a if let b = a => {}
+ | ^
+ |
+ = note: this pattern will always match, so the guard is useless
+ = help: consider removing the guard and adding a `let` inside the match arm
+note: the lint level is defined here
+ --> $DIR/lint-match-arms-2.rs:17:16
+ |
+LL | #[deny(irrefutable_let_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0170`.
diff --git a/tests/ui/lint/lint-missing-doc.rs b/tests/ui/lint/lint-missing-doc.rs
index 4a234d265..b59f2212f 100644
--- a/tests/ui/lint/lint-missing-doc.rs
+++ b/tests/ui/lint/lint-missing-doc.rs
@@ -1,12 +1,17 @@
// When denying at the crate level, be sure to not get random warnings from the
// injected intrinsics by the compiler.
+// aux-build:missing_docs.rs
#![deny(missing_docs)]
#![allow(dead_code)]
#![feature(associated_type_defaults, extern_types)]
+#![feature(trait_alias)]
//! Some garbage docs for the crate here
#![doc="More garbage"]
+// There should be not "missing_docs" warning on "pub extern crate".
+pub extern crate missing_docs;
+
type Typedef = String;
pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias
@@ -202,4 +207,6 @@ extern "C" {
//~^ ERROR: missing documentation for a foreign type
}
+pub trait T = Sync; //~ ERROR: missing documentation for a trait alias
+
fn main() {}
diff --git a/tests/ui/lint/lint-missing-doc.stderr b/tests/ui/lint/lint-missing-doc.stderr
index 733d062a0..adcc21c44 100644
--- a/tests/ui/lint/lint-missing-doc.stderr
+++ b/tests/ui/lint/lint-missing-doc.stderr
@@ -1,152 +1,158 @@
error: missing documentation for a type alias
- --> $DIR/lint-missing-doc.rs:11:1
+ --> $DIR/lint-missing-doc.rs:16:1
|
LL | pub type PubTypedef = String;
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/lint-missing-doc.rs:3:9
+ --> $DIR/lint-missing-doc.rs:4:9
|
LL | #![deny(missing_docs)]
| ^^^^^^^^^^^^
error: missing documentation for a struct
- --> $DIR/lint-missing-doc.rs:18:1
+ --> $DIR/lint-missing-doc.rs:23:1
|
LL | pub struct PubFoo {
| ^^^^^^^^^^^^^^^^^
error: missing documentation for a struct field
- --> $DIR/lint-missing-doc.rs:19:5
+ --> $DIR/lint-missing-doc.rs:24:5
|
LL | pub a: isize,
| ^^^^^^^^^^^^
error: missing documentation for a module
- --> $DIR/lint-missing-doc.rs:30:1
+ --> $DIR/lint-missing-doc.rs:35:1
|
LL | pub mod pub_module_no_dox {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a function
- --> $DIR/lint-missing-doc.rs:34:1
+ --> $DIR/lint-missing-doc.rs:39:1
|
LL | pub fn foo2() {}
| ^^^^^^^^^^^^^
error: missing documentation for a trait
- --> $DIR/lint-missing-doc.rs:52:1
+ --> $DIR/lint-missing-doc.rs:57:1
|
LL | pub trait C {
| ^^^^^^^^^^^
error: missing documentation for a method
- --> $DIR/lint-missing-doc.rs:53:5
+ --> $DIR/lint-missing-doc.rs:58:5
|
LL | fn foo(&self);
| ^^^^^^^^^^^^^^
error: missing documentation for a method
- --> $DIR/lint-missing-doc.rs:54:5
+ --> $DIR/lint-missing-doc.rs:59:5
|
LL | fn foo_with_impl(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for an associated function
- --> $DIR/lint-missing-doc.rs:55:5
+ --> $DIR/lint-missing-doc.rs:60:5
|
LL | fn foo_no_self();
| ^^^^^^^^^^^^^^^^^
error: missing documentation for an associated function
- --> $DIR/lint-missing-doc.rs:56:5
+ --> $DIR/lint-missing-doc.rs:61:5
|
LL | fn foo_no_self_with_impl() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for an associated type
- --> $DIR/lint-missing-doc.rs:66:5
+ --> $DIR/lint-missing-doc.rs:71:5
|
LL | type AssociatedType;
| ^^^^^^^^^^^^^^^^^^^
error: missing documentation for an associated type
- --> $DIR/lint-missing-doc.rs:67:5
+ --> $DIR/lint-missing-doc.rs:72:5
|
LL | type AssociatedTypeDef = Self;
| ^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for an associated function
- --> $DIR/lint-missing-doc.rs:83:5
+ --> $DIR/lint-missing-doc.rs:88:5
|
LL | pub fn foo() {}
| ^^^^^^^^^^^^
error: missing documentation for an enum
- --> $DIR/lint-missing-doc.rs:120:1
+ --> $DIR/lint-missing-doc.rs:125:1
|
LL | pub enum PubBaz {
| ^^^^^^^^^^^^^^^
error: missing documentation for a variant
- --> $DIR/lint-missing-doc.rs:121:5
+ --> $DIR/lint-missing-doc.rs:126:5
|
LL | PubBazA {
| ^^^^^^^
error: missing documentation for a struct field
- --> $DIR/lint-missing-doc.rs:122:9
+ --> $DIR/lint-missing-doc.rs:127:9
|
LL | a: isize,
| ^^^^^^^^
error: missing documentation for a constant
- --> $DIR/lint-missing-doc.rs:153:1
+ --> $DIR/lint-missing-doc.rs:158:1
|
LL | pub const FOO4: u32 = 0;
| ^^^^^^^^^^^^^^^^^^^
error: missing documentation for a static
- --> $DIR/lint-missing-doc.rs:163:1
+ --> $DIR/lint-missing-doc.rs:168:1
|
LL | pub static BAR4: u32 = 0;
| ^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a function
- --> $DIR/lint-missing-doc.rs:169:5
+ --> $DIR/lint-missing-doc.rs:174:5
|
LL | pub fn undocumented1() {}
| ^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a function
- --> $DIR/lint-missing-doc.rs:170:5
+ --> $DIR/lint-missing-doc.rs:175:5
|
LL | pub fn undocumented2() {}
| ^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a function
- --> $DIR/lint-missing-doc.rs:176:9
+ --> $DIR/lint-missing-doc.rs:181:9
|
LL | pub fn also_undocumented1() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a function
- --> $DIR/lint-missing-doc.rs:191:5
+ --> $DIR/lint-missing-doc.rs:196:5
|
LL | pub fn extern_fn_undocumented(f: f32) -> f32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a static
- --> $DIR/lint-missing-doc.rs:196:5
+ --> $DIR/lint-missing-doc.rs:201:5
|
LL | pub static EXTERN_STATIC_UNDOCUMENTED: u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a foreign type
- --> $DIR/lint-missing-doc.rs:201:5
+ --> $DIR/lint-missing-doc.rs:206:5
|
LL | pub type ExternTyUndocumented;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 24 previous errors
+error: missing documentation for a trait alias
+ --> $DIR/lint-missing-doc.rs:210:1
+ |
+LL | pub trait T = Sync;
+ | ^^^^^^^^^^^
+
+error: aborting due to 25 previous errors
diff --git a/tests/ui/lint/lint-non-uppercase-trait-assoc-const.rs b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.rs
new file mode 100644
index 000000000..4409611c2
--- /dev/null
+++ b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.rs
@@ -0,0 +1,15 @@
+#![deny(non_upper_case_globals)]
+
+trait Trait {
+ const item: usize;
+ //~^ ERROR associated constant `item` should have an upper case name [non_upper_case_globals]
+}
+
+struct Foo;
+
+impl Trait for Foo {
+ const item: usize = 5;
+ // ^^^ there should be no error here (in the trait `impl`)
+}
+
+fn main() {}
diff --git a/tests/ui/lint/lint-non-uppercase-trait-assoc-const.stderr b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.stderr
new file mode 100644
index 000000000..98d8d1dd2
--- /dev/null
+++ b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.stderr
@@ -0,0 +1,14 @@
+error: associated constant `item` should have an upper case name
+ --> $DIR/lint-non-uppercase-trait-assoc-const.rs:4:11
+ |
+LL | const item: usize;
+ | ^^^^ help: convert the identifier to upper case: `ITEM`
+ |
+note: the lint level is defined here
+ --> $DIR/lint-non-uppercase-trait-assoc-const.rs:1:9
+ |
+LL | #![deny(non_upper_case_globals)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lint/lint-uppercase-variables.stderr b/tests/ui/lint/lint-uppercase-variables.stderr
index 42ec9364b..922082801 100644
--- a/tests/ui/lint/lint-uppercase-variables.stderr
+++ b/tests/ui/lint/lint-uppercase-variables.stderr
@@ -12,12 +12,6 @@ error[E0170]: pattern binding `Foo` is named the same as one of the variants of
LL | let Foo = foo::Foo::Foo;
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
-error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
- --> $DIR/lint-uppercase-variables.rs:33:17
- |
-LL | fn in_param(Foo: foo::Foo) {}
- | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
-
warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:22:9
|
@@ -37,6 +31,12 @@ warning: unused variable: `Foo`
LL | let Foo = foo::Foo::Foo;
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`
+error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
+ --> $DIR/lint-uppercase-variables.rs:33:17
+ |
+LL | fn in_param(Foo: foo::Foo) {}
+ | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
+
warning: unused variable: `Foo`
--> $DIR/lint-uppercase-variables.rs:33:17
|
diff --git a/tests/ui/lint/must_not_suspend/boxed.stderr b/tests/ui/lint/must_not_suspend/boxed.stderr
index 9efc7b069..a2abfffc1 100644
--- a/tests/ui/lint/must_not_suspend/boxed.stderr
+++ b/tests/ui/lint/must_not_suspend/boxed.stderr
@@ -4,7 +4,7 @@ error: boxed `Umm` held across a suspend point, but should not be
LL | let _guard = bar();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/boxed.rs:20:9
diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr
index 262657da5..cd3baa857 100644
--- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr
@@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be
LL | let no = No {};
| ^^
LL | wheeee(&no).await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/dedup.rs:19:9
diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr
index 262657da5..cd3baa857 100644
--- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr
+++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr
@@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be
LL | let no = No {};
| ^^
LL | wheeee(&no).await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/dedup.rs:19:9
diff --git a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr
index 7ed43d257..aff2f7c32 100644
--- a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr
@@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be
LL | let no = No {};
| ^^
LL | wheeee(&no).await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/dedup.rs:19:9
@@ -21,7 +21,7 @@ error: `No` held across a suspend point, but should not be
--> $DIR/dedup.rs:20:13
|
LL | wheeee(&no).await;
- | ^^ ------ the value is held across this suspend point
+ | ^^ ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/dedup.rs:20:13
diff --git a/tests/ui/lint/must_not_suspend/dedup.stderr b/tests/ui/lint/must_not_suspend/dedup.stderr
deleted file mode 100644
index 18880f5a7..000000000
--- a/tests/ui/lint/must_not_suspend/dedup.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error: `No` held across a suspend point, but should not be
- --> $DIR/dedup.rs:19:13
- |
-LL | wheeee(&No {}).await;
- | ^^^^^ ------ the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/dedup.rs:19:13
- |
-LL | wheeee(&No {}).await;
- | ^^^^^
-note: the lint level is defined here
- --> $DIR/dedup.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/mutex.stderr b/tests/ui/lint/must_not_suspend/mutex.stderr
index c251cb845..9b5fc37a3 100644
--- a/tests/ui/lint/must_not_suspend/mutex.stderr
+++ b/tests/ui/lint/must_not_suspend/mutex.stderr
@@ -4,7 +4,7 @@ error: `MutexGuard` held across a suspend point, but should not be
LL | let _guard = m.lock().unwrap();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Futures to not implement `Send`
--> $DIR/mutex.rs:8:9
diff --git a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr
index 180e187c1..348880b9c 100644
--- a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr
@@ -5,7 +5,7 @@ LL | let guard = &mut self.u;
| ^^^^^
LL |
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/ref-drop-tracking.rs:19:13
diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr
index e3628ca5e..fb18c2be9 100644
--- a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr
@@ -5,7 +5,7 @@ LL | let guard = &mut self.u;
| ^^^^^
LL |
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/ref.rs:22:13
diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr
index e3628ca5e..fb18c2be9 100644
--- a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr
+++ b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr
@@ -5,7 +5,7 @@ LL | let guard = &mut self.u;
| ^^^^^
LL |
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/ref.rs:22:13
diff --git a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr
index e9bfa08b5..6976dd349 100644
--- a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr
@@ -5,7 +5,7 @@ LL | let guard = &mut self.u;
| ^^^^^^
LL |
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/ref.rs:22:26
diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr
index 6e62a228a..8c8ad1f37 100644
--- a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr
@@ -5,7 +5,7 @@ LL | let _guard1 = r#impl();
| ^^^^^^^
...
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/trait.rs:24:9
@@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn();
| ^^^^^^^
LL |
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/trait.rs:25:9
diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr
index 6e62a228a..8c8ad1f37 100644
--- a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr
+++ b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr
@@ -5,7 +5,7 @@ LL | let _guard1 = r#impl();
| ^^^^^^^
...
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/trait.rs:24:9
@@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn();
| ^^^^^^^
LL |
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/trait.rs:25:9
diff --git a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr
index 6e62a228a..8c8ad1f37 100644
--- a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr
@@ -5,7 +5,7 @@ LL | let _guard1 = r#impl();
| ^^^^^^^
...
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/trait.rs:24:9
@@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn();
| ^^^^^^^
LL |
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/trait.rs:25:9
diff --git a/tests/ui/lint/must_not_suspend/trait.stderr b/tests/ui/lint/must_not_suspend/trait.stderr
deleted file mode 100644
index 6e62a228a..000000000
--- a/tests/ui/lint/must_not_suspend/trait.stderr
+++ /dev/null
@@ -1,37 +0,0 @@
-error: implementer of `Wow` held across a suspend point, but should not be
- --> $DIR/trait.rs:24:9
- |
-LL | let _guard1 = r#impl();
- | ^^^^^^^
-...
-LL | other().await;
- | ------ the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:24:9
- |
-LL | let _guard1 = r#impl();
- | ^^^^^^^
-note: the lint level is defined here
- --> $DIR/trait.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: boxed `Wow` trait object held across a suspend point, but should not be
- --> $DIR/trait.rs:25:9
- |
-LL | let _guard2 = r#dyn();
- | ^^^^^^^
-LL |
-LL | other().await;
- | ------ the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:25:9
- |
-LL | let _guard2 = r#dyn();
- | ^^^^^^^
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr
index f89b3e341..e24cffdd0 100644
--- a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr
@@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be
LL | let _guard = bar();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/unit.rs:22:9
diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr
index f89b3e341..e24cffdd0 100644
--- a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr
+++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr
@@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be
LL | let _guard = bar();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/unit.rs:22:9
diff --git a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr
index f89b3e341..e24cffdd0 100644
--- a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr
@@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be
LL | let _guard = bar();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/unit.rs:22:9
diff --git a/tests/ui/lint/must_not_suspend/unit.stderr b/tests/ui/lint/must_not_suspend/unit.stderr
deleted file mode 100644
index 50ca292c2..000000000
--- a/tests/ui/lint/must_not_suspend/unit.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-error: `Umm` held across a suspend point, but should not be
- --> $DIR/unit.rs:23:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-LL | other().await;
- | ------ the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/unit.rs:23:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/unit.rs:23:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-note: the lint level is defined here
- --> $DIR/unit.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr
index 7a422891a..4f7b40a5e 100644
--- a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr
@@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be
LL | let _guard = bar();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/warn.rs:24:9
diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr
index 7a422891a..4f7b40a5e 100644
--- a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr
+++ b/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr
@@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be
LL | let _guard = bar();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/warn.rs:24:9
diff --git a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr
index 7a422891a..4f7b40a5e 100644
--- a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr
@@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be
LL | let _guard = bar();
| ^^^^^^
LL | other().await;
- | ------ the value is held across this suspend point
+ | ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
--> $DIR/warn.rs:24:9
diff --git a/tests/ui/lint/must_not_suspend/warn.stderr b/tests/ui/lint/must_not_suspend/warn.stderr
deleted file mode 100644
index 7a422891a..000000000
--- a/tests/ui/lint/must_not_suspend/warn.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-warning: `Umm` held across a suspend point, but should not be
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-LL | other().await;
- | ------ the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-note: the lint level is defined here
- --> $DIR/warn.rs:7:9
- |
-LL | #![warn(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/lint/noop-method-call.rs b/tests/ui/lint/noop-method-call.rs
index 89b296635..dbcf2a513 100644
--- a/tests/ui/lint/noop-method-call.rs
+++ b/tests/ui/lint/noop-method-call.rs
@@ -19,18 +19,17 @@ fn main() {
let clone_type_ref = &CloneType(1u32);
let clone_type_ref_clone: CloneType<u32> = clone_type_ref.clone();
- // Calling clone on a double reference doesn't warn since the method call itself
- // peels the outer reference off
let clone_type_ref = &&CloneType(1u32);
let clone_type_ref_clone: &CloneType<u32> = clone_type_ref.clone();
+ //~^ WARNING using `.clone()` on a double reference, which returns `&CloneType<u32>`
let non_deref_type = &PlainType(1u32);
let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref();
//~^ WARNING call to `.deref()` on a reference in this situation does nothing
- // Dereferencing a &&T does not warn since it has collapsed the double reference
let non_deref_type = &&PlainType(1u32);
let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref();
+ //~^ WARNING using `.deref()` on a double reference, which returns `&PlainType<u32>`
let non_borrow_type = &PlainType(1u32);
let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow();
@@ -41,7 +40,8 @@ fn main() {
let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow();
let xs = ["a", "b", "c"];
- let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // ok, but could use `*x` instead
+ let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead
+ //~^ WARNING using `.clone()` on a double reference, which returns `&str`
}
fn generic<T>(non_clone_type: &PlainType<T>) {
diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr
index 6a904d01a..37cd1a0fc 100644
--- a/tests/ui/lint/noop-method-call.stderr
+++ b/tests/ui/lint/noop-method-call.stderr
@@ -11,22 +11,42 @@ note: the lint level is defined here
LL | #![warn(noop_method_call)]
| ^^^^^^^^^^^^^^^^
+warning: using `.clone()` on a double reference, which returns `&CloneType<u32>` instead of cloning the inner type
+ --> $DIR/noop-method-call.rs:23:63
+ |
+LL | let clone_type_ref_clone: &CloneType<u32> = clone_type_ref.clone();
+ | ^^^^^^^^
+ |
+ = note: `#[warn(suspicious_double_ref_op)]` on by default
+
warning: call to `.deref()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:28:63
+ --> $DIR/noop-method-call.rs:27:63
|
LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref();
| ^^^^^^^^ unnecessary method call
|
= note: the type `&PlainType<u32>` which `deref` is being called on is the same as the type returned from `deref`, so the method call does not do anything and can be removed
+warning: using `.deref()` on a double reference, which returns `&PlainType<u32>` instead of dereferencing the inner type
+ --> $DIR/noop-method-call.rs:31:63
+ |
+LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref();
+ | ^^^^^^^^
+
warning: call to `.borrow()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:36:66
+ --> $DIR/noop-method-call.rs:35:66
|
LL | let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow();
| ^^^^^^^^^ unnecessary method call
|
= note: the type `&PlainType<u32>` which `borrow` is being called on is the same as the type returned from `borrow`, so the method call does not do anything and can be removed
+warning: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type
+ --> $DIR/noop-method-call.rs:43:44
+ |
+LL | let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead
+ | ^^^^^^^^
+
warning: call to `.clone()` on a reference in this situation does nothing
--> $DIR/noop-method-call.rs:48:19
|
@@ -43,5 +63,5 @@ LL | non_clone_type.clone();
|
= note: the type `&PlainType<u32>` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed
-warning: 5 warnings emitted
+warning: 8 warnings emitted
diff --git a/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr b/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr
index 2c35647b8..4852c3313 100644
--- a/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr
+++ b/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr
@@ -1,15 +1,3 @@
-error: unused variable: `this_is_my_function`
- --> $DIR/expect_nested_lint_levels.rs:48:9
- |
-LL | let this_is_my_function = 3;
- | ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_is_my_function`
- |
-note: the lint level is defined here
- --> $DIR/expect_nested_lint_levels.rs:45:10
- |
-LL | #[forbid(unused_variables)]
- | ^^^^^^^^^^^^^^^^
-
warning: variable does not need to be mutable
--> $DIR/expect_nested_lint_levels.rs:36:13
|
@@ -25,6 +13,18 @@ note: the lint level is defined here
LL | unused_mut,
| ^^^^^^^^^^
+error: unused variable: `this_is_my_function`
+ --> $DIR/expect_nested_lint_levels.rs:48:9
+ |
+LL | let this_is_my_function = 3;
+ | ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_is_my_function`
+ |
+note: the lint level is defined here
+ --> $DIR/expect_nested_lint_levels.rs:45:10
+ |
+LL | #[forbid(unused_variables)]
+ | ^^^^^^^^^^^^^^^^
+
warning: this lint expectation is unfulfilled
--> $DIR/expect_nested_lint_levels.rs:7:5
|
diff --git a/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr b/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr
index 5942fa8ae..169f03aed 100644
--- a/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr
+++ b/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr
@@ -12,12 +12,6 @@ warning: unused variable: `fox_name`
LL | let fox_name = "Sir Nibbles";
| ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_fox_name`
-warning: unused variable: `this_should_fulfill_the_expectation`
- --> $DIR/force_warn_expected_lints_fulfilled.rs:43:9
- |
-LL | let this_should_fulfill_the_expectation = "The `#[allow]` has no power here";
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_should_fulfill_the_expectation`
-
warning: variable does not need to be mutable
--> $DIR/force_warn_expected_lints_fulfilled.rs:32:9
|
@@ -28,6 +22,12 @@ LL | let mut what_does_the_fox_say = "*ding* *deng* *dung*";
|
= note: requested on the command line with `--force-warn unused-mut`
+warning: unused variable: `this_should_fulfill_the_expectation`
+ --> $DIR/force_warn_expected_lints_fulfilled.rs:43:9
+ |
+LL | let this_should_fulfill_the_expectation = "The `#[allow]` has no power here";
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_should_fulfill_the_expectation`
+
warning: denote infinite loops with `loop { ... }`
--> $DIR/force_warn_expected_lints_fulfilled.rs:10:5
|
diff --git a/tests/ui/lint/rfc-2383-lint-reason/root-attribute-confusion.rs b/tests/ui/lint/rfc-2383-lint-reason/root-attribute-confusion.rs
new file mode 100644
index 000000000..0cade7fef
--- /dev/null
+++ b/tests/ui/lint/rfc-2383-lint-reason/root-attribute-confusion.rs
@@ -0,0 +1,7 @@
+// check-pass
+// compile-flags: -Dunused_attributes
+
+#![deny(unused_crate_dependencies)]
+#![feature(lint_reasons)]
+
+fn main() {}
diff --git a/tests/ui/lint/suspicious-double-ref-op.rs b/tests/ui/lint/suspicious-double-ref-op.rs
new file mode 100644
index 000000000..b9bcd31c2
--- /dev/null
+++ b/tests/ui/lint/suspicious-double-ref-op.rs
@@ -0,0 +1,30 @@
+#![feature(lazy_cell)]
+#![deny(suspicious_double_ref_op, noop_method_call)]
+
+pub fn clone_on_double_ref() {
+ let x = vec![1];
+ let y = &&x;
+ let z: &Vec<_> = y.clone();
+ //~^ ERROR using `.clone()` on a double reference, which returns `&Vec<i32>`
+
+ println!("{:p} {:p}", *y, z);
+}
+
+use std::sync::LazyLock;
+
+pub static STRS: LazyLock<&str> = LazyLock::new(|| "First");
+
+// https://github.com/rust-lang/rust-clippy/issues/9272
+fn rust_clippy_issue_9272() {
+ let str = STRS.clone();
+ println!("{str}")
+}
+
+fn check(mut encoded: &[u8]) {
+ let _ = &mut encoded.clone();
+ //~^ ERROR call to `.clone()` on a reference in this situation does nothing
+ let _ = &encoded.clone();
+ //~^ ERROR call to `.clone()` on a reference in this situation does nothing
+}
+
+fn main() {}
diff --git a/tests/ui/lint/suspicious-double-ref-op.stderr b/tests/ui/lint/suspicious-double-ref-op.stderr
new file mode 100644
index 000000000..d15487ca2
--- /dev/null
+++ b/tests/ui/lint/suspicious-double-ref-op.stderr
@@ -0,0 +1,35 @@
+error: using `.clone()` on a double reference, which returns `&Vec<i32>` instead of cloning the inner type
+ --> $DIR/suspicious-double-ref-op.rs:7:23
+ |
+LL | let z: &Vec<_> = y.clone();
+ | ^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/suspicious-double-ref-op.rs:2:9
+ |
+LL | #![deny(suspicious_double_ref_op, noop_method_call)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: call to `.clone()` on a reference in this situation does nothing
+ --> $DIR/suspicious-double-ref-op.rs:24:25
+ |
+LL | let _ = &mut encoded.clone();
+ | ^^^^^^^^ unnecessary method call
+ |
+ = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed
+note: the lint level is defined here
+ --> $DIR/suspicious-double-ref-op.rs:2:35
+ |
+LL | #![deny(suspicious_double_ref_op, noop_method_call)]
+ | ^^^^^^^^^^^^^^^^
+
+error: call to `.clone()` on a reference in this situation does nothing
+ --> $DIR/suspicious-double-ref-op.rs:26:21
+ |
+LL | let _ = &encoded.clone();
+ | ^^^^^^^^ unnecessary method call
+ |
+ = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/lint/unaligned_references.stderr b/tests/ui/lint/unaligned_references.stderr
index 775dcac67..5f9cecadb 100644
--- a/tests/ui/lint/unaligned_references.stderr
+++ b/tests/ui/lint/unaligned_references.stderr
@@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned
LL | &self.x;
| ^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ = &good.ptr;
| ^^^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -22,7 +24,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ = &good.data;
| ^^^^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -31,7 +34,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ = &good.data as *const _;
| ^^^^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -40,7 +44,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _: *const _ = &good.data;
| ^^^^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -49,7 +54,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ = good.data.clone();
| ^^^^^^^^^^^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -58,7 +64,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ = &good.data2[0];
| ^^^^^^^^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -67,7 +74,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ = &packed2.x;
| ^^^^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -76,7 +84,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ref = &m1.1.a;
| ^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned
@@ -85,7 +94,8 @@ error[E0793]: reference to packed field is unaligned
LL | let _ref = &m2.1.a;
| ^^^^^^^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error: aborting due to 10 previous errors
diff --git a/tests/ui/lint/unaligned_references_external_macro.stderr b/tests/ui/lint/unaligned_references_external_macro.stderr
index 5b08f433e..94a95c1d8 100644
--- a/tests/ui/lint/unaligned_references_external_macro.stderr
+++ b/tests/ui/lint/unaligned_references_external_macro.stderr
@@ -9,7 +9,8 @@ LL | | }
LL | | }
| |_^
|
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
= note: this error originates in the macro `unaligned_references_external_crate::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed b/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed
index 71ebaea8e..9c52ca557 100644
--- a/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed
+++ b/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed
@@ -21,17 +21,32 @@ fn lint_on_top_level() {
let _ = |a: u8| 0; //~ ERROR unnecessary parentheses around pattern
}
-fn _no_lint_attr() {
+fn no_lint_attr() {
let _x = #[allow(dead_code)] (1 + 2);
}
-fn _no_lint_yeet() -> Result<(), ()> {
+fn no_lint_yeet() -> Result<(), ()> {
#[allow(unreachable_code)]
if (do yeet) {}
Ok(())
}
+fn no_lint_ops() {
+ #![allow(unreachable_code, irrefutable_let_patterns)]
+ if ((..{}) == ..{}) {}
+ if (!return) {}
+ loop { match (() = () = () = break {}) {} }
+ while let () = (*&mut false |= true && return) {}
+}
+
+fn lint_break_if_not_followed_by_block() {
+ #![allow(unreachable_code)]
+ loop { if break {} } //~ ERROR unnecessary parentheses
+ loop { if break ({ println!("hello") }) {} } //~ ERROR unnecessary parentheses
+ loop { if (break { println!("hello") }) {} }
+}
+
// Don't lint in these cases (#64106).
fn or_patterns_no_lint() {
match Box::new(0) {
diff --git a/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs b/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs
index 28b662dd0..196ecf0c1 100644
--- a/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs
+++ b/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs
@@ -21,17 +21,32 @@ fn lint_on_top_level() {
let _ = |(a): u8| 0; //~ ERROR unnecessary parentheses around pattern
}
-fn _no_lint_attr() {
+fn no_lint_attr() {
let _x = #[allow(dead_code)] (1 + 2);
}
-fn _no_lint_yeet() -> Result<(), ()> {
+fn no_lint_yeet() -> Result<(), ()> {
#[allow(unreachable_code)]
if (do yeet) {}
Ok(())
}
+fn no_lint_ops() {
+ #![allow(unreachable_code, irrefutable_let_patterns)]
+ if ((..{}) == ..{}) {}
+ if (!return) {}
+ loop { match (() = () = () = break {}) {} }
+ while let () = (*&mut false |= true && return) {}
+}
+
+fn lint_break_if_not_followed_by_block() {
+ #![allow(unreachable_code)]
+ loop { if (break) {} } //~ ERROR unnecessary parentheses
+ loop { if (break ({ println!("hello") })) {} } //~ ERROR unnecessary parentheses
+ loop { if (break { println!("hello") }) {} }
+}
+
// Don't lint in these cases (#64106).
fn or_patterns_no_lint() {
match Box::new(0) {
diff --git a/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr b/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr
index a5e69e6d9..f916bba81 100644
--- a/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr
+++ b/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr
@@ -75,8 +75,32 @@ LL - let _ = |(a): u8| 0;
LL + let _ = |a: u8| 0;
|
+error: unnecessary parentheses around `if` condition
+ --> $DIR/issue-54538-unused-parens-lint.rs:45:15
+ |
+LL | loop { if (break) {} }
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - loop { if (break) {} }
+LL + loop { if break {} }
+ |
+
+error: unnecessary parentheses around `if` condition
+ --> $DIR/issue-54538-unused-parens-lint.rs:46:15
+ |
+LL | loop { if (break ({ println!("hello") })) {} }
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - loop { if (break ({ println!("hello") })) {} }
+LL + loop { if break ({ println!("hello") }) {} }
+ |
+
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:56:12
+ --> $DIR/issue-54538-unused-parens-lint.rs:71:12
|
LL | if let (0 | 1) = 0 {}
| ^ ^
@@ -88,7 +112,7 @@ LL + if let 0 | 1 = 0 {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:57:13
+ --> $DIR/issue-54538-unused-parens-lint.rs:72:13
|
LL | if let ((0 | 1),) = (0,) {}
| ^ ^
@@ -100,7 +124,7 @@ LL + if let (0 | 1,) = (0,) {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:58:13
+ --> $DIR/issue-54538-unused-parens-lint.rs:73:13
|
LL | if let [(0 | 1)] = [0] {}
| ^ ^
@@ -112,7 +136,7 @@ LL + if let [0 | 1] = [0] {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:59:16
+ --> $DIR/issue-54538-unused-parens-lint.rs:74:16
|
LL | if let 0 | (1 | 2) = 0 {}
| ^ ^
@@ -124,7 +148,7 @@ LL + if let 0 | 1 | 2 = 0 {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:61:15
+ --> $DIR/issue-54538-unused-parens-lint.rs:76:15
|
LL | if let TS((0 | 1)) = TS(0) {}
| ^ ^
@@ -136,7 +160,7 @@ LL + if let TS(0 | 1) = TS(0) {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:63:20
+ --> $DIR/issue-54538-unused-parens-lint.rs:78:20
|
LL | if let NS { f: (0 | 1) } = (NS { f: 0 }) {}
| ^ ^
@@ -148,7 +172,7 @@ LL + if let NS { f: 0 | 1 } = (NS { f: 0 }) {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:73:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:88:9
|
LL | (_) => {}
| ^ ^
@@ -160,7 +184,7 @@ LL + _ => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:74:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:89:9
|
LL | (y) => {}
| ^ ^
@@ -172,7 +196,7 @@ LL + y => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:75:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:90:9
|
LL | (ref r) => {}
| ^ ^
@@ -184,7 +208,7 @@ LL + ref r => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:76:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:91:9
|
LL | (e @ 1...2) => {}
| ^ ^
@@ -196,7 +220,7 @@ LL + e @ 1...2 => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:82:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:97:9
|
LL | (e @ &(1...2)) => {}
| ^ ^
@@ -208,7 +232,7 @@ LL + e @ &(1...2) => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:83:10
+ --> $DIR/issue-54538-unused-parens-lint.rs:98:10
|
LL | &(_) => {}
| ^ ^
@@ -220,7 +244,7 @@ LL + &_ => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:94:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:109:9
|
LL | (_) => {}
| ^ ^
@@ -232,7 +256,7 @@ LL + _ => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:95:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:110:9
|
LL | (y) => {}
| ^ ^
@@ -244,7 +268,7 @@ LL + y => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:96:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:111:9
|
LL | (ref r) => {}
| ^ ^
@@ -256,7 +280,7 @@ LL + ref r => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:97:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:112:9
|
LL | (e @ 1..=2) => {}
| ^ ^
@@ -268,7 +292,7 @@ LL + e @ 1..=2 => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:103:9
+ --> $DIR/issue-54538-unused-parens-lint.rs:118:9
|
LL | (e @ &(1..=2)) => {}
| ^ ^
@@ -280,7 +304,7 @@ LL + e @ &(1..=2) => {}
|
error: unnecessary parentheses around pattern
- --> $DIR/issue-54538-unused-parens-lint.rs:104:10
+ --> $DIR/issue-54538-unused-parens-lint.rs:119:10
|
LL | &(_) => {}
| ^ ^
@@ -291,5 +315,5 @@ LL - &(_) => {}
LL + &_ => {}
|
-error: aborting due to 24 previous errors
+error: aborting due to 26 previous errors
diff --git a/tests/ui/lint/unused/lint-unused-mut-variables.rs b/tests/ui/lint/unused/lint-unused-mut-variables.rs
index 67ec7facf..5334ab582 100644
--- a/tests/ui/lint/unused/lint-unused-mut-variables.rs
+++ b/tests/ui/lint/unused/lint-unused-mut-variables.rs
@@ -205,3 +205,11 @@ fn bar() {
let mut b = vec![2]; //~ ERROR: variable does not need to be mutable
}
+
+struct Arg(i32);
+
+// Regression test for https://github.com/rust-lang/rust/issues/110849
+fn write_through_reference(mut arg: &mut Arg) {
+ //~^ WARN: variable does not need to be mutable
+ arg.0 = 1
+}
diff --git a/tests/ui/lint/unused/lint-unused-mut-variables.stderr b/tests/ui/lint/unused/lint-unused-mut-variables.stderr
index 805ed2b40..5f66c0315 100644
--- a/tests/ui/lint/unused/lint-unused-mut-variables.stderr
+++ b/tests/ui/lint/unused/lint-unused-mut-variables.stderr
@@ -218,5 +218,13 @@ note: the lint level is defined here
LL | #[deny(unused_mut)]
| ^^^^^^^^^^
-error: aborting due to previous error; 25 warnings emitted
+warning: variable does not need to be mutable
+ --> $DIR/lint-unused-mut-variables.rs:212:28
+ |
+LL | fn write_through_reference(mut arg: &mut Arg) {
+ | ----^^^
+ | |
+ | help: remove this `mut`
+
+error: aborting due to previous error; 26 warnings emitted
diff --git a/tests/ui/lint/unused/lint-unused-variables.stderr b/tests/ui/lint/unused/lint-unused-variables.stderr
index fd9a5bcbf..09729eeba 100644
--- a/tests/ui/lint/unused/lint-unused-variables.stderr
+++ b/tests/ui/lint/unused/lint-unused-variables.stderr
@@ -10,12 +10,6 @@ note: the lint level is defined here
LL | #![deny(unused_variables)]
| ^^^^^^^^^^^^^^^^
-error: unused variable: `b`
- --> $DIR/lint-unused-variables.rs:14:5
- |
-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
|
@@ -23,6 +17,12 @@ LL | a: i32,
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
+ --> $DIR/lint-unused-variables.rs:14:5
+ |
+LL | b: i32,
+ | ^ help: if this is intentional, prefix it with an underscore: `_b`
+
+error: unused variable: `b`
--> $DIR/lint-unused-variables.rs:29:9
|
LL | b: i32,