Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021
This commit is contained in:
parent
69e1d22ddb
commit
c2d0f1457a
9 changed files with 177 additions and 32 deletions
|
@ -471,6 +471,8 @@ E0778: include_str!("./error_codes/E0778.md"),
|
|||
E0779: include_str!("./error_codes/E0779.md"),
|
||||
E0780: include_str!("./error_codes/E0780.md"),
|
||||
E0781: include_str!("./error_codes/E0781.md"),
|
||||
E0782: include_str!("./error_codes/E0782.md"),
|
||||
E0783: include_str!("./error_codes/E0783.md"),
|
||||
;
|
||||
// E0006, // merged with E0005
|
||||
// E0008, // cannot bind by-move into a pattern guard
|
||||
|
|
17
compiler/rustc_error_codes/src/error_codes/E0782.md
Normal file
17
compiler/rustc_error_codes/src/error_codes/E0782.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
Trait objects must include the `dyn` keyword.
|
||||
|
||||
Trait objects are a way to call methods on types that are not known until
|
||||
runtime but conform to some trait.
|
||||
|
||||
In the following code the trait object should be formed with
|
||||
`Box<dyn Foo>`, but `dyn` is left off.
|
||||
|
||||
```compile_fail,E0782
|
||||
trait Foo {}
|
||||
fn test(arg: Box<Foo>) {}
|
||||
```
|
||||
|
||||
This makes it harder to see that `arg` is a trait object and not a
|
||||
simply a heap allocated type called `Foo`.
|
||||
|
||||
This used to be allowed before edition 2021, but is now an error.
|
18
compiler/rustc_error_codes/src/error_codes/E0783.md
Normal file
18
compiler/rustc_error_codes/src/error_codes/E0783.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
The range pattern `...` is no longer allowed.
|
||||
|
||||
Older Rust code using previous editions allowed `...` to stand for exclusive
|
||||
ranges which are now signified using `..=`.
|
||||
|
||||
The following code use to compile, but now it now longer does.
|
||||
|
||||
```compile_fail,E0783
|
||||
fn main() {
|
||||
let n = 2u8;
|
||||
match n {
|
||||
...9 => println!("Got a number less than 10),
|
||||
_ => println!("Got a number 10 or more")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To make this code compile replace the `...` with `..=`.
|
Loading…
Add table
Add a link
Reference in a new issue