@@ -1747,22 +1747,23 @@ impl<'a> Parser<'a> {
1747
1747
// This is a struct literal, but we don't can't accept them here.
1748
1748
let expr = self . parse_struct_expr ( lo, path. clone ( ) , attrs. clone ( ) ) ;
1749
1749
if let ( Ok ( expr) , false ) = ( & expr, struct_allowed) {
1750
- self . struct_span_err ( expr. span , "struct literals are not allowed here" )
1751
- . multipart_suggestion (
1752
- "surround the struct literal with parentheses" ,
1753
- vec ! [
1754
- ( lo. shrink_to_lo( ) , "(" . to_string( ) ) ,
1755
- ( expr. span. shrink_to_hi( ) , ")" . to_string( ) ) ,
1756
- ] ,
1757
- Applicability :: MachineApplicable ,
1758
- )
1759
- . emit ( ) ;
1750
+ self . error_struct_lit_not_allowed_here ( lo, expr. span ) ;
1760
1751
}
1761
1752
return Some ( expr) ;
1762
1753
}
1763
1754
None
1764
1755
}
1765
1756
1757
+ fn error_struct_lit_not_allowed_here ( & self , lo : Span , sp : Span ) {
1758
+ self . struct_span_err ( sp, "struct literals are not allowed here" )
1759
+ . multipart_suggestion (
1760
+ "surround the struct literal with parentheses" ,
1761
+ vec ! [ ( lo. shrink_to_lo( ) , "(" . to_string( ) ) , ( sp. shrink_to_hi( ) , ")" . to_string( ) ) ] ,
1762
+ Applicability :: MachineApplicable ,
1763
+ )
1764
+ . emit ( ) ;
1765
+ }
1766
+
1766
1767
pub ( super ) fn parse_struct_expr (
1767
1768
& mut self ,
1768
1769
lo : Span ,
0 commit comments