Don't warn about unused parens when they are used by yeet expr
This commit is contained in:
parent
c5351ad4dc
commit
84a46352ac
@ -617,7 +617,10 @@ fn is_expr_delims_necessary(
|
||||
lhs_needs_parens
|
||||
|| (followed_by_block
|
||||
&& match &inner.kind {
|
||||
ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true,
|
||||
ExprKind::Ret(_)
|
||||
| ExprKind::Break(..)
|
||||
| ExprKind::Yield(..)
|
||||
| ExprKind::Yeet(..) => true,
|
||||
ExprKind::Range(_lhs, Some(rhs), _limits) => {
|
||||
matches!(rhs.kind, ExprKind::Block(..))
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(box_patterns, stmt_expr_attributes)]
|
||||
#![feature(box_patterns, stmt_expr_attributes, yeet_expr)]
|
||||
|
||||
#![allow(
|
||||
dead_code,
|
||||
@ -25,6 +25,13 @@ fn _no_lint_attr() {
|
||||
let _x = #[allow(dead_code)] (1 + 2);
|
||||
}
|
||||
|
||||
fn _no_lint_yeet() -> Result<(), ()> {
|
||||
#[allow(unreachable_code)]
|
||||
if (do yeet) {}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Don't lint in these cases (#64106).
|
||||
fn or_patterns_no_lint() {
|
||||
match Box::new(0) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(box_patterns, stmt_expr_attributes)]
|
||||
#![feature(box_patterns, stmt_expr_attributes, yeet_expr)]
|
||||
|
||||
#![allow(
|
||||
dead_code,
|
||||
@ -25,6 +25,13 @@ fn _no_lint_attr() {
|
||||
let _x = #[allow(dead_code)] (1 + 2);
|
||||
}
|
||||
|
||||
fn _no_lint_yeet() -> Result<(), ()> {
|
||||
#[allow(unreachable_code)]
|
||||
if (do yeet) {}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Don't lint in these cases (#64106).
|
||||
fn or_patterns_no_lint() {
|
||||
match Box::new(0) {
|
||||
|
@ -76,7 +76,7 @@ LL + let _ = |a: u8| 0;
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:49:12
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:56:12
|
||||
|
|
||||
LL | if let (0 | 1) = 0 {}
|
||||
| ^ ^
|
||||
@ -88,7 +88,7 @@ LL + if let 0 | 1 = 0 {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:50:13
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:57:13
|
||||
|
|
||||
LL | if let ((0 | 1),) = (0,) {}
|
||||
| ^ ^
|
||||
@ -100,7 +100,7 @@ LL + if let (0 | 1,) = (0,) {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:51:13
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:58:13
|
||||
|
|
||||
LL | if let [(0 | 1)] = [0] {}
|
||||
| ^ ^
|
||||
@ -112,7 +112,7 @@ LL + if let [0 | 1] = [0] {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:52:16
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:59:16
|
||||
|
|
||||
LL | if let 0 | (1 | 2) = 0 {}
|
||||
| ^ ^
|
||||
@ -124,7 +124,7 @@ LL + if let 0 | 1 | 2 = 0 {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:54:15
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:61:15
|
||||
|
|
||||
LL | if let TS((0 | 1)) = TS(0) {}
|
||||
| ^ ^
|
||||
@ -136,7 +136,7 @@ LL + if let TS(0 | 1) = TS(0) {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:56:20
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:63:20
|
||||
|
|
||||
LL | if let NS { f: (0 | 1) } = (NS { f: 0 }) {}
|
||||
| ^ ^
|
||||
@ -148,7 +148,7 @@ LL + if let NS { f: 0 | 1 } = (NS { f: 0 }) {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:66:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:73:9
|
||||
|
|
||||
LL | (_) => {}
|
||||
| ^ ^
|
||||
@ -160,7 +160,7 @@ LL + _ => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:67:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:74:9
|
||||
|
|
||||
LL | (y) => {}
|
||||
| ^ ^
|
||||
@ -172,7 +172,7 @@ LL + y => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:68:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:75:9
|
||||
|
|
||||
LL | (ref r) => {}
|
||||
| ^ ^
|
||||
@ -184,7 +184,7 @@ LL + ref r => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:69:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:76:9
|
||||
|
|
||||
LL | (e @ 1...2) => {}
|
||||
| ^ ^
|
||||
@ -196,7 +196,7 @@ LL + e @ 1...2 => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:75:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:82:9
|
||||
|
|
||||
LL | (e @ &(1...2)) => {}
|
||||
| ^ ^
|
||||
@ -208,7 +208,7 @@ LL + e @ &(1...2) => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:76:10
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:83:10
|
||||
|
|
||||
LL | &(_) => {}
|
||||
| ^ ^
|
||||
@ -220,7 +220,7 @@ LL + &_ => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:87:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:94:9
|
||||
|
|
||||
LL | (_) => {}
|
||||
| ^ ^
|
||||
@ -232,7 +232,7 @@ LL + _ => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:88:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:95:9
|
||||
|
|
||||
LL | (y) => {}
|
||||
| ^ ^
|
||||
@ -244,7 +244,7 @@ LL + y => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:89:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:96:9
|
||||
|
|
||||
LL | (ref r) => {}
|
||||
| ^ ^
|
||||
@ -256,7 +256,7 @@ LL + ref r => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:90:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:97:9
|
||||
|
|
||||
LL | (e @ 1..=2) => {}
|
||||
| ^ ^
|
||||
@ -268,7 +268,7 @@ LL + e @ 1..=2 => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:96:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:103:9
|
||||
|
|
||||
LL | (e @ &(1..=2)) => {}
|
||||
| ^ ^
|
||||
@ -280,7 +280,7 @@ LL + e @ &(1..=2) => {}
|
||||
|
|
||||
|
||||
error: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:97:10
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:104:10
|
||||
|
|
||||
LL | &(_) => {}
|
||||
| ^ ^
|
||||
|
Loading…
Reference in New Issue
Block a user