Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,10 @@ trait UnusedDelimLint {
&& !snip.ends_with(' ')
{
" "
} else if let Ok(snip) = sm.span_to_prev_source(value_span)
&& snip.ends_with(|c: char| c.is_alphanumeric())
{
" "
} else {
""
};
Expand All @@ -852,6 +856,10 @@ trait UnusedDelimLint {
&& !snip.starts_with(' ')
{
" "
} else if let Ok(snip) = sm.span_to_prev_source(value_span)
&& snip.starts_with(|c: char| c.is_alphanumeric())
{
" "
} else {
""
};
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/lint/unused_parens_follow_ident.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ run-rustfix

#![deny(unused_parens)]

macro_rules! wrap {
($name:ident $arg:expr) => {
$name($arg);
};
}

fn main() {
wrap!(unary routine()); //~ ERROR unnecessary parentheses around function argument
wrap!(unary routine()); //~ ERROR unnecessary parentheses around function argument
}

fn unary(_: ()) {}
fn routine() {}
17 changes: 17 additions & 0 deletions tests/ui/lint/unused_parens_follow_ident.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ run-rustfix

#![deny(unused_parens)]

macro_rules! wrap {
($name:ident $arg:expr) => {
$name($arg);
};
}

fn main() {
wrap!(unary(routine())); //~ ERROR unnecessary parentheses around function argument
wrap!(unary (routine())); //~ ERROR unnecessary parentheses around function argument
}

fn unary(_: ()) {}
fn routine() {}
31 changes: 31 additions & 0 deletions tests/ui/lint/unused_parens_follow_ident.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error: unnecessary parentheses around function argument
--> $DIR/unused_parens_follow_ident.rs:12:16
|
LL | wrap!(unary(routine()));
| ^ ^
|
note: the lint level is defined here
--> $DIR/unused_parens_follow_ident.rs:3:9
|
LL | #![deny(unused_parens)]
| ^^^^^^^^^^^^^
help: remove these parentheses
|
LL - wrap!(unary(routine()));
LL + wrap!(unary routine());
|

error: unnecessary parentheses around function argument
--> $DIR/unused_parens_follow_ident.rs:13:17
|
LL | wrap!(unary (routine()));
| ^ ^
|
help: remove these parentheses
|
LL - wrap!(unary (routine()));
LL + wrap!(unary routine());
|

error: aborting due to 2 previous errors

Loading