@@ -375,9 +375,9 @@ impl<'a> Parser<'a> {
375375 let last_span = * negative_bounds. last ( ) . unwrap ( ) ;
376376 let mut err = self . struct_span_err (
377377 negative_bounds,
378- "negative trait bounds are not supported" ,
378+ "negative bounds are not supported" ,
379379 ) ;
380- err. span_label ( last_span, "negative trait bounds are not supported" ) ;
380+ err. span_label ( last_span, "negative bounds are not supported" ) ;
381381 if let Some ( bound_list) = colon_span {
382382 let bound_list = bound_list. to ( self . prev_span ) ;
383383 let mut new_bound_list = String :: new ( ) ;
@@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
392392 }
393393 err. span_suggestion_hidden (
394394 bound_list,
395- & format ! ( "remove the trait bound{}" , pluralize!( negative_bounds_len) ) ,
395+ & format ! ( "remove the bound{}" , pluralize!( negative_bounds_len) ) ,
396396 new_bound_list,
397397 Applicability :: MachineApplicable ,
398398 ) ;
@@ -418,25 +418,23 @@ impl<'a> Parser<'a> {
418418 /// ```
419419 /// BOUND = TY_BOUND | LT_BOUND
420420 /// ```
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 > > {
424422 let anchor_lo = self . prev_span ;
425423 let lo = self . token . span ;
426424 let has_parens = self . eat ( & token:: OpenDelim ( token:: Paren ) ) ;
427425 let inner_lo = self . token . span ;
428426 let is_negative = self . eat ( & token:: Not ) ;
429427 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) ?
432430 } 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+ } )
440438 }
441439
442440 /// Parses a lifetime ("outlives") bound, e.g. `'a`, according to:
@@ -497,16 +495,15 @@ impl<'a> Parser<'a> {
497495 lo : Span ,
498496 has_parens : bool ,
499497 question : Option < Span > ,
500- ) -> PResult < ' a , ( Span , GenericBound ) > {
498+ ) -> PResult < ' a , GenericBound > {
501499 let lifetime_defs = self . parse_late_bound_lifetime_defs ( ) ?;
502500 let path = self . parse_path ( PathStyle :: Type ) ?;
503501 if has_parens {
504502 self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
505503 }
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 ) ) ;
508505 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) )
510507 }
511508
512509 pub ( super ) fn parse_late_bound_lifetime_defs ( & mut self ) -> PResult < ' a , Vec < GenericParam > > {
0 commit comments