@@ -15,7 +15,7 @@ use rustc_middle::ty::print::with_crate_prefix;
15
15
use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt , TypeFoldable , WithConstness } ;
16
16
use rustc_span:: lev_distance;
17
17
use 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 } ;
19
19
use rustc_trait_selection:: traits:: query:: evaluate_obligation:: InferCtxtExt ;
20
20
use rustc_trait_selection:: traits:: { FulfillmentError , Obligation } ;
21
21
@@ -1301,7 +1301,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1301
1301
// We don't want to suggest a container type when the missing
1302
1302
// method is `.clone()` or `.deref()` otherwise we'd suggest
1303
1303
// `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 ) ) ;
1305
1309
// Make sure the method is defined for the *actual* receiver: we don't
1306
1310
// want to treat `Box<Self>` as a receiver if it only works because of
1307
1311
// an autoderef to `&self`
0 commit comments