Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing leading space in suggestion #117395

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ impl EarlyLintPass for UnusedParens {

fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
if let StmtKind::Local(ref local) = s.kind {
self.check_unused_parens_pat(cx, &local.pat, true, false, (false, false));
self.check_unused_parens_pat(cx, &local.pat, true, false, (true, false));
gurry marked this conversation as resolved.
Show resolved Hide resolved
}

<Self as UnusedDelimLint>::check_stmt(self, cx, s)
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/lint/lint-unnecessary-parens.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ fn main() {
_a = 0; //~ ERROR unnecessary parentheses around assigned value
_a += 1; //~ ERROR unnecessary parentheses around assigned value

let mut _a = 3; //~ ERROR unnecessary parentheses around pattern
let mut _a = 3; //~ ERROR unnecessary parentheses around pattern
let mut _a = 3; //~ ERROR unnecessary parentheses around pattern

let _a = 3; //~ ERROR unnecessary parentheses around pattern
let _a = 3; //~ ERROR unnecessary parentheses around pattern
let _a = 3; //~ ERROR unnecessary parentheses around pattern

let _a = baz!(3, 4);
let _b = baz!(3);
}
8 changes: 8 additions & 0 deletions tests/ui/lint/lint-unnecessary-parens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ fn main() {
_a = (0); //~ ERROR unnecessary parentheses around assigned value
_a += (1); //~ ERROR unnecessary parentheses around assigned value

let(mut _a) = 3; //~ ERROR unnecessary parentheses around pattern
let (mut _a) = 3; //~ ERROR unnecessary parentheses around pattern
let( mut _a) = 3; //~ ERROR unnecessary parentheses around pattern

let(_a) = 3; //~ ERROR unnecessary parentheses around pattern
let (_a) = 3; //~ ERROR unnecessary parentheses around pattern
let( _a) = 3; //~ ERROR unnecessary parentheses around pattern

let _a = baz!(3, 4);
let _b = baz!(3);
}
74 changes: 73 additions & 1 deletion tests/ui/lint/lint-unnecessary-parens.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,77 @@ LL - _a += (1);
LL + _a += 1;
|

error: aborting due to 22 previous errors
error: unnecessary parentheses around pattern
--> $DIR/lint-unnecessary-parens.rs:87:8
|
LL | let(mut _a) = 3;
| ^ ^
|
help: remove these parentheses
|
LL - let(mut _a) = 3;
LL + let mut _a = 3;
|

error: unnecessary parentheses around pattern
--> $DIR/lint-unnecessary-parens.rs:88:9
|
LL | let (mut _a) = 3;
| ^ ^
|
help: remove these parentheses
|
LL - let (mut _a) = 3;
LL + let mut _a = 3;
|

error: unnecessary parentheses around pattern
--> $DIR/lint-unnecessary-parens.rs:89:8
|
LL | let( mut _a) = 3;
| ^^ ^
|
help: remove these parentheses
|
LL - let( mut _a) = 3;
LL + let mut _a = 3;
|

error: unnecessary parentheses around pattern
--> $DIR/lint-unnecessary-parens.rs:91:8
|
LL | let(_a) = 3;
| ^ ^
|
help: remove these parentheses
|
LL - let(_a) = 3;
LL + let _a = 3;
|

error: unnecessary parentheses around pattern
--> $DIR/lint-unnecessary-parens.rs:92:9
|
LL | let (_a) = 3;
| ^ ^
|
help: remove these parentheses
|
LL - let (_a) = 3;
LL + let _a = 3;
|

error: unnecessary parentheses around pattern
--> $DIR/lint-unnecessary-parens.rs:93:8
|
LL | let( _a) = 3;
| ^^ ^
|
help: remove these parentheses
|
LL - let( _a) = 3;
LL + let _a = 3;
|

error: aborting due to 28 previous errors

Loading