Skip to content

Commit

Permalink
Skip unused_parens report for Paren(Path(..)) in macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
surechen committed Apr 1, 2024
1 parent 66de611 commit b6d90c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ impl EarlyLintPass for UnusedParens {
ast::TyKind::BareFn(b)
if self.with_self_ty_parens && b.generic_params.len() > 0 => {}
ast::TyKind::ImplTrait(_, bounds) if bounds.len() > 1 => {}
ast::TyKind::Path(_, _) if ty.span.from_expansion() => {}
_ => {
let spans = r
.span
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//@ check-pass
#![warn(unused_parens)]
#![deny(warnings)]

trait Foo {
fn bar();
}

macro_rules! problem {
($ty:ident) => {
impl<$ty: Foo> Foo for ($ty,) {
fn bar() { <$ty>::bar() }
}
};
($ty:ident $(, $rest:ident)*) => {
impl<$ty: Foo, $($rest: Foo),*> Foo for ($ty, $($rest),*) {
fn bar() {
<$ty>::bar();
<($($rest),*)>::bar()
}
}

problem!($($rest),*);
}
}

fn main() {
problem!(T1, T2, T3);
}

0 comments on commit b6d90c4

Please sign in to comment.