Skip to content

Commit

Permalink
Add test case for suggestion E0283
Browse files Browse the repository at this point in the history
  • Loading branch information
sasurau4 committed Jan 18, 2021
1 parent db95b5c commit 8b041cd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/test/ui/error-codes/E0283.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -17,3 +29,9 @@ impl Generator for AnotherImpl {
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);
}
16 changes: 14 additions & 2 deletions src/test/ui/error-codes/E0283.stderr
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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`.

0 comments on commit 8b041cd

Please sign in to comment.