From 2179d01a0776645962799a9f03ca8cf9ec9df246 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Wed, 14 Jan 2026 19:10:40 +0100 Subject: [PATCH] Stabilize assert_matches feature Makes `assert_matches` and `debug_assert_matches` accessible via `std::` and `core::`. Not added to prelude because of ecosystem conflict. --- compiler/rustc_abi/src/extern_abi/tests.rs | 3 +++ compiler/rustc_abi/src/lib.rs | 2 +- .../src/diagnostics/explain_borrow.rs | 3 +++ compiler/rustc_borrowck/src/lib.rs | 2 +- .../src/type_check/input_output.rs | 3 +++ compiler/rustc_builtin_macros/src/lib.rs | 2 +- compiler/rustc_builtin_macros/src/test.rs | 3 +++ compiler/rustc_codegen_llvm/src/asm.rs | 3 +++ .../src/coverageinfo/mapgen.rs | 3 +++ compiler/rustc_codegen_llvm/src/intrinsic.rs | 3 +++ compiler/rustc_codegen_llvm/src/lib.rs | 2 +- compiler/rustc_codegen_ssa/src/back/write.rs | 3 +++ compiler/rustc_codegen_ssa/src/lib.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/builder.rs | 3 +++ .../rustc_const_eval/src/check_consts/check.rs | 3 +++ compiler/rustc_const_eval/src/interpret/call.rs | 3 +++ compiler/rustc_const_eval/src/interpret/cast.rs | 3 +++ .../src/interpret/eval_context.rs | 3 +++ .../rustc_const_eval/src/interpret/intrinsics.rs | 3 +++ .../rustc_const_eval/src/interpret/memory.rs | 3 +++ .../rustc_const_eval/src/interpret/operand.rs | 3 +++ compiler/rustc_const_eval/src/interpret/place.rs | 3 +++ compiler/rustc_const_eval/src/lib.rs | 2 +- .../rustc_data_structures/src/graph/scc/mod.rs | 3 +++ compiler/rustc_data_structures/src/lib.rs | 2 +- compiler/rustc_errors/src/lib.rs | 5 ++++- compiler/rustc_hir_analysis/src/collect.rs | 3 +++ .../src/collect/generics_of.rs | 3 +++ .../src/collect/predicates_of.rs | 3 +++ compiler/rustc_hir_analysis/src/delegation.rs | 3 +++ .../src/hir_ty_lowering/mod.rs | 3 +++ compiler/rustc_hir_analysis/src/impl_wf_check.rs | 3 +++ compiler/rustc_hir_analysis/src/lib.rs | 2 +- compiler/rustc_hir_typeck/src/lib.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 3 +++ .../rustc_infer/src/infer/outlives/verify.rs | 3 +++ .../rustc_infer/src/infer/snapshot/undo_log.rs | 3 +++ compiler/rustc_infer/src/lib.rs | 2 +- .../rustc_lint/src/impl_trait_overcaptures.rs | 3 +++ compiler/rustc_lint/src/lib.rs | 2 +- compiler/rustc_middle/src/lib.rs | 2 +- compiler/rustc_middle/src/ty/consts/kind.rs | 3 +++ compiler/rustc_middle/src/ty/context.rs | 3 +++ compiler/rustc_middle/src/ty/instance.rs | 3 +++ compiler/rustc_middle/src/ty/mod.rs | 3 +++ compiler/rustc_middle/src/ty/sty.rs | 3 +++ .../rustc_mir_build/src/builder/coverageinfo.rs | 3 +++ .../rustc_mir_build/src/builder/expr/as_place.rs | 3 +++ .../rustc_mir_build/src/builder/matches/mod.rs | 3 +++ .../src/builder/matches/user_ty.rs | 3 +++ compiler/rustc_mir_build/src/lib.rs | 2 +- compiler/rustc_mir_build/src/thir/pattern/mod.rs | 3 +++ compiler/rustc_mir_build/src/thir/util.rs | 3 +++ .../rustc_mir_dataflow/src/impls/initialized.rs | 3 +++ compiler/rustc_mir_dataflow/src/lib.rs | 2 +- .../rustc_mir_dataflow/src/value_analysis.rs | 3 +++ .../src/dataflow_const_prop.rs | 3 +++ compiler/rustc_mir_transform/src/inline.rs | 3 +++ compiler/rustc_mir_transform/src/lib.rs | 2 +- .../rustc_mir_transform/src/promote_consts.rs | 3 +++ compiler/rustc_mir_transform/src/shim.rs | 3 +++ compiler/rustc_parse/src/lib.rs | 2 +- compiler/rustc_parse/src/parser/mod.rs | 3 +++ compiler/rustc_parse/src/parser/tests.rs | 3 +++ .../rustc_query_system/src/dep_graph/graph.rs | 3 +++ compiler/rustc_query_system/src/lib.rs | 2 +- compiler/rustc_resolve/src/late.rs | 3 +++ compiler/rustc_resolve/src/lib.rs | 2 +- compiler/rustc_symbol_mangling/src/export.rs | 3 +++ compiler/rustc_symbol_mangling/src/lib.rs | 2 +- .../src/error_reporting/traits/suggestions.rs | 3 +++ compiler/rustc_trait_selection/src/lib.rs | 2 +- .../src/solve/inspect/analyse.rs | 3 +++ .../src/traits/select/mod.rs | 3 +++ compiler/rustc_ty_utils/src/abi.rs | 3 +++ compiler/rustc_ty_utils/src/layout/invariant.rs | 3 +++ compiler/rustc_ty_utils/src/lib.rs | 2 +- library/alloc/src/lib.rs | 1 - library/alloctests/lib.rs | 2 +- library/alloctests/tests/lib.rs | 2 +- library/alloctests/tests/str.rs | 3 +++ library/alloctests/tests/string.rs | 3 +++ library/alloctests/tests/vec.rs | 3 +++ library/alloctests/tests/vec_deque.rs | 3 +++ library/core/src/lib.rs | 12 ++++++------ library/core/src/macros/mod.rs | 16 ++++++---------- library/std/src/lib.rs | 14 ++++++++++---- library/std/src/sys/process/unix/unix.rs | 2 +- src/librustdoc/clean/utils.rs | 3 +++ src/librustdoc/lib.rs | 2 +- src/tools/clippy/clippy_utils/src/lib.rs | 2 +- src/tools/clippy/clippy_utils/src/ty/mod.rs | 3 +++ tests/ui-fulldeps/rustc_public/check_abi.rs | 5 ++++- .../ui-fulldeps/rustc_public/check_allocation.rs | 5 ++++- .../rustc_public/check_assoc_items.rs | 2 +- .../rustc_public/check_coroutine_body.rs | 2 +- .../ui-fulldeps/rustc_public/check_crate_defs.rs | 2 +- tests/ui-fulldeps/rustc_public/check_def_ty.rs | 2 +- tests/ui-fulldeps/rustc_public/check_defs.rs | 5 ++++- tests/ui-fulldeps/rustc_public/check_foreign.rs | 5 ++++- tests/ui-fulldeps/rustc_public/check_instance.rs | 2 +- .../ui-fulldeps/rustc_public/check_intrinsics.rs | 5 ++++- .../ui-fulldeps/rustc_public/check_item_kind.rs | 2 +- .../rustc_public/check_trait_queries.rs | 2 +- .../ui-fulldeps/rustc_public/check_transform.rs | 2 +- tests/ui-fulldeps/rustc_public/check_ty_fold.rs | 2 +- tests/ui-fulldeps/rustc_public/check_variant.rs | 2 +- .../rustc_public/closure-generic-body.rs | 2 +- tests/ui-fulldeps/rustc_public/closure_body.rs | 2 +- .../rustc_public/compilation-result.rs | 2 +- tests/ui-fulldeps/rustc_public/crate-info.rs | 5 ++++- tests/ui-fulldeps/rustc_public/projections.rs | 5 ++++- tests/ui-fulldeps/rustc_public/smir_internal.rs | 2 +- tests/ui-fulldeps/rustc_public/smir_serde.rs | 2 +- tests/ui-fulldeps/rustc_public/smir_visitor.rs | 2 +- tests/ui/coroutine/uninhabited-field.rs | 3 +-- tests/ui/macros/assert-matches-macro-msg.rs | 4 +--- tests/ui/stdlib-unit-tests/matches2021.rs | 4 +--- 118 files changed, 282 insertions(+), 79 deletions(-) diff --git a/compiler/rustc_abi/src/extern_abi/tests.rs b/compiler/rustc_abi/src/extern_abi/tests.rs index fc546a6570f0a..7e8b6efbcb313 100644 --- a/compiler/rustc_abi/src/extern_abi/tests.rs +++ b/compiler/rustc_abi/src/extern_abi/tests.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::str::FromStr; diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 061ad8617893c..fbfeb7d02f487 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1,6 +1,6 @@ // tidy-alphabetical-start #![cfg_attr(feature = "nightly", allow(internal_features))] -#![cfg_attr(feature = "nightly", feature(assert_matches))] +#![cfg_attr(all(feature = "nightly", bootstrap), feature(assert_matches))] #![cfg_attr(feature = "nightly", feature(rustc_attrs))] #![cfg_attr(feature = "nightly", feature(step_trait))] // tidy-alphabetical-end diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 743a28822eb97..1d5f1ea905218 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -3,6 +3,9 @@ #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_errors::{Applicability, Diag, EmissionGuarantee}; diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 91defbad0a0e0..ce4c09c509895 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -2,7 +2,7 @@ // tidy-alphabetical-start #![allow(internal_features)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(file_buffered)] #![feature(if_let_guard)] diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index eb31b5de05d2d..688ff3bc2d8b8 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -7,6 +7,9 @@ //! `RETURN_PLACE` the MIR arguments) are always fully normalized (and //! contain revealed `impl Trait` values). +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use itertools::Itertools; diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index e1c5a4f85c1ba..262d3734023b1 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -5,7 +5,7 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(decl_macro)] #![feature(if_let_guard)] diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 6f14385d5d30d..a475721e3636a 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -1,6 +1,9 @@ //! The expansion from a test function to the appropriate test struct for libtest //! Ideally, this code would be in libtest but for efficiency and error messages it lives here. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::iter; diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index ee1b6d45e149d..0ac5534479fd4 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_abi::{BackendRepr, Float, Integer, Primitive, Scalar}; diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index a728f3ea1e668..abbfcdce206e6 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::sync::Arc; diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 481f75f337d63..741ced34ba287 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::cmp::Ordering; use std::ffi::c_uint; diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index e0007f69828dc..6c0bd346cc32d 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -5,7 +5,7 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(extern_types)] #![feature(file_buffered)] #![feature(if_let_guard)] diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 3e36bd8552b18..71034d865621c 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::marker::PhantomData; use std::panic::AssertUnwindSafe; diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 8c39d04ef21dd..8120213a3308a 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -1,7 +1,7 @@ // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(file_buffered)] #![feature(if_let_guard)] diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs index 4f45c614e0030..dfa0d4c82cca5 100644 --- a/compiler/rustc_codegen_ssa/src/traits/builder.rs +++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::ops::Deref; diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 3a85ca3760d20..c7f0c73d2c1dc 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -1,5 +1,8 @@ //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::borrow::Cow; use std::mem; diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 94c6fd1b32387..1d1b8277d3ade 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -1,5 +1,8 @@ //! Manages calling a concrete function (with known MIR body) with argument passing, //! and returning the return value to the caller. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::borrow::Cow; diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index 3485a5c625baa..a71b1e3818d62 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_abi::{FieldIdx, Integer}; diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index d23369caffa42..45b80e33be082 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -1,4 +1,7 @@ +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use either::{Left, Right}; use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout}; diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index fe1dd1b6eb352..6fdaa84d40ff0 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -4,6 +4,9 @@ mod simd; +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_abi::{FIRST_VARIANT, FieldIdx, HasDataLayout, Size, VariantIdx}; diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 862fe47790808..f959679092043 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -6,6 +6,9 @@ //! integer. It is crucial that these operations call `check_align` *before* //! short-circuiting the empty case! +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::borrow::{Borrow, Cow}; use std::cell::Cell; diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 9a956259ba57d..60e69dacd7b58 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -1,6 +1,9 @@ //! Functions concerning immediate values and operands, and reading from operands. //! All high-level functions to read from memory work on operands as sources. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use either::{Either, Left, Right}; diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index a409c7fad4175..b407a04a9e3e3 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -2,6 +2,9 @@ //! into a place. //! All high-level functions to write to memory work on places as destinations. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use either::{Either, Left, Right}; diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index 9b1d4652212b6..1ba7223df92c9 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -1,7 +1,7 @@ // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![feature(array_try_map)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(decl_macro)] #![feature(if_let_guard)] diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 1882e6e835a4e..8f61309f6dd23 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -8,7 +8,10 @@ //! Typical examples would include: minimum element in SCC, maximum element //! reachable from it, etc. +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::fmt::Debug; use std::marker::PhantomData; use std::ops::Range; diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 41f6292e740bd..739d77a2a673c 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -15,7 +15,7 @@ #![feature(allocator_api)] #![feature(ascii_char)] #![feature(ascii_char_variants)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(auto_traits)] #![feature(cfg_select)] #![feature(core_intrinsics)] diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 148368045f4f5..d52d1a96a5a0f 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -8,7 +8,7 @@ #![allow(rustc::direct_use_of_rustc_type_ir)] #![allow(rustc::untranslatable_diagnostic)] #![cfg_attr(bootstrap, feature(array_windows))] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(default_field_values)] @@ -23,6 +23,9 @@ extern crate self as rustc_errors; +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::backtrace::{Backtrace, BacktraceStatus}; use std::borrow::Cow; diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 2c02534093870..072ef54d23e7b 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -14,6 +14,9 @@ //! At present, however, we do run collection across all items in the //! crate as a kind of pass. This should eventually be factored away. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::cell::Cell; use std::iter; diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 3d2f0466cad08..ff8dfb7797201 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::ops::ControlFlow; diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 178c47b09c84d..9da23ad868884 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use hir::Node; diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index cf0533c39e73f..ab501afebabfa 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -2,7 +2,10 @@ //! //! For more information about delegation design, see the tracking issue #118212. +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def::DefKind; diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 6e1e6c157a91e..b455b6a10880d 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -19,6 +19,9 @@ mod dyn_trait; pub mod errors; pub mod generics; +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::slice; diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index cadbc54c34108..745ae8a9eb72a 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -8,7 +8,10 @@ //! specialization errors. These things can (and probably should) be //! fixed, but for the moment it's easier to do these checks early. +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use min_specialization::check_min_specialization; use rustc_data_structures::fx::FxHashSet; diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index a51355adf72fe..44dca031e67c2 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -58,7 +58,7 @@ This API is completely unstable and subject to change. // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(gen_blocks)] #![feature(if_let_guard)] #![feature(iter_intersperse)] diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 39c28c4f4e995..6f032b2d3beb3 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -1,5 +1,5 @@ // tidy-alphabetical-start -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(if_let_guard)] #![feature(iter_intersperse)] diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index beb0337d8c591..b00e101893b55 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1,6 +1,9 @@ +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; use std::cell::{Cell, RefCell}; use std::cmp::max; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::ops::Deref; use rustc_data_structures::fx::FxHashSet; diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index f67b99cb3f846..8c8c7eeb5db8f 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_middle::ty::outlives::{Component, compute_alias_components_recursive}; diff --git a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs index c859d64133c49..6c0952317f6c2 100644 --- a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs +++ b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::marker::PhantomData; diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs index 05ea0f813818d..2bb20e390c475 100644 --- a/compiler/rustc_infer/src/lib.rs +++ b/compiler/rustc_infer/src/lib.rs @@ -14,7 +14,7 @@ // tidy-alphabetical-start #![allow(rustc::direct_use_of_rustc_type_ir)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(extend_one)] #![recursion_limit = "512"] // For rustdoc // tidy-alphabetical-end diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index 2fc9d562dc566..f83a18d8b3ca1 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -1,5 +1,8 @@ +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; use std::cell::LazyCell; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::unord::UnordSet; diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index ec7ce1ade9290..713bb7fb98383 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -22,7 +22,7 @@ // tidy-alphabetical-start #![allow(internal_features)] #![cfg_attr(bootstrap, feature(array_windows))] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(if_let_guard)] #![feature(iter_order_by)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 5f62d44df6b61..04f9b4da98beb 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -31,7 +31,7 @@ #![allow(rustc::untranslatable_diagnostic)] #![cfg_attr(bootstrap, feature(array_windows))] #![feature(allocator_api)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(associated_type_defaults)] #![feature(box_as_ptr)] #![feature(box_patterns)] diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index b3436550e8e07..3786919cdedff 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index a3eec72214c06..4667d07ec11a4 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -4,9 +4,12 @@ pub mod tls; +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; use std::borrow::{Borrow, Cow}; use std::cmp::Ordering; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::env::VarError; use std::ffi::OsStr; use std::hash::{Hash, Hasher}; diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index c27d47fcc0d8d..3b05228f47c5c 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::fmt; diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e2a94b607de10..bb26c392cd77f 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -11,6 +11,9 @@ #![allow(rustc::usage_of_ty_tykind)] +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::fmt::Debug; use std::hash::{Hash, Hasher}; diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index c282f2211f650..6542e7289fe83 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2,8 +2,11 @@ #![allow(rustc::usage_of_ty_tykind)] +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; use std::borrow::Cow; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::ops::{ControlFlow, Range}; use hir::def::{CtorKind, DefKind}; diff --git a/compiler/rustc_mir_build/src/builder/coverageinfo.rs b/compiler/rustc_mir_build/src/builder/coverageinfo.rs index 091b9dad5bc15..a3d1d4881f025 100644 --- a/compiler/rustc_mir_build/src/builder/coverageinfo.rs +++ b/compiler/rustc_mir_build/src/builder/coverageinfo.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::collections::hash_map::Entry; diff --git a/compiler/rustc_mir_build/src/builder/expr/as_place.rs b/compiler/rustc_mir_build/src/builder/expr/as_place.rs index 139c6da29d440..3a62e99b9870d 100644 --- a/compiler/rustc_mir_build/src/builder/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_place.rs @@ -1,5 +1,8 @@ //! See docs in build/expr/mod.rs +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::iter; diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 0463f7c914a4a..7c0deb00e9b07 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -5,8 +5,11 @@ //! This also includes code for pattern bindings in `let` statements and //! function parameters. +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; use std::borrow::Borrow; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::mem; use std::sync::Arc; diff --git a/compiler/rustc_mir_build/src/builder/matches/user_ty.rs b/compiler/rustc_mir_build/src/builder/matches/user_ty.rs index 2dcfd3772902c..ed377cc42d7fd 100644 --- a/compiler/rustc_mir_build/src/builder/matches/user_ty.rs +++ b/compiler/rustc_mir_build/src/builder/matches/user_ty.rs @@ -4,6 +4,9 @@ //! This avoids having to repeatedly clone a partly-built [`UserTypeProjections`] //! at every step of the traversal, which is what the previous code was doing. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::iter; diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 91cc4dfa665f4..b8db93807a466 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -3,7 +3,7 @@ // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(if_let_guard)] #![feature(try_blocks)] diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 650650cbaac90..5bf802d7dcab2 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -4,6 +4,9 @@ mod check_match; mod const_to_pat; mod migration; +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::cmp::Ordering; use std::sync::Arc; diff --git a/compiler/rustc_mir_build/src/thir/util.rs b/compiler/rustc_mir_build/src/thir/util.rs index 457957f5fce95..cbff8b348f329 100644 --- a/compiler/rustc_mir_build/src/thir/util.rs +++ b/compiler/rustc_mir_build/src/thir/util.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_hir as hir; diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs index 9216106b6eddc..31837fe19a8d8 100644 --- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs +++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_abi::VariantIdx; diff --git a/compiler/rustc_mir_dataflow/src/lib.rs b/compiler/rustc_mir_dataflow/src/lib.rs index 485925e7b50cd..f875312700cd0 100644 --- a/compiler/rustc_mir_dataflow/src/lib.rs +++ b/compiler/rustc_mir_dataflow/src/lib.rs @@ -1,5 +1,5 @@ // tidy-alphabetical-start -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(exact_size_is_empty)] diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index ac94ee5c8104e..7316b94634c61 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -1,4 +1,7 @@ +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::fmt::{Debug, Formatter}; use std::ops::Range; diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index 5254f60a15036..0f94106fb4895 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -2,6 +2,9 @@ //! //! Currently, this pass only propagates scalar values. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::cell::RefCell; use std::fmt::Formatter; diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 1e9665f4337d7..4510d197ea1c2 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -1,6 +1,9 @@ //! Inlining pass for MIR functions. +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::iter; use std::ops::{Range, RangeFrom}; diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 328a4b23c1751..9e61a570f9c03 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -1,6 +1,6 @@ // tidy-alphabetical-start #![cfg_attr(bootstrap, feature(array_windows))] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(const_type_name)] #![feature(cow_is_borrowed)] diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index 11266ccc2832a..9dfdca2901ca1 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -10,6 +10,9 @@ //! otherwise silence errors, if move analysis runs after promotion on broken //! MIR. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::cell::Cell; use std::{cmp, iter, mem}; diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 85e340c0a02ab..71990ce223a62 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::{fmt, iter}; diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 1fb44df65347e..16cdbf9eb453d 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -3,7 +3,7 @@ // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(debug_closure_helpers)] #![feature(default_field_values)] diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index d6e99bc540f74..1dfebe7e4c0c8 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -16,7 +16,10 @@ mod ty; pub mod asm; pub mod cfg_select; +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::{fmt, mem, slice}; use attr_wrapper::{AttrWrapper, UsePreAttrPos}; diff --git a/compiler/rustc_parse/src/parser/tests.rs b/compiler/rustc_parse/src/parser/tests.rs index 62e97c0c308c1..a96b3c08dad24 100644 --- a/compiler/rustc_parse/src/parser/tests.rs +++ b/compiler/rustc_parse/src/parser/tests.rs @@ -1,4 +1,7 @@ #![allow(rustc::symbol_intern_string_literal)] +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::io::prelude::*; use std::iter::Peekable; diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 8634274c3a751..51da66dffe2ff 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::fmt::Debug; use std::hash::Hash; diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs index 7fa643d91aa3b..03733674e0245 100644 --- a/compiler/rustc_query_system/src/lib.rs +++ b/compiler/rustc_query_system/src/lib.rs @@ -1,6 +1,6 @@ // tidy-alphabetical-start #![allow(internal_features)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(core_intrinsics)] #![feature(min_specialization)] // tidy-alphabetical-end diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 6d00976317729..59fc8dc142d17 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -6,9 +6,12 @@ //! If you wonder why there's no `early.rs`, that's because it's split into three files - //! `build_reduced_graph.rs`, `macros.rs` and `imports.rs`. +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; use std::borrow::Cow; use std::collections::hash_map::Entry; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::mem::{replace, swap, take}; use std::ops::ControlFlow; diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 2c22aacb32412..e02ddaf2fbc97 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -11,7 +11,7 @@ #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] #![feature(arbitrary_self_types)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_patterns)] #![feature(control_flow_into_value)] #![feature(decl_macro)] diff --git a/compiler/rustc_symbol_mangling/src/export.rs b/compiler/rustc_symbol_mangling/src/export.rs index 3896e06a627b7..589fe96d950ab 100644 --- a/compiler/rustc_symbol_mangling/src/export.rs +++ b/compiler/rustc_symbol_mangling/src/export.rs @@ -1,4 +1,7 @@ +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use rustc_abi::IntegerType; use rustc_data_structures::stable_hasher::StableHasher; diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index 7e126cb6a6e95..35a3d0dac8afa 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -88,7 +88,7 @@ //! DefPaths which are much more robust in the face of changes to the code base. // tidy-alphabetical-start -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] // tidy-alphabetical-end use rustc_hir::def::DefKind; diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index ef50dafec9503..7fef579195c4e 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -1,7 +1,10 @@ // ignore-tidy-filelength +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; use std::borrow::Cow; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::iter; use std::path::PathBuf; diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 6705d271bc7d9..c55aabeb7ef11 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -13,7 +13,7 @@ // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(default_field_values)] diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs index 944d57bf95d12..602dfbff7e93b 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs @@ -9,6 +9,9 @@ //! coherence right now and was annoying to implement, so I am leaving it //! as is until we start using it for something else. +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_infer::infer::InferCtxt; diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index d6c9adfb28177..2aef3ec1e51f7 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2,6 +2,9 @@ //! //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::cell::{Cell, RefCell}; use std::cmp; diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index ad621c67772cc..36cab6d870761 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::iter; diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index b013902f3fe3c..145abce842d2a 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use rustc_abi::{BackendRepr, FieldsShape, Scalar, Size, TagEncoding, Variants}; diff --git a/compiler/rustc_ty_utils/src/lib.rs b/compiler/rustc_ty_utils/src/lib.rs index d8b50b2d2e42f..18a8ba6d8bb91 100644 --- a/compiler/rustc_ty_utils/src/lib.rs +++ b/compiler/rustc_ty_utils/src/lib.rs @@ -5,7 +5,7 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(if_let_guard)] diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 3ca9f3ae0bc91..1a4798997a1ca 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -90,7 +90,6 @@ #![feature(allocator_api)] #![feature(array_into_iter_constructors)] #![feature(ascii_char)] -#![feature(assert_matches)] #![feature(async_fn_traits)] #![feature(async_iterator)] #![feature(box_vec_non_null)] diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 02364c01d4d62..12df80605b5ce 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -17,7 +17,7 @@ #![feature(alloc_layout_extra)] #![feature(allocator_api)] #![feature(array_into_iter_constructors)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_vec_non_null)] #![feature(char_internals)] #![feature(const_alloc_error)] diff --git a/library/alloctests/tests/lib.rs b/library/alloctests/tests/lib.rs index c7fdc2054f712..4ed8635bf8896 100644 --- a/library/alloctests/tests/lib.rs +++ b/library/alloctests/tests/lib.rs @@ -3,7 +3,7 @@ #![feature(const_heap)] #![feature(deque_extend_front)] #![feature(iter_array_chunks)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(wtf8_internals)] #![feature(cow_is_borrowed)] #![feature(core_intrinsics)] diff --git a/library/alloctests/tests/str.rs b/library/alloctests/tests/str.rs index fbb3b01fd67f9..881312773c10e 100644 --- a/library/alloctests/tests/str.rs +++ b/library/alloctests/tests/str.rs @@ -1,5 +1,8 @@ #![allow(invalid_from_utf8)] +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::borrow::Cow; use std::cmp::Ordering::{Equal, Greater, Less}; diff --git a/library/alloctests/tests/string.rs b/library/alloctests/tests/string.rs index 71557f284f475..a970a7074ef78 100644 --- a/library/alloctests/tests/string.rs +++ b/library/alloctests/tests/string.rs @@ -1,3 +1,6 @@ +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::borrow::Cow; use std::cell::Cell; diff --git a/library/alloctests/tests/vec.rs b/library/alloctests/tests/vec.rs index c8f9504ae14e8..f3f5bdfd0117f 100644 --- a/library/alloctests/tests/vec.rs +++ b/library/alloctests/tests/vec.rs @@ -3,6 +3,9 @@ use core::num::NonZero; use core::ptr::NonNull; use core::{assert_eq, assert_ne}; use std::alloc::System; +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::borrow::Cow; use std::cell::Cell; diff --git a/library/alloctests/tests/vec_deque.rs b/library/alloctests/tests/vec_deque.rs index e9f860f8df9bd..3a76234f76bc9 100644 --- a/library/alloctests/tests/vec_deque.rs +++ b/library/alloctests/tests/vec_deque.rs @@ -1,5 +1,8 @@ use core::cell::Cell; use core::num::NonZero; +#[cfg(not(bootstrap))] +use std::assert_matches; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; use std::collections::TryReserveErrorKind::*; use std::collections::VecDeque; diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index dfc9a7b5dbc32..aba0de74977fb 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -222,12 +222,12 @@ use prelude::rust_2024::*; #[macro_use] mod macros; -#[unstable(feature = "assert_matches", issue = "82775")] -/// Unstable module containing the unstable `assert_matches` macro. -pub mod assert_matches { - #[unstable(feature = "assert_matches", issue = "82775")] - pub use crate::macros::{assert_matches, debug_assert_matches}; -} +// These macros are explicitly exported here and not in the preludes - for now - to require manual +// import by users to avoid compatibility issues such as with the third-party assert_matches macro. +// See https://github.com/rust-lang/rust/pull/137487 and +// https://github.com/rust-lang/rust/issues/82913 +#[stable(feature = "assert_matches", since = "CURRENT_RUSTC_VERSION")] +pub use crate::macros::{assert_matches, debug_assert_matches}; #[unstable(feature = "derive_from", issue = "144889")] /// Unstable module containing the unstable `From` derive macro. diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index a437a4795481c..1985362c94cd3 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -138,7 +138,7 @@ macro_rules! assert_ne { /// be disabled. See [`debug_assert_matches!`] for assertions that are disabled in /// release builds by default. /// -/// [`debug_assert_matches!`]: crate::assert_matches::debug_assert_matches +/// [`debug_assert_matches!`]: crate::debug_assert_matches /// /// On panic, this macro will print the value of the expression with its debug representation. /// @@ -147,9 +147,7 @@ macro_rules! assert_ne { /// # Examples /// /// ``` -/// #![feature(assert_matches)] -/// -/// use std::assert_matches::assert_matches; +/// use std::assert_matches; /// /// let a = Some(345); /// let b = Some(56); @@ -166,7 +164,7 @@ macro_rules! assert_ne { /// assert_matches!(a, Some(x) if x > 100); /// // assert_matches!(a, Some(x) if x < 100); // panics /// ``` -#[unstable(feature = "assert_matches", issue = "82775")] +#[stable(feature = "assert_matches", since = "CURRENT_RUSTC_VERSION")] #[allow_internal_unstable(panic_internals)] #[rustc_macro_transparency = "semiopaque"] pub macro assert_matches { @@ -380,9 +378,7 @@ macro_rules! debug_assert_ne { /// # Examples /// /// ``` -/// #![feature(assert_matches)] -/// -/// use std::assert_matches::debug_assert_matches; +/// use std::debug_assert_matches; /// /// let a = Some(345); /// let b = Some(56); @@ -399,12 +395,12 @@ macro_rules! debug_assert_ne { /// debug_assert_matches!(a, Some(x) if x > 100); /// // debug_assert_matches!(a, Some(x) if x < 100); // panics /// ``` -#[unstable(feature = "assert_matches", issue = "82775")] +#[stable(feature = "assert_matches", since = "CURRENT_RUSTC_VERSION")] #[allow_internal_unstable(assert_matches)] #[rustc_macro_transparency = "semiopaque"] pub macro debug_assert_matches($($arg:tt)*) { if $crate::cfg!(debug_assertions) { - $crate::assert_matches::assert_matches!($($arg)*); + $crate::assert_matches!($($arg)*); } } diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index f5b9f69a5f9f9..656fb0ebe4e8c 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -392,7 +392,6 @@ // // Only for re-exporting: // tidy-alphabetical-start -#![feature(assert_matches)] #![feature(async_iterator)] #![feature(c_variadic)] #![feature(cfg_accessible)] @@ -470,6 +469,13 @@ extern crate std as realstd; #[macro_use] mod macros; +// These macros are explicitly exported here and not in the preludes - for now - to require manual +// import by users to avoid compatibility issues such as with the third-party assert_matches macro. +// See https://github.com/rust-lang/rust/pull/137487 and +// https://github.com/rust-lang/rust/issues/82913 +#[stable(feature = "assert_matches", since = "CURRENT_RUSTC_VERSION")] +pub use core::{assert_matches, debug_assert_matches}; + // The runtime entry point and a few unstable public functions used by the // compiler #[macro_use] @@ -711,9 +717,9 @@ pub use core::todo; // Re-export built-in macros defined through core. #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use core::{ - assert, assert_matches, cfg, column, compile_error, concat, const_format_args, env, file, - format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, - module_path, option_env, stringify, trace_macros, + assert, cfg, column, compile_error, concat, const_format_args, env, file, format_args, + format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env, + stringify, trace_macros, }; // Re-export macros defined in core. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/sys/process/unix/unix.rs b/library/std/src/sys/process/unix/unix.rs index 460d5ec0f0747..62d6e0581e6c8 100644 --- a/library/std/src/sys/process/unix/unix.rs +++ b/library/std/src/sys/process/unix/unix.rs @@ -524,7 +524,7 @@ impl Command { return Ok(None); } } - core::assert_matches::debug_assert_matches!(support, SPAWN | NO); + core::debug_assert_matches!(support, SPAWN | NO); } } _ => { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 0f75a332ad6bc..e35a05bc0147a 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -1,4 +1,7 @@ +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::fmt::{self, Display, Write as _}; use std::sync::LazyLock as Lazy; use std::{ascii, mem}; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 137319ae0c069..e37ea7e9d38bc 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -5,7 +5,7 @@ )] #![feature(ascii_char)] #![feature(ascii_char_variants)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(box_into_inner)] #![feature(box_patterns)] #![feature(file_buffered)] diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 2a620e9172285..b277018f3bbbb 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -3,7 +3,7 @@ #![feature(macro_metavar_expr)] #![feature(never_type)] #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(unwrap_infallible)] #![cfg_attr(bootstrap, feature(array_windows))] #![recursion_limit = "512"] diff --git a/src/tools/clippy/clippy_utils/src/ty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/mod.rs index a90d64e972c1f..53ad6675ab070 100644 --- a/src/tools/clippy/clippy_utils/src/ty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/mod.rs @@ -29,7 +29,10 @@ use rustc_span::{DUMMY_SP, Span, Symbol, sym}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt; use rustc_trait_selection::traits::{Obligation, ObligationCause}; +#[cfg(bootstrap)] use std::assert_matches::debug_assert_matches; +#[cfg(not(bootstrap))] +use std::debug_assert_matches; use std::collections::hash_map::Entry; use std::{iter, mem}; diff --git a/tests/ui-fulldeps/rustc_public/check_abi.rs b/tests/ui-fulldeps/rustc_public/check_abi.rs index b3519a2c60eda..c5c34914d7a34 100644 --- a/tests/ui-fulldeps/rustc_public/check_abi.rs +++ b/tests/ui-fulldeps/rustc_public/check_abi.rs @@ -6,7 +6,7 @@ //@ ignore-remote #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(ascii_char, ascii_char_variants)] extern crate rustc_driver; @@ -25,7 +25,10 @@ use rustc_public::mir::mono::Instance; use rustc_public::target::MachineInfo; use rustc_public::ty::{AdtDef, RigidTy, Ty, TyKind}; use rustc_public::{CrateDef, CrateItem, CrateItems, ItemKind}; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; +#[cfg(not(bootstrap))] +use std::assert_matches; use std::collections::HashSet; use std::convert::TryFrom; use std::io::Write; diff --git a/tests/ui-fulldeps/rustc_public/check_allocation.rs b/tests/ui-fulldeps/rustc_public/check_allocation.rs index 3a0a2382be728..a74e0cc4bbefb 100644 --- a/tests/ui-fulldeps/rustc_public/check_allocation.rs +++ b/tests/ui-fulldeps/rustc_public/check_allocation.rs @@ -8,7 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(ascii_char, ascii_char_variants)] extern crate rustc_hir; @@ -20,7 +20,10 @@ extern crate rustc_interface; extern crate rustc_public; use std::ascii::Char; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; +#[cfg(not(bootstrap))] +use std::assert_matches; use std::cmp::{max, min}; use std::collections::HashMap; use std::ffi::CStr; diff --git a/tests/ui-fulldeps/rustc_public/check_assoc_items.rs b/tests/ui-fulldeps/rustc_public/check_assoc_items.rs index 194d6be88a764..8aa2584e7a1ec 100644 --- a/tests/ui-fulldeps/rustc_public/check_assoc_items.rs +++ b/tests/ui-fulldeps/rustc_public/check_assoc_items.rs @@ -8,7 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs b/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs index 75f4f1f5bf4c0..80c944a598536 100644 --- a/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs +++ b/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs @@ -7,7 +7,7 @@ //@ edition: 2024 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_crate_defs.rs b/tests/ui-fulldeps/rustc_public/check_crate_defs.rs index 7d949eae39106..83ec195574497 100644 --- a/tests/ui-fulldeps/rustc_public/check_crate_defs.rs +++ b/tests/ui-fulldeps/rustc_public/check_crate_defs.rs @@ -6,7 +6,7 @@ //@ ignore-remote #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_hir; extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_def_ty.rs b/tests/ui-fulldeps/rustc_public/check_def_ty.rs index 5984d6f8821a9..bc485faa52d2c 100644 --- a/tests/ui-fulldeps/rustc_public/check_def_ty.rs +++ b/tests/ui-fulldeps/rustc_public/check_def_ty.rs @@ -8,7 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_defs.rs b/tests/ui-fulldeps/rustc_public/check_defs.rs index e6f9fb9972b0f..2d7fbb7e0545e 100644 --- a/tests/ui-fulldeps/rustc_public/check_defs.rs +++ b/tests/ui-fulldeps/rustc_public/check_defs.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; @@ -19,7 +19,10 @@ use mir::{TerminatorKind::*, mono::Instance}; use rustc_public::mir::mono::InstanceKind; use rustc_public::ty::{RigidTy, Ty, TyKind, UintTy}; use rustc_public::*; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; +#[cfg(not(bootstrap))] +use std::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/check_foreign.rs b/tests/ui-fulldeps/rustc_public/check_foreign.rs index bd34fb5cf8a88..511e6b7324bf9 100644 --- a/tests/ui-fulldeps/rustc_public/check_foreign.rs +++ b/tests/ui-fulldeps/rustc_public/check_foreign.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; @@ -20,7 +20,10 @@ use rustc_public::{ ty::{Abi, ForeignItemKind}, *, }; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; +#[cfg(not(bootstrap))] +use std::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/check_instance.rs b/tests/ui-fulldeps/rustc_public/check_instance.rs index fd7523963fa9b..1b622d2fa67d9 100644 --- a/tests/ui-fulldeps/rustc_public/check_instance.rs +++ b/tests/ui-fulldeps/rustc_public/check_instance.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_intrinsics.rs b/tests/ui-fulldeps/rustc_public/check_intrinsics.rs index f722f0bbd7180..a02be4bd71b6f 100644 --- a/tests/ui-fulldeps/rustc_public/check_intrinsics.rs +++ b/tests/ui-fulldeps/rustc_public/check_intrinsics.rs @@ -10,7 +10,7 @@ //@ ignore-remote #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; extern crate rustc_hir; @@ -24,7 +24,10 @@ use rustc_public::mir::mono::{Instance, InstanceKind}; use rustc_public::mir::visit::{Location, MirVisitor}; use rustc_public::mir::{LocalDecl, Terminator, TerminatorKind}; use rustc_public::ty::{FnDef, GenericArgs, RigidTy, TyKind}; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; +#[cfg(not(bootstrap))] +use std::assert_matches; use std::convert::TryFrom; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/check_item_kind.rs b/tests/ui-fulldeps/rustc_public/check_item_kind.rs index c687b3af1c632..babeb5d38f42c 100644 --- a/tests/ui-fulldeps/rustc_public/check_item_kind.rs +++ b/tests/ui-fulldeps/rustc_public/check_item_kind.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_trait_queries.rs b/tests/ui-fulldeps/rustc_public/check_trait_queries.rs index 5603add82f591..2ac05adbee930 100644 --- a/tests/ui-fulldeps/rustc_public/check_trait_queries.rs +++ b/tests/ui-fulldeps/rustc_public/check_trait_queries.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_transform.rs b/tests/ui-fulldeps/rustc_public/check_transform.rs index 815dec57b8be3..ae6954395b490 100644 --- a/tests/ui-fulldeps/rustc_public/check_transform.rs +++ b/tests/ui-fulldeps/rustc_public/check_transform.rs @@ -6,7 +6,7 @@ //@ ignore-remote #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] #![feature(ascii_char, ascii_char_variants)] extern crate rustc_hir; diff --git a/tests/ui-fulldeps/rustc_public/check_ty_fold.rs b/tests/ui-fulldeps/rustc_public/check_ty_fold.rs index 93cd304934409..b64717e7473d5 100644 --- a/tests/ui-fulldeps/rustc_public/check_ty_fold.rs +++ b/tests/ui-fulldeps/rustc_public/check_ty_fold.rs @@ -8,7 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/check_variant.rs b/tests/ui-fulldeps/rustc_public/check_variant.rs index 9bdd0c9d80ba4..dc37ac0f91fc9 100644 --- a/tests/ui-fulldeps/rustc_public/check_variant.rs +++ b/tests/ui-fulldeps/rustc_public/check_variant.rs @@ -8,7 +8,7 @@ //@ edition: 2024 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/closure-generic-body.rs b/tests/ui-fulldeps/rustc_public/closure-generic-body.rs index 46aeca76ba650..f7a3ada0b2f0c 100644 --- a/tests/ui-fulldeps/rustc_public/closure-generic-body.rs +++ b/tests/ui-fulldeps/rustc_public/closure-generic-body.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/closure_body.rs b/tests/ui-fulldeps/rustc_public/closure_body.rs index 43cbca8baab87..d1468539bafc7 100644 --- a/tests/ui-fulldeps/rustc_public/closure_body.rs +++ b/tests/ui-fulldeps/rustc_public/closure_body.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/compilation-result.rs b/tests/ui-fulldeps/rustc_public/compilation-result.rs index d33e602e8191a..9e17dd30fc5e7 100644 --- a/tests/ui-fulldeps/rustc_public/compilation-result.rs +++ b/tests/ui-fulldeps/rustc_public/compilation-result.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui-fulldeps/rustc_public/crate-info.rs b/tests/ui-fulldeps/rustc_public/crate-info.rs index 06cbbfcd69ec7..da4e4d22244fa 100644 --- a/tests/ui-fulldeps/rustc_public/crate-info.rs +++ b/tests/ui-fulldeps/rustc_public/crate-info.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_hir; extern crate rustc_middle; @@ -22,7 +22,10 @@ use rustc_public::ItemKind; use rustc_public::crate_def::CrateDef; use rustc_public::mir::mono::Instance; use rustc_public::ty::{RigidTy, TyKind}; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; +#[cfg(not(bootstrap))] +use std::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/projections.rs b/tests/ui-fulldeps/rustc_public/projections.rs index c1cdb5374d460..12c854ae39854 100644 --- a/tests/ui-fulldeps/rustc_public/projections.rs +++ b/tests/ui-fulldeps/rustc_public/projections.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_hir; extern crate rustc_middle; @@ -21,7 +21,10 @@ use rustc_public::ItemKind; use rustc_public::crate_def::CrateDef; use rustc_public::mir::{ProjectionElem, Rvalue, StatementKind}; use rustc_public::ty::{RigidTy, TyKind, UintTy}; +#[cfg(bootstrap)] use std::assert_matches::assert_matches; +#[cfg(not(bootstrap))] +use std::assert_matches; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/rustc_public/smir_internal.rs b/tests/ui-fulldeps/rustc_public/smir_internal.rs index b74bdfe4eb194..e63bd6dca27d6 100644 --- a/tests/ui-fulldeps/rustc_public/smir_internal.rs +++ b/tests/ui-fulldeps/rustc_public/smir_internal.rs @@ -8,7 +8,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_driver; extern crate rustc_interface; diff --git a/tests/ui-fulldeps/rustc_public/smir_serde.rs b/tests/ui-fulldeps/rustc_public/smir_serde.rs index 972bc5efe206c..56eaa146aa817 100644 --- a/tests/ui-fulldeps/rustc_public/smir_serde.rs +++ b/tests/ui-fulldeps/rustc_public/smir_serde.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_driver; diff --git a/tests/ui-fulldeps/rustc_public/smir_visitor.rs b/tests/ui-fulldeps/rustc_public/smir_visitor.rs index 9438f46a59b5a..c0082fdc24853 100644 --- a/tests/ui-fulldeps/rustc_public/smir_visitor.rs +++ b/tests/ui-fulldeps/rustc_public/smir_visitor.rs @@ -7,7 +7,7 @@ //@ edition: 2021 #![feature(rustc_private)] -#![feature(assert_matches)] +#![cfg_attr(bootstrap, feature(assert_matches))] extern crate rustc_middle; diff --git a/tests/ui/coroutine/uninhabited-field.rs b/tests/ui/coroutine/uninhabited-field.rs index d6ada07ce0cbc..6debd89ef4a9e 100644 --- a/tests/ui/coroutine/uninhabited-field.rs +++ b/tests/ui/coroutine/uninhabited-field.rs @@ -1,11 +1,10 @@ // Test that uninhabited saved local doesn't make the entire variant uninhabited. //@ run-pass #![allow(unused)] -#![feature(assert_matches)] #![feature(coroutine_trait)] #![feature(coroutines, stmt_expr_attributes)] #![feature(never_type)] -use std::assert_matches::assert_matches; +use std::assert_matches; use std::ops::Coroutine; use std::ops::CoroutineState; use std::pin::Pin; diff --git a/tests/ui/macros/assert-matches-macro-msg.rs b/tests/ui/macros/assert-matches-macro-msg.rs index 956bc9cf0f49b..17900936a299b 100644 --- a/tests/ui/macros/assert-matches-macro-msg.rs +++ b/tests/ui/macros/assert-matches-macro-msg.rs @@ -4,9 +4,7 @@ //@ error-pattern: right: 3 //@ needs-subprocess -#![feature(assert_matches)] - -use std::assert_matches::assert_matches; +use std::assert_matches; fn main() { assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3"); diff --git a/tests/ui/stdlib-unit-tests/matches2021.rs b/tests/ui/stdlib-unit-tests/matches2021.rs index 78c8be7321362..0958e82f43e42 100644 --- a/tests/ui/stdlib-unit-tests/matches2021.rs +++ b/tests/ui/stdlib-unit-tests/matches2021.rs @@ -3,9 +3,7 @@ // regression test for https://github.com/rust-lang/rust/pull/85678 -#![feature(assert_matches)] - -use std::assert_matches::assert_matches; +use std::assert_matches; fn main() { assert!(matches!((), ()));