Change or_patterns_back_compat lint to rust_2021_incompatible_or_patterns
This commit is contained in:
parent
df71a99a0e
commit
1d49658f5c
7 changed files with 14 additions and 10 deletions
|
@ -18,7 +18,9 @@ use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||||
use rustc_feature::Features;
|
use rustc_feature::Features;
|
||||||
use rustc_lint_defs::builtin::{OR_PATTERNS_BACK_COMPAT, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS};
|
use rustc_lint_defs::builtin::{
|
||||||
|
RUST_2021_INCOMPATIBLE_OR_PATTERNS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
|
||||||
|
};
|
||||||
use rustc_lint_defs::BuiltinLintDiagnostics;
|
use rustc_lint_defs::BuiltinLintDiagnostics;
|
||||||
use rustc_parse::parser::Parser;
|
use rustc_parse::parser::Parser;
|
||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::parse::ParseSess;
|
||||||
|
@ -975,7 +977,7 @@ fn check_matcher_core(
|
||||||
Some(NonterminalKind::PatParam { inferred: false }),
|
Some(NonterminalKind::PatParam { inferred: false }),
|
||||||
));
|
));
|
||||||
sess.buffer_lint_with_diagnostic(
|
sess.buffer_lint_with_diagnostic(
|
||||||
&OR_PATTERNS_BACK_COMPAT,
|
&RUST_2021_INCOMPATIBLE_OR_PATTERNS,
|
||||||
span,
|
span,
|
||||||
ast::CRATE_NODE_ID,
|
ast::CRATE_NODE_ID,
|
||||||
"the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro",
|
"the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro",
|
||||||
|
|
|
@ -326,6 +326,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
|
||||||
store.register_renamed("overlapping_patterns", "overlapping_range_endpoints");
|
store.register_renamed("overlapping_patterns", "overlapping_range_endpoints");
|
||||||
store.register_renamed("safe_packed_borrows", "unaligned_references");
|
store.register_renamed("safe_packed_borrows", "unaligned_references");
|
||||||
store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
|
store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
|
||||||
|
store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
|
||||||
|
|
||||||
// These were moved to tool lints, but rustc still sees them when compiling normally, before
|
// These were moved to tool lints, but rustc still sees them when compiling normally, before
|
||||||
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
|
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
|
||||||
|
|
|
@ -2970,7 +2970,7 @@ declare_lint_pass! {
|
||||||
RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
|
RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
|
||||||
LEGACY_DERIVE_HELPERS,
|
LEGACY_DERIVE_HELPERS,
|
||||||
PROC_MACRO_BACK_COMPAT,
|
PROC_MACRO_BACK_COMPAT,
|
||||||
OR_PATTERNS_BACK_COMPAT,
|
RUST_2021_INCOMPATIBLE_OR_PATTERNS,
|
||||||
LARGE_ASSIGNMENTS,
|
LARGE_ASSIGNMENTS,
|
||||||
FUTURE_PRELUDE_COLLISION,
|
FUTURE_PRELUDE_COLLISION,
|
||||||
RESERVED_PREFIX,
|
RESERVED_PREFIX,
|
||||||
|
@ -3183,12 +3183,12 @@ declare_lint! {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `or_patterns_back_compat` lint detects usage of old versions of or-patterns.
|
/// The `rust_2021_incompatible_or_patterns` lint detects usage of old versions of or-patterns.
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
/// ```rust,compile_fail
|
/// ```rust,compile_fail
|
||||||
/// #![deny(or_patterns_back_compat)]
|
/// #![deny(rust_2021_incompatible_or_patterns)]
|
||||||
/// macro_rules! match_any {
|
/// macro_rules! match_any {
|
||||||
/// ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
|
/// ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
|
||||||
/// match $expr {
|
/// match $expr {
|
||||||
|
@ -3211,7 +3211,7 @@ declare_lint! {
|
||||||
/// ### Explanation
|
/// ### Explanation
|
||||||
///
|
///
|
||||||
/// In Rust 2021, the pat matcher will match new patterns, which include the | character.
|
/// In Rust 2021, the pat matcher will match new patterns, which include the | character.
|
||||||
pub OR_PATTERNS_BACK_COMPAT,
|
pub RUST_2021_INCOMPATIBLE_OR_PATTERNS,
|
||||||
Allow,
|
Allow,
|
||||||
"detects usage of old versions of or-patterns",
|
"detects usage of old versions of or-patterns",
|
||||||
@future_incompatible = FutureIncompatibleInfo {
|
@future_incompatible = FutureIncompatibleInfo {
|
||||||
|
|
|
@ -164,6 +164,7 @@
|
||||||
#![feature(no_niche)] // rust-lang/rust#68303
|
#![feature(no_niche)] // rust-lang/rust#68303
|
||||||
#![feature(no_coverage)] // rust-lang/rust#84605
|
#![feature(no_coverage)] // rust-lang/rust#84605
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
#![allow(renamed_and_removed_lints)]
|
||||||
#![deny(or_patterns_back_compat)]
|
#![deny(or_patterns_back_compat)]
|
||||||
|
|
||||||
// allow using `core::` in intra-doc links
|
// allow using `core::` in intra-doc links
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
// aux-build:or-pattern.rs
|
// aux-build:or-pattern.rs
|
||||||
|
|
||||||
#![deny(or_patterns_back_compat)]
|
#![deny(rust_2021_incompatible_or_patterns)]
|
||||||
#![allow(unused_macros)]
|
#![allow(unused_macros)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
// aux-build:or-pattern.rs
|
// aux-build:or-pattern.rs
|
||||||
|
|
||||||
#![deny(or_patterns_back_compat)]
|
#![deny(rust_2021_incompatible_or_patterns)]
|
||||||
#![allow(unused_macros)]
|
#![allow(unused_macros)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -7,8 +7,8 @@ LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/macro-or-patterns-back-compat.rs:4:9
|
--> $DIR/macro-or-patterns-back-compat.rs:4:9
|
||||||
|
|
|
|
||||||
LL | #![deny(or_patterns_back_compat)]
|
LL | #![deny(rust_2021_incompatible_or_patterns)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>
|
= note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue