Introduce proc_macro_back_compat
lint, and emit for time-macros-impl
Now that future-incompat-report support has landed in nightly Cargo, we can start to make progress towards removing the various proc-macro back-compat hacks that have accumulated in the compiler. This PR introduces a new lint `proc_macro_back_compat`, which results in a future-incompat-report entry being generated. All proc-macro back-compat warnings will be grouped under this lint. Note that this lint will never actually become a hard error - instead, we will remove the special cases for various macros, which will cause older versions of those crates to emit some other error. I've added code to fire this lint for the `time-macros-impl` case. This is the easiest case out of all of our current back-compat hacks - the crate was renamed to `time-macros`, so seeing a filename with `time-macros-impl` guarantees that an older version of the parent `time` crate is in use. When Cargo's future-incompat-report feature gets stabilized, affected users will start to see future-incompat warnings when they build their crates.
This commit is contained in:
parent
d6eaea1c88
commit
f190bc4f47
8 changed files with 206 additions and 65 deletions
|
@ -6,7 +6,7 @@
|
|||
//! compiler code, rather than using their own custom pass. Those
|
||||
//! lints are all available in `rustc_lint::builtin`.
|
||||
|
||||
use crate::{declare_lint, declare_lint_pass};
|
||||
use crate::{declare_lint, declare_lint_pass, FutureBreakage};
|
||||
use rustc_span::edition::Edition;
|
||||
|
||||
declare_lint! {
|
||||
|
@ -2955,6 +2955,7 @@ declare_lint_pass! {
|
|||
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
|
||||
DISJOINT_CAPTURE_DROP_REORDER,
|
||||
LEGACY_DERIVE_HELPERS,
|
||||
PROC_MACRO_BACK_COMPAT,
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -3082,3 +3083,53 @@ declare_lint! {
|
|||
edition: None,
|
||||
};
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `proc_macro_back_compat` lint detects uses of old versions of certain
|
||||
/// proc-macro crates, which have hardcoded workarounds in the compiler.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,ignore (needs-dependency)
|
||||
///
|
||||
/// use time_macros_impl::impl_macros;
|
||||
/// struct Foo;
|
||||
/// impl_macros!(Foo);
|
||||
/// ```
|
||||
///
|
||||
/// This will produce:
|
||||
///
|
||||
/// ```text
|
||||
/// warning: using an old version of `time-macros-impl`
|
||||
/// ::: $DIR/group-compat-hack.rs:27:5
|
||||
/// |
|
||||
/// LL | impl_macros!(Foo);
|
||||
/// | ------------------ in this macro invocation
|
||||
/// |
|
||||
/// = note: `#[warn(proc_macro_back_compat)]` on by default
|
||||
/// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
/// = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
|
||||
/// = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
|
||||
/// = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
/// ```
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// Eventually, the backwards-compatibility hacks present in the compiler will be removed,
|
||||
/// causing older versions of certain crates to stop compiling.
|
||||
/// This is a [future-incompatible] lint to ease the transition to an error.
|
||||
/// See [issue #83125] for more details.
|
||||
///
|
||||
/// [issue #83125]: https://github.com/rust-lang/rust/issues/83125
|
||||
/// [future-incompatible]: ../index.md#future-incompatible-lints
|
||||
pub PROC_MACRO_BACK_COMPAT,
|
||||
Warn,
|
||||
"detects usage of old versions of certain proc-macro crates",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>",
|
||||
edition: None,
|
||||
future_breakage: Some(FutureBreakage {
|
||||
date: None
|
||||
})
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue