@@ -375,9 +375,9 @@ impl<'a> Parser<'a> {
375
375
let last_span = * negative_bounds. last ( ) . unwrap ( ) ;
376
376
let mut err = self . struct_span_err (
377
377
negative_bounds,
378
- "negative trait bounds are not supported" ,
378
+ "negative bounds are not supported" ,
379
379
) ;
380
- err. span_label ( last_span, "negative trait bounds are not supported" ) ;
380
+ err. span_label ( last_span, "negative bounds are not supported" ) ;
381
381
if let Some ( bound_list) = colon_span {
382
382
let bound_list = bound_list. to ( self . prev_span ) ;
383
383
let mut new_bound_list = String :: new ( ) ;
@@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
392
392
}
393
393
err. span_suggestion_hidden (
394
394
bound_list,
395
- & format ! ( "remove the trait bound{}" , pluralize!( negative_bounds_len) ) ,
395
+ & format ! ( "remove the bound{}" , pluralize!( negative_bounds_len) ) ,
396
396
new_bound_list,
397
397
Applicability :: MachineApplicable ,
398
398
) ;
@@ -418,25 +418,23 @@ impl<'a> Parser<'a> {
418
418
/// ```
419
419
/// BOUND = TY_BOUND | LT_BOUND
420
420
/// ```
421
- fn parse_generic_bound (
422
- & mut self ,
423
- ) -> PResult < ' a , Result < GenericBound , Span > > {
421
+ fn parse_generic_bound ( & mut self ) -> PResult < ' a , Result < GenericBound , Span > > {
424
422
let anchor_lo = self . prev_span ;
425
423
let lo = self . token . span ;
426
424
let has_parens = self . eat ( & token:: OpenDelim ( token:: Paren ) ) ;
427
425
let inner_lo = self . token . span ;
428
426
let is_negative = self . eat ( & token:: Not ) ;
429
427
let question = self . eat ( & token:: Question ) . then_some ( self . prev_span ) ;
430
- if self . token . is_lifetime ( ) {
431
- Ok ( Ok ( self . parse_generic_lt_bound ( lo, inner_lo, has_parens, question) ?) )
428
+ let bound = if self . token . is_lifetime ( ) {
429
+ self . parse_generic_lt_bound ( lo, inner_lo, has_parens, question) ?
432
430
} else {
433
- let ( poly_span , bound ) = self . parse_generic_ty_bound ( lo, has_parens, question) ?;
434
- if is_negative {
435
- Ok ( Err ( anchor_lo . to ( poly_span ) ) )
436
- } else {
437
- Ok ( Ok ( bound ) )
438
- }
439
- }
431
+ self . parse_generic_ty_bound ( lo, has_parens, question) ?
432
+ } ;
433
+ Ok ( if is_negative {
434
+ Err ( anchor_lo . to ( self . prev_span ) )
435
+ } else {
436
+ Ok ( bound )
437
+ } )
440
438
}
441
439
442
440
/// Parses a lifetime ("outlives") bound, e.g. `'a`, according to:
@@ -497,16 +495,15 @@ impl<'a> Parser<'a> {
497
495
lo : Span ,
498
496
has_parens : bool ,
499
497
question : Option < Span > ,
500
- ) -> PResult < ' a , ( Span , GenericBound ) > {
498
+ ) -> PResult < ' a , GenericBound > {
501
499
let lifetime_defs = self . parse_late_bound_lifetime_defs ( ) ?;
502
500
let path = self . parse_path ( PathStyle :: Type ) ?;
503
501
if has_parens {
504
502
self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
505
503
}
506
- let poly_span = lo. to ( self . prev_span ) ;
507
- let poly_trait = PolyTraitRef :: new ( lifetime_defs, path, poly_span) ;
504
+ let poly_trait = PolyTraitRef :: new ( lifetime_defs, path, lo. to ( self . prev_span ) ) ;
508
505
let modifier = question. map_or ( TraitBoundModifier :: None , |_| TraitBoundModifier :: Maybe ) ;
509
- Ok ( ( poly_span , GenericBound :: Trait ( poly_trait, modifier) ) )
506
+ Ok ( GenericBound :: Trait ( poly_trait, modifier) )
510
507
}
511
508
512
509
pub ( super ) fn parse_late_bound_lifetime_defs ( & mut self ) -> PResult < ' a , Vec < GenericParam > > {
0 commit comments