@@ -2403,13 +2403,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2403
2403
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
2404
2404
// instead we suggest `T: 'a + 'b` in that case.
2405
2405
let hir_generics = self . tcx . hir ( ) . get_generics ( scope) . unwrap ( ) ;
2406
- let sugg_span = match hir_generics
2407
- . bounds_span_for_suggestions_with_parentheses ( def_id)
2406
+ let sugg_span = match hir_generics. bounds_span_for_suggestions ( def_id)
2408
2407
{
2409
- Some ( ( span, needs_parentheses ) ) => Some ( ( span, true , needs_parentheses ) ) ,
2408
+ Some ( ( span, open_paren_sp ) ) => Some ( ( span, true , open_paren_sp ) ) ,
2410
2409
// If `param` corresponds to `Self`, no usable suggestion span.
2411
2410
None if generics. has_self && param. index == 0 => None ,
2412
- None => Some ( ( self . tcx . def_span ( def_id) . shrink_to_hi ( ) , false , false ) ) ,
2411
+ None => Some ( ( self . tcx . def_span ( def_id) . shrink_to_hi ( ) , false , None ) ) ,
2413
2412
} ;
2414
2413
( scope, sugg_span)
2415
2414
}
@@ -2432,15 +2431,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2432
2431
let mut suggs = vec ! [ ] ;
2433
2432
let lt_name = self . suggest_name_region ( sub, & mut suggs) ;
2434
2433
2435
- if let Some ( ( sp, has_lifetimes, needs_parentheses ) ) = type_param_sugg_span
2434
+ if let Some ( ( sp, has_lifetimes, open_paren_sp ) ) = type_param_sugg_span
2436
2435
&& suggestion_scope == type_scope
2437
2436
{
2438
2437
let suggestion =
2439
2438
if has_lifetimes { format ! ( " + {lt_name}" ) } else { format ! ( ": {lt_name}" ) } ;
2440
2439
2441
- if needs_parentheses {
2442
- suggs. push ( ( sp . shrink_to_lo ( ) , "(" . to_string ( ) ) ) ;
2443
- suggs. push ( ( sp. shrink_to_hi ( ) , format ! ( "){suggestion}" ) ) ) ;
2440
+ if let Some ( open_paren_sp ) = open_paren_sp {
2441
+ suggs. push ( ( open_paren_sp , "(" . to_string ( ) ) ) ;
2442
+ suggs. push ( ( sp, format ! ( "){suggestion}" ) ) ) ;
2444
2443
} else {
2445
2444
suggs. push ( ( sp, suggestion) )
2446
2445
}
0 commit comments