@@ -371,33 +371,7 @@ impl<'a> Parser<'a> {
371
371
}
372
372
373
373
if !negative_bounds. is_empty ( ) {
374
- let negative_bounds_len = negative_bounds. len ( ) ;
375
- let last_span = * negative_bounds. last ( ) . unwrap ( ) ;
376
- let mut err = self . struct_span_err (
377
- negative_bounds,
378
- "negative bounds are not supported" ,
379
- ) ;
380
- err. span_label ( last_span, "negative bounds are not supported" ) ;
381
- if let Some ( bound_list) = colon_span {
382
- let bound_list = bound_list. to ( self . prev_span ) ;
383
- let mut new_bound_list = String :: new ( ) ;
384
- if !bounds. is_empty ( ) {
385
- let mut snippets = bounds. iter ( ) . map ( |bound| bound. span ( ) )
386
- . map ( |span| self . span_to_snippet ( span) ) ;
387
- while let Some ( Ok ( snippet) ) = snippets. next ( ) {
388
- new_bound_list. push_str ( " + " ) ;
389
- new_bound_list. push_str ( & snippet) ;
390
- }
391
- new_bound_list = new_bound_list. replacen ( " +" , ":" , 1 ) ;
392
- }
393
- err. span_suggestion_hidden (
394
- bound_list,
395
- & format ! ( "remove the bound{}" , pluralize!( negative_bounds_len) ) ,
396
- new_bound_list,
397
- Applicability :: MachineApplicable ,
398
- ) ;
399
- }
400
- err. emit ( ) ;
374
+ self . error_negative_bounds ( colon_span, & bounds, negative_bounds) ;
401
375
}
402
376
403
377
Ok ( bounds)
@@ -414,6 +388,40 @@ impl<'a> Parser<'a> {
414
388
|| self . check ( & token:: OpenDelim ( token:: Paren ) )
415
389
}
416
390
391
+ fn error_negative_bounds (
392
+ & self ,
393
+ colon_span : Option < Span > ,
394
+ bounds : & [ GenericBound ] ,
395
+ negative_bounds : Vec < Span > ,
396
+ ) {
397
+ let negative_bounds_len = negative_bounds. len ( ) ;
398
+ let last_span = * negative_bounds. last ( ) . unwrap ( ) ;
399
+ let mut err = self . struct_span_err (
400
+ negative_bounds,
401
+ "negative bounds are not supported" ,
402
+ ) ;
403
+ err. span_label ( last_span, "negative bounds are not supported" ) ;
404
+ if let Some ( bound_list) = colon_span {
405
+ let bound_list = bound_list. to ( self . prev_span ) ;
406
+ let mut new_bound_list = String :: new ( ) ;
407
+ if !bounds. is_empty ( ) {
408
+ let mut snippets = bounds. iter ( ) . map ( |bound| self . span_to_snippet ( bound. span ( ) ) ) ;
409
+ while let Some ( Ok ( snippet) ) = snippets. next ( ) {
410
+ new_bound_list. push_str ( " + " ) ;
411
+ new_bound_list. push_str ( & snippet) ;
412
+ }
413
+ new_bound_list = new_bound_list. replacen ( " +" , ":" , 1 ) ;
414
+ }
415
+ err. span_suggestion_hidden (
416
+ bound_list,
417
+ & format ! ( "remove the bound{}" , pluralize!( negative_bounds_len) ) ,
418
+ new_bound_list,
419
+ Applicability :: MachineApplicable ,
420
+ ) ;
421
+ }
422
+ err. emit ( ) ;
423
+ }
424
+
417
425
/// Parses a bound according to the grammar:
418
426
/// ```
419
427
/// BOUND = TY_BOUND | LT_BOUND
0 commit comments