Add compatibility info to lints

This commit is contained in:
Ryan Levick 2021-04-13 16:55:54 +02:00
parent cebc520034
commit aa4457fa5f
6 changed files with 62 additions and 4 deletions

View File

@ -18,7 +18,7 @@ simply a heap allocated type called `Foo`.
To fix this issue, add `dyn` before the trait name.
```
```edition2021
trait Foo {}
fn test(arg: Box<dyn Foo>) {} // ok!
```

View File

@ -14,7 +14,7 @@ ranges which are now signified using `..=`.
To make this code compile replace the `...` with `..=`.
```
```edition2021
match 2u8 {
0..=9 => println!("Got a number less than 10"), // ok!
_ => println!("Got a number 10 or more"),

View File

@ -1655,7 +1655,11 @@ declare_lint! {
/// [`..` range expression]: https://doc.rust-lang.org/reference/expressions/range-expr.html
pub ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
Warn,
"`...` range patterns are deprecated"
"`...` range patterns are deprecated",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
edition: Some(Edition::Edition2021),
};
}
#[derive(Default)]

View File

@ -1618,7 +1618,11 @@ declare_lint! {
/// [`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
pub BARE_TRAIT_OBJECTS,
Warn,
"suggest using `dyn Trait` for trait objects"
"suggest using `dyn Trait` for trait objects",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
edition: Some(Edition::Edition2021),
};
}
declare_lint! {

View File

@ -0,0 +1,16 @@
// edition:2018
#[deny(bare_trait_objects)]
fn function(x: &SomeTrait, y: Box<SomeTrait>) {
//~^ ERROR trait objects without an explicit `dyn` are deprecated
//~| WARN this was previously accepted
//~| ERROR trait objects without an explicit `dyn` are deprecated
//~| WARN this was previously accepted
let _x: &SomeTrait = todo!();
//~^ ERROR trait objects without an explicit `dyn` are deprecated
//~| WARN this was previously accepted
}
trait SomeTrait {}
fn main() {}

View File

@ -0,0 +1,34 @@
error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:4:17
|
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
|
note: the lint level is defined here
--> $DIR/dyn-2018-edition-lint.rs:2:8
|
LL | #[deny(bare_trait_objects)]
| ^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:4:35
|
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
error: trait objects without an explicit `dyn` are deprecated
--> $DIR/dyn-2018-edition-lint.rs:9:14
|
LL | let _x: &SomeTrait = todo!();
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
error: aborting due to 3 previous errors