Skip to content

Commit 8b041cd

Browse files
committed
Add test case for suggestion E0283
1 parent db95b5c commit 8b041cd

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

Diff for: src/test/ui/error-codes/E0283.rs

+18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ impl Generator for Impl {
88
fn create() -> u32 { 1 }
99
}
1010

11+
impl Impl {
12+
fn new() -> Self {
13+
Impl{}
14+
}
15+
}
16+
17+
impl Into<u32> for Impl {
18+
fn into(self) -> u32 { 1 }
19+
}
20+
21+
fn foo(bar: u32) {}
22+
1123
struct AnotherImpl;
1224

1325
impl Generator for AnotherImpl {
@@ -17,3 +29,9 @@ impl Generator for AnotherImpl {
1729
fn main() {
1830
let cont: u32 = Generator::create(); //~ ERROR E0283
1931
}
32+
33+
fn buzz() {
34+
let foo_impl = Impl::new();
35+
let bar = foo_impl.into() * 1u32; //~ ERROR E0283
36+
foo(bar);
37+
}

Diff for: src/test/ui/error-codes/E0283.stderr

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0283]: type annotations needed
2-
--> $DIR/E0283.rs:18:21
2+
--> $DIR/E0283.rs:30:21
33
|
44
LL | fn create() -> u32;
55
| ------------------- required by `Generator::create`
@@ -9,6 +9,18 @@ LL | let cont: u32 = Generator::create();
99
|
1010
= note: cannot satisfy `_: Generator`
1111

12-
error: aborting due to previous error
12+
error[E0283]: type annotations needed
13+
--> $DIR/E0283.rs:35:24
14+
|
15+
LL | let bar = foo_impl.into() * 1u32;
16+
| ---------^^^^--
17+
| | |
18+
| | cannot infer type for type parameter `T` declared on the trait `Into`
19+
| this method call resolves to `T`
20+
| help: use the fully qualified path for the potential candidate: `<Impl as Into<u32>>::into(foo_impl)`
21+
|
22+
= note: cannot satisfy `Impl: Into<_>`
23+
24+
error: aborting due to 2 previous errors
1325

1426
For more information about this error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)