Rust
E0610 Field Access on a Primitive Fix
E0610 is the compiler saying a value has no fields to access: primitives such as integers, floats, booleans, and characters hold a single value, not named parts, so x.foo on an integer can never resolve. The repair the error index gives is to hold the data in a struct, whose named fields can be read. This guide shows the error on four primitive types, the struct repair running, and the boundary around the code - the shapes that look like the same mistake but draw a different error, E0609 or E0599, because the value in front of the dot is not itself a primitive.
Written December 1, 2026 · Tested with Rust 1.99.0 · 13 min read
- The rule underneath: primitives have no fields
- How to read the diagnostic
- The first failure: the index example
- The same error across the primitive scalars
Written December 1, 2026
Tested with Rust 1.99.0
What this guide is
Error E0610 is about what kind of value stands in front of the dot. The error codes index opens: "Attempted to access a field on a primitive type." Its erroneous example reads a field named foo on a u32, and its repair declares a struct with two fields and reads those fields instead. Nothing is wrong with the field name as a name - the same name on a struct compiles in this guide's repair. The defect is the type: a primitive holds one value and has no named parts, so there is nothing for a field access to find.
The practical payoff is twofold. First, the repair is a data-modeling step, not a syntax tweak: the parts you want to name have to live in a struct (or be reached another way - a tuple position, or a method the type actually has). Second, the code is narrower than it looks. In the probed set, E0610 fired only when the value itself was a primitive scalar; close shapes - a string, an array, a tuple, a reference - drew E0609, and a method call drew E0599. Knowing which code you actually got tells you which situation you are in. A neighboring field error is E0609, no field on a type that could have fields; E0610 is the case where the type cannot have fields at all. A struct that lacks the named field is E0560.
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: primitives have no fields
A field access value.field asks for a named part of value. Structs are the types built for that: a struct definition names its fields, and each instance stores a value per field. The primitive types - integers, floats, bool, char - store a single value with no named parts. The error index states it plainly: "Primitive types are the most basic types available in Rust and don't have fields. To access data via named fields, struct types are used."
The diagnostic says the same thing in one line, naming the concrete type: "u32 is a primitive type and therefore doesn't have fields". There is no suggestion to rename the field and no list of available fields, because there are none to list. When the fix is applied, it changes the type of the data, not the spelling of the access.
How to read the diagnostic
In the probed set, an E0610 failure is a single error. The header names the concrete primitive type and states that it does not have fields. The span is short: three carets under the field name alone - not the whole expression, and not the variable. The variable's type is what the header reports, so read the two together: the caret shows where the access was attempted, and the header shows why that type can never satisfy it.
There is no note and no help line in the probed E0610 diagnostics. That absence is itself a signal: the compiler has no nearby field to suggest, because the type has no fields at all. The neighboring codes behave differently, as the boundary section below shows - E0609 on a tuple adds a note listing the available positions, which E0610 never does.
The first failure: the index example
The smallest shape is the error index's own, an integer with a named field read:
fn main() {
let x: u32 = 0;
println!("{}", x.foo);
}
error[E0610]: `u32` is a primitive type and therefore doesn't have fields
--> int.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 u32, the carets sit under foo, and that is the whole diagnostic. The value 0 and the println! around the access play no part: any named field on this variable, read anywhere, draws the same code, because the type is the problem.
The same error across the primitive scalars
A float fails identically, with its own type named in the header:
fn main() {
let x: f64 = 1.5;
println!("{}", x.foo);
}
error[E0610]: `f64` is a primitive type and therefore doesn't have fields
--> float.rs:3:22
|
3 | println!("{}", x.foo);
| ^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0610`.
A boolean fails the same way:
fn main() {
let x: bool = true;
println!("{}", x.foo);
}
error[E0610]: `bool` is a primitive type and therefore doesn't have fields
--> bool.rs:3:22
|
3 | println!("{}", x.foo);
| ^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0610`.
And a character fails the same way:
fn main() {
let x: char = 'a';
println!("{}", x.foo);
}
error[E0610]: `char` is a primitive type and therefore doesn't have fields
--> char.rs:3:22
|
3 | println!("{}", x.foo);
| ^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0610`.
In the probed set the four scalar primitives - integer, float, boolean, character - produced the identical diagnostic shape: one E0610 error, the concrete type named in the header, three carets under the field name, no note, no help. Which primitive you started from changes only the type name in the header. The repair is the same for all of them, because the missing thing is the same: a type with fields.
The boundary: shapes that draw E0609 instead
The code stops at the primitive scalars. A string slice is not one of them for this diagnostic: the same access on a &str draws E0609, "no field on type", with the carets labeled "unknown field":
fn main() {
let s: &str = "hi";
println!("{}", s.foo);
}
error[E0609]: no field `foo` on type `&str`
--> strslice.rs:3:22
|
3 | println!("{}", s.foo);
| ^^^ unknown field
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
An owned String draws the same E0609:
fn main() {
let s: String = String::from("hi");
println!("{}", s.foo);
}
error[E0609]: no field `foo` on type `String`
--> string.rs:3:22
|
3 | println!("{}", s.foo);
| ^^^ unknown field
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
An array draws E0609 as well - an array has positions, reached by indexing, but no named fields:
fn main() {
let a: [i32; 3] = [1, 2, 3];
println!("{}", a.foo);
}
error[E0609]: no field `foo` on type `[i32; 3]`
--> array.rs:3:22
|
3 | println!("{}", a.foo);
| ^^^ unknown field
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
A tuple with a named field draws E0609 too, and here the diagnostic adds the note E0610 never has: it lists the fields the tuple does have, its numbered positions:
fn main() {
let t: (i32, i32) = (1, 2);
println!("{}", t.foo);
}
error[E0609]: no field `foo` on type `(i32, i32)`
--> tuple_named.rs:3:22
|
3 | println!("{}", t.foo);
| ^^^ 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`.
Most surprising in the probed set: putting a reference in front of the access changes the code. A reference to an integer is not itself the integer, and r.foo on a &u32 draws E0609 naming the reference type:
fn main() {
let x: u32 = 0;
let r: &u32 = &x;
println!("{}", r.foo);
}
error[E0609]: no field `foo` on type `&u32`
--> refprim.rs:4:22
|
4 | println!("{}", r.foo);
| ^^^ unknown field
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0609`.
So the line the compiler draws, in this probed set, is exact: E0610 when the value's own type is a primitive scalar; E0609 when the value's type is anything else that lacks the named field - a string slice, a String, an array, a tuple, or a reference. The mistake looks identical at the keyboard. The code in the header tells you which side of the line the value's type is on, and the repair differs: E0609 can mean the field name is wrong on a type that has fields, while E0610 always means the type itself must change.
The lookalike: a method call is E0599
Adding parentheses changes the question. x.foo asks for a field; x.foo() asks for a method - and a missing method on an integer is E0599, not E0610:
fn main() {
let x: u32 = 0;
println!("{}", x.foo());
}
error[E0599]: no method named `foo` found for type `u32` in the current scope
--> methodcall.rs:3:22
|
3 | println!("{}", x.foo());
| ^^^ method not found in `u32`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0599`.
The header names the missing method and the type it was looked for on, and the carets are labeled "method not found". If your error is E0599, the type may well have the capability under another name - integers have real methods, such as to_string - and the fix is to call one that exists or define the behavior another way. If your error is E0610, no field name will work, because there are no fields. Checking whether your code has parentheses after the name is the fastest way to tell the two situations apart.
The repair: hold the data in a struct
The error index's repair gives the data a struct type with named fields, and then reads those fields with the same dot syntax that failed on the integer:
struct Foo {
x: u32,
y: i64,
}
fn main() {
let variable = Foo { x: 0, y: -12 };
println!("x: {}, y: {}", variable.x, variable.y);
}
x: 0, y: -12
The output is x: 0, y: -12 - the two values stored in the instance, read back through the field names. The access expression did not change in kind: variable.x is the same shape as x.foo. What changed is the type of the value in front of the dot, from a primitive with no fields to a struct whose definition names x and y. That is the whole repair for E0610: wherever you were reading named parts off a primitive, define a struct with those names as fields, construct it with the values, and read the fields off the struct.
The controls: tuple positions, and a field through a reference
Two controls bound the rule. First, a tuple's parts are reachable - by number, not by name. The same tuple that rejected .foo with E0609 gives up both values through its positions:
fn main() {
let t: (i32, i32) = (3, 4);
println!("{} {}", t.0, t.1);
}
3 4
The output is 3 4. If the data has a fixed small number of parts and their order is their meaning, a tuple with numbered access may be all you need; if the parts need names, that is the struct repair above.
Second, a reference does not block a field read when the value behind it has the field. A &Foo reads x directly:
struct Foo {
x: u32,
}
fn main() {
let f = Foo { x: 7 };
let r: &Foo = &f;
println!("{}", r.x);
}
7
The output is 7. Field access automatically dereferences, so a reference to a struct behaves like the struct for reading fields. Contrast the &u32 case above: the reference was not the obstacle there either - the integer behind it has no field, and the compiler reported the reference type with E0609. References are transparent to field access; what matters is whether the type ultimately reached has the field, and whether the value's own type is a primitive scalar, which is what selects E0610 over E0609.
Fixes in reach order
First, read the header's code before changing anything. E0610 means the value's own type is a primitive scalar: no field name exists for it, so do not hunt for a correct spelling. E0609 means the type lacks that field - check the name against the type's fields first. E0599 means the parentheses made it a method call: look for a method that exists.
Second, for E0610, give the data a struct. Define a struct with a field for each named part you were trying to read, construct an instance holding the values, and read the fields off the instance. That is the error index's repair, and in the probed set it compiled and ran with the accesses unchanged in shape.
Third, if the parts do not need names, use the access the type already supports: tuple positions by number (t.0, t.1), array and slice elements by index, and a primitive's own methods (such as an integer's to_string) for behavior. These are not workarounds for E0610 - they are the operations those types actually offer.
Last, check for a modeling slip upstream: a primitive standing where a record belongs - a bare integer carrying what should be a row, a reading, or a configuration - will keep drawing field errors at every part read. Moving the struct definition to where the value is created fixes the whole family of accesses at once, not one read at a time.
Decision summary
E0610, in this guide's probed set, fired exactly when a named field was read on a value whose own type was a primitive scalar: an integer, a float, a boolean, and a character each produced the single error naming that type, with carets under the field name and no note or help. The same access on a string slice, a String, an array, a tuple, and a reference to an integer produced E0609 instead, and a method call on an integer produced E0599. The error index's struct repair compiled and ran, reading both fields back. Tuple positions read by number worked, and a field read through a reference to a struct worked by automatic dereferencing.
Checklist
- Read the code in the header first: E0610 (the type is primitive), E0609 (the type lacks that field), and E0599 (a method call, not a field) are three different situations with three different repairs.
- Do not rename the field on an E0610: the diagnostic lists no available fields because the type has none; the type is what must change.
- Give named parts a struct: define the fields, construct the instance, and read the fields off it - the access syntax stays the same.
- Remember the reference case: a field read on a reference to a primitive draws E0609 naming the reference type, not E0610 - check the value's own type, not the expression's surface.
- Use what the type offers when names are not needed: tuple positions by number, elements by index, and the primitive's real methods for behavior.
- If field errors repeat on the same primitive, look upstream: the value probably should have been a struct from where it was created.
Related guides on this site
- E0026 Struct Variant Has No Field Fix
- Field Specified More Than Once E0062 Fix
- Tuple Pattern Field Count E0023 Fix
- E0451 Private Struct Field Fix
Sources
- Rust error codes index, E0610 - attempted to access a field on a primitive type; the erroneous example reading
x.fooon au32, the statement that primitive types do not have fields and that struct types are used to access data via named fields, and the struct repair reading both fields back. - Rust error codes index, E0609 - the neighboring code the probed boundary shapes drew: no field on a type, for the string slice,
String, array, tuple, and reference shapes in this guide. - The Rust Programming Language, Defining and Instantiating Structs - how a struct definition names its fields and how an instance is constructed and its fields read, the mechanism the repair uses.
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.