File tree 2 files changed +8
-2
lines changed
compiler/rustc_parse/src/parser
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,13 @@ impl<'a> Parser<'a> {
179
179
& self . sess . span_diagnostic
180
180
}
181
181
182
+ pub ( super ) fn diagnostic_snapshot ( & self ) -> Self {
183
+ let mut snapshot = self . clone ( ) ;
184
+ // initialize unclosed_delims to avoid duplicate errors.
185
+ snapshot. unclosed_delims = vec ! [ ] ;
186
+ snapshot
187
+ }
188
+
182
189
pub ( super ) fn span_to_snippet ( & self , span : Span ) -> Result < String , SpanSnippetError > {
183
190
self . sess . source_map ( ) . span_to_snippet ( span)
184
191
}
Original file line number Diff line number Diff line change @@ -625,8 +625,7 @@ impl<'a> Parser<'a> {
625
625
} else if self . check_type ( ) {
626
626
// Parse type argument.
627
627
let is_const_fn = self . look_ahead ( 1 , |t| t. kind == token:: OpenDelim ( token:: Paren ) ) ;
628
- let mut snapshot = self . clone ( ) ;
629
- snapshot. unclosed_delims = vec ! [ ] ;
628
+ let mut snapshot = self . diagnostic_snapshot ( ) ;
630
629
match self . parse_ty ( ) {
631
630
Ok ( ty) => GenericArg :: Type ( ty) ,
632
631
Err ( err) => {
You can’t perform that action at this time.
0 commit comments