Add test case for suggestion E0283

This commit is contained in:
Daiki Ihara 2021-01-15 22:33:51 +09:00
parent db95b5ca9b
commit 8b041cd8f9
2 changed files with 32 additions and 2 deletions

View File

@ -8,6 +8,18 @@ impl Generator for Impl {
fn create() -> u32 { 1 }
}
impl Impl {
fn new() -> Self {
Impl{}
}
}
impl Into<u32> for Impl {
fn into(self) -> u32 { 1 }
}
fn foo(bar: u32) {}
struct AnotherImpl;
impl Generator for AnotherImpl {
@ -17,3 +29,9 @@ fn create() -> u32 { 2 }
fn main() {
let cont: u32 = Generator::create(); //~ ERROR E0283
}
fn buzz() {
let foo_impl = Impl::new();
let bar = foo_impl.into() * 1u32; //~ ERROR E0283
foo(bar);
}

View File

@ -1,5 +1,5 @@
error[E0283]: type annotations needed
--> $DIR/E0283.rs:18:21
--> $DIR/E0283.rs:30:21
|
LL | fn create() -> u32;
| ------------------- required by `Generator::create`
@ -9,6 +9,18 @@ LL | let cont: u32 = Generator::create();
|
= note: cannot satisfy `_: Generator`
error: aborting due to previous error
error[E0283]: type annotations needed
--> $DIR/E0283.rs:35:24
|
LL | let bar = foo_impl.into() * 1u32;
| ---------^^^^--
| | |
| | cannot infer type for type parameter `T` declared on the trait `Into`
| this method call resolves to `T`
| help: use the fully qualified path for the potential candidate: `<Impl as Into<u32>>::into(foo_impl)`
|
= note: cannot satisfy `Impl: Into<_>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0283`.