Skip to content

Commit 50b43f6

Browse files
committed
E0283 error explain
1 parent 9da7706 commit 50b43f6

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

src/librustc/diagnostics.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,46 @@ This will fail because the compiler does not know which instance of `Foo` to
15871587
call `bar` on. Change `Foo::bar()` to `Foo::<T>::bar()` to resolve the error.
15881588
"##,
15891589

1590+
E0283: r##"
1591+
This error occurs when the compiler doesn't have enough information
1592+
to unambiguously choose an implementation.
1593+
1594+
For example:
1595+
1596+
```
1597+
trait Generator {
1598+
fn create() -> u32;
1599+
}
1600+
1601+
struct Impl;
1602+
impl Generator for Impl {
1603+
fn create() -> u32 { 1 }
1604+
}
1605+
1606+
struct AnotherImpl;
1607+
impl Generator for AnotherImpl {
1608+
fn create() -> u32 { 2 }
1609+
}
1610+
1611+
fn main() {
1612+
let cont: u32 = Generator::create();
1613+
// error, impossible to choose one of Generator trait implementation
1614+
// Impl or AnotherImpl? Maybe anything else?
1615+
}
1616+
```
1617+
1618+
To resolve this error use the concrete type:
1619+
1620+
```
1621+
fn main() {
1622+
let gen1 = AnotherImpl::create();
1623+
1624+
// if there are multiple methods with same name (different traits)
1625+
let gen2 = <AnotherImpl as Generator>::create();
1626+
}
1627+
```
1628+
"##,
1629+
15901630
E0296: r##"
15911631
This error indicates that the given recursion limit could not be parsed. Ensure
15921632
that the value provided is a positive integer between quotes, like so:
@@ -1900,7 +1940,6 @@ register_diagnostics! {
19001940
E0278, // requirement is not satisfied
19011941
E0279, // requirement is not satisfied
19021942
E0280, // requirement is not satisfied
1903-
E0283, // cannot resolve type
19041943
E0284, // cannot resolve type
19051944
E0285, // overflow evaluation builtin bounds
19061945
E0298, // mismatched types between arms

0 commit comments

Comments
 (0)