about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_typeck/src/check/method/suggest.rs8
-rw-r--r--src/test/ui/typeck/issue-89806.stderr17
2 files changed, 6 insertions, 19 deletions
diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs
index 934b83bd700..8007b9f2377 100644
--- a/compiler/rustc_typeck/src/check/method/suggest.rs
+++ b/compiler/rustc_typeck/src/check/method/suggest.rs
@@ -15,7 +15,7 @@ use rustc_middle::ty::print::with_crate_prefix;
 use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
 use rustc_span::lev_distance;
 use rustc_span::symbol::{kw, sym, Ident};
-use rustc_span::{source_map, FileName, MultiSpan, Span};
+use rustc_span::{source_map, FileName, MultiSpan, Span, Symbol};
 use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
 use rustc_trait_selection::traits::{FulfillmentError, Obligation};
 
@@ -1301,7 +1301,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                             // We don't want to suggest a container type when the missing
                             // method is `.clone()` or `.deref()` otherwise we'd suggest
                             // `Arc::new(foo).clone()`, which is far from what the user wants.
-                            let skip = skippable.contains(&did);
+                            // Explicitly ignore the `Pin::as_ref()` method as `Pin` does not
+                            // implement the `AsRef` trait.
+                            let skip = skippable.contains(&did)
+                                || (("Pin::new" == *pre)
+                                    && (Symbol::intern("as_ref") == item_name.name));
                             // Make sure the method is defined for the *actual* receiver: we don't
                             // want to treat `Box<Self>` as a receiver if it only works because of
                             // an autoderef to `&self`
diff --git a/src/test/ui/typeck/issue-89806.stderr b/src/test/ui/typeck/issue-89806.stderr
index 9a54fac5261..c36b4967ee9 100644
--- a/src/test/ui/typeck/issue-89806.stderr
+++ b/src/test/ui/typeck/issue-89806.stderr
@@ -3,23 +3,6 @@ error[E0599]: no method named `as_ref` found for type `u8` in the current scope
    |
 LL |     0u8.as_ref();
    |         ^^^^^^ method not found in `u8`
-   |
-  ::: $SRC_DIR/core/src/pin.rs:LL:COL
-   |
-LL |     pub fn as_ref(&self) -> Pin<&P::Target> {
-   |            ------
-   |            |
-   |            the method is available for `Pin<&mut u8>` here
-   |            the method is available for `Pin<&u8>` here
-   |
-help: consider wrapping the receiver expression with the appropriate type
-   |
-LL |     Pin::new(&mut 0u8).as_ref();
-   |     +++++++++++++    +
-help: consider wrapping the receiver expression with the appropriate type
-   |
-LL |     Pin::new(&0u8).as_ref();
-   |     ++++++++++   +
 
 error: aborting due to previous error