diff options
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0283.md')
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0283.md | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0283.md b/compiler/rustc_error_codes/src/error_codes/E0283.md new file mode 100644 index 000000000..79d2c8204 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0283.md @@ -0,0 +1,29 @@ +An implementation cannot be chosen unambiguously because of lack of information. + +Erroneous code example: + +```compile_fail,E0283 +struct Foo; + +impl Into<u32> for Foo { + fn into(self) -> u32 { 1 } +} + +let foo = Foo; +let bar: u32 = foo.into() * 1u32; +``` + +This error can be solved by adding type annotations that provide the missing +information to the compiler. In this case, the solution is to specify the +trait's type parameter: + +``` +struct Foo; + +impl Into<u32> for Foo { + fn into(self) -> u32 { 1 } +} + +let foo = Foo; +let bar: u32 = Into::<u32>::into(foo) * 1u32; +``` |