E0609 No Field Fix
A dot, a name, and a type that has no field by that name: a typo, a field that belongs to a different struct, a position past the end of a tuple struct, a wrapper still around the struct, a generic parameter with no such guarantee. This guide separates the shapes that produce E0609 and matches each one to the change that makes the access name a field the type actually has.
Written November 23, 2026 · Tested with Rust 1.99.1 · 31 min read
- The rule underneath: a dot access is checked against the field list of the type named in the header
- How to read the diagnostic
- The first failure: a misspelled field on a named struct
- The second failure: a field that exists on a different struct
Written November 23, 2026
Tested with Rust 1.99.1
What this guide is
Error E0609 is a name that does not match. The error codes index states it in one line: an attempted access to a nonexistent field in a struct. The header names both halves of the mismatch: "no field emial on type User" - the field name the code wrote, and the type the compiler checked it against. The access fails on the name alone: the field list of a struct is fixed by its definition, and a name that is not in that list is rejected however plausible it looks. The index gives the whole diagnosis in its fix line: check that you did not misspell the field's name, or that the field actually exists.
The forms in this guide each reproduce E0609 with a small, complete program, and each fails for a different reason. A misspelled field on a named struct. A field that exists - on a different struct standing in the same scope. A numeric position past the end of a tuple struct. A named field on a tuple struct, whose fields have positions and no names. A struct's own field, read while an Option still wraps the struct. A misspelled field read through a reference, where the header names the reference type. A field read on a generic type parameter, which carries no fields at all until a trait provides access. And a field read on an array, whose elements are not named fields. In each family the failing program is small, the full compiler output is shown, and the fix makes the access name something the type has: correct the spelling, read the field on the value that has it, use a position that exists, get the struct out of its wrapper first, or go through a trait method instead of a field.
Five neighboring results are not E0609 and are worked only in the traps and the decision summary. A field that exists but is private is E0616 - visibility fails, not existence. A field read on a primitive type is E0610 - a primitive has no fields to misspell. Indexing into a struct with square brackets is E0608. Calling a field as though it were a method is E0599, no method named. And reading a method as though it were a field, without the call parentheses, is E0615.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.
The rule underneath: a dot access is checked against the field list of the type named in the header
A struct definition fixes the names and types of its pieces of data, which the Book's struct chapter calls its fields, and getting a value out of an instance is dot notation against exactly those names: user1.email reads the email field because the definition declares one. There is no fallback - no other struct's field list is consulted, no method is tried under the same name, and no similar name is silently substituted. The compiler does often print the substitution it believes was meant, as a help - "a field with a similar name exists" - or the list it checked against, as a note: "available fields are: width, height". Those two lines are the fastest read of the error: if the intended field is in the list or in the help, the name was the problem; if it is in neither, the value is not the type the code took it for.
That second case is why the type in the header matters as much as the field name. A field expression, as the Reference describes it, is a container operand, a dot, and an identifier - and when the container's type implements Deref, it is automatically dereferenced as many times as necessary to make the field access possible. That autoderef is why a misspelling through a &Rectangle reports "no field wdith on type &Rectangle": the reference would have been followed to the struct's fields, so the check is the struct's field list, named under the type the expression started from. Autoderef follows references and Box-like dereference; it does not unwrap an Option. Option<User> is a different type from User, with no name field of its own, so maybe.name fails even though the struct inside has exactly that field - the wrapper has to come off first, by a match, an if let, or another deliberate handling of the empty case. The same logic reaches generic code from the other side: a type parameter T stands for a type the function does not know, traits cannot require fields, and so value.name on a &T fails with the parameter itself named in the header - the guarantee a field access needs cannot be written as a bound, and the value has to be exposed through a trait method instead.
Two consequences follow. First, the fix is always one of a small set of moves, and the header picks between them: if the type in the header is the type intended, fix the name (or the position, on a tuple struct); if the type in the header is not the type intended - a wrapper, a sibling struct, a type parameter - fix which value the access runs on, or how that value is reached. Second, existence is its own question, distinct from visibility and from kind. The same dot access can fail because the field does not exist (E0609), because it exists and is private (E0616), or because the name belongs to a method rather than a field (E0615 in one direction, E0599 in the other) - and each failure is reported under its own code, so reading which question failed is the whole diagnosis.
How to read the diagnostic
The header gives the two facts everything else hangs on: "no field emial on type User". Read the type first. If it is the struct the code meant to read from, the problem is the name - a spelling, a renamed field the call site predates, or a field that was never added. If it is not - Option<User>, &Rectangle, &T, [{integer}; 3] - the name may be perfectly correct for some other type, and the problem is the value the access actually ran on.
The label under the access is short: "unknown field", pointing at the name or position that failed. What follows it separates the families. A "help: a field with a similar name exists" block rewrites the line with the compiler's best guess - safe to take when the guess is the field intended, and a warning sign when it is not, because accepting it reads a different field than the code meant. A note reading "available fields are: ..." prints the complete list the name was checked against, positions included for a tuple struct, which settles both the spelling question and the does-it-exist question in one line. A help reading "one of the expressions' fields has a field of the same name" appears when the name exists one level in - on a value held in one of the container's own fields, or inside a wrapper such as an Option - and its rewrite inserts the step that reaches it: the field path in the first case (o.inner.email), an unwrap in the second (maybe.unwrap().name). The field-path rewrite is exact; the unwrap rewrite compiles but chooses the panicking route on an empty value, and whether that route is acceptable is a decision the diagnostic deliberately does not make. And when no help and no list appear - the generic-parameter and array families below - the absence is itself the information: there is no near name to offer, because the type has no field list of the kind the access assumed.
The first failure: a misspelled field on a named struct
User declares username and email. The access writes emial - two letters transposed. This is the shape of the error codes index's own erroneous example, a field name that is not in the struct's list:
struct User {
username: String,
email: String,
}
fn main() {
let user = User {
username: String::from("ada"),
email: String::from("ada@example.com"),
};
println!("{}", user.emial);
}
$ rustc --edition 2021 fail_misspell.rs -o fail_misspell
error[E0609]: no field `emial` on type `User`
--> fail_misspell.rs:11:25
|
11 | println!("{}", user.emial);
| ^^^^^ unknown field
|
help: a field with a similar name exists
|
11 - println!("{}", user.emial);
11 + println!("{}", user.email);
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
The type in the header is the right type, and the help names the intended field exactly: "a field with a similar name exists", with the line rewritten as user.email. When the help's guess is the field the code meant, the fix is that rewrite:
struct User {
username: String,
email: String,
}
fn main() {
let user = User {
username: String::from("ada"),
email: String::from("ada@example.com"),
};
println!("{} {}", user.username, user.email);
}
$ rustc --edition 2021 fix_misspell.rs -o fix_misspell
$ ./fix_misspell
ada ada@example.com
The output is ada ada@example.com, the username and the correctly spelled email field. Read the help's guess before accepting it, though: the compiler offers the closest name it has, and on a struct with several similar fields - email beside email_verified, say - the closest name can be a real field that is not the one intended, in which case the corrected program compiles and quietly reads the wrong data.
The second failure: a field that exists on a different struct
radius is a real field name in this program - on Circle. The access reads it on a Rectangle, whose fields are width and height:
struct Rectangle {
width: u32,
height: u32,
}
struct Circle {
radius: u32,
}
fn main() {
let rect = Rectangle { width: 30, height: 50 };
let circle = Circle { radius: 7 };
println!("{}", rect.radius);
println!("{}", circle.radius);
}
$ rustc --edition 2021 fail_other_struct.rs -o fail_other_struct
error[E0609]: no field `radius` on type `Rectangle`
--> fail_other_struct.rs:13:25
|
13 | println!("{}", rect.radius);
| ^^^^^^ unknown field
|
= note: available fields are: `width`, `height`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
There is no similar-name help here, because radius is not close to either real field - instead the note prints the whole list the name was checked against: "available fields are: width, height". That list is the tell for this family: the name is spelled correctly and exists somewhere in the program, just not on this type, so no respelling fixes it. Either the wrong value was named, as here, or the code was written against a shape the type no longer has. The fix reads each field on the value that has it:
struct Rectangle {
width: u32,
height: u32,
}
struct Circle {
radius: u32,
}
fn main() {
let rect = Rectangle { width: 30, height: 50 };
let circle = Circle { radius: 7 };
println!("{}", rect.width * rect.height);
println!("{}", circle.radius);
}
$ rustc --edition 2021 fix_other_struct.rs -o fix_other_struct
$ ./fix_other_struct
1500
7
The output is 1500, the rectangle's area from its own two fields, then 7, the circle's radius read on the circle. When this family appears in larger code, it usually means two values of different types were confused at a call site - the variable, not the field, is the side to change - or a computation genuinely needs a value the type does not store, which is a method to write or a field to add, not a name to hunt for.
The third failure: a numeric index past the end of a tuple struct
A tuple struct's fields have no names, only positions, and the Book's struct chapter covers the access form: a dot followed by the index, as with a tuple. Pair declares two fields, positions 0 and 1. The access asks for position 2:
struct Pair(i32, i32);
fn main() {
let p = Pair(3, 4);
println!("{}", p.2);
}
$ rustc --edition 2021 fail_tuple_index.rs -o fail_tuple_index
error[E0609]: no field `2` on type `Pair`
--> fail_tuple_index.rs:5:22
|
5 | println!("{}", p.2);
| ^ unknown field
|
= note: available fields are: `0`, `1`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
The header treats the position as a field name - "no field 2 on type Pair" - and the note lists the positions that exist, "0, 1", in the same "available fields" form as the named-field family. A position past the end fails at compile time under E0609; it is not a runtime bounds check and cannot panic, because the field list, positions included, is part of the type. The fix uses a position the declaration has:
struct Pair(i32, i32);
fn main() {
let p = Pair(3, 4);
println!("{}, {}", p.0, p.1);
}
$ rustc --edition 2021 fix_tuple_index.rs -o fix_tuple_index
$ ./fix_tuple_index
3, 4
The output is 3, 4, the two fields in declaration order. When the code genuinely needs a third value, the type is the side that is short: Pair grows a third field, and every construction of a Pair in the program then has to supply it - the same trade as adding a named field, made in the declaration rather than at the access.
The fourth failure: a named field on a tuple struct
The mirror image of the previous family. Point is a tuple struct, so its fields are positions - but the access asks for a name, x, as though Point were a braced struct:
struct Point(i32, i32);
fn main() {
let p = Point(3, 4);
println!("{}", p.x);
}
$ rustc --edition 2021 fail_tuple_named.rs -o fail_tuple_named
error[E0609]: no field `x` on type `Point`
--> fail_tuple_named.rs:5:22
|
5 | println!("{}", p.x);
| ^ unknown field
|
help: a field with a similar name exists
|
5 - println!("{}", p.x);
5 + println!("{}", p.0);
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
The help gives this family away: the "similar name" it offers for x is 0, the first position - the compiler is mapping the intended first coordinate onto the position that holds it. The fix takes the position:
struct Point(i32, i32);
fn main() {
let p = Point(3, 4);
println!("{}, {}", p.0, p.1);
}
$ rustc --edition 2021 fix_tuple_named.rs -o fix_tuple_named
$ ./fix_tuple_named
3, 4
The output is 3, 4. If names are what the code keeps reaching for - several accesses, or coordinates that are easy to swap by position - that is the signal to convert the tuple struct into a braced struct with named fields x and y, a change to the declaration and its constructions, after which p.x is the correct spelling of the access rather than an error.
The fifth failure: a field read through an Option
The name is right and the struct is right - but the value in hand is not the struct. maybe is an Option<User>, and name is a field of the User inside it, not of the Option:
struct User {
name: String,
}
fn main() {
let maybe = Some(User { name: String::from("Ada") });
println!("{}", maybe.name);
}
$ rustc --edition 2021 fail_option.rs -o fail_option
error[E0609]: no field `name` on type `Option<User>`
--> fail_option.rs:7:26
|
7 | println!("{}", maybe.name);
| ^^^^ unknown field
|
help: one of the expressions' fields has a field of the same name
|
7 | println!("{}", maybe.unwrap().name);
| +++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
The header's type is the whole diagnosis: "on type Option<User>", not "on type User". The help confirms the name exists one level in - "one of the expressions' fields has a field of the same name" - and rewrites the line with .unwrap() inserted. That rewrite compiles, and it panics at runtime whenever the value is None, so it is the right fix only where the empty case cannot occur or a panic is the intended handling. The deliberate fix handles both cases and reads the field on the unwrapped value:
struct User {
name: String,
}
fn main() {
let maybe = Some(User { name: String::from("Ada") });
if let Some(user) = maybe {
println!("{}", user.name);
}
}
$ rustc --edition 2021 fix_option.rs -o fix_option
$ ./fix_option
Ada
The output is Ada. The same shape appears with every wrapper that does not dereference to the struct - a Vec<User> read as though it were a User, a Result read before its error case is handled - and the read of the diagnostic is the same each time: trust the type in the header over the type the code was picturing, and put the step that gets from one to the other back into the code.
The sixth failure: a misspelled field read through a reference
area takes its rectangle by reference, and the access inside it misspells width as wdith. Field access through a reference is ordinary - the Reference's autoderef rule follows the reference to the struct's fields - so the failure is the first family's, with one difference worth reading:
struct Rectangle {
width: u32,
height: u32,
}
fn area(rect: &Rectangle) -> u32 {
rect.wdith * rect.height
}
fn main() {
let rect = Rectangle { width: 30, height: 50 };
println!("{}", area(&rect));
}
$ rustc --edition 2021 fail_reference.rs -o fail_reference
error[E0609]: no field `wdith` on type `&Rectangle`
--> fail_reference.rs:7:10
|
7 | rect.wdith * rect.height
| ^^^^^ unknown field
|
help: a field with a similar name exists
|
7 - rect.wdith * rect.height
7 + rect.width * rect.height
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
The header names the type the expression started from - "on type &Rectangle" - not the struct behind it. That naming is consistent across the reference shapes: a &mut, a Box, or any dereferencing container reports under its own type while checking against the fields autoderef reaches, so in a longer chain the header tells you where the access began, and the similar-name help tells you the field list it was checked against. Do not read the & in the header as the problem - the reference is not what failed. The fix is the spelling:
struct Rectangle {
width: u32,
height: u32,
}
fn area(rect: &Rectangle) -> u32 {
rect.width * rect.height
}
fn main() {
let rect = Rectangle { width: 30, height: 50 };
println!("{}", area(&rect));
}
$ rustc --edition 2021 fix_reference.rs -o fix_reference
$ ./fix_reference
1500
The output is 1500, the area computed through the reference. Compare the fifth family: a reference is followed automatically and an Option is not, so the same-looking access value.field is checked against the struct's fields in one case and against the wrapper's own (nonexistent) fields in the other - the header's type is what tells the two situations apart.
The seventh failure: a field read on a generic type parameter
first_name is generic: its parameter is a &T, for a T the function does not choose. Inside the function, the access asks T for a name field - but no type parameter has fields, because T could be a type with none, and a trait bound cannot require a field:
fn first_name<T>(value: &T) -> &str {
value.name
}
struct Person {
name: String,
}
fn main() {
let person = Person { name: String::from("Ada") };
println!("{}", first_name(&person));
}
$ rustc --edition 2021 fail_generic.rs -o fail_generic
error[E0609]: no field `name` on type `&T`
--> fail_generic.rs:2:11
|
1 | fn first_name<T>(value: &T) -> &str {
| - type parameter 'T' declared here
2 | value.name
| ^^^^ unknown field
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
The error is reported inside the generic function, at its definition, before any caller is considered - the note underlines the parameter declaration itself, "type parameter 'T' declared here", and there is no help and no available-fields list, because there is no field list to offer. That the one caller passes a Person, which does have a name field, changes nothing: a generic function must be valid for every type its bounds admit, and an unbounded T admits types with no fields at all. The fix moves the access behind a trait method - the trait requires the method, each type implements it by reading its own field, and the generic function calls the method:
trait HasName {
fn name(&self) -> &str;
}
struct Person {
name: String,
}
impl HasName for Person {
fn name(&self) -> &str {
&self.name
}
}
fn first_name<T: HasName>(value: &T) -> &str {
value.name()
}
fn main() {
let person = Person { name: String::from("Ada") };
println!("{}", first_name(&person));
}
$ rustc --edition 2021 fix_generic.rs -o fix_generic
$ ./fix_generic
Ada
The output is Ada, read through the name method the bound guarantees. When only one concrete type is ever passed, the simpler fix is to drop the generic parameter and take that type - fn first_name(value: &Person) -> &str - after which value.name is an ordinary field access on a known field list. The trait form earns its extra code only when several types genuinely go through the one function.
The eighth failure: a field read on an array
An array's elements are reached by position - indexing, or iteration - and have no names. The access asks the array for a total, as though a summary of the elements were stored on it as a field:
fn main() {
let values = [10, 20, 30];
println!("{}", values.total);
}
$ rustc --edition 2021 fail_array.rs -o fail_array
error[E0609]: no field `total` on type `[{integer}; 3]`
--> fail_array.rs:3:27
|
3 | println!("{}", values.total);
| ^^^^^ unknown field
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
The header names the array type in its full form, "[{integer}; 3]" - element type and length - and, as in the generic family, there is no help and no available-fields list: an array type has no fields to list. What an array does have is methods, reached with the same dot: a total is a computation over the elements, and the standard library expresses it as an iterator method chain, not a stored field. The fix computes it:
fn main() {
let values = [10, 20, 30];
println!("{}", values.iter().sum::<i32>());
}
$ rustc --edition 2021 fix_array.rs -o fix_array
$ ./fix_array
60
The output is 60, the sum of the three elements. This family is most often a kind confusion rather than a spelling slip - the code expected a struct with a total field and was handed the raw collection instead - so when it appears, check where the value came from before rewriting the access: if a summary value is needed in several places, computing it once into a struct with a real total field makes the original spelling correct, on a different value.
The fixes in reach order
- The header names the intended struct and the help offers a similar name that is the field intended: take the help's spelling.
- The note lists "available fields" and the wanted name is not among them: the field does not exist on this type - read it on the value that has it, add the field, or write the method that computes it.
- The access is a number and the note lists positions: the highest position is the field count minus one - use a position in range, or add a field to the tuple struct.
- The access is a name and the type is a tuple struct, with the help offering a position: use the position - or convert the type to a braced struct with named fields if names are what the code keeps reaching for.
- The header's type is a wrapper -
Option<...>,Result<...>- and the help says a field of the same name exists one level in: get the inner value out first, handling the empty or error case deliberately rather than by the help'sunwrapalone. (AVec<...>header is the same existence failure with no such help offered: index or iterate to an element first, then read the field.) - The header's type carries a
&and the help offers a similar name: the reference is fine and autoderef reaches the fields - fix the spelling, exactly as on the owned struct. - The header's type is a type parameter (
&T,T): no field access is possible there - expose the value through a trait method and bound the parameter by that trait, or take the concrete type. - The header's type is an array or another fieldless type and no help is offered: the value wanted is a computation or an element, not a field - use a method, an index, or iteration.
Traps
- A field that exists but is private is E0616, not E0609.
balanceis a declared field ofAccount- the access fails because the field is not public outside its module, not because it is missing:
mod bank {
pub struct Account {
pub owner: String,
balance: i32,
}
impl Account {
pub fn new(owner: String, balance: i32) -> Account {
Account { owner, balance }
}
}
}
use bank::Account;
fn main() {
let account = Account::new(String::from("Ada"), 100);
println!("{}", account.balance);
}
$ rustc --edition 2021 probe_private.rs -o probe_private
error[E0616]: field `balance` of struct `Account` is private
--> probe_private.rs:18:28
|
18 | println!("{}", account.balance);
| ^^^^^^^ private field
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0616`.
balance of struct Account is private" and the label reads "private field" - existence is not in question. The error codes index defines E0616 as an attempted access to a private field on a struct, and gives the two fixes: make the field public, or add a getter method that reads it. Which of those is right is an encapsulation decision - a balance is the classic case for the getter - and neither involves the spelling. If the same access is moved inside the defining module, it compiles unchanged: privacy is about where the access stands, E0609 about whether the field is there at all.
- A field read on a primitive type is E0610, not E0609. An integer is not a struct with a short field list - it has no fields, and the compiler says so in those words rather than reporting a missing name:fn main() {
let x = 5;
println!("{}", x.foo);
}
$ rustc --edition 2021 probe_primitive.rs -o probe_primitive
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> probe_primitive.rs:3:22
|
3 | println!("{}", x.foo);
| ^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0610`.
The header names no field at all - "{integer} is a primitive type and therefore doesn't have fields". The error codes index defines E0610 as an attempted access to a field on a primitive type, and notes that named fields belong to struct types. This shape usually means a variable holds a plainer value than the code assumed - a count where a record was expected - so trace the value's type rather than hunting for a field name.
- Indexing into a struct is E0608, not E0609. Square brackets are not a second spelling of field access: a struct does not implement indexing, so rect[0] fails on the indexing itself, before any field question:
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect = Rectangle { width: 30, height: 50 };
println!("{}", rect[0]);
}
$ rustc --edition 2021 probe_index_struct.rs -o probe_index_struct
error[E0608]: cannot index into a value of type `Rectangle`
--> probe_index_struct.rs:8:24
|
8 | println!("{}", rect[0]);
| ^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0608`.
The header reads "cannot index into a value of type Rectangle". The error codes index defines E0608 as an attempt to index a value whose type does not implement the Index trait, and adds the positive rule this family needs: tuples and structs are indexed with a dot, not with brackets, and tuple element names are their positions. The fix is the dot form - rect.width, or p.0 on a tuple struct - and note the boundary with the third family: the right syntax with a position that does not exist is E0609, while the bracket syntax on a struct is E0608 whatever position it names.
- Calling a field as a method is E0599, not E0609. email exists on User - as a field. Adding call parentheses makes the compiler look for a method of that name, and there is none:
struct User {
email: String,
}
fn main() {
let user = User { email: String::from("ada@example.com") };
println!("{}", user.email());
}
$ rustc --edition 2021 probe_field_as_method.rs -o probe_field_as_method
error[E0599]: no method named `email` found for struct `User` in the current scope
--> probe_field_as_method.rs:7:25
|
1 | struct User {
| ----------- method `email` not found for this struct
...
7 | println!("{}", user.email());
| ^^^^^-- help: remove the arguments
| |
| field, not a method
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0599`.
The header is the method-existence form - "no method named email found for struct User in the current scope", the error the error codes index describes as a method used on a type that does not implement it - and the sub-label settles it: "field, not a method", with a help to remove the arguments. Fields and methods share the dot and live in separate namespaces for this check: parentheses after the name switch the lookup from the field list to the method set, so the same name can be E0609 without parentheses (no such field) and E0599 with them (no such method). The fix is to drop the parentheses and read the field.
- Taking a method as a field is E0615, not E0609. area exists on Rectangle - as a method. Reading it without the call parentheses tries to take the method's value, which Rust does not allow as a field-style read:
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn area(&self) -> u32 {
self.width * self.height
}
}
fn main() {
let rect = Rectangle { width: 30, height: 50 };
println!("{}", rect.area);
}
$ rustc --edition 2021 probe_method_as_field.rs -o probe_method_as_field
error[E0615]: attempted to take value of method `area` on type `Rectangle`
--> probe_method_as_field.rs:14:25
|
14 | println!("{}", rect.area);
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
14 | println!("{}", rect.area());
| ++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0615`.
The label is the mirror of the previous trap's: "method, not a field", and the help performs the fix it names, "use parentheses to call the method". The error codes index defines E0615 as an attempt to access a method like a field. Together the last two traps mark the exact boundary of E0609: the name after the dot is looked up as a field only when it is written as one, and a name that resolves to a method - or fails to resolve as a method, when called - reports under the method codes, not the field code.
Decision summary
- The header says "no field" under E0609, names the intended struct, and the help offers a similar name that is the field intended: a spelling error - take the offered name.
- The header says "no field" under E0609 and the note lists the available fields, with the wanted name absent: the field does not exist on this type - the wrong value was named, the field was never added, or it lives on a different struct.
- The missing name is a number and the available fields are positions: a tuple struct or tuple read past its last position - use a position in range or extend the type.
- The missing name is a word and the type is a tuple struct, with a position offered as the similar name: positions are the only fields there are - use one, or convert the type to named fields.
- The header's type is a wrapper such as
Option<User>: the field belongs to the value inside - unwrap or pattern-match first, deciding the empty case on purpose. - The header's type is a reference such as
&Rectangleand a similar name is offered: autoderef reaches the struct's fields and the spelling failed - correct it as on the owned value. - The header's type is a type parameter such as
&T: fields cannot be required by a bound - expose the value through a trait method, or make the parameter concrete. - The header says "is private" (E0616): the field exists - make it public or add a getter; spelling is not involved.
- The header says a primitive "doesn't have fields" (E0610): the value is plainer than the code assumed - trace its type.
- The header says "cannot index into a value" (E0608): brackets were used where a dot belongs - switch to the field or position form.
- The header says "no method named" and the label says "field, not a method" (E0599): a field was called - drop the parentheses.
- The header says "attempted to take value of method" and the label says "method, not a field" (E0615): a method was read as a field - add the call parentheses.
Checklist
- The type in the header read before the field name: the intended struct, or something else - a wrapper, a reference, a type parameter, a different struct - because that decides whether the name or the value is the side to fix.
- The help and notes read for what they offer: a similar name (spelling), an available-fields list (existence and the complete alternatives), or a field of the same name one level in (a wrapper to remove).
- On a tuple struct, positions counted from the declaration: the access is in range, and a named access converted to the position that holds the value.
- Wrappers handled before the access, not by the access: an
Optionmatched or unwrapped with the empty case decided, rather than a field read attempted through it. - Generics checked for field assumptions: no field read on a type parameter - the value is exposed by a trait method, or the function takes the concrete type.
- The neighboring questions separated: field exists (not E0609), field is visible from here (not E0616), value is a struct at all (not E0610), syntax is a dot rather than brackets (not E0608), and the name is a field rather than a method in either direction (not E0599, not E0615).
- The fixed program run, and its output checked against what the failing program was trying to read.
Related guides on this site
- Fix Rust E0599 "no method named" — Import the Trait, Fix the Receiver, or Use the Current Name
- Fix Rust E0597 "`x` does not live long enough" — a Block Scope, a Stored Reference, a Struct Field, and a Closure Capture
- Fix Rust E0507 "cannot move out of ..." — Vec Index, HashMap Index, a Shared Reference, a Struct Field, and a Mutable Reference
- Fix Rust E0596 "cannot borrow as mutable" — a Vec Without mut, a Function Taking &Vec, a &self Method Pushing to a Field, and a Shared Reference in a Binding
Sources
- Rust, Error codes index: E0609 - the definition of the error: an attempt to access a nonexistent field in a struct, fixed by checking that the field's name was not misspelled or that the field actually exists.
- The Rust Programming Language, Defining and Instantiating Structs - a struct's fields as the named pieces of data in its definition, dot notation to get a value from an instance, and tuple structs whose fields have types and positions but no names, accessed with a dot followed by the index.
- The Rust Programming Language, An Example Program Using Structs - field access on a borrowed struct instance,
rectangle.widthandrectangle.heightthrough a&Rectangle, and descriptive field names in place of tuple index values. - The Rust Reference, Field access expressions - the field expression as a container operand, a dot, and an identifier, evaluating to the location of a field of a struct or union, with automatic dereferencing of the container as many times as necessary to make the access possible.
- Rust, Error codes index: E0616 - the neighboring visibility error: an attempt to access a private field on a struct, fixed by setting the field public or adding a getter function.
- Rust, Error codes index: E0610 - the neighboring kind error: an attempt to access a field on a primitive type; primitive types do not have fields, and named fields belong to struct types.
- Rust, Error codes index: E0608 - the neighboring syntax error: an attempt to index a value whose type does not implement the
Indextrait; tuples and structs are indexed with a dot, not brackets, and tuple element names are their positions. - Rust, Error codes index: E0599 - the neighboring method error: a method used on a type which does not implement it, so the name is not found as a method on the receiver - including a field's name written with call parentheses.
- Rust, Error codes index: E0615 - the neighboring method-as-field error: an attempt to access a method like a field, fixed by adding
()after the name to call it.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.