File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
src/librustc_parse/parser Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -665,17 +665,23 @@ impl<'a> Parser<'a> {
665
665
) ;
666
666
let mut err = self . struct_span_err ( span, & msg) ;
667
667
let suggestion = "try surrounding the expression in parentheses" ;
668
- if let Ok ( expr_str) = expr_str {
669
- err. span_suggestion (
670
- span,
671
- suggestion,
672
- format ! ( "({})" , expr_str) ,
673
- Applicability :: MachineApplicable ,
674
- )
668
+ // if type ascription is "likely an error", the user will already be getting a useful
669
+ // help message, and doesn't need a second.
670
+ if self . last_type_ascription . map_or ( false , |last_ascription| last_ascription. 1 ) {
671
+ self . maybe_annotate_with_ascription ( & mut err, false ) ;
675
672
} else {
676
- err. span_help ( span, suggestion)
673
+ if let Ok ( expr_str) = expr_str {
674
+ err. span_suggestion (
675
+ span,
676
+ suggestion,
677
+ format ! ( "({})" , expr_str) ,
678
+ Applicability :: MachineApplicable ,
679
+ ) ;
680
+ } else {
681
+ err. span_help ( span, suggestion) ;
682
+ }
677
683
}
678
- . emit ( ) ;
684
+ err . emit ( ) ;
679
685
} ;
680
686
Ok ( with_postfix)
681
687
}
You can’t perform that action at this time.
0 commit comments