From ce7328badb4bbebdb569a86dfb0067f38323fbe4 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 18 Jan 2024 13:49:36 +0100 Subject: [PATCH] Make it allow-by-default to appease CI --- compiler/rustc_lint_defs/src/builtin.rs | 3 ++- ...-ref-patterns-default-binding-modes-fixable.fixed | 1 + ...ove-ref-patterns-default-binding-modes-fixable.rs | 1 + ...ref-patterns-default-binding-modes-fixable.stderr | 12 ++++++++---- .../move-ref-patterns-default-binding-modes.rs | 1 + .../move-ref-patterns-default-binding-modes.stderr | 12 ++++++++---- tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs | 1 + .../ui/rfcs/rfc-2005-default-binding-mode/for.stderr | 12 ++++++++---- 8 files changed, 30 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 805cec2df7bd1..bf171b1204f98 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1586,6 +1586,7 @@ declare_lint! { /// ### Example /// /// ```rust + /// # #![warn(dereferencing_mut_binding)] /// let x = Some(123u32); /// let _y = match &x { /// Some(mut x) => { @@ -1604,7 +1605,7 @@ declare_lint! { /// `u32`, which was deeped surprising. After edition 2024, adding `mut` will not change the /// type of `x`. This lint warns users of editions before 2024 to update their code. pub DEREFERENCING_MUT_BINDING, - Warn, + Allow, "detects `mut x` bindings that change the type of `x`" } diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed index 1332f3bb24557..4814dd8585d53 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed @@ -1,5 +1,6 @@ // run-rustfix #![allow(unused_variables)] +#![warn(dereferencing_mut_binding)] fn main() { struct U; diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs index 9009c94793ae0..a77898f8ae392 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs @@ -1,5 +1,6 @@ // run-rustfix #![allow(unused_variables)] +#![warn(dereferencing_mut_binding)] fn main() { struct U; diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.stderr b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.stderr index 26381ead4b001..ebbfd97439611 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.stderr +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.stderr @@ -1,18 +1,22 @@ warning: dereferencing `mut` binding - --> $DIR/move-ref-patterns-default-binding-modes-fixable.rs:10:13 + --> $DIR/move-ref-patterns-default-binding-modes-fixable.rs:11:13 | LL | let (a, mut b) = &mut p; | ^^^^^ `mut` dereferences the type of this binding | help: this will change in edition 2024 - --> $DIR/move-ref-patterns-default-binding-modes-fixable.rs:10:13 + --> $DIR/move-ref-patterns-default-binding-modes-fixable.rs:11:13 | LL | let (a, mut b) = &mut p; | ^^^^^ - = note: `#[warn(dereferencing_mut_binding)]` on by default +note: the lint level is defined here + --> $DIR/move-ref-patterns-default-binding-modes-fixable.rs:3:9 + | +LL | #![warn(dereferencing_mut_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0507]: cannot move out of a mutable reference - --> $DIR/move-ref-patterns-default-binding-modes-fixable.rs:10:22 + --> $DIR/move-ref-patterns-default-binding-modes-fixable.rs:11:22 | LL | let (a, mut b) = &mut p; | ----- ^^^^^^ diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.rs b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.rs index 06d829ad91e29..08c642f43c83f 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.rs +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.rs @@ -1,3 +1,4 @@ +#![warn(dereferencing_mut_binding)] fn main() { struct U; diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr index b0f127198be36..ae7ac394cc0e9 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes.stderr @@ -1,18 +1,22 @@ warning: dereferencing `mut` binding - --> $DIR/move-ref-patterns-default-binding-modes.rs:8:13 + --> $DIR/move-ref-patterns-default-binding-modes.rs:9:13 | LL | let (a, mut b) = &p; | ^^^^^ `mut` dereferences the type of this binding | help: this will change in edition 2024 - --> $DIR/move-ref-patterns-default-binding-modes.rs:8:13 + --> $DIR/move-ref-patterns-default-binding-modes.rs:9:13 | LL | let (a, mut b) = &p; | ^^^^^ - = note: `#[warn(dereferencing_mut_binding)]` on by default +note: the lint level is defined here + --> $DIR/move-ref-patterns-default-binding-modes.rs:1:9 + | +LL | #![warn(dereferencing_mut_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0507]: cannot move out of a shared reference - --> $DIR/move-ref-patterns-default-binding-modes.rs:8:22 + --> $DIR/move-ref-patterns-default-binding-modes.rs:9:22 | LL | let (a, mut b) = &p; | ----- ^^ diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs index be136c880e7dd..61d508ed191ac 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs @@ -1,3 +1,4 @@ +#![warn(dereferencing_mut_binding)] struct Foo {} pub fn main() { diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr index bc2a21a817a5c..57d14ea5b337e 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr @@ -1,18 +1,22 @@ warning: dereferencing `mut` binding - --> $DIR/for.rs:6:13 + --> $DIR/for.rs:7:13 | LL | for (n, mut m) in &tups { | ^^^^^ `mut` dereferences the type of this binding | help: this will change in edition 2024 - --> $DIR/for.rs:6:13 + --> $DIR/for.rs:7:13 | LL | for (n, mut m) in &tups { | ^^^^^ - = note: `#[warn(dereferencing_mut_binding)]` on by default +note: the lint level is defined here + --> $DIR/for.rs:1:9 + | +LL | #![warn(dereferencing_mut_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0507]: cannot move out of a shared reference - --> $DIR/for.rs:6:23 + --> $DIR/for.rs:7:23 | LL | for (n, mut m) in &tups { | ----- ^^^^^