mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-24 02:36:59 +00:00
When looking for the field names and types of a given type, account for tuples. This allows suggestions for incorrectly nested field accesses and field name typos to trigger as intended. Previously these suggestions only worked on `ty::Adt`, including tuple structs which are no different to tuples, so they should behave the same in suggestions. ``` 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(); | ++ ```
18 lines
660 B
Rust
18 lines
660 B
Rust
use std::{fs::File, io::BufReader};
|
|
|
|
struct F(BufReader<File>);
|
|
|
|
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
|
|
}
|