E0119 Conflicting Impl Fix
For any trait and type pair there can be exactly one implementation, and E0119 is the compiler refusing to choose between two. This guide separates the shapes that produce it - exact duplicates, would-be overrides, blanket impls that already cover the specific case, generic impls that overlap a concrete one, type aliases that are not new types, and collisions with a blanket impl in core - and matches each one to the correction that leaves exactly one impl standing.
Written November 23, 2026 · Tested with Rust 1.99.1 · 30 min read
- The rule underneath: coherence - exactly one impl for each trait and type pair
- How to read the diagnostic
- The first failure: the same trait implemented twice for the same type
- The second failure: a second impl with a different body, as an attempted override
Written November 23, 2026
Tested with Rust 1.99.1
What this guide is
Error E0119 is a collision between implementations. The error codes index states it in one line: there are conflicting trait implementations for the same type. When the compiler looks up which implementation of a trait applies to a type, it must find exactly one. If two impl blocks can both apply - because they name the same trait and type outright, or because a generic one can be instantiated to the same pair as a concrete one - the compiler will not pick a winner, prefer the later block, or prefer the more specific one. It reports E0119 and stops.
The forms in this guide each reproduce E0119 with a small, complete program, and each collides for a different reason. The same trait implemented twice for the same type, word for word. The same pair implemented twice with different method bodies, as an attempted override. A blanket implementation for every T next to a specific implementation for one type. A blanket implementation narrowed by a trait bound that the specific type still satisfies. A generic implementation for Vec<T> next to a concrete one for Vec<i32>. A generic trait argument next to a concrete trait argument it can equal. An implementation for a type alias, which is the same type under a second name. And an implementation that collides with a blanket implementation that already exists in core, where the first implementation is not in your file at all. In each family the failing program is small, the full compiler output is shown, and the fix leaves exactly one implementation for the pair - by deleting one block, or by changing the design so the two blocks no longer claim the same pair.
Three neighboring results are not E0119 and are worked only in the traps and the decision summary. A foreign trait implemented over a type parameter that no local type covers is E0210, an orphan-rule failure about who may write the impl at all. A foreign trait implemented for a foreign type, with no local type anywhere in the impl, is E0117, the plain form of the same orphan rule. And a method call on a type that implements nothing providing that method is E0599 - the subject of the E0599 guide - because there the problem is zero implementations in reach, not two.
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: coherence - exactly one impl for each trait and type pair
The property behind E0119 is coherence. The Rust Reference states the overlap half of it directly: a trait implementation is considered incoherent if either the orphan rules check fails or there are overlapping implementation instances, and two trait implementations overlap when there is a non-empty intersection of the traits the implementation is for - when the implementations can be instantiated with the same type. That last clause is the one that catches generic code: the two blocks do not have to name the same type in the source. It is enough that some instantiation makes them the same, as Vec<T> and Vec<i32> meet at T = i32, and as Named<T> and Named<String> meet at T = String.
The Book gives the reason the guarantee exists: coherence, and the orphan rule inside it, ensure that other people's code can't break your code and vice versa - without the rule, two crates could implement the same trait for the same type, and Rust wouldn't know which implementation to use. Method resolution, trait objects, and every generic function bounded by the trait all rely on the answer being unique, so the compiler enforces uniqueness at the point the second impl is written, not at the point a method is called. That ordering explains a feature of every diagnostic in this guide: E0119 fires even when the program never calls the method, and even when the two bodies are identical. The conflict is between the claims, not between the behaviors.
Two consequences follow for fixing the error. First, there is no priority rule to appeal to: Rust does not let a specific impl override a general one, does not let the later block shadow the earlier one, and a trait bound on a generic impl separates it from a concrete impl only if the compiler can prove the concrete type can never satisfy the bound - a bound the type merely happens to satisfy today, like i32: Display, separates nothing. Second, the second impl is not always in your file. A blanket impl in a library - above all core's impl<T> From<T> for T - already claims every pair it covers, and an impl you write inside that coverage conflicts with a block you cannot see or delete. The diagnostic names it in a note instead, and the fix has to happen on your side.
How to read the diagnostic
The header names the pair in dispute: "conflicting implementations of trait Describe for type Meter", "conflicting implementations of trait Label for type Vec<i32>", "conflicting implementations of trait From<Token> for type Token". Read the type in the header as the meeting point: for generic collisions it is the instantiated type where the two impls meet, not necessarily a type written in the generic block - in the generic family below, the generic block names Vec<T> and the concrete block names Vec<i32> outright; the header reports the instantiated pair the generic block reaches at T = i32.
The body of the diagnostic then shows both claims. The caret span marks the block being rejected, labeled "conflicting implementation for Meter", and a second span above it marks the earlier block, labeled "first implementation here". Those two spans are the whole fix list: one of the two blocks they point at has to go, or one of them has to change its trait, its type, or its generic parameters so the pair is no longer claimed twice. When the first implementation lives in another crate, there is no second span in your file; instead a note states it, in the form "conflicting implementation in crate core: - impl
The first failure: the same trait implemented twice for the same type
Describe is implemented for Meter in two blocks with the same body - the shape a copy-paste, a merge, or a regenerated file leaves behind:
trait Describe { fn describe(&self) -> String; }
struct Meter { reading: i32 }
impl Describe for Meter { fn describe(&self) -> String { format!("meter {}", self.reading) } }
impl Describe for Meter { fn describe(&self) -> String { format!("meter {}", self.reading) } }
fn main() { println!("{}", Meter { reading: 7 }.describe()); }
$ rustc --edition 2021 fail_dup_same.rs -o fail_dup_same
error[E0119]: conflicting implementations of trait `Describe` for type `Meter`
--> fail_dup_same.rs:4:1
|
3 | impl Describe for Meter { fn describe(&self) -> String { format!("meter {}", self.reading) } }
| ----------------------- first implementation here
4 | impl Describe for Meter { fn describe(&self) -> String { format!("meter {}", self.reading) } }
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Meter`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
The identical bodies change nothing: the compiler is not comparing behavior, it is counting claims on the pair (Describe, Meter), and there are two. The fix deletes one block - it does not matter which, since they are the same - and keeps a single implementation:
trait Describe { fn describe(&self) -> String; }
struct Meter { reading: i32 }
impl Describe for Meter { fn describe(&self) -> String { format!("meter {}", self.reading) } }
fn main() { println!("{}", Meter { reading: 7 }.describe()); }
$ rustc --edition 2021 fix_dup_same.rs -o fix_dup_same
$ ./fix_dup_same
meter 7
The output is meter 7, the one implementation's formatting of the stored reading. When the two blocks are not in the same file - one in the type's module, one added later elsewhere in the crate - the diagnostic's two spans are what find them: follow "first implementation here" to the block you forgot existed rather than editing the block in front of you.
The second failure: a second impl with a different body, as an attempted override
The same pair, but now the second block was written on purpose, to change the behavior - hi instead of hello - in the expectation that the newer or more local block wins:
trait Greet { fn greet(&self) -> String; }
struct Person { name: String }
impl Greet for Person { fn greet(&self) -> String { format!("hello {}", self.name) } }
impl Greet for Person { fn greet(&self) -> String { format!("hi {}", self.name) } }
fn main() { println!("{}", Person { name: "Ana".to_string() }.greet()); }
$ rustc --edition 2021 fail_diff_bodies.rs -o fail_diff_bodies
error[E0119]: conflicting implementations of trait `Greet` for type `Person`
--> fail_diff_bodies.rs:4:1
|
3 | impl Greet for Person { fn greet(&self) -> String { format!("hello {}", self.name) } }
| --------------------- first implementation here
4 | impl Greet for Person { fn greet(&self) -> String { format!("hi {}", self.name) } }
| ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Person`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
Rust has no override for trait implementations: the differing bodies make the intent clearer and the error identical, because the second block is still a second claim on (Greet, Person). To change the behavior, edit the one implementation - or, if both behaviors are genuinely needed, separate them so they are not the same pair: a second trait, a parameter on the trait, or a distinct wrapper type for the second case. The fix here takes the first route and keeps the hello body as the single impl:
trait Greet { fn greet(&self) -> String; }
struct Person { name: String }
impl Greet for Person { fn greet(&self) -> String { format!("hello {}", self.name) } }
fn main() { println!("{}", Person { name: "Ana".to_string() }.greet()); }
$ rustc --edition 2021 fix_diff_bodies.rs -o fix_diff_bodies
$ ./fix_diff_bodies
hello Ana
The output is hello Ana. The contrast with the first family is only in the remedy you reach for: a duplicated block is deleted without a decision, while an attempted override forces the design decision - one behavior per pair, chosen in the single surviving block, or a real separation of the two cases into different pairs.
The third failure: a blanket impl next to a specific impl
A blanket implementation, impl<T> Describe for T, claims the trait for every type at once. Adding a specific implementation for Meter afterward claims a pair the blanket impl already holds - this is the example the error codes index itself leads with:
trait Describe { fn describe(&self) -> String; }
impl<T> Describe for T { fn describe(&self) -> String { "generic".to_string() } }
struct Meter { reading: i32 }
impl Describe for Meter { fn describe(&self) -> String { format!("meter {}", self.reading) } }
fn main() { println!("{}", Meter { reading: 7 }.describe()); }
$ rustc --edition 2021 fail_blanket_specific.rs -o fail_blanket_specific
error[E0119]: conflicting implementations of trait `Describe` for type `Meter`
--> fail_blanket_specific.rs:4:1
|
2 | impl<T> Describe for T { fn describe(&self) -> String { "generic".to_string() } }
| ---------------------- first implementation here
3 | struct Meter { reading: i32 }
4 | impl Describe for Meter { fn describe(&self) -> String { format!("meter {}", self.reading) } }
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Meter`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
The index explains the mechanism in one sentence: writing the blanket impl makes the trait implemented on all types in scope, so implementing it on another one after that conflicts. There is no exception for the type you had in mind when you wrote the blanket impl, and no way to carve one type out of for T. The choice is structural: keep the blanket impl and let it serve every type including Meter, or remove the blanket impl and write the per-type impls you actually need. The fix keeps the blanket impl and deletes the specific one:
trait Describe { fn describe(&self) -> String; }
impl<T> Describe for T { fn describe(&self) -> String { "generic".to_string() } }
struct Meter { reading: i32 }
fn main() { println!("{}", Meter { reading: 7 }.describe()); }
$ rustc --edition 2021 fix_blanket_specific.rs -o fix_blanket_specific
$ ./fix_blanket_specific
generic
The output is generic - the blanket impl's answer, now the only one. That change of output is the cost to notice before choosing this side of the fix: every type that was going to get a hand-written impl now gets the blanket behavior instead, and if even one type needs different behavior, the blanket impl is the block that has to go, replaced by per-type impls or by a default method on the trait that individual impls override - a trait's default method can be overridden per impl; a blanket impl cannot be overridden at all.
The fourth failure: a bound on the blanket impl that the specific type satisfies
Narrowing the blanket impl with a trait bound looks like it should leave room for a specific impl outside the bound. It does - but i32 is inside this bound, because i32 implements Display, so the two impls still meet at i32:
use std::fmt::Display;
trait Describe { fn describe(&self) -> String; }
impl<T: Display> Describe for T { fn describe(&self) -> String { format!("value {}", self) } }
impl Describe for i32 { fn describe(&self) -> String { "an integer".to_string() } }
fn main() { println!("{}", 7.describe()); }
$ rustc --edition 2021 fail_bounded_blanket.rs -o fail_bounded_blanket
error[E0119]: conflicting implementations of trait `Describe` for type `i32`
--> fail_bounded_blanket.rs:4:1
|
3 | impl<T: Display> Describe for T { fn describe(&self) -> String { format!("value {}", self) } }
| ------------------------------- first implementation here
4 | impl Describe for i32 { fn describe(&self) -> String { "an integer".to_string() } }
| ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
The overlap test from the Reference is about whether the impls can be instantiated with the same type, and a bound is a condition on instantiation, not an exclusion list. impl<T: Display> Describe for T can be instantiated with T = i32 precisely because i32: Display holds, so the intersection is non-empty and the pair is claimed twice. A bound separates two impls only when the compiler can prove the specific type never satisfies it - and for a bound as widely implemented as Display, almost no common type qualifies. The fix deletes the specific impl and lets the bounded blanket impl serve i32:
use std::fmt::Display;
trait Describe { fn describe(&self) -> String; }
impl<T: Display> Describe for T { fn describe(&self) -> String { format!("value {}", self) } }
fn main() { println!("{}", 7.describe()); }
$ rustc --edition 2021 fix_bounded_blanket.rs -o fix_bounded_blanket
$ ./fix_bounded_blanket
value 7
The output is value 7, the blanket impl formatting the value through Display. If the integer case truly needs its own wording, the separation has to be made in the types or the trait - a wrapper type for the special case, or the special case moved to its own trait - not in a bound that the type already satisfies.
The fifth failure: a generic impl for Vec<T> next to a concrete impl for Vec<i32>
Neither block names the same implementing type: one implements Label for Vec<T> for all T, the other for Vec<i32> alone. They collide because the first can be instantiated as the second:
trait Label { fn label(&self) -> String; }
impl<T> Label for Vec<T> { fn label(&self) -> String { format!("list of {}", self.len()) } }
impl Label for Vec<i32> { fn label(&self) -> String { "numbers".to_string() } }
fn main() { println!("{}", vec![1, 2, 3].label()); }
$ rustc --edition 2021 fail_generic_concrete.rs -o fail_generic_concrete
error[E0119]: conflicting implementations of trait `Label` for type `Vec<i32>`
--> fail_generic_concrete.rs:3:1
|
2 | impl<T> Label for Vec<T> { fn label(&self) -> String { format!("list of {}", self.len()) } }
| ------------------------ first implementation here
3 | impl Label for Vec<i32> { fn label(&self) -> String { "numbers".to_string() } }
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Vec<i32>`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
The header names the meeting point, Vec<i32>: with T = i32, the generic impl is an impl of Label for Vec<i32>, which is exactly what the concrete block claims. This is the specialization shape - general rule plus a special case for one element type - and stable Rust does not provide it for trait impls: the concrete block cannot be kept as an exception to the generic one. The usual redesigns move the special case out of the impl system: branch on a runtime property inside the one impl, give the special case its own trait, or wrap the special element type in a newtype so its Vec is a different implementing type. The fix takes the simplest route and keeps only the generic impl:
trait Label { fn label(&self) -> String; }
impl<T> Label for Vec<T> { fn label(&self) -> String { format!("list of {}", self.len()) } }
fn main() { println!("{}", vec![1, 2, 3].label()); }
$ rustc --edition 2021 fix_generic_concrete.rs -o fix_generic_concrete
$ ./fix_generic_concrete
list of 3
The output is list of 3, the generic impl reporting the vector's length. Note what did not collide on the way here: impls for Vec<i32> and Vec<String> would coexist, because no instantiation makes them the same type - the conflict needs the generic parameter that can range over the concrete type, not merely two impls mentioning the same outer type.
The sixth failure: a generic trait argument that can equal a concrete one
The overlap can live in the trait's arguments rather than in the implementing type. Holder is the implementing type in both blocks; the first implements Named<String> for it, the second implements Named<T> for all T - and T can be String:
trait Named<T> { fn name_for(&self, value: T) -> String; }
struct Holder;
impl Named<String> for Holder { fn name_for(&self, value: String) -> String { value } }
impl<T> Named<T> for Holder { fn name_for(&self, _value: T) -> String { "generic".to_string() } }
fn main() { println!("{}", Holder.name_for("x".to_string())); }
$ rustc --edition 2021 fail_trait_param.rs -o fail_trait_param
error[E0119]: conflicting implementations of trait `Named<String>` for type `Holder`
--> fail_trait_param.rs:4:1
|
3 | impl Named<String> for Holder { fn name_for(&self, value: String) -> String { value } }
| ----------------------------- first implementation here
4 | impl<T> Named<T> for Holder { fn name_for(&self, _value: T) -> String { "generic".to_string() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Holder`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
The header shows the full trait reference in dispute, Named<String> - the pair for coherence purposes is the whole trait reference, type arguments included, not the trait name alone. Two impls of the same trait for the same type coexist only when their argument lists can never be made equal, as Named<String> and Named<i32> cannot. A generic argument can always be made equal to the concrete one by instantiation, so the generic block claims every argument the concrete block claims, plus all the others. The fix deletes the generic block and keeps the concrete impl the program uses:
trait Named<T> { fn name_for(&self, value: T) -> String; }
struct Holder;
impl Named<String> for Holder { fn name_for(&self, value: String) -> String { value } }
fn main() { println!("{}", Holder.name_for("x".to_string())); }
$ rustc --edition 2021 fix_trait_param.rs -o fix_trait_param
$ ./fix_trait_param
x
The output is x, the string passed through by the surviving impl. If both a generic and a String behavior are really needed, the generic behavior belongs in a differently parameterized trait or in a default method - the argument list of one trait cannot carry an exception for one of its own instantiations.
The seventh failure: an impl for a type alias, which is the same type
A type alias is a second name for a type, not a new type. Count is u32, so implementing Describe for both names is implementing it twice for one type:
trait Describe { fn describe(&self) -> String; }
type Count = u32;
impl Describe for u32 { fn describe(&self) -> String { "a count".to_string() } }
impl Describe for Count { fn describe(&self) -> String { "a count".to_string() } }
fn main() { let n: Count = 3; println!("{}", n.describe()); }
$ rustc --edition 2021 fail_alias.rs -o fail_alias
error[E0119]: conflicting implementations of trait `Describe` for type `u32`
--> fail_alias.rs:4:1
|
3 | impl Describe for u32 { fn describe(&self) -> String { "a count".to_string() } }
| --------------------- first implementation here
4 | impl Describe for Count { fn describe(&self) -> String { "a count".to_string() } }
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
The header gives the alias away: it reports the conflict "for type u32", never mentioning Count, because by the time coherence is checked the alias has been expanded to the type it names. This family is the usual result of reaching for an alias as if it were a wrapper - expecting Count values to behave differently from other u32 values. An alias cannot carry that difference; a newtype struct, struct Count(u32), is a genuinely distinct type that can hold its own impl alongside the u32 impl. The fix for the alias as written is to keep one impl - under either name, since they denote the same type:
trait Describe { fn describe(&self) -> String; }
type Count = u32;
impl Describe for Count { fn describe(&self) -> String { "a count".to_string() } }
fn main() { let n: Count = 3; println!("{}", n.describe()); }
$ rustc --edition 2021 fix_alias.rs -o fix_alias
$ ./fix_alias
a count
The output is a count. The diagnostic's wording is the tell for this family in real code: when the header names a type that appears in only one of the two blocks, the other block's type is an alias, a generic instantiation, or a re-export of it - find the name that expands to the header's type.
The eighth failure: an impl that collides with a blanket impl in core
Token converts into itself, and core already implements that conversion for every type: the blanket impl impl<T> From<T> for T covers From<Token> for Token before your block is considered. Writing the identity conversion by hand therefore conflicts with an implementation that is not in your file:
struct Token { value: i32 }
impl From<Token> for Token { fn from(t: Token) -> Self { t } }
fn main() { let t = Token::from(Token { value: 5 }); println!("{}", t.value); }
$ rustc --edition 2021 fail_std_blanket.rs -o fail_std_blanket
error[E0119]: conflicting implementations of trait `From<Token>` for type `Token`
--> fail_std_blanket.rs:2:1
|
2 | impl From<Token> for Token { fn from(t: Token) -> Self { t } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> From<T> for T;
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
The shape of the diagnostic changes: there is no "first implementation here" span, because the first implementation is in another crate, and the note names it instead - "conflicting implementation in crate core: - implFrom is where that blanket impl lives, and it is also what provides the corresponding Into conversion automatically. Since the other side cannot be deleted or edited, the fix is always on your side: remove your impl and use the one that already exists - here the identity conversion needs no code at all, so the fix constructs the value directly:
struct Token { value: i32 }
fn main() { let t = Token { value: 5 }; println!("{}", t.value); }
$ rustc --edition 2021 fix_std_blanket.rs -o fix_std_blanket
$ ./fix_std_blanket
5
The output is 5. This family generalizes past From: any trait with a blanket impl in the standard library - Into, the blanket impls behind ToString, Borrow, and others - already claims the pairs inside its coverage, and an impl you write there meets a note like this one rather than a span in your file. When a conflict diagnostic shows a note instead of a second span, stop searching your own crate for the duplicate; it is not there.
The fixes in reach order
- The diagnostic shows two spans in your files, both naming the same trait and type outright: an exact duplicate or an attempted override - delete one block, or separate the two behaviors into different traits, trait arguments, or types.
- One span is a blanket impl,
impl<T> Trait for T, and the other names a specific type: the blanket impl already claims that type - delete the specific impl, or delete the blanket impl and write per-type impls. - One span is a blanket impl with a bound, and the header's type satisfies the bound: the bound separates nothing - the same choice as the unbounded case, or a separation made in the types rather than the bound.
- The header's type is an instantiation of a generic block, such as
Vec<i32>reached fromVec<T>atT = i32: a generic impl overlaps a concrete one - delete the concrete exception, or move the special case to its own trait or a newtype. - The header's trait reference carries a concrete argument, such as
Named<String>, against a generic-argument impl: the generic argument can equal the concrete one - keep one argument list per implementing type, or split the behaviors across traits. - The header names a type that appears in only one block: the other block's type expands to it - most often a type alias; keep one impl, or replace the alias with a newtype struct if the two cases must differ.
- The diagnostic has a note naming an impl in another crate instead of a second span: the conflict is with a library blanket impl - delete your impl; the other side cannot change.
Traps
- An uncovered type parameter in a foreign trait impl is E0210, not E0119.
Box<T>is a fundamental type, soTinside it is uncovered, and no local type appears in this impl of the foreign traitUnwindSafeat all - the impl is rejected for who may write it, before any question of a second impl arises:
use std::panic::UnwindSafe;
impl<T> UnwindSafe for Box<T> {}
fn main() {}
$ rustc --edition 2021 probe_e0210.rs -o probe_e0210
error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct<T>`)
--> probe_e0210.rs:2:6
|
2 | impl<T> UnwindSafe for Box<T> {}
| ^ 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
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0210`.
T must be used as an argument to some local type" and the error codes index defines E0210 as a violation of the orphan rules concerning type parameters in an implementation of a foreign trait, which must be covered by a local type. There is only one impl in the program: E0119 needs two claims on a pair, E0210 needs one claim nobody is allowed to make. The fix direction differs accordingly - cover the parameter with a local type, as in impl<T> UnwindSafe for MyType<T>, rather than deleting an impl.
- A foreign trait implemented for a foreign type is E0117, not E0119. Display is defined in the standard library and so is Vec, so this impl has no local trait and no local type - the plain orphan-rule failure:use std::fmt;
impl fmt::Display for Vec<i32> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "numbers") } }
fn main() { println!("{}", vec![1, 2]); }
$ rustc --edition 2021 probe_e0117.rs -o probe_e0117
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
--> probe_e0117.rs:2:1
|
2 | impl fmt::Display for Vec<i32> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "numbers") } }
| ^^^^^^^^^^^^^^^^^^^^^^--------
| |
| `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`.
The header reads "only traits defined in the current crate can be implemented for types defined outside of the crate" and the error codes index defines E0117 as the orphan-rule violation where the implementing type and every trait parameter are foreign. E0210 and E0117 are the two faces of the orphan rule - an uncovered parameter, and no local type at all - while E0119 is the overlap rule, and it can fire on impls that pass the orphan check perfectly, as every family in this guide does: local trait, local types, and still two claims. The note's own remedy is the standard one for both orphan codes: define and implement a trait or new type instead - wrap the foreign type in a local newtype, or define a local trait.
- A method that no impl provides is E0599, not E0119. Meter here has no Describe impl at all - nothing is duplicated; the method simply does not exist for the type:
struct Meter { reading: i32 }
fn main() { println!("{}", Meter { reading: 7 }.describe()); }
$ rustc --edition 2021 probe_e0599.rs -o probe_e0599
error[E0599]: no method named `describe` found for struct `Meter` in the current scope
--> probe_e0599.rs:2:49
|
1 | struct Meter { reading: i32 }
| ------------ method `describe` not found for this struct
2 | fn main() { println!("{}", Meter { reading: 7 }.describe()); }
| ^^^^^^^^ method not found in `Meter`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0599`.
The header reads "no method named describe found for struct Meter in the current scope" - the count of usable implementations is zero, where E0119 is a count of two. The two codes meet in practice: deleting the wrong block while fixing E0119, or deleting both, turns the conflict into this error at the call site. The E0599 guide works that side, including the common case where the impl exists but the trait is not in scope. A fix for E0119 is only complete when the program compiles past both - one impl standing, and the call resolving to it.
Decision summary
- The header says "conflicting implementations of trait
Xfor typeY" (E0119): two impls can apply to the pair - keep one, or redesign so the two blocks claim different pairs. - The two spans are identical or near-identical blocks in your files (E0119): a duplicate - delete one; if the bodies differ, the second was an attempted override, and the behavior choice belongs in the surviving block.
- One span is a blanket impl, bounded or not, and the other is specific (E0119): the blanket impl already covers the specific type - one of the two blocks goes.
- The header's type or trait argument is an instantiation, such as
Vec<i32>orNamed<String>(E0119): a generic impl overlaps a concrete one at that instantiation - the concrete exception cannot stand next to the generic impl. - The header names a type written in only one block (E0119): the other block reaches the same type through an alias or a generic parameter - an alias is the same type; a newtype is a different one.
- A note names a conflicting implementation in another crate, such as
core(E0119): a library blanket impl holds the pair - delete your impl. - The header says a type parameter "must be used as an argument to some local type" (E0210): an orphan-rule failure over an uncovered parameter - cover the parameter with a local type; there is no duplicate to delete.
- The header says "only traits defined in the current crate can be implemented for types defined outside of the crate" (E0117): a foreign trait for a foreign type - define a local trait or wrap the type in a newtype.
- The header says "no method named ... found" (E0599): no impl provides the method - add the impl, or bring the trait that provides it into scope.
- The header says "mismatched types" (E0308): no impl question at all - a value's type differs from the expected type, the subject of the E0308 guide.
Checklist
- Both claims located before any edit: the diagnostic's two spans, or the span plus the note naming an impl in another crate - the fix always acts on one of those two.
- The overlap mechanism identified: same pair written twice, a blanket impl covering a specific type, a bound the type satisfies, a generic instantiation meeting a concrete impl, or an alias expanding to the same type - each has a different redesign when deletion is not acceptable.
- No appeal to priority: the later block does not win, the specific block does not win, and identical bodies do not merge - exactly one impl must remain.
- Bounds checked for actual separation: a bound separates a blanket impl from a specific impl only if the compiler can prove the specific type never satisfies it.
- Aliases treated as the same type: differing behavior for an alias's values requires a newtype struct, not a second impl.
- Library blanket impls accounted for before writing an impl of a standard trait:
From,Into, and their kin may already claim the pair, and the note in the diagnostic is the sign. - After one impl is removed, the program compiled again and run: deleting both blocks, or the one the call sites used, surfaces as E0599, and the fix is finished only when the call resolves to the surviving impl and the output is the value the program was written to produce.
Related guides on this site
- Fix Rust E0277 "the trait bound ... is not satisfied" — Missing Trait Impl, Missing Ord, the ? Conversion, Sized, and Clone
- E0107 Wrong Generics Fix
- E0061 Wrong Argument Count Fix
- E0432 Unresolved Import Fix
Sources
- Rust, Error codes index: E0119 - the definition of the error: there are conflicting trait implementations for the same type, with the blanket impl example -
impl<T> MyTrait for Tfollowed by an impl for one type - and the explanation that a trait cannot be implemented multiple times for the same type. - The Rust Reference, Implementations - trait implementation coherence: an implementation is incoherent if the orphan rules check fails or there are overlapping implementation instances, two implementations overlap when they can be instantiated with the same type, and the orphan rule allows an impl only if the trait or at least one of its types is local.
- The Rust Programming Language, Traits: Defining Shared Behavior - trait definitions and implementations, and the coherence and orphan-rule restriction: a trait can be implemented for a type only if either the trait or the type is local to the crate, because without the rule two crates could implement the same trait for the same type and Rust would not know which implementation to use.
- Rust std::convert, From - the
Fromtrait and its blanket implementation for every type,impl<T> From<T> for T, which already provides the identity conversion and the correspondingIntoimpl - the other side of the eighth family. - Rust, Error codes index: E0210 - the neighboring orphan-rule error for type parameters: a violation of the orphan rules for trait implementations, where type parameters in an implementation of a foreign trait must be covered by a local type.
- Rust, Error codes index: E0117 - the neighboring orphan-rule error for foreign types: only traits defined in the current crate can be implemented for arbitrary types, covering an implementation of a foreign trait where the implementing type and all trait parameters are foreign.
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.