Skip to content

Commit 38ea235

Browse files
committed
Don't use main; improve example
1 parent 1cbacc0 commit 38ea235

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

compiler/rustc_error_codes/src/error_codes/E0283.md

+5-9
Original file line numberDiff line numberDiff 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

1816
This error can be solved by adding type annotations that provide the missing
1917
information to the compiler. In this case, the solution is to specify the
20-
fully-qualified method:
18+
trait's type parameter:
2119

2220
```
2321
struct 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
```

compiler/rustc_error_codes/src/error_codes/E0790.md

+6-10
Original file line numberDiff line numberDiff 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

3028
This 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
```

0 commit comments

Comments
 (0)