@@ -430,12 +430,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
430
430
actual. prefix_string( self . tcx) ,
431
431
ty_str_reported,
432
432
) ;
433
- if let Mode :: MethodCall = mode {
434
- if let SelfSource :: MethodCall ( call) = source {
435
- self . suggest_await_before_method (
436
- & mut err, item_name, actual, call, span,
437
- ) ;
438
- }
433
+ if let Mode :: MethodCall = mode && let SelfSource :: MethodCall ( cal) = source {
434
+ self . suggest_await_before_method (
435
+ & mut err, item_name, actual, cal, span,
436
+ ) ;
439
437
}
440
438
if let Some ( span) =
441
439
tcx. resolutions ( ( ) ) . confused_type_with_std_module . get ( & span)
@@ -1525,43 +1523,41 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1525
1523
( self . tcx . mk_diagnostic_item ( * rcvr_ty, sym:: Arc ) , "Arc::new" ) ,
1526
1524
( self . tcx . mk_diagnostic_item ( * rcvr_ty, sym:: Rc ) , "Rc::new" ) ,
1527
1525
] {
1528
- if let Some ( new_rcvr_t) = * rcvr_ty {
1529
- if let Ok ( pick) = self . lookup_probe (
1530
- span,
1531
- item_name,
1532
- new_rcvr_t,
1533
- rcvr,
1534
- crate :: check:: method:: probe:: ProbeScope :: AllTraits ,
1535
- ) {
1536
- debug ! ( "try_alt_rcvr: pick candidate {:?}" , pick) ;
1537
- let did = Some ( pick. item . container . id ( ) ) ;
1538
- // We don't want to suggest a container type when the missing
1539
- // method is `.clone()` or `.deref()` otherwise we'd suggest
1540
- // `Arc::new(foo).clone()`, which is far from what the user wants.
1541
- // Explicitly ignore the `Pin::as_ref()` method as `Pin` does not
1542
- // implement the `AsRef` trait.
1543
- let skip = skippable. contains ( & did)
1544
- || ( ( "Pin::new" == * pre) && ( sym:: as_ref == item_name. name ) ) ;
1545
- // Make sure the method is defined for the *actual* receiver: we don't
1546
- // want to treat `Box<Self>` as a receiver if it only works because of
1547
- // an autoderef to `&self`
1548
- if pick. autoderefs == 0 && !skip {
1549
- err. span_label (
1550
- pick. item . ident ( self . tcx ) . span ,
1551
- & format ! ( "the method is available for `{}` here" , new_rcvr_t) ,
1552
- ) ;
1553
- err. multipart_suggestion (
1554
- "consider wrapping the receiver expression with the \
1555
- appropriate type",
1556
- vec ! [
1557
- ( rcvr. span. shrink_to_lo( ) , format!( "{}({}" , pre, post) ) ,
1558
- ( rcvr. span. shrink_to_hi( ) , ")" . to_string( ) ) ,
1559
- ] ,
1560
- Applicability :: MaybeIncorrect ,
1561
- ) ;
1562
- // We don't care about the other suggestions.
1563
- alt_rcvr_sugg = true ;
1564
- }
1526
+ if let Some ( new_rcvr_t) = * rcvr_ty && let Ok ( pick) = self . lookup_probe (
1527
+ span,
1528
+ item_name,
1529
+ new_rcvr_t,
1530
+ rcvr,
1531
+ crate :: check:: method:: probe:: ProbeScope :: AllTraits ,
1532
+ ) {
1533
+ debug ! ( "try_alt_rcvr: pick candidate {:?}" , pick) ;
1534
+ let did = Some ( pick. item . container . id ( ) ) ;
1535
+ // We don't want to suggest a container type when the missing
1536
+ // method is `.clone()` or `.deref()` otherwise we'd suggest
1537
+ // `Arc::new(foo).clone()`, which is far from what the user wants.
1538
+ // Explicitly ignore the `Pin::as_ref()` method as `Pin` does not
1539
+ // implement the `AsRef` trait.
1540
+ let skip = skippable. contains ( & did)
1541
+ || ( ( "Pin::new" == * pre) && ( sym:: as_ref == item_name. name ) ) ;
1542
+ // Make sure the method is defined for the *actual* receiver: we don't
1543
+ // want to treat `Box<Self>` as a receiver if it only works because of
1544
+ // an autoderef to `&self`
1545
+ if pick. autoderefs == 0 && !skip {
1546
+ err. span_label (
1547
+ pick. item . ident ( self . tcx ) . span ,
1548
+ & format ! ( "the method is available for `{}` here" , new_rcvr_t) ,
1549
+ ) ;
1550
+ err. multipart_suggestion (
1551
+ "consider wrapping the receiver expression with the \
1552
+ appropriate type",
1553
+ vec ! [
1554
+ ( rcvr. span. shrink_to_lo( ) , format!( "{}({}" , pre, post) ) ,
1555
+ ( rcvr. span. shrink_to_hi( ) , ")" . to_string( ) ) ,
1556
+ ] ,
1557
+ Applicability :: MaybeIncorrect ,
1558
+ ) ;
1559
+ // We don't care about the other suggestions.
1560
+ alt_rcvr_sugg = true ;
1565
1561
}
1566
1562
}
1567
1563
}
0 commit comments