File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ use syntax::attr;
22
22
use syntax:: feature_gate:: { BUILTIN_ATTRIBUTES , AttributeType } ;
23
23
use syntax:: symbol:: keywords;
24
24
use syntax:: ptr:: P ;
25
+ use syntax:: print:: pprust;
25
26
use syntax:: util:: parser;
26
27
use syntax_pos:: Span ;
27
28
@@ -325,9 +326,16 @@ impl UnusedParens {
325
326
let necessary = struct_lit_needs_parens &&
326
327
parser:: contains_exterior_struct_lit ( & inner) ;
327
328
if !necessary {
328
- cx. span_lint ( UNUSED_PARENS ,
329
- value. span ,
330
- & format ! ( "unnecessary parentheses around {}" , msg) )
329
+ let span_msg = format ! ( "unnecessary parentheses around {}" , msg) ;
330
+ let mut err = cx. struct_span_lint ( UNUSED_PARENS ,
331
+ value. span ,
332
+ & span_msg) ;
333
+ let parens_removed = pprust:: expr_to_string ( value)
334
+ . trim_matches ( |c| c == '(' || c == ')' ) . to_owned ( ) ;
335
+ err. span_suggestion_short ( value. span ,
336
+ "remove these parentheses" ,
337
+ parens_removed) ;
338
+ err. emit ( ) ;
331
339
}
332
340
}
333
341
}
You can’t perform that action at this time.
0 commit comments