File tree 2 files changed +11
-19
lines changed
compiler/rustc_error_codes/src/error_codes
2 files changed +11
-19
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,13 @@ impl Into<u32> for Foo {
9
9
fn into(self) -> u32 { 1 }
10
10
}
11
11
12
- fn main() {
13
- let foo = Foo;
14
- let bar: u32 = foo.into() * 1u32;
15
- }
12
+ let foo = Foo;
13
+ let bar: u32 = foo.into() * 1u32;
16
14
```
17
15
18
16
This error can be solved by adding type annotations that provide the missing
19
17
information to the compiler. In this case, the solution is to specify the
20
- fully-qualified method :
18
+ trait's type parameter :
21
19
22
20
```
23
21
struct Foo;
@@ -26,8 +24,6 @@ impl Into<u32> for Foo {
26
24
fn into(self) -> u32 { 1 }
27
25
}
28
26
29
- fn main() {
30
- let foo = Foo;
31
- let bar: u32 = <Foo as Into<u32>>::into(foo) * 1u32;
32
- }
27
+ let foo = Foo;
28
+ let bar: u32 = Into::<u32>::into(foo) * 1u32;
33
29
```
Original file line number Diff line number Diff line change @@ -20,11 +20,9 @@ impl Generator for AnotherImpl {
20
20
fn create() -> u32 { 2 }
21
21
}
22
22
23
- fn main() {
24
- let cont: u32 = Generator::create();
25
- // error, impossible to choose one of Generator trait implementation
26
- // Should it be Impl or AnotherImpl, maybe something else?
27
- }
23
+ let cont: u32 = Generator::create();
24
+ // error, impossible to choose one of Generator trait implementation
25
+ // Should it be Impl or AnotherImpl, maybe something else?
28
26
```
29
27
30
28
This error can be solved by adding type annotations that provide the missing
@@ -42,10 +40,8 @@ impl Generator for AnotherImpl {
42
40
fn create() -> u32 { 2 }
43
41
}
44
42
45
- fn main() {
46
- let gen1 = AnotherImpl::create();
43
+ let gen1 = AnotherImpl::create();
47
44
48
- // if there are multiple methods with same name (different traits)
49
- let gen2 = <AnotherImpl as Generator>::create();
50
- }
45
+ // if there are multiple methods with same name (different traits)
46
+ let gen2 = <AnotherImpl as Generator>::create();
51
47
```
You can’t perform that action at this time.
0 commit comments