Skip to content

Commit

Permalink
Make it allow-by-default to appease CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Jan 18, 2024
1 parent 860e50a commit ce7328b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,7 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// # #![warn(dereferencing_mut_binding)]
/// let x = Some(123u32);
/// let _y = match &x {
/// Some(mut x) => {
Expand All @@ -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`"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#![allow(unused_variables)]
#![warn(dereferencing_mut_binding)]
fn main() {
struct U;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#![allow(unused_variables)]
#![warn(dereferencing_mut_binding)]
fn main() {
struct U;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
| ----- ^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![warn(dereferencing_mut_binding)]
fn main() {
struct U;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
| ----- ^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![warn(dereferencing_mut_binding)]
struct Foo {}

pub fn main() {
Expand Down
12 changes: 8 additions & 4 deletions tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr
Original file line number Diff line number Diff line change
@@ -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 {
| ----- ^^^^^
Expand Down

0 comments on commit ce7328b

Please sign in to comment.