Rust

Inherent Impl on Foreign Type E0116 Fix

You want to add a method to a type from another crate - a helper on Vec, String, or a collection - and write an inherent impl for it directly. The compiler stops with E0116: an inherent impl belongs to the crate that defined the type. Some neighboring attempts look like the same complaint but are not: an inherent impl on a primitive draws E0390, and a foreign trait for a foreign type draws E0117. This guide shows each failing shape, which code it actually draws, the impls that compile and run, and the two repairs the error itself names - a newtype wrapper and a local trait.

Written December 2, 2026 · Tested with Rust 1.99.0 · 18 min read

By the end of this guide
  • The rule underneath: an inherent impl belongs to the defining crate
  • How to read the diagnostic
  • The first failure: the index example
  • Every named foreign type draws the same code

Written December 2, 2026

Tested with Rust 1.99.0

What this guide is

Error E0116 means an inherent implementation was defined for a type outside the current crate. The error codes index puts it in one sentence: "An inherent implementation was defined for a type outside the current crate."

In the shapes probed in this guide, E0116 is drawn by an inherent impl on a named foreign type such as Vec, String, or Box. An inherent impl on a primitive type is a different error - E0390 - even though the underlying wish, adding methods to a type that is not yours, is the same. This guide shows the E0116 shapes, the neighboring impls that draw E0390, E0117, E0210, or E0119 instead, the impls that compile and run, and the two repairs the diagnostic itself names.

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 belongs to the defining crate

An inherent impl - an impl block with no trait in it - adds methods, associated functions, and associated constants directly to a type. Only the crate that defined the type may do that. If any other crate could add inherent methods, two crates could add the same method name to the same type and neither program nor reader could tell which one a call meant.

That is why the restriction is about where the type was defined, not about where the impl is written. An inherent impl on a local type written in another module of the same crate compiles in the probed shape below. An inherent impl on a foreign type written inside a function body - the index example's shape - still draws E0116. Trait impls follow the related orphan rules instead: at least one side, the trait or the type, must be local, which is why a local trait for a foreign type compiles while a foreign trait for a foreign type draws E0117.

How to read the diagnostic

The header is "cannot define inherent impl for a type outside of the crate where the type is defined", the label under the impl says "impl for type defined outside of crate", and the help names both repairs: "consider defining a trait and implementing it for the type or using a newtype wrapper" - the help even sketches the wrapper's shape. A note then points to the orphan rules in the reference.

The E0390 diagnostic reads differently: "cannot define inherent impl for primitive types", with the help "consider using an extension trait instead". If your header says "primitive types", you are in E0390 territory, not E0116, however similar the attempt feels.

The first failure: the index example

The index's erroneous example, verbatim:

Rust
#![allow(unused)]
fn main() {
impl Vec<u8> { } // error
}
Output
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
 --> fail_index.rs:3:1
  |
3 | impl Vec<u8> { } // error
  | ^^^^^^^^^^^^ 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`.

The example is an empty impl on Vec<u8>, inside the main body, and it draws exactly one E0116 - no second code hides in it. The impl needs no method to fail: being an inherent impl on a foreign type is enough. The index gives the two fix directions - define a trait and implement it for the type, or define a new type wrapping the type - and both are shown running in the repairs below.

Every named foreign type draws the same code

An inherent impl meant to add a real method to Vec fails the same way - the header and label are unchanged:

Rust
impl Vec<i32> {
    fn doubled(&self) -> usize { self.len() * 2 }
}
fn main() { println!("x"); }
Output
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
 --> fail_vec_method.rs:1:1
  |
1 | impl Vec<i32> {
  | ^^^^^^^^^^^^^ 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`.

A String impl draws E0116 as well. So do impls on the following types, each as exactly one E0116 in the probed shapes:

  • A boxed vector, in an impl written as Box<Vec<i32>>.
  • An Option type, in an impl written as Option<i32>.
  • A Result type, in an impl written as Result<i32, String>.
  • A map type, in an impl written as HashMap<String, i32>.

Making the impl generic does not help: a generic impl over Vec draws E0116, with the impl header naming the type parameter:

Rust
impl<T> Vec<T> {
    fn my_len(&self) -> usize { self.len() }
}
fn main() { println!("x"); }
Output
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
 --> fail_generic_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`.

The impl's contents do not matter either: an impl on Vec<i32> holding only an associated constant - no method at all - draws E0116 in the probed shape.

A type alias does not make the type yours

The index warns that the type keyword does not work here, because it only introduces an alias. The probed alias impl draws E0116, and the diagnostic adds a note saying exactly that:

Rust
type Bytes = Vec<u8>;
impl Bytes {
    fn extra(&self) -> usize { self.len() }
}
fn main() { println!("x"); }
Output
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
 --> fail_alias.rs:2:1
  |
2 | impl Bytes {
  | ^^^^^^^^^^ 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>
note: `Bytes` does not define a new type, only an alias of `Vec<u8>` defined here
 --> fail_alias.rs:1:1
  |
1 | type Bytes = Vec<u8>;
  | ^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0116`.

The index's own alias example, in its fn main() wrapper, draws exactly one E0116 the same way. An alias is a second name for the same foreign type, not a new local type - the newtype repair below is the shape that does create a new type.

Wrapping a local type in a foreign type is still foreign

Putting a local type inside a foreign wrapper does not make the impl local. An impl on a boxed local struct draws E0116:

Rust
struct Local { v: i32 }
impl Box<Local> {
    fn get(&self) -> i32 { self.v }
}
fn main() { println!("x"); }
Output
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
 --> fail_box_local.rs:2:1
  |
2 | impl Box<Local> {
  | ^^^^^^^^^^^^^^^ 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`.

In the probed shape, the type named by the impl is Box, a foreign type, and the local type inside it does not change the code. For trait impls the local type inside a wrapper can matter under the orphan rules; for an inherent impl, the probed shape shows it does not rescue the impl.

The shapes that are not this error: primitives draw E0390

An inherent impl on a primitive type does not draw E0116. An i32 impl draws E0390:

Rust
impl i32 {
    fn inc(&self) -> i32 { self + 1 }
}
fn main() { println!("x"); }
Output
error[E0390]: cannot define inherent `impl` for primitive types
 --> fail_i32.rs:1:1
  |
1 | impl i32 {
  | ^^^^^^^^
  |
  = 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 same code, E0390, was drawn in the probed shapes by inherent impls on bool, u8, and char, on an array type written as [i32; 3], on a slice type written as [i32], on a tuple type written as (i32, i32), and on str. References draw E0390 too: an impl on a reference to a local struct and an impl on a reference to str each drew E0390, with an added note suggesting moving the reference to the uses of the type inside the implementation. In every one of these shapes the header says "primitive types" - read the header, not just the wish behind the code, before choosing a repair.

The shapes that are not this error: trait impls draw E0117, E0210, or E0119

Switching from an inherent impl to a trait impl changes the rule, and a foreign trait for a foreign type breaks it in its own way. Implementing the foreign Display trait for a foreign type draws E0117:

Rust
impl std::fmt::Display for Vec<i32> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "vec") }
}
fn main() { println!("x"); }
Output
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
 --> neighbour_foreign_trait_foreign_type.rs:1:1
  |
1 | impl std::fmt::Display for Vec<i32> {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^--------
  |                            |
  |                            `Vec` is not defined in the current crate
  |
  = note: impl doesn't have any local type before any uncovered type parameters
  = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
  = note: define and implement a trait or new type instead

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0117`.

A generic version of the same attempt - Display for a generic Vec - also drew E0117 in the probed shape, not E0210. E0210 appeared for a different shape: an uncovered type parameter standing before the first local type in a foreign-trait impl. The probed shape implements the foreign From trait, for a bare type parameter, from a local struct:

Rust
struct S;
impl<T> std::convert::From<S> for T { fn from(_: S) -> Self { todo!() } }
fn main() { println!("x"); }
Output
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`S`)
 --> neighbour_e0210_b.rs:2:6
  |
2 | impl<T> std::convert::From<S> for T { fn from(_: S) -> Self { todo!() } }
  |      ^ uncovered type parameter
  |
  = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local,
          and no uncovered type parameters appear before that first local type
  = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`,
          where `T0` is the first and `Tn` is the last

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0210`.

A third neighboring code appeared for a generic From impl whose target was a local type: it drew E0119, a conflicting implementation, because the standard library already provides the blanket conversion the impl would duplicate. None of these three shapes is E0116: E0116 is only the inherent impl, with no trait named at all.

What does work: an inherent impl on a local type

An inherent impl on a type defined in the same crate compiles and runs. The probed struct impl printed 42:

Rust
struct Point { x: i32 }
impl Point {
    fn doubled(&self) -> i32 { self.x * 2 }
}
fn main() { println!("{}", Point { x: 21 }.doubled()); }
Output
42

A local enum works the same way: an inherent impl on a local enum compiled and its method printed 9 in the probed shape. Splitting a local type's inherent methods across two impl blocks also compiles: the probed type had one block with a mutating method and a second block with a getter, and the program printed 2.

Where the impl sits inside the crate does not matter in the probed shape: an inherent impl for a local struct, written in a different module of the same crate from the struct's definition, compiles and runs, printing 21:

Rust
mod inner {
    pub struct Local { pub v: i32 }
}
mod methods {
    impl super::inner::Local {
        pub fn triple(&self) -> i32 { self.v * 3 }
    }
}
fn main() { println!("{}", inner::Local { v: 7 }.triple()); }
Output
21

What does work: a trait impl with one local side

A foreign trait for a local type compiles: the probed Display impl for a local struct printed Point(3). A local trait for a foreign type compiles too - that is the trait repair below, shown running there. A local trait for a specific instance of a local generic type also compiles in the probed shape: a trait implemented for a wrapper type at i32 printed wrap 5.

A blanket impl of a local trait for every type also compiled in the probed shape - a local trait implemented for all T - and the program printed x and exited with code 0, with only a warning that the trait was never used. That probed shape is a local trait only; it says nothing about a foreign trait in the same position.

Orphan-rule mistakes cluster together. For a foreign trait implemented for a foreign type, see Orphan Rule E0117 Fix. For an uncovered type parameter in a trait impl, see Type Parameter Orphan Rule E0210 Fix. For an impl that duplicates an existing one, see Conflicting Implementations E0119 Fix.

The repairs

Wrap the foreign type in a new local type, and put the inherent impl on the wrapper. This is the newtype direction the index and the diagnostic both name; the wrapper's field is reached as .0, and the methods are called on the wrapper:

Rust
struct MyVec(Vec<i32>);
impl MyVec {
    fn total(&self) -> i32 { self.0.iter().sum() }
    fn doubled_len(&self) -> usize { self.0.len() * 2 }
}
fn main() { let v = MyVec(vec![1, 2, 3]); println!("{} {}", v.total(), v.doubled_len()); }
Output
6 6

The wrapper can be generic: a generic newtype over Vec compiled in the probed shape, and its length method printed 3. A wrapper over String works the same way: the probed wrapper's method returned the uppercased contents and printed HI.

Or define a local trait with the desired methods, and implement that trait for the foreign type. This is the second direction the index names; callers bring the trait into scope and then call the method on the foreign value directly:

Rust
trait Total {
    fn total(&self) -> i32;
}
impl Total for Vec<i32> {
    fn total(&self) -> i32 { self.iter().sum() }
}
fn main() { let v = vec![1, 2, 3]; println!("{}", v.total()); }
Output
6

The same trait shape for String compiled and printed HI in the probed shape, with the trait method returning the uppercased string. Choose the wrapper when the value should be a distinct type of its own - the wrapper is what callers hold - and the trait when the method should be callable on the foreign value itself, as in the probed programs.

Fixes in reach order

First, read which code you actually have. If the header is "cannot define inherent impl for a type outside of the crate where the type is defined" the code is E0116: in the probed shapes that means an inherent impl - with a method, with only a constant, empty, or generic - on a named foreign type such as Vec, String, Box, Option, Result, or HashMap, on an alias for such a type, or on a Box of a local type. If the header says "primitive types", the code is E0390; if it says only traits defined in the current crate can be implemented for outside types, the code is E0117; an uncovered type parameter before the first local type is E0210; and the probed generic From impl for a local type drew E0119.

Second, for E0116, stop trying to make the foreign type local. Renaming it with a type alias does not work in the probed shapes, adding a type parameter does not work, and wrapping a local type inside the foreign type does not work. Pick one of the two repairs instead.

Third, apply the newtype repair when the value can travel as your own type: declare a tuple struct wrapping the foreign type, move the methods onto the wrapper, and reach the wrapped value as .0 inside them, as in the probed MyVec and string-wrapper programs.

Fourth, apply the trait repair when the method must be called on the foreign value itself: declare a local trait, implement it for the foreign type, and bring the trait into scope at the call site, as in the probed Vec and String trait programs.

Last, leave the legal impls alone: an inherent impl on a local struct or enum, in the same module or another module of the same crate, split across two blocks, a foreign trait for a local type, and a local trait for a foreign type or for a specific instance of a local generic type all compile in the probed shapes. Do not rewrite them while fixing the E0116 next to them.

Decision summary

E0116 fired for every inherent impl on a named foreign type probed - the index example (Vec<u8>, exactly one E0116), a Vec<i32> method impl, a generic Vec impl, String, a boxed vector, Option, Result, a HashMap type, an impl holding only a constant, an alias for Vec<u8> (at top level and in the index's own alias example, each exactly one E0116), and a Box of a local struct. It did not fire for an inherent impl on a primitive or primitive-like type: i32, bool, u8, char, an array, a slice, a tuple, str, and references to a local struct and to str all drew E0390. It did not fire for trait impls: a foreign trait for a foreign type drew E0117 (concrete and generic shapes), an uncovered type parameter before the first local type drew E0210, and a generic From impl for a local type drew E0119. The shapes that compiled and ran were an inherent impl on a local struct (printing 42) or enum (printing 9), a local impl split across two blocks (printing 2), a local impl written in another module of the same crate (printing 21), a foreign trait for a local type (printing Point(3)), a local trait for a specific instance of a local generic type (printing wrap 5), a blanket local trait impl, and the repairs: a newtype wrapper over a vector (printing 6 6), a generic newtype (printing 3), a newtype over String (printing HI), and a local trait implemented for a vector (printing 6) or for String (printing HI).

Checklist

  • An inherent impl - no trait named - may only be written for a type defined in the current crate: Vec, String, Box, Option, Result, and HashMap types draw E0116 in the probed shapes.
  • A type alias is not a new type: an inherent impl on an alias for Vec<u8> draws E0116, with a note that the alias does not define a new type.
  • Generics and contents do not change E0116: a generic impl over Vec, and an impl holding only a constant, draw E0116 in the probed shapes.
  • A local type inside a foreign wrapper does not make the impl local: an inherent impl on a Box of a local struct draws E0116 in the probed shape.
  • Primitives keep their own code: inherent impls on i32, bool, u8, char, an array, a slice, a tuple, str, and references draw E0390, not E0116.
  • Trait impls keep their own codes: a foreign trait for a foreign type is E0117, an uncovered type parameter before the first local type is E0210, and the probed generic From impl for a local type is E0119.
  • The two repairs in the probed shapes: a newtype wrapper with the inherent impl on the wrapper, and a local trait implemented for the foreign type - both compile and run.

Sources

  • Rust error codes index, E0116 - an inherent implementation was defined for a type outside the current crate; the erroneous example defines an impl on Vec<u8>, the page says a trait implemented for the type or a new type wrapping the type fixes it, and it warns that a type alias does not work because it only introduces an alias.
  • Rust error codes index, E0390 - an inherent implementation was defined for a primitive type; the code drawn by inherent impls on i32, bool, u8, char, an array, a slice, a tuple, str, and references in the probed shapes.
  • Rust error codes index, E0117 - only traits defined in the current crate can be implemented for types defined outside of the crate; the code drawn by a foreign trait implemented for a foreign type.
  • Rust error codes index, E0210 - a type parameter must be covered by another type when it appears before the first local type; the code drawn by the probed foreign-trait impl for a bare type parameter.
  • Rust error codes index, E0119 - conflicting implementations of a trait; the code drawn by the probed generic From impl for a local type.

Keep Exploring