mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 06:35:27 +00:00
Add compatibility info to lints
This commit is contained in:
parent
cebc520034
commit
aa4457fa5f
@ -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!
|
||||
```
|
||||
|
@ -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"),
|
||||
|
@ -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)]
|
||||
|
@ -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! {
|
||||
|
16
src/test/ui/dyn-keyword/dyn-2018-edition-lint.rs
Normal file
16
src/test/ui/dyn-keyword/dyn-2018-edition-lint.rs
Normal 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() {}
|
34
src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr
Normal file
34
src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user