File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed
compiler/rustc_error_codes/src/error_codes Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Erroneous code example:
4
4
5
5
``` edition2021,compile_fail,E782
6
6
trait Foo {}
7
- fn test(arg: Box<Foo>) {}
7
+ fn test(arg: Box<Foo>) {} // error!
8
8
```
9
9
10
10
Trait objects are a way to call methods on types that are not known until
@@ -20,7 +20,7 @@ To fix this issue, add `dyn` before the trait name.
20
20
21
21
```
22
22
trait Foo {}
23
- fn test(arg: Box<dyn Foo>) {}
23
+ fn test(arg: Box<dyn Foo>) {} // ok!
24
24
```
25
25
26
26
This used to be allowed before edition 2021, but is now an error.
Original file line number Diff line number Diff line change @@ -3,11 +3,9 @@ The range pattern `...` is no longer allowed.
3
3
Erroneous code example:
4
4
5
5
``` edition2021,compile_fail,E782
6
- fn main() {
7
- match 2u8 {
8
- 0...9 => println!("Got a number less than 10"),
9
- _ => println!("Got a number 10 or more")
10
- }
6
+ match 2u8 {
7
+ 0...9 => println!("Got a number less than 10"), // error!
8
+ _ => println!("Got a number 10 or more"),
11
9
}
12
10
```
13
11
@@ -17,10 +15,8 @@ ranges which are now signified using `..=`.
17
15
To make this code compile replace the ` ... ` with ` ..= ` .
18
16
19
17
```
20
- fn main() {
21
- match 2u8 {
22
- 0..=9 => println!("Got a number less than 10"),
23
- _ => println!("Got a number 10 or more")
24
- }
18
+ match 2u8 {
19
+ 0..=9 => println!("Got a number less than 10"), // ok!
20
+ _ => println!("Got a number 10 or more"),
25
21
}
26
22
```
You can’t perform that action at this time.
0 commit comments