parent
f2c5acd611
commit
5c9f806d78
1 changed files with 11 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ use syntax::attr;
|
||||||
use syntax::feature_gate::{BUILTIN_ATTRIBUTES, AttributeType};
|
use syntax::feature_gate::{BUILTIN_ATTRIBUTES, AttributeType};
|
||||||
use syntax::symbol::keywords;
|
use syntax::symbol::keywords;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
use syntax::print::pprust;
|
||||||
use syntax::util::parser;
|
use syntax::util::parser;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
|
|
@ -325,9 +326,16 @@ impl UnusedParens {
|
||||||
let necessary = struct_lit_needs_parens &&
|
let necessary = struct_lit_needs_parens &&
|
||||||
parser::contains_exterior_struct_lit(&inner);
|
parser::contains_exterior_struct_lit(&inner);
|
||||||
if !necessary {
|
if !necessary {
|
||||||
cx.span_lint(UNUSED_PARENS,
|
let span_msg = format!("unnecessary parentheses around {}", msg);
|
||||||
value.span,
|
let mut err = cx.struct_span_lint(UNUSED_PARENS,
|
||||||
&format!("unnecessary parentheses around {}", msg))
|
value.span,
|
||||||
|
&span_msg);
|
||||||
|
let parens_removed = pprust::expr_to_string(value)
|
||||||
|
.trim_matches(|c| c == '(' || c == ')').to_owned();
|
||||||
|
err.span_suggestion_short(value.span,
|
||||||
|
"remove these parentheses",
|
||||||
|
parens_removed);
|
||||||
|
err.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue