Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021
This commit is contained in:
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 `..=`.
|
||||
Reference in New Issue
Block a user