mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Update error code docs even more
This commit is contained in:
parent
4f67392c48
commit
2c1429ca5e
@ -4,7 +4,7 @@ Erroneous code example:
|
|||||||
|
|
||||||
```edition2021,compile_fail,E782
|
```edition2021,compile_fail,E782
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
fn test(arg: Box<Foo>) {}
|
fn test(arg: Box<Foo>) {} // error!
|
||||||
```
|
```
|
||||||
|
|
||||||
Trait objects are a way to call methods on types that are not known until
|
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.
|
|||||||
|
|
||||||
```
|
```
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
fn test(arg: Box<dyn Foo>) {}
|
fn test(arg: Box<dyn Foo>) {} // ok!
|
||||||
```
|
```
|
||||||
|
|
||||||
This used to be allowed before edition 2021, but is now an error.
|
This used to be allowed before edition 2021, but is now an error.
|
||||||
|
@ -3,11 +3,9 @@ The range pattern `...` is no longer allowed.
|
|||||||
Erroneous code example:
|
Erroneous code example:
|
||||||
|
|
||||||
```edition2021,compile_fail,E782
|
```edition2021,compile_fail,E782
|
||||||
fn main() {
|
match 2u8 {
|
||||||
match 2u8 {
|
0...9 => println!("Got a number less than 10"), // error!
|
||||||
0...9 => println!("Got a number less than 10"),
|
_ => println!("Got a number 10 or more"),
|
||||||
_ => println!("Got a number 10 or more")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -17,10 +15,8 @@ ranges which are now signified using `..=`.
|
|||||||
To make this code compile replace the `...` with `..=`.
|
To make this code compile replace the `...` with `..=`.
|
||||||
|
|
||||||
```
|
```
|
||||||
fn main() {
|
match 2u8 {
|
||||||
match 2u8 {
|
0..=9 => println!("Got a number less than 10"), // ok!
|
||||||
0..=9 => println!("Got a number less than 10"),
|
_ => println!("Got a number 10 or more"),
|
||||||
_ => println!("Got a number 10 or more")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user