Skip to content

Commit 3eeabe7

Browse files
committed
Add hardwired lint for dyn trait
1 parent da9dc05 commit 3eeabe7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/librustc/lint/builtin.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! lints are all available in `rustc_lint::builtin`.
1616
1717
use lint::{LintPass, LateLintPass, LintArray};
18+
use session::config::Epoch;
1819

1920
declare_lint! {
2021
pub CONST_ERR,
@@ -252,6 +253,13 @@ declare_lint! {
252253
"hidden lifetime parameters are deprecated, try `Foo<'_>`"
253254
}
254255

256+
declare_lint! {
257+
pub BARE_TRAIT_OBJECT,
258+
Warn,
259+
"suggest using `dyn Trait` for trait objects",
260+
Epoch::Epoch2018
261+
}
262+
255263
/// Does nothing as a lint pass, but registers some `Lint`s
256264
/// which are used by other parts of the compiler.
257265
#[derive(Copy, Clone)]
@@ -298,8 +306,8 @@ impl LintPass for HardwiredLints {
298306
COERCE_NEVER,
299307
SINGLE_USE_LIFETIME,
300308
TYVAR_BEHIND_RAW_POINTER,
301-
ELIDED_LIFETIME_IN_PATH
302-
309+
ELIDED_LIFETIME_IN_PATH,
310+
BARE_TRAIT_OBJECT
303311
)
304312
}
305313
}

src/librustc_lint/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
272272
reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
273273
epoch: None,
274274
},
275+
FutureIncompatibleInfo {
276+
id: LintId::of(lint::builtin::BARE_TRAIT_OBJECT),
277+
reference: "issue #48457 <https://github.com/rust-lang/rust/issues/48457>",
278+
epoch: Some(session::config::Epoch::Epoch2018),
279+
}
275280
]);
276281

277282
// Register renamed and removed lints

0 commit comments

Comments
 (0)