@@ -360,36 +360,24 @@ impl<'a> Parser<'a> {
360
360
) -> PResult < ' a , GenericBounds > {
361
361
let mut bounds = Vec :: new ( ) ;
362
362
let mut negative_bounds = Vec :: new ( ) ;
363
- let mut last_plus_span = None ;
364
- let mut was_negative = false ;
365
363
while self . can_begin_bound ( ) {
366
- match self . parse_generic_bound ( colon_span , last_plus_span ) ? {
364
+ match self . parse_generic_bound ( ) ? {
367
365
Ok ( bound) => bounds. push ( bound) ,
368
- Err ( neg_sp) => {
369
- was_negative = true ;
370
- if let Some ( neg_sp) = neg_sp {
371
- negative_bounds. push ( neg_sp) ;
372
- }
373
- }
366
+ Err ( neg_sp) => negative_bounds. push ( neg_sp) ,
374
367
}
375
-
376
368
if !allow_plus || !self . eat_plus ( ) {
377
369
break
378
- } else {
379
- last_plus_span = Some ( self . prev_span ) ;
380
370
}
381
371
}
382
372
383
- if !negative_bounds. is_empty ( ) || was_negative {
373
+ if !negative_bounds. is_empty ( ) {
384
374
let negative_bounds_len = negative_bounds. len ( ) ;
385
- let last_span = negative_bounds. last ( ) . map ( |sp| * sp ) ;
375
+ let last_span = * negative_bounds. last ( ) . unwrap ( ) ;
386
376
let mut err = self . struct_span_err (
387
377
negative_bounds,
388
378
"negative trait bounds are not supported" ,
389
379
) ;
390
- if let Some ( sp) = last_span {
391
- err. span_label ( sp, "negative trait bounds are not supported" ) ;
392
- }
380
+ err. span_label ( last_span, "negative trait bounds are not supported" ) ;
393
381
if let Some ( bound_list) = colon_span {
394
382
let bound_list = bound_list. to ( self . prev_span ) ;
395
383
let mut new_bound_list = String :: new ( ) ;
@@ -432,9 +420,8 @@ impl<'a> Parser<'a> {
432
420
/// ```
433
421
fn parse_generic_bound (
434
422
& mut self ,
435
- colon_span : Option < Span > ,
436
- last_plus_span : Option < Span > ,
437
- ) -> PResult < ' a , Result < GenericBound , Option < Span > > > {
423
+ ) -> PResult < ' a , Result < GenericBound , Span > > {
424
+ let anchor_lo = self . prev_span ;
438
425
let lo = self . token . span ;
439
426
let has_parens = self . eat ( & token:: OpenDelim ( token:: Paren ) ) ;
440
427
let inner_lo = self . token . span ;
@@ -445,7 +432,7 @@ impl<'a> Parser<'a> {
445
432
} else {
446
433
let ( poly_span, bound) = self . parse_generic_ty_bound ( lo, has_parens, question) ?;
447
434
if is_negative {
448
- Ok ( Err ( last_plus_span . or ( colon_span ) . map ( |sp| sp . to ( poly_span) ) ) )
435
+ Ok ( Err ( anchor_lo . to ( poly_span) ) )
449
436
} else {
450
437
Ok ( Ok ( bound) )
451
438
}
0 commit comments