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