Skip to content

Commit aa4457f

Browse files
committed
Add compatibility info to lints
1 parent cebc520 commit aa4457f

File tree

6 files changed

+62
-4
lines changed

6 files changed

+62
-4
lines changed

compiler/rustc_error_codes/src/error_codes/E0782.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ simply a heap allocated type called `Foo`.
1818

1919
To fix this issue, add `dyn` before the trait name.
2020

21-
```
21+
```edition2021
2222
trait Foo {}
2323
fn test(arg: Box<dyn Foo>) {} // ok!
2424
```

compiler/rustc_error_codes/src/error_codes/E0783.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ranges which are now signified using `..=`.
1414

1515
To make this code compile replace the `...` with `..=`.
1616

17-
```
17+
```edition2021
1818
match 2u8 {
1919
0..=9 => println!("Got a number less than 10"), // ok!
2020
_ => println!("Got a number 10 or more"),

compiler/rustc_lint/src/builtin.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,11 @@ declare_lint! {
16551655
/// [`..` range expression]: https://doc.rust-lang.org/reference/expressions/range-expr.html
16561656
pub ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
16571657
Warn,
1658-
"`...` range patterns are deprecated"
1658+
"`...` range patterns are deprecated",
1659+
@future_incompatible = FutureIncompatibleInfo {
1660+
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
1661+
edition: Some(Edition::Edition2021),
1662+
};
16591663
}
16601664

16611665
#[derive(Default)]

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,11 @@ declare_lint! {
16181618
/// [`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
16191619
pub BARE_TRAIT_OBJECTS,
16201620
Warn,
1621-
"suggest using `dyn Trait` for trait objects"
1621+
"suggest using `dyn Trait` for trait objects",
1622+
@future_incompatible = FutureIncompatibleInfo {
1623+
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
1624+
edition: Some(Edition::Edition2021),
1625+
};
16221626
}
16231627

16241628
declare_lint! {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// edition:2018
2+
#[deny(bare_trait_objects)]
3+
4+
fn function(x: &SomeTrait, y: Box<SomeTrait>) {
5+
//~^ ERROR trait objects without an explicit `dyn` are deprecated
6+
//~| WARN this was previously accepted
7+
//~| ERROR trait objects without an explicit `dyn` are deprecated
8+
//~| WARN this was previously accepted
9+
let _x: &SomeTrait = todo!();
10+
//~^ ERROR trait objects without an explicit `dyn` are deprecated
11+
//~| WARN this was previously accepted
12+
}
13+
14+
trait SomeTrait {}
15+
16+
fn main() {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: trait objects without an explicit `dyn` are deprecated
2+
--> $DIR/dyn-2018-edition-lint.rs:4:17
3+
|
4+
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
5+
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/dyn-2018-edition-lint.rs:2:8
9+
|
10+
LL | #[deny(bare_trait_objects)]
11+
| ^^^^^^^^^^^^^^^^^^
12+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
13+
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
14+
15+
error: trait objects without an explicit `dyn` are deprecated
16+
--> $DIR/dyn-2018-edition-lint.rs:4:35
17+
|
18+
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
19+
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
20+
|
21+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
22+
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
23+
24+
error: trait objects without an explicit `dyn` are deprecated
25+
--> $DIR/dyn-2018-edition-lint.rs:9:14
26+
|
27+
LL | let _x: &SomeTrait = todo!();
28+
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
29+
|
30+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
31+
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
32+
33+
error: aborting due to 3 previous errors
34+

0 commit comments

Comments
 (0)