File tree Expand file tree Collapse file tree 2 files changed +11
-19
lines changed
compiler/rustc_error_codes/src/error_codes Expand file tree Collapse file tree 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 {
99 fn into(self) -> u32 { 1 }
1010}
1111
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;
1614```
1715
1816This error can be solved by adding type annotations that provide the missing
1917information to the compiler. In this case, the solution is to specify the
20- fully-qualified method :
18+ trait's type parameter :
2119
2220```
2321struct Foo;
@@ -26,8 +24,6 @@ impl Into<u32> for Foo {
2624 fn into(self) -> u32 { 1 }
2725}
2826
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;
3329```
Original file line number Diff line number Diff line change @@ -20,11 +20,9 @@ impl Generator for AnotherImpl {
2020 fn create() -> u32 { 2 }
2121}
2222
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?
2826```
2927
3028This error can be solved by adding type annotations that provide the missing
@@ -42,10 +40,8 @@ impl Generator for AnotherImpl {
4240 fn create() -> u32 { 2 }
4341}
4442
45- fn main() {
46- let gen1 = AnotherImpl::create();
43+ let gen1 = AnotherImpl::create();
4744
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();
5147```
You can’t perform that action at this time.
0 commit comments