E0118 Inherent Impl on Non-Nominal Type Fix
Written December 3, 2026 · Tested with Rust 1.99.1 · 20 min read
- The rule underneath: an inherent impl needs a nominal type
- How to read the diagnostic
- The first failure: the index example
- The same error through an alias
Written December 3, 2026
Tested with Rust 1.99.1
What this guide is
Error E0118 means an inherent implementation was defined for something which isn't a struct, enum, union, or trait object - in the index's words, no nominal type was found for the inherent implementation. The error codes index example puts an inherent impl directly on a generic parameter, impl<T> T, and its advice is to implement a trait on the type instead, or wrap it in a struct.
In the shapes probed in this guide, the index example verbatim drew one E0118 plus one E0308 - and the E0308 is separable: it comes from the example's elided method body, not from the impl target, and the same impl header with a complete body drew exactly one E0118 and no other code. E0118 fired on its own in the probed shapes for a generic parameter with a trait bound, for the same header reached through a type alias, and alongside an unresolved name as a ride-along pair. The count follows the impl blocks, in the probed shapes: two methods inside one offending block drew one report, and two offending blocks drew two. Neighboring shapes draw a different code instead: an inherent impl on a primitive type, a reference, a slice, an array, a tuple, a function pointer, a raw pointer, or the str type drew E0390 in the probed shapes; an inherent impl on a foreign nominal type - Vec, String, or an alias to one - drew E0116; and a foreign trait implemented for a primitive type drew E0117. At the boundary, inherent impls on a local struct, a local enum, a local union, a generic local struct, and a trait object compile and run, an alias to a local struct takes an inherent impl and runs, and a local trait implemented for a primitive type compiles and runs. This guide shows the E0118 shapes, the separable ride-along in the index example, the neighboring shapes, the boundary, and the repairs.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts, the file names are the bare names shown on the command line.
The rule underneath: an inherent impl needs a nominal type
An inherent impl attaches methods and associated items directly to a type, with no trait in between. The Rust Reference defines an inherent implementation as an impl whose implementing type is a path to a nominal type - a type with a name of its own, declared as a struct, enum, or union, or a trait object. A generic parameter such as T is a placeholder, not a name: at the point of the impl it stands for whatever type a caller later supplies, so there is no nominal type for the methods to attach to. That is the mismatch E0118 reports, and adding a trait bound does not cure it in the probed shapes - impl<T: Clone> T drew the same single E0118, because a bound narrows what T may be without making it a nominal type.
Three different questions are easy to confuse here, and the probed shapes give each its own code. Is there a nominal type at all? If not - a bare parameter - the code is E0118. Is the target a primitive or another built-in shape with no nominal definition of its own? In the probed shapes that drew E0390, whose diagnostic names primitive types directly and suggests an extension trait. Is the target a nominal type, but one defined in another crate? That drew E0116, the foreign-type inherent impl code. The defect feels the same - "I want to add a method to this type" - but the repair differs by which question fails, so read the code before reaching for a fix.
The honest repairs follow from the rule. If the method is meant to apply to many types, put it on a trait and implement the trait - a trait impl may name a generic parameter or a primitive as its target, as the repairs below show running. If the method belongs to one type of value, wrap that value in a struct of your own - a newtype - and put the inherent impl on the wrapper, which is nominal and yours.
How to read the diagnostic
The E0118 header is fixed wording: "no nominal type found for inherent implementation". The single span covers the whole impl header - in the probed shapes, impl<T> T underlined from the impl keyword through the target - and labels it "impl requires a nominal type". One note follows: "either implement a trait on it or create a newtype to wrap it instead". Those two suggestions are exactly the two repairs, and both are shown running below.
The count follows the impl blocks, in the probed shapes - not the methods inside them. One block holding two methods drew exactly one E0118. Two separate blocks, each on its own generic parameter, drew exactly two E0118 reports, one per block, ending with "aborting due to 2 previous errors". Fix every offending block in the output before recompiling; a second bad block is already reported, not hidden behind the first.
The first failure: the index example
The index's erroneous example, verbatim - an inherent impl on the generic parameter T, with the method body elided the way the index prints it:
#![allow(unused)]
fn main() {
impl<T> T { // error: no nominal type found for inherent implementation
fn get_state(&self) -> String {
// ...
}
}
}
error[E0118]: no nominal type found for inherent implementation
--> fail_index.rs:3:1
|
3 | impl<T> T { // error: no nominal type found for inherent implementation
| ^^^^^^^^^ impl requires a nominal type
|
= note: either implement a trait on it or create a newtype to wrap it instead
error[E0308]: mismatched types
--> fail_index.rs:4:28
|
4 | fn get_state(&self) -> String {
| --------- ^^^^^^ expected `String`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0118, E0308.
For more information about an error, try `rustc --explain E0118`.
Two reports, and only one of them is about the impl. The E0118 names the impl header, as expected. The E0308 is a separate defect the printed example carries: the method promises a String and its elided body returns nothing, so the body alone is a type mismatch. That ride-along is separable, and the separation is worth seeing because it decides what this error is really about. The same impl header with a complete body - the identical impl<T> T, with the method returning a string - drew exactly one E0118 and no other code:
error[E0118]: no nominal type found for inherent implementation
--> sep_body_string.rs:1:1
|
1 | impl<T> T {
| ^^^^^^^^^ impl requires a nominal type
|
= note: either implement a trait on it or create a newtype to wrap it instead
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0118`.
And the elided body on its own, inside an inherent impl on a local struct where an inherent impl is legal, drew exactly one E0308 and no E0118. So the E0308 belongs to the body, not to the impl target: give the method any complete body, or a unit return, and E0118 stands alone. A bound on the parameter changes nothing, in the probed shapes: impl<T: Clone> T with a complete body drew exactly one E0118, in the file fail_generic_bound.rs.
The same error through an alias
Writing the parameter through an alias does not give it a name that counts. An alias defined as the parameter itself, with the impl written on the alias, drew exactly one E0118 in the probed shape:
error[E0118]: no nominal type found for inherent implementation
--> fail_alias_generic_param.rs:2:1
|
2 | impl<T> Wrap<T> {
| ^^^^^^^^^^^^^^^ impl requires a nominal type
|
= note: either implement a trait on it or create a newtype to wrap it instead
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0118`.
The alias is transparent: the compiler looks through Wrap<T> to the T underneath, finds no nominal type, and reports the same code on the alias's impl header. An alias only changes the outcome when what it names changes the outcome - the alias shapes split three ways in the probed shapes, and they are covered with the neighboring codes below, because each alias lands on a different code.
The shapes that are not this error
Aim the same inherent impl at a primitive type and the code changes. impl u32 drew exactly one E0390 in the probed shape - not E0118:
error[E0390]: cannot define inherent `impl` for primitive types
--> fail_primitive.rs:1:1
|
1 | impl u32 {
| ^^^^^^^^
|
= help: consider using an extension trait instead
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0390`.
The split, in the probed shapes, is that a primitive type is a concrete built-in target the compiler names directly - its diagnostic says "cannot define inherent impl for primitive types" and suggests an extension trait - while a generic parameter is not a type the compiler can name at all, which is E0118's "no nominal type found". The whole primitive family landed on E0390 in the probed shapes: bool, a shared reference &u32, a mutable reference, a slice [u32], an array, a tuple, a function pointer, a raw pointer *const u32, and the str type each drew exactly one E0390 - the full transcripts are the fail_primitive shape under each target's name, in the files fail_bool.rs, fail_reference.rs, fail_mut_reference.rs, fail_slice.rs, fail_array.rs, fail_tuple.rs, fail_fn_pointer.rs, fail_pointer.rs, and fail_str.rs. An alias to a primitive landed there too: type MyInt = u32; with the impl on MyInt drew exactly one E0390, because the alias looks through to the primitive underneath.
Aim the impl at a nominal type defined in another crate, and the code changes the other way. An inherent impl on Vec<T> drew exactly one E0116 in the probed shape:
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> neighbour_foreign_nominal_vec.rs:1:1
|
1 | impl<T> Vec<T> {
| ^^^^^^^^^^^^^^ impl for type defined outside of crate
|
= help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it
= note: for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0116`.
Here there is a nominal type - Vec is a struct - but it is not defined in this crate, and an inherent impl must live with its type. String drew the same single E0116 in the probed shape, and so did an alias to a foreign type: type MyVec = Vec<i32>; with the impl on MyVec drew exactly one E0116, with an added note stating that MyVec does not define a new type, only an alias. That note is the alias rule in one line: an alias never creates a nominal type, so an impl written on an alias is judged by whatever the alias names - a parameter (E0118), a primitive (E0390), or a foreign type (E0116).
One more neighbor belongs to the trait side. Implementing a foreign trait for a primitive type - Display for u32 - drew exactly one E0117 in the probed shape, the orphan-rule code: neither the trait nor the type is local. That is the failure the trait repair must avoid, and the repair below avoids it by making the trait local.
Two offending blocks of different kinds report side by side, in the probed shapes: a generic-parameter block and a u32 block in one program drew one E0118 and one E0390 together, ending with "aborting due to 2 previous errors" - each block judged by its own target, in the file fail_two_blocks.rs.
The shape where a second code rides along
Other errors in the same program are reported alongside E0118. A program whose offending impl shared the file with an unresolved name in the entry point drew E0425 and E0118 together in the probed shape, ending with "aborting due to 2 previous errors":
error[E0425]: cannot find value `missing_name` in this scope
--> ride_unresolved.rs:4:28
|
4 | fn main() { println!("{}", missing_name); }
| ^^^^^^^^^^^^ not found in this scope
error[E0118]: no nominal type found for inherent implementation
--> ride_unresolved.rs:1:1
|
1 | impl<T> T {
| ^^^^^^^^^ impl requires a nominal type
|
= note: either implement a trait on it or create a newtype to wrap it instead
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0118, E0425.
For more information about an error, try `rustc --explain E0118`.
Fixing the impl clears the E0118 in that shape and leaves the E0425 standing - the unresolved name is a separate problem that happens to share the output, the same separation the index example's E0308 needed.
The boundary: targets an inherent impl accepts
The line is whether the target is a nominal type defined in this crate - or a trait object - and on the other side of it the same impl shape is ordinary code. An inherent impl on a local struct compiled and ran in the probed shape, printing state 3, the value the method read from the struct's field:
struct Local { v: u32 }
impl Local {
fn get_state(&self) -> String { format!("state {}", self.v) }
}
fn main() { let x = Local { v: 3 }; println!("{}", x.get_state()); }
state 3
A local enum and a local union take inherent impls the same way: in the probed shapes the enum's method printed enum and the union's method printed union. A generic local struct is still nominal - impl<T> Wrap<T> for a struct Wrap<T> the program defines compiled and ran in the probed shape, printing wrap. Genericity is not the defect; the index example fails because its target is the parameter itself, not a generic type built around one.
An alias to a local struct takes an inherent impl too, in the probed shape: type Alias = Local; with the impl written on Alias compiled and ran, printing x - the alias looks through to a local nominal type, and that is enough. Contrast the alias shapes above: the same alias syntax lands on E0118, E0390, or E0116 when the alias names a parameter, a primitive, or a foreign type.
A trait object is on the accepted side of the line, as the index's own definition says. An inherent impl on dyn Live - a trait the program defines - compiled and ran in the probed shape, the method added by that impl printing dyn when called through a boxed trait object.
And a trait impl is not bound by the nominal rule at all. A trait defined in the program, implemented for the primitive u32, compiled and ran in the probed shape, printing local trait - the trait being local is what the orphan rule asks for, and it is the opening the first repair uses.
Related guides
For an inherent impl on a type defined in another crate, the neighboring code is E0116. For a trait impl where neither the trait nor the type is local, the neighboring code is E0117. For an unresolved name used in the same program, the neighboring code is E0425.
The repairs
Every repair below starts from the same observation: the impl target is not a nominal type of this crate. Either stop writing an inherent impl - put the method on a trait, and implement the trait for the target - or give the value a nominal type of your own and put the inherent impl on that.
Implement a trait on the type. This is the index's own first repair: declare the method on a trait, then implement the trait for the generic parameter. The blanket impl compiled and ran in the probed shape, printing He's dead, Jim! - the index's own string - when the method was called on a u32:
trait LiveLongAndProsper {
fn get_state(&self) -> String;
}
impl<T> LiveLongAndProsper for T {
fn get_state(&self) -> String {
"He's dead, Jim!".to_owned()
}
}
fn main() { println!("{}", 3u32.get_state()); }
He's dead, Jim!
The trait is local, so the orphan rule is satisfied even though the impl covers foreign types like u32 - the same construction that drew E0117 above drew no error here, because there the trait was foreign too. Where only one primitive needs the method, implementing a local trait for that primitive alone is the narrower form of the same repair, and it is the shape that printed local trait at the boundary.
Wrap the value in a newtype. This is the index's second repair: a tuple struct wrapping the value is a nominal type of this crate, so the inherent impl belongs on it. The index's generic wrapper compiled and ran in the probed shape, printing Fascinating! - again the index's own string:
struct TypeWrapper<T>(T);
impl<T> TypeWrapper<T> {
fn get_state(&self) -> String {
"Fascinating!".to_owned()
}
}
fn main() { let w = TypeWrapper(3); println!("{}", w.get_state()); }
Fascinating!
The concrete form is the one most real code wants: wrap the primitive itself and implement on the wrapper. A wrapper around a u32, with a method that reads the wrapped value back out, compiled and ran in the probed shape, printing wrapped 42:
struct MyInt(u32);
impl MyInt {
fn get_state(&self) -> String { format!("wrapped {}", self.0) }
}
fn main() { let w = MyInt(42); println!("{}", w.get_state()); }
wrapped 42
Fixes in reach order
First, read the code on the report before choosing a repair. E0118 says there is no nominal type; E0390 says the target is a primitive or another built-in shape; E0116 says the nominal type belongs to another crate. The three feel alike and repair differently.
Second, if the method is meant for the generic parameter as such - for whatever type a caller supplies - it cannot be inherent. Declare it on a trait and implement the trait for the parameter, as in the blanket repair above.
Third, if the method is meant for one concrete built-in value, wrap the value in a newtype struct and implement on the wrapper. Do not rename the target with an alias instead - in the probed shapes an alias is looked through, and the impl is judged by the type underneath it.
Fourth, if the report is E0390 on a primitive, the diagnostic's own suggestion is the lighter repair: an extension trait - a local trait implemented for the primitive - adds the method without a wrapper, and it compiled and ran in the probed shapes.
Fifth, if the report is E0116 on a foreign nominal type, neither an inherent impl nor an alias helps; use a local trait implemented for that type, or a newtype that wraps it.
Sixth, if the output also carries a second code, separate it before judging the program: an elided or empty method body that promises a value is an E0308 of its own, and an unresolved name elsewhere is an E0425 of its own - each survives the impl fix until it is fixed on its own terms.
Decision summary
E0118 fired in the probed shapes for the index example's impl header (one E0118, plus a separable E0308 from the example's elided body), for the same header with a complete body and for the same header with a unit-returning body (exactly one E0118 each), for a generic parameter with a trait bound (exactly one E0118), and for the same target reached through a type alias to the parameter (exactly one E0118). The count followed the impl blocks in the probed shapes: two methods in one block drew one E0118, and two generic blocks drew two. It rode along with E0425 for an unresolved name elsewhere in the program, in the probed shapes. It did not fire, in the probed shapes, for an inherent impl on a local struct (compiled and ran, printing state 3), a local enum (printing enum), a local union (printing union), a generic local struct (printing wrap), a trait object (printing dyn), an alias to a local struct (printing x), or a local trait implemented for a primitive type (printing local trait). The neighboring shapes drew other codes instead in the probed shapes: an inherent impl on u32, bool, a shared or mutable reference, a slice, an array, a tuple, a function pointer, a raw pointer, the str type, or an alias to a primitive each drew exactly one E0390; an inherent impl on Vec, on String, or on an alias to Vec each drew exactly one E0116; a foreign trait implemented for a primitive type drew exactly one E0117; and an empty body promising a String inside a legal impl drew exactly one E0308. The repairs that compiled and ran in the probed shapes were implementing a local trait for the generic parameter (printing He's dead, Jim!), wrapping the value in the index's generic newtype (printing Fascinating!), and wrapping a u32 in a concrete newtype (printing wrapped 42).
Checklist
- The target is the test, in the probed shapes: an inherent impl needs a nominal type - a struct, enum, or union defined in this crate, or a trait object - and a generic parameter is none of those.
- A bound does not cure it, in the probed shapes:
impl<T: Clone> Tdrew the same E0118 asimpl<T> T. - An alias does not cure it either, in the probed shapes: the impl is judged by what the alias names - a parameter drew E0118, a primitive drew E0390, a foreign type drew E0116, and only an alias to a local struct compiled and ran.
- The count is per impl block, in the probed shapes: two methods in one block drew one report, and two blocks drew two.
- The code names the failure, in the probed shapes: no nominal type is E0118, a primitive target is E0390, and a foreign nominal type is E0116 - read the code before choosing the repair.
- On the other side of the line there is no error, in the probed shapes: a local struct, enum, union, generic struct, trait object, or local-struct alias takes its inherent impl and runs, and a local trait can be implemented for a primitive or a generic parameter.
Sources
- Rust error codes index, E0118 - an inherent implementation was defined for something which isn't a struct, enum, union, or trait object; the erroneous example is an inherent impl on a generic parameter, and the fixes are to implement a trait on the type or to wrap it in a newtype struct.
- Rust error codes index, E0390 - a method or constant was implemented on a primitive type; the neighboring code drawn in the probed shapes by an inherent impl on a primitive, reference, slice, array, tuple, function pointer, raw pointer, or str target, whose diagnostic suggests an extension trait instead.
- Rust error codes index, E0116 - an inherent impl cannot be defined for a type outside the crate where the type is defined; the neighboring code drawn in the probed shapes by an inherent impl on Vec, on String, and on an alias to Vec.
- Rust error codes index, E0117 - the orphan rule allows only local traits or local types in a trait impl; the neighboring code drawn in the probed shape by a foreign trait implemented for a primitive type.
- Rust error codes index, E0425 - an unresolved name was used; the neighboring code drawn in the probed shape alongside E0118 by a program that also used an unresolved name.
- The Rust Reference, Implementations - an inherent implementation's implementing type is a path to a nominal type defined in the same crate, and the orphan rules that govern trait implementations.
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.