about summary refs log tree commit diff
path: root/tests/ui/tuple
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-07-29 20:14:02 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-08-07 21:39:00 +0000
commitdd3b8255ca6215b5129181ceb6912aed1370bdce (patch)
treef1964d1ee7121e7be5620ece793f745e90681d1c /tests/ui/tuple
parent26c12c746296e01c2dc13d8078b0a2f1569fcb1c (diff)
downloadrust-dd3b8255ca6215b5129181ceb6912aed1370bdce.tar.gz
rust-dd3b8255ca6215b5129181ceb6912aed1370bdce.zip
Do not suggest pinning missing `.get_ref()`
When suggesting field access which would encounter a method not found, do not suggest pinning when those methods are on `impl Pin` itself.

```
error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope
  --> $DIR/missing-field-access.rs:11:15
   |
LL |     let x = f.get_ref();
   |               ^^^^^^^ method not found in `(BufReader<File>,)`
   |
help: one of the expressions' fields has a method of the same name
   |
LL |     let x = f.0.get_ref();
   |               ++
```
instead of
```
error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope
  --> $DIR/missing-field-access.rs:11:15
   |
LL |     let x = f.get_ref();
   |               ^^^^^^^ method not found in `(BufReader<File>,)`
   |
help: one of the expressions' fields has a method of the same name
   |
LL |     let x = f.0.get_ref();
   |               ++
help: consider pinning the expression
   |
LL ~     let mut pinned = std::pin::pin!(f);
LL ~     let x = pinned.as_ref().get_ref();
   |
```
Diffstat (limited to 'tests/ui/tuple')
-rw-r--r--tests/ui/tuple/missing-field-access.rs9
-rw-r--r--tests/ui/tuple/missing-field-access.stderr14
2 files changed, 6 insertions, 17 deletions
diff --git a/tests/ui/tuple/missing-field-access.rs b/tests/ui/tuple/missing-field-access.rs
index 4ccd759ccd2..b94b7cf977c 100644
--- a/tests/ui/tuple/missing-field-access.rs
+++ b/tests/ui/tuple/missing-field-access.rs
@@ -1,3 +1,7 @@
+// Ensure that suggestions to search for missing intermediary field accesses are available for both
+// tuple structs *and* regular tuples.
+// Ensure that we do not suggest pinning the expression just because `Pin::get_ref` exists.
+// https://github.com/rust-lang/rust/issues/144602
 use std::{fs::File, io::BufReader};
 
 struct F(BufReader<File>);
@@ -6,12 +10,7 @@ fn main() {
     let f = F(BufReader::new(File::open("x").unwrap()));
     let x = f.get_ref(); //~ ERROR E0599
     //~^ HELP one of the expressions' fields has a method of the same name
-    //~| HELP consider pinning the expression
     let f = (BufReader::new(File::open("x").unwrap()), );
     let x = f.get_ref(); //~ ERROR E0599
     //~^ HELP one of the expressions' fields has a method of the same name
-    //~| HELP consider pinning the expression
-
-    // FIXME(estebank): the pinning suggestion should not be included in either case.
-    // https://github.com/rust-lang/rust/issues/144602
 }
diff --git a/tests/ui/tuple/missing-field-access.stderr b/tests/ui/tuple/missing-field-access.stderr
index 711a8906d62..fd9f01f8ff6 100644
--- a/tests/ui/tuple/missing-field-access.stderr
+++ b/tests/ui/tuple/missing-field-access.stderr
@@ -1,5 +1,5 @@
 error[E0599]: no method named `get_ref` found for struct `F` in the current scope
-  --> $DIR/missing-field-access.rs:7:15
+  --> $DIR/missing-field-access.rs:11:15
    |
 LL | struct F(BufReader<File>);
    | -------- method `get_ref` not found for this struct
@@ -11,14 +11,9 @@ help: one of the expressions' fields has a method of the same name
    |
 LL |     let x = f.0.get_ref();
    |               ++
-help: consider pinning the expression
-   |
-LL ~     let mut pinned = std::pin::pin!(f);
-LL ~     let x = pinned.as_ref().get_ref();
-   |
 
 error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope
-  --> $DIR/missing-field-access.rs:11:15
+  --> $DIR/missing-field-access.rs:14:15
    |
 LL |     let x = f.get_ref();
    |               ^^^^^^^ method not found in `(BufReader<File>,)`
@@ -27,11 +22,6 @@ help: one of the expressions' fields has a method of the same name
    |
 LL |     let x = f.0.get_ref();
    |               ++
-help: consider pinning the expression
-   |
-LL ~     let mut pinned = std::pin::pin!(f);
-LL ~     let x = pinned.as_ref().get_ref();
-   |
 
 error: aborting due to 2 previous errors