@@ -15,7 +15,7 @@ use rustc_middle::ty::print::with_crate_prefix;
1515use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt , TypeFoldable , WithConstness } ;
1616use rustc_span:: lev_distance;
1717use rustc_span:: symbol:: { kw, sym, Ident } ;
18- use rustc_span:: { source_map, FileName , MultiSpan , Span } ;
18+ use rustc_span:: { source_map, FileName , MultiSpan , Span , Symbol } ;
1919use rustc_trait_selection:: traits:: query:: evaluate_obligation:: InferCtxtExt ;
2020use rustc_trait_selection:: traits:: { FulfillmentError , Obligation } ;
2121
@@ -1301,7 +1301,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13011301 // We don't want to suggest a container type when the missing
13021302 // method is `.clone()` or `.deref()` otherwise we'd suggest
13031303 // `Arc::new(foo).clone()`, which is far from what the user wants.
1304- let skip = skippable. contains ( & did) ;
1304+ // Explicitly ignore the `Pin::as_ref()` method as `Pin` does not
1305+ // implement the `AsRef` trait.
1306+ let skip = skippable. contains ( & did)
1307+ || ( ( "Pin::new" == * pre)
1308+ && ( Symbol :: intern ( "as_ref" ) == item_name. name ) ) ;
13051309 // Make sure the method is defined for the *actual* receiver: we don't
13061310 // want to treat `Box<Self>` as a receiver if it only works because of
13071311 // an autoderef to `&self`
0 commit comments