File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
src/librustc_parse/parser Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -383,10 +383,7 @@ impl<'a> Parser<'a> {
383383 let is_negative = self . eat ( & token:: Not ) ;
384384 let question = if self . eat ( & token:: Question ) { Some ( self . prev_span ) } else { None } ;
385385 if self . token . is_lifetime ( ) {
386- if let Some ( question_span) = question {
387- self . span_err ( question_span,
388- "`?` may only modify trait bounds, not lifetime bounds" ) ;
389- }
386+ self . error_opt_out_lifetime ( question) ;
390387 bounds. push ( GenericBound :: Outlives ( self . expect_lifetime ( ) ) ) ;
391388 if has_parens {
392389 let inner_span = inner_lo. to ( self . prev_span ) ;
@@ -473,6 +470,13 @@ impl<'a> Parser<'a> {
473470 return Ok ( bounds) ;
474471 }
475472
473+ fn error_opt_out_lifetime ( & self , question : Option < Span > ) {
474+ if let Some ( span) = question {
475+ self . struct_span_err ( span, "`?` may only modify trait bounds, not lifetime bounds" )
476+ . emit ( ) ;
477+ }
478+ }
479+
476480 pub ( super ) fn parse_late_bound_lifetime_defs ( & mut self ) -> PResult < ' a , Vec < GenericParam > > {
477481 if self . eat_keyword ( kw:: For ) {
478482 self . expect_lt ( ) ?;
You can’t perform that action at this time.
0 commit comments