-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #118359 - hkmatsumoto:suggest-box-ref, r=TaKO8Ki
Suggest swapping the order of `ref` and `box` It is not valid grammar to write `ref box <ident>` in patterns, but `box ref <ident>` is. This patch adds a diagnostic to suggest swapping them, analogous to what we do for `mut let`.
- Loading branch information
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// run-rustfix | ||
|
||
#![feature(box_patterns)] | ||
#![allow(dead_code)] | ||
|
||
fn foo(f: Option<Box<i32>>) { | ||
match f { | ||
Some(box ref _i) => {}, | ||
//~^ ERROR switch the order of `ref` and `box` | ||
None => {} | ||
} | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// run-rustfix | ||
|
||
#![feature(box_patterns)] | ||
#![allow(dead_code)] | ||
|
||
fn foo(f: Option<Box<i32>>) { | ||
match f { | ||
Some(ref box _i) => {}, | ||
//~^ ERROR switch the order of `ref` and `box` | ||
None => {} | ||
} | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: switch the order of `ref` and `box` | ||
--> $DIR/pattern-bad-ref-box-order.rs:8:14 | ||
| | ||
LL | Some(ref box _i) => {}, | ||
| ^^^^^^^ help: swap them: `box ref` | ||
|
||
error: aborting due to 1 previous error | ||
|