Skip to content

Commit 3da3651

Browse files
authored
Rollup merge of rust-lang#144331 - jplatte:matches-allow-non_exhaustive_omitted_patterns, r=Nadrieril
Disable non_exhaustive_omitted_patterns within matches! macro Closes rust-lang#117304. I believe I can skip all of the bootstrap stuff mentioned in rust-lang#117304 (comment) due to https://blog.rust-lang.org/inside-rust/2025/05/29/redesigning-the-initial-bootstrap-sequence/, right? cc `@Jules-Bertholet`
2 parents 50b68d9 + 8ff3ac7 commit 3da3651

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

core/src/macros/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,10 @@ pub macro debug_assert_matches($($arg:tt)*) {
426426
#[macro_export]
427427
#[stable(feature = "matches_macro", since = "1.42.0")]
428428
#[rustc_diagnostic_item = "matches_macro"]
429+
#[allow_internal_unstable(non_exhaustive_omitted_patterns_lint, stmt_expr_attributes)]
429430
macro_rules! matches {
430431
($expression:expr, $pattern:pat $(if $guard:expr)? $(,)?) => {
432+
#[allow(non_exhaustive_omitted_patterns)]
431433
match $expression {
432434
$pattern $(if $guard)? => true,
433435
_ => false

coretests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#![feature(min_specialization)]
7777
#![feature(never_type)]
7878
#![feature(next_index)]
79+
#![feature(non_exhaustive_omitted_patterns_lint)]
7980
#![feature(numfmt)]
8081
#![feature(pattern)]
8182
#![feature(pointer_is_aligned_to)]

coretests/tests/macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,9 @@ fn _expression() {
213213
}
214214
);
215215
}
216+
217+
#[deny(non_exhaustive_omitted_patterns)]
218+
fn _matches_does_not_trigger_non_exhaustive_omitted_patterns_lint(o: core::sync::atomic::Ordering) {
219+
// Ordering is a #[non_exhaustive] enum from a separate crate
220+
let _m = matches!(o, core::sync::atomic::Ordering::Relaxed);
221+
}

0 commit comments

Comments
 (0)