Add migration lint for reserved prefixes.
This commit is contained in:
parent
40fb2e9705
commit
d837c00d10
4 changed files with 63 additions and 7 deletions
|
@ -2973,6 +2973,7 @@ declare_lint_pass! {
|
|||
OR_PATTERNS_BACK_COMPAT,
|
||||
LARGE_ASSIGNMENTS,
|
||||
FUTURE_PRELUDE_COLLISION,
|
||||
RESERVED_PREFIX,
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -3263,3 +3264,39 @@ declare_lint! {
|
|||
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
|
||||
};
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `reserved_prefix` lint detects identifiers that will be parsed as a
|
||||
/// prefix instead in Rust 2021.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(reserved_prefix)]
|
||||
///
|
||||
/// macro_rules! m {
|
||||
/// (z $x:expr) => ();
|
||||
/// }
|
||||
///
|
||||
/// m!(z"hey");
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// In Rust 2015 and 2018, `z"hey"` is two tokens: the identifier `z`
|
||||
/// followed by the string literal `"hey"`. In Rust 2021, the `z` is
|
||||
/// considered a prefix for `"hey"`.
|
||||
///
|
||||
/// This lint suggests to add whitespace between the `z` and `"hey"` tokens
|
||||
/// to keep them separated in Rust 2021.
|
||||
pub RESERVED_PREFIX,
|
||||
Allow,
|
||||
"identifiers that will be parsed as a prefix in Rust 2021",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reference: "issue #84978 <https://github.com/rust-lang/rust/issues/84978>",
|
||||
edition: Some(Edition::Edition2021),
|
||||
};
|
||||
crate_level_only
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue