diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-14 18:41:46 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-14 18:43:48 -0400 |
| commit | 1d33f06de80ce6b473460cdf87566d57f53a0b4e (patch) | |
| tree | 9043d6a61fa9cfe09a8fd124be3d6fdc00d0ba0f /src/librustc_lint | |
| parent | ca3766e2e58f462a20922e42c821a37eaf0e13db (diff) | |
| download | rust-1d33f06de80ce6b473460cdf87566d57f53a0b4e.tar.gz rust-1d33f06de80ce6b473460cdf87566d57f53a0b4e.zip | |
Don't mark expression with attributes as not needing parentheses
This is not perfectly correct as `#[attr] (5)` will still not lint, but it does seem good enough, in particular as the parentheses in that case are not unambiguously incorrect.
Diffstat (limited to 'src/librustc_lint')
| -rw-r--r-- | src/librustc_lint/unused.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 561bf202dfe..20c05800889 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -370,7 +370,8 @@ impl UnusedParens { right_pos: Option<BytePos>) { match value.node { ast::ExprKind::Paren(ref inner) => { - if !Self::is_expr_parens_necessary(inner, followed_by_block) { + if !Self::is_expr_parens_necessary(inner, followed_by_block) && + value.attrs.is_empty() { let expr_text = if let Ok(snippet) = cx.sess().source_map() .span_to_snippet(value.span) { snippet |
