@@ -360,36 +360,24 @@ impl<'a> Parser<'a> {
360360 ) -> PResult < ' a , GenericBounds > {
361361 let mut bounds = Vec :: new ( ) ;
362362 let mut negative_bounds = Vec :: new ( ) ;
363- let mut last_plus_span = None ;
364- let mut was_negative = false ;
365363 while self . can_begin_bound ( ) {
366- match self . parse_generic_bound ( colon_span , last_plus_span ) ? {
364+ match self . parse_generic_bound ( ) ? {
367365 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) ,
374367 }
375-
376368 if !allow_plus || !self . eat_plus ( ) {
377369 break
378- } else {
379- last_plus_span = Some ( self . prev_span ) ;
380370 }
381371 }
382372
383- if !negative_bounds. is_empty ( ) || was_negative {
373+ if !negative_bounds. is_empty ( ) {
384374 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 ( ) ;
386376 let mut err = self . struct_span_err (
387377 negative_bounds,
388378 "negative trait bounds are not supported" ,
389379 ) ;
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" ) ;
393381 if let Some ( bound_list) = colon_span {
394382 let bound_list = bound_list. to ( self . prev_span ) ;
395383 let mut new_bound_list = String :: new ( ) ;
@@ -432,9 +420,8 @@ impl<'a> Parser<'a> {
432420 /// ```
433421 fn parse_generic_bound (
434422 & 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 ;
438425 let lo = self . token . span ;
439426 let has_parens = self . eat ( & token:: OpenDelim ( token:: Paren ) ) ;
440427 let inner_lo = self . token . span ;
@@ -445,7 +432,7 @@ impl<'a> Parser<'a> {
445432 } else {
446433 let ( poly_span, bound) = self . parse_generic_ty_bound ( lo, has_parens, question) ?;
447434 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) ) )
449436 } else {
450437 Ok ( Ok ( bound) )
451438 }
0 commit comments