diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs index b6cb5b4504ee1..7377159be370a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs @@ -128,20 +128,14 @@ pub fn parse_cfg_select( } } - if let Some(features) = features - && features.enabled(sym::cfg_select) - { - let it = branches - .reachable - .iter() - .map(|(entry, _, _)| CfgSelectPredicate::Cfg(entry.clone())) - .chain(branches.wildcard.as_ref().map(|(t, _, _)| CfgSelectPredicate::Wildcard(*t))) - .chain( - branches.unreachable.iter().map(|(entry, _, _)| CfgSelectPredicate::clone(entry)), - ); - - lint_unreachable(p, it, lint_node_id); - } + let it = branches + .reachable + .iter() + .map(|(entry, _, _)| CfgSelectPredicate::Cfg(entry.clone())) + .chain(branches.wildcard.as_ref().map(|(t, _, _)| CfgSelectPredicate::Wildcard(*t))) + .chain(branches.unreachable.iter().map(|(entry, _, _)| CfgSelectPredicate::clone(entry))); + + lint_unreachable(p, it, lint_node_id); Ok(branches) } diff --git a/compiler/rustc_codegen_cranelift/patches/0027-sysroot_tests-128bit-atomic-operations.patch b/compiler/rustc_codegen_cranelift/patches/0027-sysroot_tests-128bit-atomic-operations.patch index 6ed0b17f679ca..7ba4475e31454 100644 --- a/compiler/rustc_codegen_cranelift/patches/0027-sysroot_tests-128bit-atomic-operations.patch +++ b/compiler/rustc_codegen_cranelift/patches/0027-sysroot_tests-128bit-atomic-operations.patch @@ -17,8 +17,8 @@ index 1e336bf..35e6f54 100644 @@ -2,4 +2,3 @@ // tidy-alphabetical-start -#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] - #![cfg_attr(test, feature(cfg_select))] #![feature(array_ptr_get)] + #![feature(array_try_from_fn)] diff --git a/coretests/tests/atomic.rs b/coretests/tests/atomic.rs index b735957..ea728b6 100644 --- a/coretests/tests/atomic.rs diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 594d6d294d75a..6bee338b23df2 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -11,6 +11,7 @@ #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] #![cfg_attr(bootstrap, feature(assert_matches))] +#![cfg_attr(bootstrap, feature(cfg_select))] #![cfg_attr(bootstrap, feature(cold_path))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] @@ -18,7 +19,6 @@ #![feature(ascii_char)] #![feature(ascii_char_variants)] #![feature(auto_traits)] -#![feature(cfg_select)] #![feature(const_default)] #![feature(const_trait_impl)] #![feature(dropck_eyepatch)] diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 24f4ed327ec5d..aa3b15dd9e890 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -102,6 +102,8 @@ declare_features! ( (accepted, cfg_doctest, "1.40.0", Some(62210)), /// Enables `#[cfg(panic = "...")]` config key. (accepted, cfg_panic, "1.60.0", Some(77443)), + /// Provides a native way to easily manage multiple conditional flags without having to rewrite each clause multiple times. + (accepted, cfg_select, "CURRENT_RUSTC_VERSION", Some(115585)), /// Allows `cfg(target_abi = "...")`. (accepted, cfg_target_abi, "1.78.0", Some(80970)), /// Allows `cfg(target_feature = "...")`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 5becbac186766..1d123385961aa 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -388,8 +388,6 @@ declare_features! ( (unstable, cfg_sanitize, "1.41.0", Some(39699)), /// Allows `cfg(sanitizer_cfi_generalize_pointers)` and `cfg(sanitizer_cfi_normalize_integers)`. (unstable, cfg_sanitizer_cfi, "1.77.0", Some(89653)), - /// Provides a native way to easily manage multiple conditional flags without having to rewrite each clause multiple times. - (unstable, cfg_select, "CURRENT_RUSTC_VERSION", Some(115585)), /// Allows `cfg(target(abi = "..."))`. (unstable, cfg_target_compact, "1.63.0", Some(96901)), /// Allows `cfg(target_has_atomic_load_store = "...")`. diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 2bec9273d38f6..0084d16e4703e 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -864,7 +864,6 @@ declare_lint! { /// ### Example /// /// ```rust - /// #![feature(cfg_select)] /// cfg_select! { /// _ => (), /// windows => (), @@ -882,7 +881,6 @@ declare_lint! { pub UNREACHABLE_CFG_SELECT_PREDICATES, Warn, "detects unreachable configuration predicates in the cfg_select macro", - @feature_gate = cfg_select; } declare_lint! { diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index d81bac4930a63..346604a46ef7d 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -103,13 +103,11 @@ impl Parse for List { struct Desc { modifier: Ident, - tcx_binding: Option, expr_list: Punctuated, } struct CacheOnDiskIf { modifier: Ident, - tcx_binding: Option, block: Block, } @@ -192,35 +190,16 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result { if modifier == "desc" { // Parse a description modifier like: - // `desc { |tcx| "foo {}", tcx.item_path(key) }` + // `desc { "foo {}", tcx.item_path(key) }` let attr_content; braced!(attr_content in input); - let tcx_binding = if attr_content.peek(Token![|]) { - attr_content.parse::()?; - let tcx = attr_content.parse()?; - attr_content.parse::()?; - Some(tcx) - } else { - None - }; let expr_list = attr_content.parse_terminated(Expr::parse, Token![,])?; - try_insert!(desc = Desc { modifier, tcx_binding, expr_list }); + try_insert!(desc = Desc { modifier, expr_list }); } else if modifier == "cache_on_disk_if" { // Parse a cache-on-disk modifier like: - // - // `cache_on_disk_if { true }` - // `cache_on_disk_if { key.is_local() }` - // `cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }` - let tcx_binding = if input.peek(token::Paren) { - let args; - parenthesized!(args in input); - let tcx = Pat::parse_single(&args)?; - Some(tcx) - } else { - None - }; + // `cache_on_disk_if { tcx.is_typeck_child(key.to_def_id()) }` let block = input.parse()?; - try_insert!(cache_on_disk_if = CacheOnDiskIf { modifier, tcx_binding, block }); + try_insert!(cache_on_disk_if = CacheOnDiskIf { modifier, block }); } else if modifier == "arena_cache" { try_insert!(arena_cache = modifier); } else if modifier == "cycle_fatal" { @@ -313,24 +292,24 @@ fn make_helpers_for_query(query: &Query, streams: &mut HelperTokenStreams) { erased_name.set_span(Span::call_site()); // Generate a function to check whether we should cache the query to disk, for some key. - if let Some(CacheOnDiskIf { tcx_binding, block, .. }) = modifiers.cache_on_disk_if.as_ref() { - let tcx = tcx_binding.as_ref().map(|t| quote! { #t }).unwrap_or_else(|| quote! { _ }); - // we're taking `key` by reference, but some rustc types usually prefer being passed by value + if let Some(CacheOnDiskIf { block, .. }) = modifiers.cache_on_disk_if.as_ref() { + // `pass_by_value`: some keys are marked with `rustc_pass_by_value`, but we take keys by + // reference here. + // FIXME: `pass_by_value` is badly named; `allow(rustc::pass_by_value)` actually means + // "allow pass by reference of `rustc_pass_by_value` types". streams.cache_on_disk_if_fns_stream.extend(quote! { #[allow(unused_variables, rustc::pass_by_value)] #[inline] - pub fn #erased_name<'tcx>(#tcx: TyCtxt<'tcx>, #key_pat: &crate::queries::#name::Key<'tcx>) -> bool + pub fn #erased_name<'tcx>(tcx: TyCtxt<'tcx>, #key_pat: &#key_ty) -> bool #block }); } - let Desc { tcx_binding, expr_list, .. } = &modifiers.desc; - let tcx = tcx_binding.as_ref().map_or_else(|| quote! { _ }, |t| quote! { #t }); + let Desc { expr_list, .. } = &modifiers.desc; let desc = quote! { #[allow(unused_variables)] - pub fn #erased_name<'tcx>(tcx: TyCtxt<'tcx>, key: #key_ty) -> String { - let (#tcx, #key_pat) = (tcx, key); + pub fn #erased_name<'tcx>(tcx: TyCtxt<'tcx>, #key_pat: #key_ty) -> String { format!(#expr_list) } }; diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 1ffbdfbf11875..5b583796c1756 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -324,11 +324,12 @@ impl StableOrd for WorkProductId { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } +// Note: `$K` and `$V` are unused but present so this can be called by `rustc_with_all_queries`. macro_rules! define_dep_nodes { ( $( $(#[$attr:meta])* - [$($modifiers:tt)*] fn $variant:ident($($K:tt)*) -> $V:ty, + [$($modifiers:tt)*] fn $variant:ident($K:ty) -> $V:ty, )* ) => { @@ -382,20 +383,20 @@ macro_rules! define_dep_nodes { } // Create various data structures for each query, and also for a few things -// that aren't queries. +// that aren't queries. The key and return types aren't used, hence the use of `()`. rustc_with_all_queries!(define_dep_nodes![ /// We use this for most things when incr. comp. is turned off. - [] fn Null() -> (), + [] fn Null(()) -> (), /// We use this to create a forever-red node. - [] fn Red() -> (), + [] fn Red(()) -> (), /// We use this to create a side effect node. - [] fn SideEffect() -> (), + [] fn SideEffect(()) -> (), /// We use this to create the anon node with zero dependencies. - [] fn AnonZeroDeps() -> (), - [] fn TraitSelect() -> (), - [] fn CompileCodegenUnit() -> (), - [] fn CompileMonoItem() -> (), - [] fn Metadata() -> (), + [] fn AnonZeroDeps(()) -> (), + [] fn TraitSelect(()) -> (), + [] fn CompileCodegenUnit(()) -> (), + [] fn CompileMonoItem(()) -> (), + [] fn Metadata(()) -> (), ]); // WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys. diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index afe39e4481efc..de3ef6deca1fc 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -181,26 +181,6 @@ impl ConstValue { Some(data.inner().inspect_with_uninit_and_ptr_outside_interpreter(start..end)) } - /// Check if a constant may contain provenance information. This is used by MIR opts. - /// Can return `true` even if there is no provenance. - pub fn may_have_provenance(&self, tcx: TyCtxt<'_>, size: Size) -> bool { - match *self { - ConstValue::ZeroSized | ConstValue::Scalar(Scalar::Int(_)) => return false, - ConstValue::Scalar(Scalar::Ptr(..)) => return true, - // It's hard to find out the part of the allocation we point to; - // just conservatively check everything. - ConstValue::Slice { alloc_id, meta: _ } => { - !tcx.global_alloc(alloc_id).unwrap_memory().inner().provenance().ptrs().is_empty() - } - ConstValue::Indirect { alloc_id, offset } => !tcx - .global_alloc(alloc_id) - .unwrap_memory() - .inner() - .provenance() - .range_empty(AllocRange::from(offset..offset + size), &tcx), - } - } - /// Check if a constant only contains uninitialized bytes. pub fn all_bytes_uninit(&self, tcx: TyCtxt<'_>) -> bool { let ConstValue::Indirect { alloc_id, .. } = self else { @@ -474,39 +454,6 @@ impl<'tcx> Const<'tcx> { let val = ConstValue::Scalar(s); Self::Val(val, ty) } - - /// Return true if any evaluation of this constant always returns the same value, - /// taking into account even pointer identity tests. - pub fn is_deterministic(&self) -> bool { - // Some constants may generate fresh allocations for pointers they contain, - // so using the same constant twice can yield two different results. - // Notably, valtrees purposefully generate new allocations. - match self { - Const::Ty(_, c) => match c.kind() { - ty::ConstKind::Param(..) => true, - // A valtree may be a reference. Valtree references correspond to a - // different allocation each time they are evaluated. Valtrees for primitive - // types are fine though. - ty::ConstKind::Value(cv) => cv.ty.is_primitive(), - ty::ConstKind::Unevaluated(..) | ty::ConstKind::Expr(..) => false, - // This can happen if evaluation of a constant failed. The result does not matter - // much since compilation is doomed. - ty::ConstKind::Error(..) => false, - // Should not appear in runtime MIR. - ty::ConstKind::Infer(..) - | ty::ConstKind::Bound(..) - | ty::ConstKind::Placeholder(..) => bug!(), - }, - Const::Unevaluated(..) => false, - Const::Val( - ConstValue::Slice { .. } - | ConstValue::ZeroSized - | ConstValue::Scalar(_) - | ConstValue::Indirect { .. }, - _, - ) => true, - } - } } /// An unevaluated (potentially generic) constant used in MIR. diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index cb922a2ad90bd..3a3a2743ec4f8 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -25,9 +25,13 @@ //! Query modifiers are special flags that alter the behavior of a query. They are parsed and processed by the `rustc_macros` //! The main modifiers are: //! -//! - `desc { ... }`: Sets the human-readable description for diagnostics and profiling. Required for every query. +//! - `desc { ... }`: Sets the human-readable description for diagnostics and profiling. Required +//! for every query. The block should contain a `format!`-style string literal followed by +//! optional arguments. The query key identifier is available for use within the block, as is +//! `tcx`. //! - `arena_cache`: Use an arena for in-memory caching of the query result. -//! - `cache_on_disk_if { ... }`: Cache the query result to disk if the provided block evaluates to true. +//! - `cache_on_disk_if { ... }`: Cache the query result to disk if the provided block evaluates to +//! true. The query key identifier is available for use within the block, as is `tcx`. //! - `cycle_fatal`: If a dependency cycle is detected, abort compilation with a fatal error. //! - `cycle_delay_bug`: If a dependency cycle is detected, emit a delayed bug instead of aborting immediately. //! - `cycle_stash`: If a dependency cycle is detected, stash the error for later handling. @@ -239,13 +243,13 @@ rustc_queries! { /// Avoid calling this query directly. query hir_module_items(key: LocalModDefId) -> &'tcx rustc_middle::hir::ModuleItems { arena_cache - desc { |tcx| "getting HIR module items in `{}`", tcx.def_path_str(key) } + desc { "getting HIR module items in `{}`", tcx.def_path_str(key) } cache_on_disk_if { true } } /// Returns HIR ID for the given `LocalDefId`. query local_def_id_to_hir_id(key: LocalDefId) -> hir::HirId { - desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key) } + desc { "getting HIR ID of `{}`", tcx.def_path_str(key) } feedable } @@ -254,7 +258,7 @@ rustc_queries! { /// This can be conveniently accessed by `tcx.hir_*` methods. /// Avoid calling this query directly. query hir_owner_parent_q(key: hir::OwnerId) -> hir::HirId { - desc { |tcx| "getting HIR parent of `{}`", tcx.def_path_str(key) } + desc { "getting HIR parent of `{}`", tcx.def_path_str(key) } } /// Gives access to the HIR nodes and bodies inside `key` if it's a HIR owner. @@ -262,7 +266,7 @@ rustc_queries! { /// This can be conveniently accessed by `tcx.hir_*` methods. /// Avoid calling this query directly. query opt_hir_owner_nodes(key: LocalDefId) -> Option<&'tcx hir::OwnerNodes<'tcx>> { - desc { |tcx| "getting HIR owner items in `{}`", tcx.def_path_str(key) } + desc { "getting HIR owner items in `{}`", tcx.def_path_str(key) } feedable } @@ -271,7 +275,7 @@ rustc_queries! { /// This can be conveniently accessed by `tcx.hir_*` methods. /// Avoid calling this query directly. query hir_attr_map(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> { - desc { |tcx| "getting HIR owner attributes in `{}`", tcx.def_path_str(key) } + desc { "getting HIR owner attributes in `{}`", tcx.def_path_str(key) } feedable } @@ -280,14 +284,14 @@ rustc_queries! { /// This can be conveniently accessed by `tcx.hir_*` methods. /// Avoid calling this query directly. query opt_ast_lowering_delayed_lints(key: hir::OwnerId) -> Option<&'tcx hir::lints::DelayedLints> { - desc { |tcx| "getting AST lowering delayed lints in `{}`", tcx.def_path_str(key) } + desc { "getting AST lowering delayed lints in `{}`", tcx.def_path_str(key) } } /// Returns the *default* of the const pararameter given by `DefId`. /// /// E.g., given `struct Ty;` this returns `3` for `N`. query const_param_default(param: DefId) -> ty::EarlyBinder<'tcx, ty::Const<'tcx>> { - desc { |tcx| "computing the default for const parameter `{}`", tcx.def_path_str(param) } + desc { "computing the default for const parameter `{}`", tcx.def_path_str(param) } cache_on_disk_if { param.is_local() } separate_provide_extern } @@ -300,7 +304,7 @@ rustc_queries! { /// /// This query will ICE if given a const that is not marked with `type const`. query const_of_item(def_id: DefId) -> ty::EarlyBinder<'tcx, ty::Const<'tcx>> { - desc { |tcx| "computing the type-level value for `{}`", tcx.def_path_str(def_id) } + desc { "computing the type-level value for `{}`", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern } @@ -324,7 +328,7 @@ rustc_queries! { /// /// [alias type]: rustc_middle::ty::AliasTy query type_of(key: DefId) -> ty::EarlyBinder<'tcx, Ty<'tcx>> { - desc { |tcx| + desc { "{action} `{path}`", action = match tcx.def_kind(key) { DefKind::TyAlias => "expanding type alias", @@ -349,14 +353,14 @@ rustc_queries! { /// /// This query will panic if the given definition is not an opaque type. query type_of_opaque(key: DefId) -> Result>, CyclePlaceholder> { - desc { |tcx| + desc { "computing type of opaque `{path}`", path = tcx.def_path_str(key), } cycle_stash } query type_of_opaque_hir_typeck(key: LocalDefId) -> ty::EarlyBinder<'tcx, Ty<'tcx>> { - desc { |tcx| + desc { "computing type of opaque `{path}` via HIR typeck", path = tcx.def_path_str(key), } @@ -376,7 +380,7 @@ rustc_queries! { /// [free]: rustc_middle::ty::Free /// [alias type]: rustc_middle::ty::AliasTy query type_alias_is_lazy(key: DefId) -> bool { - desc { |tcx| + desc { "computing whether the type alias `{path}` is lazy", path = tcx.def_path_str(key), } @@ -400,7 +404,7 @@ rustc_queries! { query unsizing_params_for_adt(key: DefId) -> &'tcx rustc_index::bit_set::DenseBitSet { arena_cache - desc { |tcx| + desc { "determining what parameters of `{}` can participate in unsizing", tcx.def_path_str(key), } @@ -409,7 +413,7 @@ rustc_queries! { /// The root query triggering all analysis passes like typeck or borrowck. query analysis(key: ()) { eval_always - desc { |tcx| + desc { "running analysis passes on crate `{}`", tcx.crate_name(LOCAL_CRATE), } @@ -436,7 +440,7 @@ rustc_queries! { /// Returns the *generics* of the definition given by `DefId`. query generics_of(key: DefId) -> &'tcx ty::Generics { - desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) } + desc { "computing generics of `{}`", tcx.def_path_str(key) } arena_cache cache_on_disk_if { key.is_local() } separate_provide_extern @@ -451,7 +455,7 @@ rustc_queries! { /// **Tip**: You can use `#[rustc_dump_predicates]` on an item to basically print /// the result of this query for use in UI tests or for debugging purposes. query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) } + desc { "computing predicates of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } } @@ -459,7 +463,7 @@ rustc_queries! { key: LocalDefId ) -> &'tcx ty::List { desc { - |tcx| "computing the opaque types defined by `{}`", + "computing the opaque types defined by `{}`", tcx.def_path_str(key.to_def_id()) } } @@ -470,7 +474,7 @@ rustc_queries! { key: LocalDefId ) -> &'tcx ty::List { desc { - |tcx| "computing the coroutines defined within `{}`", + "computing the coroutines defined within `{}`", tcx.def_path_str(key.to_def_id()) } } @@ -494,7 +498,7 @@ rustc_queries! { /// // ^^^^^^^^^^^^^^^ /// ``` query explicit_item_bounds(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) } + desc { "finding item bounds for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern feedable @@ -507,7 +511,7 @@ rustc_queries! { /// /// [explicit item bounds]: Self::explicit_item_bounds query explicit_item_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) } + desc { "finding item bounds for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern feedable @@ -537,19 +541,19 @@ rustc_queries! { /// ] /// ``` query item_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> { - desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) } + desc { "elaborating item bounds for `{}`", tcx.def_path_str(key) } } query item_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> { - desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) } + desc { "elaborating item assumptions for `{}`", tcx.def_path_str(key) } } query item_non_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> { - desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) } + desc { "elaborating item assumptions for `{}`", tcx.def_path_str(key) } } query impl_super_outlives(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> { - desc { |tcx| "elaborating supertrait outlives for trait of `{}`", tcx.def_path_str(key) } + desc { "elaborating supertrait outlives for trait of `{}`", tcx.def_path_str(key) } } /// Look up all native libraries this crate depends on. @@ -564,7 +568,7 @@ rustc_queries! { query shallow_lint_levels_on(key: hir::OwnerId) -> &'tcx rustc_middle::lint::ShallowLintLevelMap { arena_cache - desc { |tcx| "looking up lint levels for `{}`", tcx.def_path_str(key) } + desc { "looking up lint levels for `{}`", tcx.def_path_str(key) } } query lint_expectations(_: ()) -> &'tcx Vec<(LintExpectationId, LintExpectation)> { @@ -578,7 +582,7 @@ rustc_queries! { } query expn_that_defined(key: DefId) -> rustc_span::ExpnId { - desc { |tcx| "getting the expansion that defined `{}`", tcx.def_path_str(key) } + desc { "getting the expansion that defined `{}`", tcx.def_path_str(key) } separate_provide_extern } @@ -589,7 +593,7 @@ rustc_queries! { } /// Checks whether a type is representable or infinitely sized - query representability(_: LocalDefId) -> rustc_middle::ty::Representability { + query representability(key: LocalDefId) -> rustc_middle::ty::Representability { desc { "checking if `{}` is representable", tcx.def_path_str(key) } // infinitely sized types will cause a cycle cycle_delay_bug @@ -600,7 +604,7 @@ rustc_queries! { } /// An implementation detail for the `representability` query - query representability_adt_ty(_: Ty<'tcx>) -> rustc_middle::ty::Representability { + query representability_adt_ty(key: Ty<'tcx>) -> rustc_middle::ty::Representability { desc { "checking if `{}` is representable", key } cycle_delay_bug anon @@ -619,7 +623,7 @@ rustc_queries! { query thir_body(key: LocalDefId) -> Result<(&'tcx Steal>, thir::ExprId), ErrorGuaranteed> { // Perf tests revealed that hashing THIR is inefficient (see #85729). no_hash - desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key) } + desc { "building THIR for `{}`", tcx.def_path_str(key) } } /// Set of all the `DefId`s in this crate that have MIR associated with @@ -634,7 +638,7 @@ rustc_queries! { /// of the MIR const-checking pass. This is the set of qualifs in /// the final value of a `const`. query mir_const_qualif(key: DefId) -> mir::ConstQualifs { - desc { |tcx| "const checking `{}`", tcx.def_path_str(key) } + desc { "const checking `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } @@ -645,7 +649,7 @@ rustc_queries! { /// /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/construction.html query mir_built(key: LocalDefId) -> &'tcx Steal> { - desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key) } + desc { "building MIR for `{}`", tcx.def_path_str(key) } feedable } @@ -654,20 +658,20 @@ rustc_queries! { key: DefId ) -> Result>>, ErrorGuaranteed> { desc { - |tcx| "building an abstract representation for `{}`", tcx.def_path_str(key), + "building an abstract representation for `{}`", tcx.def_path_str(key), } separate_provide_extern } query mir_drops_elaborated_and_const_checked(key: LocalDefId) -> &'tcx Steal> { no_hash - desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key) } + desc { "elaborating drops for `{}`", tcx.def_path_str(key) } } query mir_for_ctfe( key: DefId ) -> &'tcx mir::Body<'tcx> { - desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) } + desc { "caching mir of `{}` for CTFE", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } @@ -677,12 +681,12 @@ rustc_queries! { &'tcx Steal>> ) { no_hash - desc { |tcx| "promoting constants in MIR for `{}`", tcx.def_path_str(key) } + desc { "promoting constants in MIR for `{}`", tcx.def_path_str(key) } } query closure_typeinfo(key: LocalDefId) -> ty::ClosureTypeInfo<'tcx> { desc { - |tcx| "finding symbols for captures of closure `{}`", + "finding symbols for captures of closure `{}`", tcx.def_path_str(key) } } @@ -696,19 +700,19 @@ rustc_queries! { /// For coroutines this only contains upvars that are shared by all states. query closure_saved_names_of_captured_variables(def_id: DefId) -> &'tcx IndexVec { arena_cache - desc { |tcx| "computing debuginfo for closure `{}`", tcx.def_path_str(def_id) } + desc { "computing debuginfo for closure `{}`", tcx.def_path_str(def_id) } separate_provide_extern } query mir_coroutine_witnesses(key: DefId) -> Option<&'tcx mir::CoroutineLayout<'tcx>> { arena_cache - desc { |tcx| "coroutine witness types for `{}`", tcx.def_path_str(key) } + desc { "coroutine witness types for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } query check_coroutine_obligations(key: LocalDefId) -> Result<(), ErrorGuaranteed> { - desc { |tcx| "verify auto trait bounds for coroutine interior type `{}`", tcx.def_path_str(key) } + desc { "verify auto trait bounds for coroutine interior type `{}`", tcx.def_path_str(key) } return_result_from_ensure_ok } @@ -723,7 +727,7 @@ rustc_queries! { /// delay a bug if it does not. query check_potentially_region_dependent_goals(key: LocalDefId) -> Result<(), ErrorGuaranteed> { desc { - |tcx| "reproving potentially region dependent HIR typeck goals for `{}", + "reproving potentially region dependent HIR typeck goals for `{}", tcx.def_path_str(key) } } @@ -731,7 +735,7 @@ rustc_queries! { /// MIR after our optimization passes have run. This is MIR that is ready /// for codegen. This is also the only query that can fetch non-local MIR, at present. query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> { - desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) } + desc { "optimizing MIR for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } @@ -742,7 +746,7 @@ rustc_queries! { /// Returns `false` if `#[coverage(off)]` was found, or `true` if /// either `#[coverage(on)]` or no coverage attribute was found. query coverage_attr_on(key: LocalDefId) -> bool { - desc { |tcx| "checking for `#[coverage(..)]` on `{}`", tcx.def_path_str(key) } + desc { "checking for `#[coverage(..)]` on `{}`", tcx.def_path_str(key) } feedable } @@ -759,7 +763,7 @@ rustc_queries! { /// /// Returns `None` for functions that were not instrumented. query coverage_ids_info(key: ty::InstanceKind<'tcx>) -> Option<&'tcx mir::coverage::CoverageIdsInfo> { - desc { |tcx| "retrieving coverage IDs info from MIR for `{}`", tcx.def_path_str(key.def_id()) } + desc { "retrieving coverage IDs info from MIR for `{}`", tcx.def_path_str(key.def_id()) } arena_cache } @@ -769,7 +773,7 @@ rustc_queries! { /// after inlining a body may refer to promoteds from other bodies. In that case you still /// need to use the `DefId` of the original body. query promoted_mir(key: DefId) -> &'tcx IndexVec> { - desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) } + desc { "optimizing promoted MIR for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } @@ -815,7 +819,7 @@ rustc_queries! { /// /// This query will panic if the given definition is not a trait. query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key) } + desc { "computing explicit predicates of trait `{}`", tcx.def_path_str(key) } } /// Returns the explicitly user-written *predicates* of the definition given by `DefId` @@ -824,7 +828,7 @@ rustc_queries! { /// You should probably use [`Self::predicates_of`] unless you're looking for /// predicates with explicit spans for diagnostics purposes. query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) } + desc { "computing explicit predicates of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern feedable @@ -837,7 +841,7 @@ rustc_queries! { /// **Tip**: You can use `#[rustc_outlives]` on an item to basically print the /// result of this query for use in UI tests or for debugging purposes. query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Clause<'tcx>, Span)] { - desc { |tcx| "computing inferred outlives-predicates of `{}`", tcx.def_path_str(key) } + desc { "computing inferred outlives-predicates of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern feedable @@ -851,7 +855,7 @@ rustc_queries! { /// because we must evaluate them even during type conversion, often before the full /// predicates are available (note that super-predicates must not be cyclic). query explicit_super_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) } + desc { "computing the super predicates of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } @@ -863,7 +867,7 @@ rustc_queries! { /// associated type bounds. For trait aliases, currently, this includes all of the /// predicates of the trait alias. query explicit_implied_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { |tcx| "computing the implied predicates of `{}`", tcx.def_path_str(key) } + desc { "computing the implied predicates of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } @@ -874,7 +878,7 @@ rustc_queries! { query explicit_supertraits_containing_assoc_item( key: (DefId, rustc_span::Ident) ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { |tcx| "computing the super traits of `{}` with associated type name `{}`", + desc { "computing the super traits of `{}` with associated type name `{}`", tcx.def_path_str(key.0), key.1 } @@ -892,7 +896,7 @@ rustc_queries! { query const_conditions( key: DefId ) -> ty::ConstConditions<'tcx> { - desc { |tcx| "computing the conditions for `{}` to be considered const", + desc { "computing the conditions for `{}` to be considered const", tcx.def_path_str(key) } separate_provide_extern @@ -906,7 +910,7 @@ rustc_queries! { query explicit_implied_const_bounds( key: DefId ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> { - desc { |tcx| "computing the implied `[const]` bounds for `{}`", + desc { "computing the implied `[const]` bounds for `{}`", tcx.def_path_str(key) } separate_provide_extern @@ -917,40 +921,40 @@ rustc_queries! { query type_param_predicates( key: (LocalDefId, LocalDefId, rustc_span::Ident) ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir_ty_param_name(key.1) } + desc { "computing the bounds for type parameter `{}`", tcx.hir_ty_param_name(key.1) } } query trait_def(key: DefId) -> &'tcx ty::TraitDef { - desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) } + desc { "computing trait definition for `{}`", tcx.def_path_str(key) } arena_cache cache_on_disk_if { key.is_local() } separate_provide_extern } query adt_def(key: DefId) -> ty::AdtDef<'tcx> { - desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) } + desc { "computing ADT definition for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } query adt_destructor(key: DefId) -> Option { - desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) } + desc { "computing `Drop` impl for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } query adt_async_destructor(key: DefId) -> Option { - desc { |tcx| "computing `AsyncDrop` impl for `{}`", tcx.def_path_str(key) } + desc { "computing `AsyncDrop` impl for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } query adt_sizedness_constraint( key: (DefId, SizedTraitKind) ) -> Option>> { - desc { |tcx| "computing the sizedness constraint for `{}`", tcx.def_path_str(key.0) } + desc { "computing the sizedness constraint for `{}`", tcx.def_path_str(key.0) } } query adt_dtorck_constraint( key: DefId ) -> &'tcx DropckConstraint<'tcx> { - desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) } + desc { "computing drop-check constraints for `{}`", tcx.def_path_str(key) } } /// Returns the constness of the function-like[^1] definition given by `DefId`. @@ -975,13 +979,13 @@ rustc_queries! { /// /// [^1]: Tuple struct/variant constructors, closures and free, associated and foreign functions. query constness(key: DefId) -> hir::Constness { - desc { |tcx| "checking if item is const: `{}`", tcx.def_path_str(key) } + desc { "checking if item is const: `{}`", tcx.def_path_str(key) } separate_provide_extern feedable } query asyncness(key: DefId) -> ty::Asyncness { - desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) } + desc { "checking if the function is async: `{}`", tcx.def_path_str(key) } separate_provide_extern } @@ -993,7 +997,7 @@ rustc_queries! { /// function does not inspect the bits of any of its arguments (so is essentially just a /// constructor function). query is_promotable_const_fn(key: DefId) -> bool { - desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) } + desc { "checking if item is promotable: `{}`", tcx.def_path_str(key) } } /// The body of the coroutine, modified to take its upvars by move rather than by ref. @@ -1003,19 +1007,19 @@ rustc_queries! { /// is run right after building the initial MIR, and will only be populated for coroutines /// which come out of the async closure desugaring. query coroutine_by_move_body_def_id(def_id: DefId) -> DefId { - desc { |tcx| "looking up the coroutine by-move body for `{}`", tcx.def_path_str(def_id) } + desc { "looking up the coroutine by-move body for `{}`", tcx.def_path_str(def_id) } separate_provide_extern } /// Returns `Some(coroutine_kind)` if the node pointed to by `def_id` is a coroutine. query coroutine_kind(def_id: DefId) -> Option { - desc { |tcx| "looking up coroutine kind of `{}`", tcx.def_path_str(def_id) } + desc { "looking up coroutine kind of `{}`", tcx.def_path_str(def_id) } separate_provide_extern feedable } query coroutine_for_closure(def_id: DefId) -> DefId { - desc { |_tcx| "Given a coroutine-closure def id, return the def id of the coroutine returned by it" } + desc { "Given a coroutine-closure def id, return the def id of the coroutine returned by it" } separate_provide_extern } @@ -1045,7 +1049,7 @@ rustc_queries! { /// **Tip**: You can use `#[rustc_variance]` on an item to basically print the /// result of this query for use in UI tests or for debugging purposes. query variances_of(def_id: DefId) -> &'tcx [ty::Variance] { - desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) } + desc { "computing the variances of `{}`", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern cycle_delay_bug @@ -1066,14 +1070,14 @@ rustc_queries! { /// Maps from an impl/trait or struct/variant `DefId` /// to a list of the `DefId`s of its associated items or fields. query associated_item_def_ids(key: DefId) -> &'tcx [DefId] { - desc { |tcx| "collecting associated items or fields of `{}`", tcx.def_path_str(key) } + desc { "collecting associated items or fields of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } /// Maps from a trait/impl item to the trait/impl item "descriptor". query associated_item(key: DefId) -> ty::AssocItem { - desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) } + desc { "computing associated item data for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern feedable @@ -1082,7 +1086,7 @@ rustc_queries! { /// Collects the associated items defined on a trait or impl. query associated_items(key: DefId) -> &'tcx ty::AssocItems { arena_cache - desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) } + desc { "collecting associated items of `{}`", tcx.def_path_str(key) } } /// Maps from associated items on a trait to the corresponding associated @@ -1108,20 +1112,20 @@ rustc_queries! { ///`{ trait_f: impl_f, trait_g: impl_g }` query impl_item_implementor_ids(impl_id: DefId) -> &'tcx DefIdMap { arena_cache - desc { |tcx| "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) } + desc { "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) } } /// Given the `item_def_id` of a trait or impl, return a mapping from associated fn def id /// to its associated type items that correspond to the RPITITs in its signature. query associated_types_for_impl_traits_in_trait_or_impl(item_def_id: DefId) -> &'tcx DefIdMap> { arena_cache - desc { |tcx| "synthesizing RPITIT items for the opaque types for methods in `{}`", tcx.def_path_str(item_def_id) } + desc { "synthesizing RPITIT items for the opaque types for methods in `{}`", tcx.def_path_str(item_def_id) } separate_provide_extern } /// Given an `impl_id`, return the trait it implements along with some header information. query impl_trait_header(impl_id: DefId) -> ty::ImplTraitHeader<'tcx> { - desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) } + desc { "computing trait implemented by `{}`", tcx.def_path_str(impl_id) } cache_on_disk_if { impl_id.is_local() } separate_provide_extern } @@ -1130,35 +1134,35 @@ rustc_queries! { /// to either being one of the built-in unsized types (str/slice/dyn) or to be a struct /// whose tail is one of those types. query impl_self_is_guaranteed_unsized(impl_def_id: DefId) -> bool { - desc { |tcx| "computing whether `{}` has a guaranteed unsized self type", tcx.def_path_str(impl_def_id) } + desc { "computing whether `{}` has a guaranteed unsized self type", tcx.def_path_str(impl_def_id) } } /// Maps a `DefId` of a type to a list of its inherent impls. /// Contains implementations of methods that are inherent to a type. /// Methods in these implementations don't need to be exported. query inherent_impls(key: DefId) -> &'tcx [DefId] { - desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) } + desc { "collecting inherent impls for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } query incoherent_impls(key: SimplifiedType) -> &'tcx [DefId] { - desc { |tcx| "collecting all inherent impls for `{:?}`", key } + desc { "collecting all inherent impls for `{:?}`", key } } /// Unsafety-check this `LocalDefId`. query check_transmutes(key: LocalDefId) { - desc { |tcx| "check transmute calls inside `{}`", tcx.def_path_str(key) } + desc { "check transmute calls inside `{}`", tcx.def_path_str(key) } } /// Unsafety-check this `LocalDefId`. query check_unsafety(key: LocalDefId) { - desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key) } + desc { "unsafety-checking `{}`", tcx.def_path_str(key) } } /// Checks well-formedness of tail calls (`become f()`). query check_tail_calls(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> { - desc { |tcx| "tail-call-checking `{}`", tcx.def_path_str(key) } + desc { "tail-call-checking `{}`", tcx.def_path_str(key) } return_result_from_ensure_ok } @@ -1167,19 +1171,19 @@ rustc_queries! { /// Note that we've liberated the late bound regions of function signatures, so /// this can not be used to check whether these types are well formed. query assumed_wf_types(key: LocalDefId) -> &'tcx [(Ty<'tcx>, Span)] { - desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) } + desc { "computing the implied bounds of `{}`", tcx.def_path_str(key) } } /// We need to store the assumed_wf_types for an RPITIT so that impls of foreign /// traits with return-position impl trait in traits can inherit the right wf types. query assumed_wf_types_for_rpitit(key: DefId) -> &'tcx [(Ty<'tcx>, Span)] { - desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) } + desc { "computing the implied bounds of `{}`", tcx.def_path_str(key) } separate_provide_extern } /// Computes the signature of the function. query fn_sig(key: DefId) -> ty::EarlyBinder<'tcx, ty::PolyFnSig<'tcx>> { - desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) } + desc { "computing function signature of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern cycle_delay_bug @@ -1187,7 +1191,7 @@ rustc_queries! { /// Performs lint checking for the module. query lint_mod(key: LocalModDefId) { - desc { |tcx| "linting {}", describe_as_module(key, tcx) } + desc { "linting {}", describe_as_module(key, tcx) } } query check_unused_traits(_: ()) { @@ -1196,22 +1200,22 @@ rustc_queries! { /// Checks the attributes in the module. query check_mod_attrs(key: LocalModDefId) { - desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) } + desc { "checking attributes in {}", describe_as_module(key, tcx) } } /// Checks for uses of unstable APIs in the module. query check_mod_unstable_api_usage(key: LocalModDefId) { - desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) } + desc { "checking for unstable API usage in {}", describe_as_module(key, tcx) } } query check_mod_privacy(key: LocalModDefId) { - desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) } + desc { "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) } } query check_liveness(key: LocalDefId) -> &'tcx rustc_index::bit_set::DenseBitSet { arena_cache - desc { |tcx| "checking liveness of variables in `{}`", tcx.def_path_str(key.to_def_id()) } - cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) } + desc { "checking liveness of variables in `{}`", tcx.def_path_str(key.to_def_id()) } + cache_on_disk_if { tcx.is_typeck_child(key.to_def_id()) } } /// Return the live symbols in the crate for dead code check. @@ -1226,7 +1230,7 @@ rustc_queries! { } query check_mod_deathness(key: LocalModDefId) { - desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) } + desc { "checking deathness of variables in {}", describe_as_module(key, tcx) } } query check_type_wf(key: ()) -> Result<(), ErrorGuaranteed> { @@ -1236,24 +1240,24 @@ rustc_queries! { /// Caches `CoerceUnsized` kinds for impls on custom types. query coerce_unsized_info(key: DefId) -> Result { - desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) } + desc { "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern return_result_from_ensure_ok } query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> { - desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) } - cache_on_disk_if(tcx) { !tcx.is_typeck_child(key.to_def_id()) } + desc { "type-checking `{}`", tcx.def_path_str(key) } + cache_on_disk_if { !tcx.is_typeck_child(key.to_def_id()) } } query used_trait_imports(key: LocalDefId) -> &'tcx UnordSet { - desc { |tcx| "finding used_trait_imports `{}`", tcx.def_path_str(key) } + desc { "finding used_trait_imports `{}`", tcx.def_path_str(key) } cache_on_disk_if { true } } query coherent_trait(def_id: DefId) -> Result<(), ErrorGuaranteed> { - desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) } + desc { "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) } return_result_from_ensure_ok } @@ -1263,7 +1267,7 @@ rustc_queries! { &'tcx FxIndexMap>, ErrorGuaranteed > { - desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) } + desc { "borrow-checking `{}`", tcx.def_path_str(key) } } /// Gets a complete map from all types to their inherent impls. @@ -1304,7 +1308,7 @@ rustc_queries! { /// Checks whether all impls in the crate pass the overlap check, returning /// which impls fail it. If all impls are correct, the returned slice is empty. query orphan_check_impl(key: LocalDefId) -> Result<(), ErrorGuaranteed> { - desc { |tcx| + desc { "checking whether impl `{}` follows the orphan rules", tcx.def_path_str(key), } @@ -1316,7 +1320,7 @@ rustc_queries! { query mir_callgraph_cyclic(key: LocalDefId) -> &'tcx Option> { cycle_fatal arena_cache - desc { |tcx| + desc { "computing (transitive) callees of `{}` that may recurse", tcx.def_path_str(key), } @@ -1326,7 +1330,7 @@ rustc_queries! { /// Obtain all the calls into other local functions query mir_inliner_callees(key: ty::InstanceKind<'tcx>) -> &'tcx [(DefId, GenericArgsRef<'tcx>)] { cycle_fatal - desc { |tcx| + desc { "computing all local function calls in `{}`", tcx.def_path_str(key.def_id()), } @@ -1355,7 +1359,7 @@ rustc_queries! { /// query eval_to_allocation_raw(key: ty::PseudoCanonicalInput<'tcx, GlobalId<'tcx>>) -> EvalToAllocationRawResult<'tcx> { - desc { |tcx| + desc { "const-evaluating + checking `{}`", key.value.display(tcx) } @@ -1364,7 +1368,7 @@ rustc_queries! { /// Evaluate a static's initializer, returning the allocation of the initializer's memory. query eval_static_initializer(key: DefId) -> EvalStaticInitializerRawResult<'tcx> { - desc { |tcx| + desc { "evaluating initializer of static `{}`", tcx.def_path_str(key) } @@ -1387,7 +1391,7 @@ rustc_queries! { /// [^1]: Such as enum variant explicit discriminants or array lengths. query eval_to_const_value_raw(key: ty::PseudoCanonicalInput<'tcx, GlobalId<'tcx>>) -> EvalToConstValueResult<'tcx> { - desc { |tcx| + desc { "simplifying constant for the type system `{}`", key.value.display(tcx) } @@ -1416,7 +1420,7 @@ rustc_queries! { } query check_match(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> { - desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) } + desc { "match-checking `{}`", tcx.def_path_str(key) } return_result_from_ensure_ok } @@ -1426,7 +1430,7 @@ rustc_queries! { desc { "checking effective visibilities" } } query check_private_in_public(module_def_id: LocalModDefId) { - desc { |tcx| + desc { "checking for private elements in public interfaces for {}", describe_as_module(module_def_id, tcx) } @@ -1441,14 +1445,14 @@ rustc_queries! { /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body; /// in the case of closures, this will be redirected to the enclosing function. query region_scope_tree(def_id: DefId) -> &'tcx crate::middle::region::ScopeTree { - desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) } + desc { "computing drop scopes for `{}`", tcx.def_path_str(def_id) } } /// Generates a MIR body for the shim. query mir_shims(key: ty::InstanceKind<'tcx>) -> &'tcx mir::Body<'tcx> { arena_cache desc { - |tcx| "generating MIR shim for `{}`, instance={:?}", + "generating MIR shim for `{}`, instance={:?}", tcx.def_path_str(key.def_id()), key } @@ -1463,7 +1467,7 @@ rustc_queries! { } query def_kind(def_id: DefId) -> DefKind { - desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) } + desc { "looking up definition kind of `{}`", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern feedable @@ -1471,7 +1475,7 @@ rustc_queries! { /// Gets the span for the definition. query def_span(def_id: DefId) -> Span { - desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) } + desc { "looking up span for `{}`", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern feedable @@ -1479,7 +1483,7 @@ rustc_queries! { /// Gets the span for the identifier of the definition. query def_ident_span(def_id: DefId) -> Option { - desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) } + desc { "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern feedable @@ -1488,57 +1492,57 @@ rustc_queries! { /// Gets the span for the type of the definition. /// Panics if it is not a definition that has a single type. query ty_span(def_id: LocalDefId) -> Span { - desc { |tcx| "looking up span for `{}`'s type", tcx.def_path_str(def_id) } + desc { "looking up span for `{}`'s type", tcx.def_path_str(def_id) } cache_on_disk_if { true } } query lookup_stability(def_id: DefId) -> Option { - desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) } + desc { "looking up stability of `{}`", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern } query lookup_const_stability(def_id: DefId) -> Option { - desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) } + desc { "looking up const stability of `{}`", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern } query lookup_default_body_stability(def_id: DefId) -> Option { - desc { |tcx| "looking up default body stability of `{}`", tcx.def_path_str(def_id) } + desc { "looking up default body stability of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } query should_inherit_track_caller(def_id: DefId) -> bool { - desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) } + desc { "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) } } query inherited_align(def_id: DefId) -> Option { - desc { |tcx| "computing inherited_align of `{}`", tcx.def_path_str(def_id) } + desc { "computing inherited_align of `{}`", tcx.def_path_str(def_id) } } query lookup_deprecation_entry(def_id: DefId) -> Option { - desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) } + desc { "checking whether `{}` is deprecated", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern } /// Determines whether an item is annotated with `#[doc(hidden)]`. query is_doc_hidden(def_id: DefId) -> bool { - desc { |tcx| "checking whether `{}` is `doc(hidden)`", tcx.def_path_str(def_id) } + desc { "checking whether `{}` is `doc(hidden)`", tcx.def_path_str(def_id) } separate_provide_extern } /// Determines whether an item is annotated with `#[doc(notable_trait)]`. query is_doc_notable_trait(def_id: DefId) -> bool { - desc { |tcx| "checking whether `{}` is `doc(notable_trait)`", tcx.def_path_str(def_id) } + desc { "checking whether `{}` is `doc(notable_trait)`", tcx.def_path_str(def_id) } } /// Returns the attributes on the item at `def_id`. /// /// Do not use this directly, use `tcx.get_attrs` instead. query attrs_for_def(def_id: DefId) -> &'tcx [hir::Attribute] { - desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) } + desc { "collecting attributes of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } @@ -1552,7 +1556,7 @@ rustc_queries! { /// Using this query would include the attribute regardless of the actual instance /// kind at the call site. query codegen_fn_attrs(def_id: DefId) -> &'tcx CodegenFnAttrs { - desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) } + desc { "computing codegen attributes of `{}`", tcx.def_path_str(def_id) } arena_cache cache_on_disk_if { def_id.is_local() } separate_provide_extern @@ -1560,11 +1564,11 @@ rustc_queries! { } query asm_target_features(def_id: DefId) -> &'tcx FxIndexSet { - desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) } + desc { "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) } } query fn_arg_idents(def_id: DefId) -> &'tcx [Option] { - desc { |tcx| "looking up function parameter identifiers for `{}`", tcx.def_path_str(def_id) } + desc { "looking up function parameter identifiers for `{}`", tcx.def_path_str(def_id) } separate_provide_extern } @@ -1572,23 +1576,23 @@ rustc_queries! { /// Used by rustdoc. query rendered_const(def_id: DefId) -> &'tcx String { arena_cache - desc { |tcx| "rendering constant initializer of `{}`", tcx.def_path_str(def_id) } + desc { "rendering constant initializer of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } /// Gets the rendered precise capturing args for an opaque for use in rustdoc. query rendered_precise_capturing_args(def_id: DefId) -> Option<&'tcx [PreciseCapturingArgKind]> { - desc { |tcx| "rendering precise capturing args for `{}`", tcx.def_path_str(def_id) } + desc { "rendering precise capturing args for `{}`", tcx.def_path_str(def_id) } separate_provide_extern } query impl_parent(def_id: DefId) -> Option { - desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) } + desc { "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } query is_mir_available(key: DefId) -> bool { - desc { |tcx| "checking if item has MIR available: `{}`", tcx.def_path_str(key) } + desc { "checking if item has MIR available: `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } @@ -1596,25 +1600,25 @@ rustc_queries! { query own_existential_vtable_entries( key: DefId ) -> &'tcx [DefId] { - desc { |tcx| "finding all existential vtable entries for trait `{}`", tcx.def_path_str(key) } + desc { "finding all existential vtable entries for trait `{}`", tcx.def_path_str(key) } } query vtable_entries(key: ty::TraitRef<'tcx>) -> &'tcx [ty::VtblEntry<'tcx>] { - desc { |tcx| "finding all vtable entries for trait `{}`", tcx.def_path_str(key.def_id) } + desc { "finding all vtable entries for trait `{}`", tcx.def_path_str(key.def_id) } } query first_method_vtable_slot(key: ty::TraitRef<'tcx>) -> usize { - desc { |tcx| "finding the slot within the vtable of `{}` for the implementation of `{}`", key.self_ty(), key.print_only_trait_name() } + desc { "finding the slot within the vtable of `{}` for the implementation of `{}`", key.self_ty(), key.print_only_trait_name() } } query supertrait_vtable_slot(key: (Ty<'tcx>, Ty<'tcx>)) -> Option { - desc { |tcx| "finding the slot within vtable for trait object `{}` vtable ptr during trait upcasting coercion from `{}` vtable", + desc { "finding the slot within vtable for trait object `{}` vtable ptr during trait upcasting coercion from `{}` vtable", key.1, key.0 } } query vtable_allocation(key: (Ty<'tcx>, Option>)) -> mir::interpret::AllocId { - desc { |tcx| "vtable const allocation for <{} as {}>", + desc { "vtable const allocation for <{} as {}>", key.0, key.1.map(|trait_ref| format!("{trait_ref}")).unwrap_or_else(|| "_".to_owned()) } @@ -1624,7 +1628,7 @@ rustc_queries! { key: PseudoCanonicalInput<'tcx, ty::TraitRef<'tcx>> ) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError> { cache_on_disk_if { true } - desc { |tcx| "computing candidate for `{}`", key.value } + desc { "computing candidate for `{}`", key.value } } /// Return all `impl` blocks in the current crate. @@ -1640,19 +1644,19 @@ rustc_queries! { /// Given a trait `trait_id`, return all known `impl` blocks. query trait_impls_of(trait_id: DefId) -> &'tcx ty::trait_def::TraitImpls { arena_cache - desc { |tcx| "finding trait impls of `{}`", tcx.def_path_str(trait_id) } + desc { "finding trait impls of `{}`", tcx.def_path_str(trait_id) } } query specialization_graph_of(trait_id: DefId) -> Result<&'tcx specialization_graph::Graph, ErrorGuaranteed> { - desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) } + desc { "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) } cache_on_disk_if { true } return_result_from_ensure_ok } query dyn_compatibility_violations(trait_id: DefId) -> &'tcx [DynCompatibilityViolation] { - desc { |tcx| "determining dyn-compatibility of trait `{}`", tcx.def_path_str(trait_id) } + desc { "determining dyn-compatibility of trait `{}`", tcx.def_path_str(trait_id) } } query is_dyn_compatible(trait_id: DefId) -> bool { - desc { |tcx| "checking if trait `{}` is dyn-compatible", tcx.def_path_str(trait_id) } + desc { "checking if trait `{}` is dyn-compatible", tcx.def_path_str(trait_id) } } /// Gets the ParameterEnvironment for a given item; this environment @@ -1664,7 +1668,7 @@ rustc_queries! { /// you should also probably have a `ParamEnv` from when it was built. If you don't, /// then you should take a `TypingEnv` to ensure that you handle opaque types correctly. query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> { - desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) } + desc { "computing normalized predicates of `{}`", tcx.def_path_str(def_id) } feedable } @@ -1672,7 +1676,7 @@ rustc_queries! { /// replaced with their hidden type. This is used in the old trait solver /// when in `PostAnalysis` mode and should not be called directly. query typing_env_normalized_for_post_analysis(def_id: DefId) -> ty::TypingEnv<'tcx> { - desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) } + desc { "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) } } /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`, @@ -1733,7 +1737,7 @@ rustc_queries! { /// those types require drop. If the ADT is known to always need drop /// then `Err(AlwaysRequiresDrop)` is returned. query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List>, AlwaysRequiresDrop> { - desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) } + desc { "computing when `{}` needs drop", tcx.def_path_str(def_id) } cache_on_disk_if { true } } @@ -1741,7 +1745,7 @@ rustc_queries! { /// those types require async drop. If the ADT is known to always need async drop /// then `Err(AlwaysRequiresDrop)` is returned. query adt_async_drop_tys(def_id: DefId) -> Result<&'tcx ty::List>, AlwaysRequiresDrop> { - desc { |tcx| "computing when `{}` needs async drop", tcx.def_path_str(def_id) } + desc { "computing when `{}` needs async drop", tcx.def_path_str(def_id) } cache_on_disk_if { true } } @@ -1752,7 +1756,7 @@ rustc_queries! { /// freeing up memory). If the ADT is known to have a significant destructor then /// `Err(AlwaysRequiresDrop)` is returned. query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List>, AlwaysRequiresDrop> { - desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) } + desc { "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) } } /// Returns a list of types which (a) have a potentially significant destructor @@ -1773,7 +1777,7 @@ rustc_queries! { /// because this query partially depends on that query. /// Otherwise, there is a risk of query cycles. query list_significant_drop_tys(ty: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> &'tcx ty::List> { - desc { |tcx| "computing when `{}` has a significant destructor", ty.value } + desc { "computing when `{}` has a significant destructor", ty.value } } /// Computes the layout of a type. Note that this implicitly @@ -1849,7 +1853,7 @@ rustc_queries! { separate_provide_extern } query has_ffi_unwind_calls(key: LocalDefId) -> bool { - desc { |tcx| "checking if `{}` contains FFI-unwind calls", tcx.def_path_str(key) } + desc { "checking if `{}` contains FFI-unwind calls", tcx.def_path_str(key) } cache_on_disk_if { true } } query required_panic_strategy(_: CrateNum) -> Option { @@ -1895,24 +1899,24 @@ rustc_queries! { /// Returns whether the impl or associated function has the `default` keyword. /// Note: This will ICE on inherent impl items. Consider using `AssocItem::defaultness`. query defaultness(def_id: DefId) -> hir::Defaultness { - desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) } + desc { "looking up whether `{}` has `default`", tcx.def_path_str(def_id) } separate_provide_extern feedable } /// Returns whether the field corresponding to the `DefId` has a default field value. query default_field(def_id: DefId) -> Option { - desc { |tcx| "looking up the `const` corresponding to the default for `{}`", tcx.def_path_str(def_id) } + desc { "looking up the `const` corresponding to the default for `{}`", tcx.def_path_str(def_id) } separate_provide_extern } query check_well_formed(key: LocalDefId) -> Result<(), ErrorGuaranteed> { - desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key) } + desc { "checking that `{}` is well-formed", tcx.def_path_str(key) } return_result_from_ensure_ok } query enforce_impl_non_lifetime_params_are_constrained(key: LocalDefId) -> Result<(), ErrorGuaranteed> { - desc { |tcx| "checking that `{}`'s generics are constrained by the impl header", tcx.def_path_str(key) } + desc { "checking that `{}`'s generics are constrained by the impl header", tcx.def_path_str(key) } return_result_from_ensure_ok } @@ -1935,12 +1939,12 @@ rustc_queries! { separate_provide_extern } query is_reachable_non_generic(def_id: DefId) -> bool { - desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) } + desc { "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern } query is_unreachable_local_definition(def_id: LocalDefId) -> bool { - desc { |tcx| + desc { "checking whether `{}` is reachable from outside the crate", tcx.def_path_str(def_id), } @@ -1968,7 +1972,7 @@ rustc_queries! { query upstream_monomorphizations_for(def_id: DefId) -> Option<&'tcx UnordMap, CrateNum>> { - desc { |tcx| + desc { "collecting available upstream monomorphizations for `{}`", tcx.def_path_str(def_id), } @@ -2086,13 +2090,13 @@ rustc_queries! { /// Do not call this directly, but instead use the `incoherent_impls` query. /// This query is only used to get the data necessary for that query. query crate_incoherent_impls(key: (CrateNum, SimplifiedType)) -> &'tcx [DefId] { - desc { |tcx| "collecting all impls for a type in a crate" } + desc { "collecting all impls for a type in a crate" } separate_provide_extern } /// Get the corresponding native library from the `native_libraries` query query native_library(def_id: DefId) -> Option<&'tcx NativeLib> { - desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) } + desc { "getting the native library for `{}`", tcx.def_path_str(def_id) } } query inherit_sig_for_delegation_item(def_id: LocalDefId) -> &'tcx [Ty<'tcx>] { @@ -2104,13 +2108,13 @@ rustc_queries! { /// See `rustc_resolve::late::lifetimes` for details. query resolve_bound_vars(owner_id: hir::OwnerId) -> &'tcx ResolveBoundVars<'tcx> { arena_cache - desc { |tcx| "resolving lifetimes for `{}`", tcx.def_path_str(owner_id) } + desc { "resolving lifetimes for `{}`", tcx.def_path_str(owner_id) } } query named_variable_map(owner_id: hir::OwnerId) -> &'tcx SortedMap { - desc { |tcx| "looking up a named region inside `{}`", tcx.def_path_str(owner_id) } + desc { "looking up a named region inside `{}`", tcx.def_path_str(owner_id) } } query is_late_bound_map(owner_id: hir::OwnerId) -> Option<&'tcx FxIndexSet> { - desc { |tcx| "testing if a region is late bound inside `{}`", tcx.def_path_str(owner_id) } + desc { "testing if a region is late bound inside `{}`", tcx.def_path_str(owner_id) } } /// Returns the *default lifetime* to be used if a trait object type were to be passed for /// the type parameter given by `DefId`. @@ -2132,7 +2136,7 @@ rustc_queries! { } query late_bound_vars_map(owner_id: hir::OwnerId) -> &'tcx SortedMap>> { - desc { |tcx| "looking up late bound vars inside `{}`", tcx.def_path_str(owner_id) } + desc { "looking up late bound vars inside `{}`", tcx.def_path_str(owner_id) } } /// For an opaque type, return the list of (captured lifetime, inner generic param). /// ```ignore (illustrative) @@ -2149,7 +2153,7 @@ rustc_queries! { /// ^^^^^^ captured lifetimes /// ``` query opaque_captured_lifetimes(def_id: LocalDefId) -> &'tcx [(ResolvedArg, LocalDefId)] { - desc { |tcx| "listing captured lifetimes for opaque `{}`", tcx.def_path_str(def_id) } + desc { "listing captured lifetimes for opaque `{}`", tcx.def_path_str(def_id) } } /// Computes the visibility of the provided `def_id`. @@ -2165,7 +2169,7 @@ rustc_queries! { /// /// In here, if you call `visibility` on `T`, it'll panic. query visibility(def_id: DefId) -> ty::Visibility { - desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) } + desc { "computing visibility of `{}`", tcx.def_path_str(def_id) } separate_provide_extern feedable } @@ -2192,7 +2196,7 @@ rustc_queries! { separate_provide_extern } query module_children(def_id: DefId) -> &'tcx [ModChild] { - desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) } + desc { "collecting child items of module `{}`", tcx.def_path_str(def_id) } separate_provide_extern } @@ -2230,7 +2234,7 @@ rustc_queries! { } /// Whether the function is an intrinsic query intrinsic_raw(def_id: DefId) -> Option { - desc { |tcx| "fetch intrinsic name if `{}` is an intrinsic", tcx.def_path_str(def_id) } + desc { "fetch intrinsic name if `{}` is an intrinsic", tcx.def_path_str(def_id) } separate_provide_extern } /// Returns the lang items defined in another crate by loading it from metadata. @@ -2323,7 +2327,7 @@ rustc_queries! { } query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap> { - desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) } + desc { "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) } } /// All available crates in the graph, including those that should not be user-facing @@ -2406,7 +2410,7 @@ rustc_queries! { } query is_codegened_item(def_id: DefId) -> bool { - desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) } + desc { "determining whether `{}` needs codegen", tcx.def_path_str(def_id) } } query codegen_unit(sym: Symbol) -> &'tcx CodegenUnit<'tcx> { @@ -2565,14 +2569,14 @@ rustc_queries! { } query instantiate_and_check_impossible_predicates(key: (DefId, GenericArgsRef<'tcx>)) -> bool { - desc { |tcx| + desc { "checking impossible instantiated predicates: `{}`", tcx.def_path_str(key.0) } } query is_impossible_associated_item(key: (DefId, DefId)) -> bool { - desc { |tcx| + desc { "checking if `{}` is impossible to reference within `{}`", tcx.def_path_str(key.1), tcx.def_path_str(key.0), @@ -2674,12 +2678,12 @@ rustc_queries! { /// /// Any other def id will ICE. query compare_impl_item(key: LocalDefId) -> Result<(), ErrorGuaranteed> { - desc { |tcx| "checking assoc item `{}` is compatible with trait definition", tcx.def_path_str(key) } + desc { "checking assoc item `{}` is compatible with trait definition", tcx.def_path_str(key) } return_result_from_ensure_ok } query deduced_param_attrs(def_id: DefId) -> &'tcx [DeducedParamAttrs] { - desc { |tcx| "deducing parameter attributes for {}", tcx.def_path_str(def_id) } + desc { "deducing parameter attributes for {}", tcx.def_path_str(def_id) } separate_provide_extern } @@ -2736,12 +2740,12 @@ rustc_queries! { } query anon_const_kind(def_id: DefId) -> ty::AnonConstKind { - desc { |tcx| "looking up anon const kind of `{}`", tcx.def_path_str(def_id) } + desc { "looking up anon const kind of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } query trivial_const(def_id: DefId) -> Option<(mir::ConstValue, Ty<'tcx>)> { - desc { |tcx| "checking if `{}` is a trivial const", tcx.def_path_str(def_id) } + desc { "checking if `{}` is a trivial const", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern } @@ -2752,7 +2756,7 @@ rustc_queries! { /// /// Returns the sanitizer settings for this def. query sanitizer_settings_for(key: LocalDefId) -> SanitizerFnAttrs { - desc { |tcx| "checking what set of sanitizers are enabled on `{}`", tcx.def_path_str(key) } + desc { "checking what set of sanitizers are enabled on `{}`", tcx.def_path_str(key) } feedable } @@ -2769,7 +2773,7 @@ rustc_queries! { } query is_rhs_type_const(def_id: DefId) -> bool { - desc { |tcx| "checking whether `{}` is a rhs type const", tcx.def_path_str(def_id) } + desc { "checking whether `{}` is a rhs type const", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } separate_provide_extern } diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 03618ee6acd46..a48fc8908f498 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -262,181 +262,146 @@ impl<'tcx> TyCtxt<'tcx> { } } -/// Calls either `query_ensure` or `query_ensure_error_guaranteed`, depending -/// on whether the list of modifiers contains `return_result_from_ensure_ok`. -macro_rules! query_ensure_select { - ([]$($args:tt)*) => { - crate::query::inner::query_ensure($($args)*) - }; - ([(return_result_from_ensure_ok) $($rest:tt)*]$($args:tt)*) => { - crate::query::inner::query_ensure_error_guaranteed($($args)*) - }; - ([$other:tt $($modifiers:tt)*]$($args:tt)*) => { - query_ensure_select!([$($modifiers)*]$($args)*) - }; -} - macro_rules! query_helper_param_ty { (DefId) => { impl $crate::query::IntoQueryParam }; (LocalDefId) => { impl $crate::query::IntoQueryParam }; ($K:ty) => { $K }; } -macro_rules! query_if_arena { - ([] $arena:tt $no_arena:tt) => { - $no_arena - }; - ([(arena_cache) $($rest:tt)*] $arena:tt $no_arena:tt) => { - $arena - }; - ([$other:tt $($modifiers:tt)*]$($args:tt)*) => { - query_if_arena!([$($modifiers)*]$($args)*) +// Expands to `$yes` if the `arena_cache` modifier is present, `$no` otherwise. +macro_rules! if_arena_cache { + ([] $then:tt $no:tt) => { $no }; + ([(arena_cache) $($modifiers:tt)*] $yes:tt $no:tt) => { $yes }; + ([$other:tt $($modifiers:tt)*] $yes:tt $no:tt) => { + if_arena_cache!([$($modifiers)*] $yes $no) }; } -/// If `separate_provide_extern`, then the key can be projected to its -/// local key via `<$K as AsLocalKey>::LocalKey`. -macro_rules! local_key_if_separate_extern { - ([] $($K:tt)*) => { - $($K)* - }; - ([(separate_provide_extern) $($rest:tt)*] $($K:tt)*) => { - <$($K)* as $crate::query::AsLocalKey>::LocalKey - }; - ([$other:tt $($modifiers:tt)*] $($K:tt)*) => { - local_key_if_separate_extern!([$($modifiers)*] $($K)*) +// Expands to `$yes` if the `separate_provide_extern` modifier is present, `$no` otherwise. +macro_rules! if_separate_provide_extern { + ([] $then:tt $no:tt) => { $no }; + ([(separate_provide_extern) $($modifiers:tt)*] $yes:tt $no:tt) => { $yes }; + ([$other:tt $($modifiers:tt)*] $yes:tt $no:tt) => { + if_separate_provide_extern!([$($modifiers)*] $yes $no) }; } -macro_rules! separate_provide_extern_decl { - ([][$name:ident]) => { - () - }; - ([(separate_provide_extern) $($rest:tt)*][$name:ident]) => { - for<'tcx> fn( - TyCtxt<'tcx>, - $name::Key<'tcx>, - ) -> $name::ProvidedValue<'tcx> - }; - ([$other:tt $($modifiers:tt)*][$($args:tt)*]) => { - separate_provide_extern_decl!([$($modifiers)*][$($args)*]) - }; -} - -macro_rules! ensure_ok_result { - ( [] ) => { - () - }; - ( [(return_result_from_ensure_ok) $($rest:tt)*] ) => { - Result<(), ErrorGuaranteed> - }; - ( [$other:tt $($modifiers:tt)*] ) => { - ensure_ok_result!( [$($modifiers)*] ) - }; -} - -macro_rules! separate_provide_extern_default { - ([][$name:ident]) => { - () - }; - ([(separate_provide_extern) $($rest:tt)*][$name:ident]) => { - |_, key| $crate::query::plumbing::default_extern_query(stringify!($name), &key) - }; - ([$other:tt $($modifiers:tt)*][$($args:tt)*]) => { - separate_provide_extern_default!([$($modifiers)*][$($args)*]) +// Expands to `$yes` if the `return_result_from_ensure_ok` modifier is present, `$no` otherwise. +macro_rules! if_return_result_from_ensure_ok { + ([] $then:tt $no:tt) => { $no }; + ([(return_result_from_ensure_ok) $($modifiers:tt)*] $yes:tt $no:tt) => { $yes }; + ([$other:tt $($modifiers:tt)*] $yes:tt $no:tt) => { + if_return_result_from_ensure_ok!([$($modifiers)*] $yes $no) }; } macro_rules! define_callbacks { ( + // You might expect the key to be `$K:ty`, but it needs to be `$($K:tt)*` so that + // `query_helper_param_ty!` can match on specific type names. $( $(#[$attr:meta])* - [$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty, + [$($modifiers:tt)*] + fn $name:ident($($K:tt)*) -> $V:ty, )* ) => { - $(#[allow(unused_lifetimes)] pub mod $name { - use super::*; - use $crate::query::erase::{self, Erased}; - - pub type Key<'tcx> = $($K)*; - pub type Value<'tcx> = $V; - - pub type LocalKey<'tcx> = local_key_if_separate_extern!([$($modifiers)*] $($K)*); - - /// This type alias specifies the type returned from query providers and the type - /// used for decoding. For regular queries this is the declared returned type `V`, - /// but `arena_cache` will use `::Provided` instead. - pub type ProvidedValue<'tcx> = query_if_arena!( - [$($modifiers)*] - (<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Provided) - ($V) - ); - - /// This helper function takes a value returned by the query provider - /// (or loaded from disk, or supplied by query feeding), allocates - /// it in an arena if requested by the `arena_cache` modifier, and - /// then returns an erased copy of it. - #[inline(always)] - pub fn provided_to_erased<'tcx>( - tcx: TyCtxt<'tcx>, - provided_value: ProvidedValue<'tcx>, - ) -> Erased> { - // For queries with the `arena_cache` modifier, store the - // provided value in an arena and get a reference to it. - let value: Value<'tcx> = query_if_arena!([$($modifiers)*] { - <$V as $crate::query::arena_cached::ArenaCached>::alloc_in_arena( - tcx, - &tcx.query_system.arenas.$name, - provided_value, - ) - } { - // Otherwise, the provided value is the value (and `tcx` is unused). - let _ = tcx; - provided_value - }); - erase::erase_val(value) - } + $( + #[allow(unused_lifetimes)] + pub mod $name { + use super::*; + use $crate::query::erase::{self, Erased}; - pub type Storage<'tcx> = <$($K)* as $crate::query::Key>::Cache>; - - // Ensure that keys grow no larger than 88 bytes by accident. - // Increase this limit if necessary, but do try to keep the size low if possible - #[cfg(target_pointer_width = "64")] - const _: () = { - if size_of::>() > 88 { - panic!("{}", concat!( - "the query `", - stringify!($name), - "` has a key type `", - stringify!($($K)*), - "` that is too large" - )); - } - }; - - // Ensure that values grow no larger than 64 bytes by accident. - // Increase this limit if necessary, but do try to keep the size low if possible - #[cfg(target_pointer_width = "64")] - #[cfg(not(feature = "rustc_randomized_layouts"))] - const _: () = { - if size_of::>() > 64 { - panic!("{}", concat!( - "the query `", - stringify!($name), - "` has a value type `", - stringify!($V), - "` that is too large" - )); + pub type Key<'tcx> = $($K)*; + pub type Value<'tcx> = $V; + + pub type LocalKey<'tcx> = if_separate_provide_extern!( + [$($modifiers)*] + ( as $crate::query::AsLocalKey>::LocalKey) + (Key<'tcx>) + ); + + /// This type alias specifies the type returned from query providers and the type + /// used for decoding. For regular queries this is the declared returned type `V`, + /// but `arena_cache` will use `::Provided` instead. + pub type ProvidedValue<'tcx> = if_arena_cache!( + [$($modifiers)*] + ( as $crate::query::arena_cached::ArenaCached<'tcx>>::Provided) + (Value<'tcx>) + ); + + /// This helper function takes a value returned by the query provider + /// (or loaded from disk, or supplied by query feeding), allocates + /// it in an arena if requested by the `arena_cache` modifier, and + /// then returns an erased copy of it. + #[inline(always)] + pub fn provided_to_erased<'tcx>( + tcx: TyCtxt<'tcx>, + provided_value: ProvidedValue<'tcx>, + ) -> Erased> { + // For queries with the `arena_cache` modifier, store the + // provided value in an arena and get a reference to it. + let value: Value<'tcx> = if_arena_cache!( + [$($modifiers)*] + { + as $crate::query::arena_cached::ArenaCached>:: + alloc_in_arena + ( + tcx, + &tcx.query_system.arenas.$name, + provided_value, + ) + } + { + // Otherwise, the provided value is the value (and `tcx` is unused). + let _ = tcx; + provided_value + } + ); + erase::erase_val(value) } - }; - })* + + pub type Storage<'tcx> = + as $crate::query::Key>::Cache>>; + + // Ensure that keys grow no larger than 88 bytes by accident. + // Increase this limit if necessary, but do try to keep the size low if possible + #[cfg(target_pointer_width = "64")] + const _: () = { + if size_of::>() > 88 { + panic!("{}", concat!( + "the query `", + stringify!($name), + "` has a key type `", + stringify!($($K)*), + "` that is too large" + )); + } + }; + + // Ensure that values grow no larger than 64 bytes by accident. + // Increase this limit if necessary, but do try to keep the size low if possible + #[cfg(target_pointer_width = "64")] + #[cfg(not(feature = "rustc_randomized_layouts"))] + const _: () = { + if size_of::>() > 64 { + panic!("{}", concat!( + "the query `", + stringify!($name), + "` has a value type `", + stringify!($V), + "` that is too large" + )); + } + }; + } + )* /// Holds per-query arenas for queries with the `arena_cache` modifier. #[derive(Default)] pub struct QueryArenas<'tcx> { $( - $(#[$attr])* - pub $name: query_if_arena!([$($modifiers)*] + pub $name: if_arena_cache!( + [$($modifiers)*] // Use the `ArenaCached` helper trait to determine the arena's value type. (TypedArena<<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Allocated>) // No arena for this query, so the field type is `()`. @@ -447,66 +412,81 @@ macro_rules! define_callbacks { #[derive(Default)] pub struct QueryCaches<'tcx> { - $($(#[$attr])* pub $name: $name::Storage<'tcx>,)* + $( + pub $name: $name::Storage<'tcx>, + )* } impl<'tcx> $crate::query::TyCtxtEnsureOk<'tcx> { - $($(#[$attr])* - #[inline(always)] - pub fn $name( - self, - key: query_helper_param_ty!($($K)*), - ) -> ensure_ok_result!([$($modifiers)*]) { - query_ensure_select!( + $( + $(#[$attr])* + #[inline(always)] + pub fn $name( + self, + key: query_helper_param_ty!($($K)*), + ) -> if_return_result_from_ensure_ok!( [$($modifiers)*] - self.tcx, - self.tcx.query_system.fns.engine.$name, - &self.tcx.query_system.caches.$name, - $crate::query::IntoQueryParam::into_query_param(key), - false, - ) - })* + (Result<(), ErrorGuaranteed>) + () + ) { + if_return_result_from_ensure_ok!( + [$($modifiers)*] + (crate::query::inner::query_ensure_error_guaranteed) + (crate::query::inner::query_ensure) + )( + self.tcx, + self.tcx.query_system.fns.engine.$name, + &self.tcx.query_system.caches.$name, + $crate::query::IntoQueryParam::into_query_param(key), + false, + ) + } + )* } impl<'tcx> $crate::query::TyCtxtEnsureDone<'tcx> { - $($(#[$attr])* - #[inline(always)] - pub fn $name(self, key: query_helper_param_ty!($($K)*)) { - crate::query::inner::query_ensure( - self.tcx, - self.tcx.query_system.fns.engine.$name, - &self.tcx.query_system.caches.$name, - $crate::query::IntoQueryParam::into_query_param(key), - true, - ); - })* + $( + $(#[$attr])* + #[inline(always)] + pub fn $name(self, key: query_helper_param_ty!($($K)*)) { + crate::query::inner::query_ensure( + self.tcx, + self.tcx.query_system.fns.engine.$name, + &self.tcx.query_system.caches.$name, + $crate::query::IntoQueryParam::into_query_param(key), + true, + ); + } + )* } impl<'tcx> TyCtxt<'tcx> { - $($(#[$attr])* - #[inline(always)] - #[must_use] - pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V - { - self.at(DUMMY_SP).$name(key) - })* + $( + $(#[$attr])* + #[inline(always)] + #[must_use] + pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V { + self.at(DUMMY_SP).$name(key) + } + )* } impl<'tcx> $crate::query::TyCtxtAt<'tcx> { - $($(#[$attr])* - #[inline(always)] - pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V - { - use $crate::query::{erase, inner}; - - erase::restore_val::<$V>(inner::query_get_at( - self.tcx, - self.tcx.query_system.fns.engine.$name, - &self.tcx.query_system.caches.$name, - self.span, - $crate::query::IntoQueryParam::into_query_param(key), - )) - })* + $( + $(#[$attr])* + #[inline(always)] + pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V { + use $crate::query::{erase, inner}; + + erase::restore_val::<$V>(inner::query_get_at( + self.tcx, + self.tcx.query_system.fns.engine.$name, + &self.tcx.query_system.caches.$name, + self.span, + $crate::query::IntoQueryParam::into_query_param(key), + )) + } + )* } /// Holds a `QueryVTable` for each query. @@ -521,7 +501,7 @@ macro_rules! define_callbacks { #[derive(Default)] pub struct QueryStates<'tcx> { $( - pub $name: $crate::query::QueryState<'tcx, $($K)*>, + pub $name: $crate::query::QueryState<'tcx, $name::Key<'tcx>>, )* } @@ -537,13 +517,23 @@ macro_rules! define_callbacks { } pub struct ExternProviders { - $(pub $name: separate_provide_extern_decl!([$($modifiers)*][$name]),)* + $( + pub $name: if_separate_provide_extern!( + [$($modifiers)*] + (for<'tcx> fn(TyCtxt<'tcx>, $name::Key<'tcx>) -> $name::ProvidedValue<'tcx>) + () + ), + )* } impl Default for Providers { fn default() -> Self { Providers { - $($name: |_, key| $crate::query::plumbing::default_query(stringify!($name), &key)),* + $( + $name: |_, key| { + $crate::query::plumbing::default_query(stringify!($name), &key) + }, + )* } } } @@ -551,7 +541,16 @@ macro_rules! define_callbacks { impl Default for ExternProviders { fn default() -> Self { ExternProviders { - $($name: separate_provide_extern_default!([$($modifiers)*][$name]),)* + $( + $name: if_separate_provide_extern!( + [$($modifiers)*] + (|_, key| $crate::query::plumbing::default_extern_query( + stringify!($name), + &key + )) + () + ), + )* } } } @@ -567,37 +566,48 @@ macro_rules! define_callbacks { } pub struct QueryEngine { - $(pub $name: for<'tcx> fn( - TyCtxt<'tcx>, - Span, - $name::Key<'tcx>, - $crate::query::QueryMode, - ) -> Option<$crate::query::erase::Erased<$V>>,)* + $( + pub $name: for<'tcx> fn( + TyCtxt<'tcx>, + Span, + $name::Key<'tcx>, + $crate::query::QueryMode, + ) -> Option<$crate::query::erase::Erased<$V>>, + )* } }; } +// Note: `$V` is unused but present so this can be called by `rustc_with_all_queries`. macro_rules! define_feedable { - ($($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => { - $(impl<'tcx, K: $crate::query::IntoQueryParam<$($K)*> + Copy> TyCtxtFeed<'tcx, K> { - $(#[$attr])* - #[inline(always)] - pub fn $name(self, value: $name::ProvidedValue<'tcx>) { - let key = self.key().into_query_param(); - - let tcx = self.tcx; - let erased_value = $name::provided_to_erased(tcx, value); - - $crate::query::inner::query_feed( - tcx, - dep_graph::DepKind::$name, - &tcx.query_system.query_vtables.$name, - &tcx.query_system.caches.$name, - key, - erased_value, - ); + ( + $( + $(#[$attr:meta])* + [$($modifiers:tt)*] + fn $name:ident($K:ty) -> $V:ty, + )* + ) => { + $( + impl<'tcx, K: $crate::query::IntoQueryParam<$K> + Copy> TyCtxtFeed<'tcx, K> { + $(#[$attr])* + #[inline(always)] + pub fn $name(self, value: $name::ProvidedValue<'tcx>) { + let key = self.key().into_query_param(); + + let tcx = self.tcx; + let erased_value = $name::provided_to_erased(tcx, value); + + $crate::query::inner::query_feed( + tcx, + dep_graph::DepKind::$name, + &tcx.query_system.query_vtables.$name, + &tcx.query_system.caches.$name, + key, + erased_value, + ); + } } - })* + )* } } diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 4e38b9dd6534b..dd8491b00cee9 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -61,10 +61,8 @@ //! The evaluated form is inserted in `evaluated` as an `OpTy` or `None` if evaluation failed. //! //! The difficulty is non-deterministic evaluation of MIR constants. Some `Const` can have -//! different runtime values each time they are evaluated. This is the case with -//! `Const::Slice` which have a new pointer each time they are evaluated, and constants that -//! contain a fn pointer (`AllocId` pointing to a `GlobalAlloc::Function`) pointing to a different -//! symbol in each codegen unit. +//! different runtime values each time they are evaluated. This happens with valtrees that +//! generate a new allocation each time they are used. This is checked by `is_deterministic`. //! //! Meanwhile, we want to be able to read indirect constants. For instance: //! ``` @@ -81,8 +79,12 @@ //! may be non-deterministic. When that happens, we assign a disambiguator to ensure that we do not //! merge the constants. See `duplicate_slice` test in `gvn.rs`. //! -//! Second, when writing constants in MIR, we do not write `Const::Slice` or `Const` -//! that contain `AllocId`s. +//! Conversely, some constants cannot cross function boundaries, which could happen because of +//! inlining. For instance, constants that contain a fn pointer (`AllocId` pointing to a +//! `GlobalAlloc::Function`) point to a different symbol in each codegen unit. To avoid this, +//! when writing constants in MIR, we do not write `Const`s that contain `AllocId`s. This is +//! checked by `may_have_provenance`. See for +//! more information. use std::borrow::Cow; use std::hash::{Hash, Hasher}; @@ -103,7 +105,7 @@ use rustc_hir::def::DefKind; use rustc_index::bit_set::DenseBitSet; use rustc_index::{IndexVec, newtype_index}; use rustc_middle::bug; -use rustc_middle::mir::interpret::GlobalAlloc; +use rustc_middle::mir::interpret::{AllocRange, GlobalAlloc}; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::layout::HasTypingEnv; @@ -487,7 +489,7 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { #[instrument(level = "trace", skip(self), ret)] fn insert_constant(&mut self, value: Const<'tcx>) -> VnIndex { - if value.is_deterministic() { + if is_deterministic(value) { // The constant is deterministic, no need to disambiguate. let constant = Value::Constant { value, disambiguator: None }; self.insert(value.ty(), constant) @@ -522,14 +524,14 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { fn insert_bool(&mut self, flag: bool) -> VnIndex { // Booleans are deterministic. let value = Const::from_bool(self.tcx, flag); - debug_assert!(value.is_deterministic()); + debug_assert!(is_deterministic(value)); self.insert(self.tcx.types.bool, Value::Constant { value, disambiguator: None }) } fn insert_scalar(&mut self, ty: Ty<'tcx>, scalar: Scalar) -> VnIndex { // Scalars are deterministic. let value = Const::from_scalar(self.tcx, scalar, ty); - debug_assert!(value.is_deterministic()); + debug_assert!(is_deterministic(value)); self.insert(ty, Value::Constant { value, disambiguator: None }) } @@ -1002,21 +1004,19 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { operand: &mut Operand<'tcx>, location: Location, ) -> Option { - match *operand { - Operand::RuntimeChecks(c) => { - Some(self.insert(self.tcx.types.bool, Value::RuntimeChecks(c))) - } - Operand::Constant(ref constant) => Some(self.insert_constant(constant.const_)), + let value = match *operand { + Operand::RuntimeChecks(c) => self.insert(self.tcx.types.bool, Value::RuntimeChecks(c)), + Operand::Constant(ref constant) => self.insert_constant(constant.const_), Operand::Copy(ref mut place) | Operand::Move(ref mut place) => { - let value = self.simplify_place_value(place, location)?; - if let Some(const_) = self.try_as_constant(value) { - *operand = Operand::Constant(Box::new(const_)); - } else if let Value::RuntimeChecks(c) = self.get(value) { - *operand = Operand::RuntimeChecks(c); - } - Some(value) + self.simplify_place_value(place, location)? } + }; + if let Some(const_) = self.try_as_constant(value) { + *operand = Operand::Constant(Box::new(const_)); + } else if let Value::RuntimeChecks(c) = self.get(value) { + *operand = Operand::RuntimeChecks(c); } + Some(value) } #[instrument(level = "trace", skip(self), ret)] @@ -1731,6 +1731,49 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { } } +/// Return true if any evaluation of this constant in the same MIR body +/// always returns the same value, taking into account even pointer identity tests. +/// +/// In other words, this answers: is "cloning" the `Const` ok? +/// +/// This returns `false` for constants that synthesize new `AllocId` when they are instantiated. +/// It is `true` for anything else, since a given `AllocId` *does* have a unique runtime value +/// within the scope of a single MIR body. +fn is_deterministic(c: Const<'_>) -> bool { + // Primitive types cannot contain provenance and always have the same value. + if c.ty().is_primitive() { + return true; + } + + match c { + // Some constants may generate fresh allocations for pointers they contain, + // so using the same constant twice can yield two different results. + // Notably, valtrees purposefully generate new allocations. + Const::Ty(..) => false, + // We do not know the contents, so don't attempt to do anything clever. + Const::Unevaluated(..) => false, + // When an evaluated constant contains provenance, it is encoded as an `AllocId`. + // Cloning the constant will reuse the same `AllocId`. If this is in the same MIR + // body, this same `AllocId` will result in the same pointer in codegen. + Const::Val(..) => true, + } +} + +/// Check if a constant may contain provenance information. +/// Can return `true` even if there is no provenance. +fn may_have_provenance(tcx: TyCtxt<'_>, value: ConstValue, size: Size) -> bool { + match value { + ConstValue::ZeroSized | ConstValue::Scalar(Scalar::Int(_)) => return false, + ConstValue::Scalar(Scalar::Ptr(..)) | ConstValue::Slice { .. } => return true, + ConstValue::Indirect { alloc_id, offset } => !tcx + .global_alloc(alloc_id) + .unwrap_memory() + .inner() + .provenance() + .range_empty(AllocRange::from(offset..offset + size), &tcx), + } +} + fn op_to_prop_const<'tcx>( ecx: &mut InterpCx<'tcx, DummyMachine>, op: &OpTy<'tcx>, @@ -1762,7 +1805,7 @@ fn op_to_prop_const<'tcx>( if !scalar.try_to_scalar_int().is_ok() { // Check that we do not leak a pointer. // Those pointers may lose part of their identity in codegen. - // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/79738 is fixed. + // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/128775 is fixed. return None; } return Some(ConstValue::Scalar(scalar)); @@ -1774,7 +1817,7 @@ fn op_to_prop_const<'tcx>( let (size, _align) = ecx.size_and_align_of_val(&mplace).discard_err()??; // Do not try interning a value that contains provenance. - // Due to https://github.com/rust-lang/rust/issues/79738, doing so could lead to bugs. + // Due to https://github.com/rust-lang/rust/issues/128775, doing so could lead to bugs. // FIXME: remove this hack once that issue is fixed. let alloc_ref = ecx.get_ptr_alloc(mplace.ptr(), size).discard_err()??; if alloc_ref.has_provenance() { @@ -1801,16 +1844,7 @@ fn op_to_prop_const<'tcx>( // Everything failed: create a new allocation to hold the data. let alloc_id = ecx.intern_with_temp_alloc(op.layout, |ecx, dest| ecx.copy_op(op, dest)).discard_err()?; - let value = ConstValue::Indirect { alloc_id, offset: Size::ZERO }; - - // Check that we do not leak a pointer. - // Those pointers may lose part of their identity in codegen. - // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/79738 is fixed. - if ecx.tcx.global_alloc(alloc_id).unwrap_memory().inner().provenance().ptrs().is_empty() { - return Some(value); - } - - None + Some(ConstValue::Indirect { alloc_id, offset: Size::ZERO }) } impl<'tcx> VnState<'_, '_, 'tcx> { @@ -1831,14 +1865,28 @@ impl<'tcx> VnState<'_, '_, 'tcx> { /// If `index` is a `Value::Constant`, return the `Constant` to be put in the MIR. fn try_as_constant(&mut self, index: VnIndex) -> Option> { - // This was already constant in MIR, do not change it. If the constant is not - // deterministic, adding an additional mention of it in MIR will not give the same value as - // the former mention. - if let Value::Constant { value, disambiguator: None } = self.get(index) { - debug_assert!(value.is_deterministic()); + let value = self.get(index); + + // This was already an *evaluated* constant in MIR, do not change it. + if let Value::Constant { value, disambiguator: None } = value + && let Const::Val(..) = value + { return Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_: value }); } + if let Some(value) = self.try_as_evaluated_constant(index) { + return Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_: value }); + } + + // We failed to provide an evaluated form, fallback to using the unevaluated constant. + if let Value::Constant { value, disambiguator: None } = value { + return Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_: value }); + } + + None + } + + fn try_as_evaluated_constant(&mut self, index: VnIndex) -> Option> { let op = self.eval_to_const(index)?; if op.layout.is_unsized() { // Do not attempt to propagate unsized locals. @@ -1849,11 +1897,12 @@ impl<'tcx> VnState<'_, '_, 'tcx> { // Check that we do not leak a pointer. // Those pointers may lose part of their identity in codegen. - // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/79738 is fixed. - assert!(!value.may_have_provenance(self.tcx, op.layout.size)); + // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/128775 is fixed. + if may_have_provenance(self.tcx, value, op.layout.size) { + return None; + } - let const_ = Const::Val(value, op.layout.ty); - Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_ }) + Some(Const::Val(value, op.layout.ty)) } /// Construct a place which holds the same value as `index` and for which all locals strictly diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 1ed601aae3562..31e81a62d5270 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -471,13 +471,12 @@ pub(crate) fn force_from_dep_node_inner<'tcx, C: QueryCache, const FLAGS: QueryF } } -// NOTE: `$V` isn't used here, but we still need to match on it so it can be passed to other macros -// invoked by `rustc_with_all_queries`. +// Note: `$K` and `$V` are unused but present so this can be called by `rustc_with_all_queries`. macro_rules! define_queries { ( $( $(#[$attr:meta])* - [$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty, + [$($modifiers:tt)*] fn $name:ident($K:ty) -> $V:ty, )* ) => { diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index dea077ce30cc3..3345f6ef31b1f 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -17,9 +17,9 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(cfg_select))] #![cfg_attr(bootstrap, feature(if_let_guard))] #![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))] -#![feature(cfg_select)] #![feature(core_io_borrowed_buf)] #![feature(map_try_insert)] #![feature(negative_impls)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 63fa54be3852b..ed1b73c6e3d96 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -98,7 +98,6 @@ // tidy-alphabetical-start #![feature(asm_experimental_arch)] #![feature(bstr_internals)] -#![feature(cfg_select)] #![feature(cfg_target_has_reliable_f16_f128)] #![feature(const_carrying_mul_add)] #![feature(const_cmp)] @@ -227,7 +226,7 @@ pub mod autodiff { #[unstable(feature = "contracts", issue = "128044")] pub mod contracts; -#[unstable(feature = "cfg_select", issue = "115585")] +#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")] pub use crate::macros::cfg_select; #[macro_use] diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index cdbb8c300455d..28eefd0013ca5 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -206,8 +206,6 @@ pub macro assert_matches { /// # Example /// /// ``` -/// #![feature(cfg_select)] -/// /// cfg_select! { /// unix => { /// fn foo() { /* unix specific functionality */ } @@ -225,14 +223,12 @@ pub macro assert_matches { /// right-hand side: /// /// ``` -/// #![feature(cfg_select)] -/// /// let _some_string = cfg_select! { /// unix => "With great power comes great electricity bills", /// _ => { "Behind every successful diet is an unwatched pizza" } /// }; /// ``` -#[unstable(feature = "cfg_select", issue = "115585")] +#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")] #[rustc_diagnostic_item = "cfg_select"] #[rustc_builtin_macro] pub macro cfg_select($($tt:tt)*) { diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 354be271ff131..17928b1e9cb31 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -80,7 +80,7 @@ mod ambiguous_macros_only { #[doc(no_inline)] pub use self::ambiguous_macros_only::{env, panic}; -#[unstable(feature = "cfg_select", issue = "115585")] +#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")] #[doc(no_inline)] pub use crate::cfg_select; diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index 85ee7cff68266..7cd946dc9a03f 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -1,6 +1,5 @@ // tidy-alphabetical-start #![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] -#![cfg_attr(test, feature(cfg_select))] #![feature(array_ptr_get)] #![feature(array_try_from_fn)] #![feature(array_try_map)] diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index 83f2a3b2c53f4..5372c44cedf75 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -15,7 +15,6 @@ #![unstable(feature = "panic_unwind", issue = "32837")] #![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] #![feature(cfg_emscripten_wasm_eh)] -#![feature(cfg_select)] #![feature(core_intrinsics)] #![feature(panic_unwind)] #![feature(staged_api)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 5620ef0254aa7..ed1c1a89bd410 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -322,7 +322,6 @@ #![feature(bstr)] #![feature(bstr_internals)] #![feature(cast_maybe_uninit)] -#![feature(cfg_select)] #![feature(char_internals)] #![feature(clone_to_uninit)] #![feature(const_convert)] @@ -695,7 +694,7 @@ mod panicking; #[allow(dead_code, unused_attributes, fuzzy_provenance_casts, unsafe_op_in_unsafe_fn)] mod backtrace_rs; -#[unstable(feature = "cfg_select", issue = "115585")] +#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")] pub use core::cfg_select; #[unstable( feature = "concat_bytes", diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index af9d28ebad356..f17f11dec7f62 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -79,7 +79,7 @@ mod ambiguous_macros_only { #[doc(no_inline)] pub use self::ambiguous_macros_only::{vec, panic}; -#[unstable(feature = "cfg_select", issue = "115585")] +#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")] #[doc(no_inline)] pub use core::prelude::v1::cfg_select; diff --git a/library/std/tests/env_modify.rs b/library/std/tests/env_modify.rs index 4cd87bf7a0027..3404ca537acca 100644 --- a/library/std/tests/env_modify.rs +++ b/library/std/tests/env_modify.rs @@ -1,6 +1,5 @@ // These tests are in a separate integration test as they modify the environment, // and would otherwise cause some other tests to fail. -#![feature(cfg_select)] use std::env::*; use std::ffi::{OsStr, OsString}; diff --git a/library/std_detect/src/lib.rs b/library/std_detect/src/lib.rs index 5e1d21bbfd17d..f9d79df670a0f 100644 --- a/library/std_detect/src/lib.rs +++ b/library/std_detect/src/lib.rs @@ -15,7 +15,7 @@ //! * `s390x`: [`is_s390x_feature_detected`] #![unstable(feature = "stdarch_internal", issue = "none")] -#![feature(staged_api, cfg_select, doc_cfg, allow_internal_unstable)] +#![feature(staged_api, doc_cfg, allow_internal_unstable)] #![deny(rust_2018_idioms)] #![allow(clippy::shadow_reuse)] #![cfg_attr(test, allow(unused_imports))] diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index 1e68eda52064e..cce6ca748cccd 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -1,7 +1,6 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] #![feature(cfg_emscripten_wasm_eh)] -#![feature(cfg_select)] #![feature(link_cfg)] #![feature(staged_api)] #![cfg_attr( diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 6177233bc04e5..389956f145994 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -675,6 +675,7 @@ fn fix_bin_or_dylib(out: &Path, fname: &Path, exec_ctx: &ExecutionContext) { // the `.nix-deps` location. // // bintools: Needed for the path of `ld-linux.so` (via `nix-support/dynamic-linker`). + // cc.lib: Needed similarly for `libstdc++.so.6`. // zlib: Needed as a system dependency of `libLLVM-*.so`. // patchelf: Needed for patching ELF binaries (see doc comment above). let nix_deps_dir = out.join(".nix-deps"); @@ -686,6 +687,7 @@ fn fix_bin_or_dylib(out: &Path, fname: &Path, exec_ctx: &ExecutionContext) { zlib patchelf stdenv.cc.bintools + stdenv.cc.cc.lib ]; } "; diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 232a24306d65e..32cadddc33aa3 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(abort_unwind)] -#![feature(cfg_select)] #![feature(rustc_private)] #![feature(float_gamma)] #![feature(float_erf)] @@ -17,6 +16,7 @@ #![feature(derive_coerce_pointee)] #![feature(arbitrary_self_types)] #![feature(iter_advance_by)] +#![cfg_attr(bootstrap, feature(cfg_select))] // Configure clippy and other lints #![allow( clippy::collapsible_else_if, diff --git a/src/tools/miri/tests/pass/float_extra_rounding_error.rs b/src/tools/miri/tests/pass/float_extra_rounding_error.rs index 24d7cf2cceee2..fc8190b7dec26 100644 --- a/src/tools/miri/tests/pass/float_extra_rounding_error.rs +++ b/src/tools/miri/tests/pass/float_extra_rounding_error.rs @@ -2,7 +2,6 @@ //@revisions: random max none //@[max]compile-flags: -Zmiri-max-extra-rounding-error //@[none]compile-flags: -Zmiri-no-extra-rounding-error -#![feature(cfg_select)] use std::collections::HashSet; use std::hint::black_box; diff --git a/tests/incremental/hashes/enum_constructors.rs b/tests/incremental/hashes/enum_constructors.rs index dee485681e447..5962727b3af0b 100644 --- a/tests/incremental/hashes/enum_constructors.rs +++ b/tests/incremental/hashes/enum_constructors.rs @@ -65,7 +65,7 @@ pub fn change_field_order_struct_like() -> Enum { #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] // FIXME(michaelwoerister):Interesting. I would have thought that that changes the MIR. And it // would if it were not all constants diff --git a/tests/incremental/hashes/struct_constructors.rs b/tests/incremental/hashes/struct_constructors.rs index da7abe049d982..b2f8d116b1e94 100644 --- a/tests/incremental/hashes/struct_constructors.rs +++ b/tests/incremental/hashes/struct_constructors.rs @@ -62,7 +62,7 @@ pub fn change_field_order_regular_struct() -> RegularStruct { #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn change_field_order_regular_struct() -> RegularStruct { RegularStruct { diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff index 88c77832a4e18..61cc233bcb528 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(copy _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff index 8a6e7fd35ccd2..655762567da32 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(copy _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff index ce10f4bb247a8..ca47d2c580b50 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(copy _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff index b19f2438d0225..9239c365537c7 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(copy _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff b/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff index a91561ba304b8..92158682c9993 100644 --- a/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff +++ b/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff @@ -5,7 +5,8 @@ let mut _0: bool; bb0: { - _0 = Eq(const no_optimize::::{constant#0}, const no_optimize::::{constant#1}); +- _0 = Eq(const no_optimize::::{constant#0}, const no_optimize::::{constant#1}); ++ _0 = Eq(const no_optimize::::{constant#0}, const true); return; } } diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.rs b/tests/mir-opt/gvn_const_eval_polymorphic.rs index 7320ad947ff2e..722720b2a6f07 100644 --- a/tests/mir-opt/gvn_const_eval_polymorphic.rs +++ b/tests/mir-opt/gvn_const_eval_polymorphic.rs @@ -51,7 +51,7 @@ fn optimize_false() -> bool { // EMIT_MIR gvn_const_eval_polymorphic.no_optimize.GVN.diff fn no_optimize() -> bool { // CHECK-LABEL: fn no_optimize( - // CHECK: _0 = Eq(const no_optimize::::{constant#0}, const no_optimize::::{constant#1}); + // CHECK: _0 = Eq(const no_optimize::::{constant#0}, const true); // CHECK-NEXT: return; (const { type_name_contains_i32(&generic::) }) == const { true } } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir index 18eeb8e4d3b61..c97c9b45d6ad5 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir @@ -17,7 +17,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option { bb0: { StorageLive(_3); - _3 = Lt(copy _2, const core::num::::BITS); + _3 = Lt(copy _2, const 32_u32); switchInt(move _3) -> [0: bb1, otherwise: bb2]; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir index 18eeb8e4d3b61..c97c9b45d6ad5 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir @@ -17,7 +17,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option { bb0: { StorageLive(_3); - _3 = Lt(copy _2, const core::num::::BITS); + _3 = Lt(copy _2, const 32_u32); switchInt(move _3) -> [0: bb1, otherwise: bb2]; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir index 83478e60b5d4e..7b681946bee1e 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir @@ -72,7 +72,7 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb6: { - assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::::MAX, const 1_u16) -> [success: bb7, unwind unreachable]; + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u16::MAX, const 1_u16) -> [success: bb7, unwind unreachable]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir index ac7a6e0445191..a0137b23ec4f4 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir @@ -72,7 +72,7 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb6: { - assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::::MAX, const 1_u16) -> [success: bb7, unwind continue]; + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u16::MAX, const 1_u16) -> [success: bb7, unwind continue]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir index c446ab395f3ec..fcb804cdbfd89 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-abort.mir @@ -6,7 +6,7 @@ fn drop_generic(_1: *mut Box) -> () { scope 1 (inlined drop_in_place::> - shim(Some(Box))) { scope 2 (inlined as Drop>::drop) { let _2: std::ptr::NonNull; - let _7: (); + let _5: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { @@ -24,7 +24,7 @@ fn drop_generic(_1: *mut Box) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _6: *mut u8; + let mut _4: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -44,8 +44,7 @@ fn drop_generic(_1: *mut Box) -> () { } } scope 7 (inlined Layout::for_value_raw::) { - let mut _3: usize; - let mut _5: std::ptr::Alignment; + let mut _3: std::ptr::Alignment; scope 8 { scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } @@ -53,7 +52,6 @@ fn drop_generic(_1: *mut Box) -> () { scope 9 (inlined size_of_val_raw::) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::) { - let _4: usize; scope 11 { scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { scope 14 (inlined core::ub_checks::check_language_ub) { @@ -72,26 +70,26 @@ fn drop_generic(_1: *mut Box) -> () { bb0: { _2 = copy (((*_1).0: std::ptr::Unique).0: std::ptr::NonNull); - _3 = const ::SIZE; - StorageLive(_4); - _4 = const ::ALIGN; - _5 = copy _4 as std::ptr::Alignment (Transmute); - StorageDead(_4); - switchInt(copy _3) -> [0: bb3, otherwise: bb1]; + _3 = const ::ALIGN as std::ptr::Alignment (Transmute); + switchInt(const ::SIZE) -> [0: bb4, otherwise: bb1]; } bb1: { - StorageLive(_6); - _6 = copy _2 as *mut u8 (Transmute); - _7 = alloc::alloc::__rust_dealloc(move _6, move _3, move _5) -> [return: bb2, unwind unreachable]; + switchInt(const ::SIZE) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageDead(_6); - goto -> bb3; + StorageLive(_4); + _4 = copy _2 as *mut u8 (Transmute); + _5 = alloc::alloc::__rust_dealloc(move _4, const ::SIZE, move _3) -> [return: bb3, unwind unreachable]; } bb3: { + StorageDead(_4); + goto -> bb4; + } + + bb4: { return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir index c446ab395f3ec..fcb804cdbfd89 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.PreCodegen.after.panic-unwind.mir @@ -6,7 +6,7 @@ fn drop_generic(_1: *mut Box) -> () { scope 1 (inlined drop_in_place::> - shim(Some(Box))) { scope 2 (inlined as Drop>::drop) { let _2: std::ptr::NonNull; - let _7: (); + let _5: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { @@ -24,7 +24,7 @@ fn drop_generic(_1: *mut Box) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _6: *mut u8; + let mut _4: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -44,8 +44,7 @@ fn drop_generic(_1: *mut Box) -> () { } } scope 7 (inlined Layout::for_value_raw::) { - let mut _3: usize; - let mut _5: std::ptr::Alignment; + let mut _3: std::ptr::Alignment; scope 8 { scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } @@ -53,7 +52,6 @@ fn drop_generic(_1: *mut Box) -> () { scope 9 (inlined size_of_val_raw::) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::) { - let _4: usize; scope 11 { scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { scope 14 (inlined core::ub_checks::check_language_ub) { @@ -72,26 +70,26 @@ fn drop_generic(_1: *mut Box) -> () { bb0: { _2 = copy (((*_1).0: std::ptr::Unique).0: std::ptr::NonNull); - _3 = const ::SIZE; - StorageLive(_4); - _4 = const ::ALIGN; - _5 = copy _4 as std::ptr::Alignment (Transmute); - StorageDead(_4); - switchInt(copy _3) -> [0: bb3, otherwise: bb1]; + _3 = const ::ALIGN as std::ptr::Alignment (Transmute); + switchInt(const ::SIZE) -> [0: bb4, otherwise: bb1]; } bb1: { - StorageLive(_6); - _6 = copy _2 as *mut u8 (Transmute); - _7 = alloc::alloc::__rust_dealloc(move _6, move _3, move _5) -> [return: bb2, unwind unreachable]; + switchInt(const ::SIZE) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageDead(_6); - goto -> bb3; + StorageLive(_4); + _4 = copy _2 as *mut u8 (Transmute); + _5 = alloc::alloc::__rust_dealloc(move _4, const ::SIZE, move _3) -> [return: bb3, unwind unreachable]; } bb3: { + StorageDead(_4); + goto -> bb4; + } + + bb4: { return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.rs b/tests/mir-opt/pre-codegen/drop_box_of_sized.rs index 1e2953aa46b75..088339b15c870 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.rs +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.rs @@ -6,10 +6,8 @@ // EMIT_MIR drop_box_of_sized.drop_generic.PreCodegen.after.mir pub unsafe fn drop_generic(x: *mut Box) { // CHECK-LABEL: fn drop_generic - // CHECK: [[SIZE:_.+]] = const ::SIZE; - // CHECK: [[ALIGN:_.+]] = const ::ALIGN; - // CHECK: [[ALIGNMENT:_.+]] = copy [[ALIGN]] as std::ptr::Alignment (Transmute) - // CHECK: alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[ALIGNMENT]]) + // CHECK: [[ALIGNMENT:_.+]] = const ::ALIGN as std::ptr::Alignment (Transmute) + // CHECK: alloc::alloc::__rust_dealloc({{.+}}, const ::SIZE, move [[ALIGNMENT]]) std::ptr::drop_in_place(x) } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir index f8e575f490b0c..f4794a974bf22 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir @@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _8: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { @@ -26,7 +26,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; + let mut _7: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -47,7 +47,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } @@ -55,7 +55,6 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; scope 11 { scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { scope 14 (inlined core::ub_checks::check_language_ub) { @@ -82,22 +81,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGN as std::ptr::Alignment (Transmute); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir index f8e575f490b0c..f4794a974bf22 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir @@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _8: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { @@ -26,7 +26,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; + let mut _7: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -47,7 +47,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } @@ -55,7 +55,6 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; scope 11 { scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { scope 14 (inlined core::ub_checks::check_language_ub) { @@ -82,22 +81,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGN as std::ptr::Alignment (Transmute); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir index f8e575f490b0c..f4794a974bf22 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir @@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _8: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { @@ -26,7 +26,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; + let mut _7: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -47,7 +47,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } @@ -55,7 +55,6 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; scope 11 { scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { scope 14 (inlined core::ub_checks::check_language_ub) { @@ -82,22 +81,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGN as std::ptr::Alignment (Transmute); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir index f8e575f490b0c..f4794a974bf22 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir @@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { let _2: std::ptr::NonNull<[T]>; let mut _3: *mut [T]; let mut _4: *const [T]; - let _9: (); + let _8: (); scope 3 { scope 4 { scope 17 (inlined Layout::size) { @@ -26,7 +26,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 23 (inlined ::deallocate) { scope 24 (inlined std::alloc::Global::deallocate_impl) { scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { - let mut _8: *mut u8; + let mut _7: *mut u8; scope 26 (inlined Layout::size) { } scope 27 (inlined NonNull::::as_ptr) { @@ -47,7 +47,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } scope 7 (inlined Layout::for_value_raw::<[T]>) { let mut _5: usize; - let mut _7: std::ptr::Alignment; + let mut _6: std::ptr::Alignment; scope 8 { scope 16 (inlined #[track_caller] Layout::from_size_alignment_unchecked) { } @@ -55,7 +55,6 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { scope 9 (inlined size_of_val_raw::<[T]>) { } scope 10 (inlined std::ptr::Alignment::of_val_raw::<[T]>) { - let _6: usize; scope 11 { scope 13 (inlined #[track_caller] std::ptr::Alignment::new_unchecked) { scope 14 (inlined core::ub_checks::check_language_ub) { @@ -82,22 +81,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { } bb1: { - StorageLive(_6); - _6 = const ::ALIGN; - _7 = copy _6 as std::ptr::Alignment (Transmute); - StorageDead(_6); + _6 = const ::ALIGN as std::ptr::Alignment (Transmute); StorageDead(_4); switchInt(copy _5) -> [0: bb4, otherwise: bb2]; } bb2: { - StorageLive(_8); - _8 = copy _3 as *mut u8 (PtrToPtr); - _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _7) -> [return: bb3, unwind unreachable]; + StorageLive(_7); + _7 = copy _3 as *mut u8 (PtrToPtr); + _8 = alloc::alloc::__rust_dealloc(move _7, move _5, move _6) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); + StorageDead(_7); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs index ae10cfb0b1713..9e56b310e8188 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs @@ -9,8 +9,7 @@ pub unsafe fn generic_in_place(ptr: *mut Box<[T]>) { // CHECK-LABEL: fn generic_in_place(_1: *mut Box<[T]>) // CHECK: (inlined as Drop>::drop) // CHECK: [[SIZE:_.+]] = std::intrinsics::size_of_val::<[T]> - // CHECK: [[ALIGN:_.+]] = const ::ALIGN; - // CHECK: [[B:_.+]] = copy [[ALIGN]] as std::ptr::Alignment (Transmute); - // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[B]]) -> + // CHECK: [[ALIGN:_.+]] = const ::ALIGN as std::ptr::Alignment (Transmute); + // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[ALIGN]]) -> std::ptr::drop_in_place(ptr) } diff --git a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs index dd2d094709942..97506cdd592b6 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs +++ b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs @@ -1,6 +1,5 @@ #![crate_type = "staticlib"] #![feature(c_variadic)] -#![feature(cfg_select)] use std::ffi::{CStr, CString, VaList, c_char, c_double, c_int, c_long, c_longlong}; diff --git a/tests/ui/asm/cfg.rs b/tests/ui/asm/cfg.rs index 90b1b3d6ee650..d7a2c78f58d26 100644 --- a/tests/ui/asm/cfg.rs +++ b/tests/ui/asm/cfg.rs @@ -3,7 +3,6 @@ //@ revisions: reva revb //@ only-x86_64 //@ run-pass -#![feature(cfg_select)] use std::arch::{asm, naked_asm}; diff --git a/tests/ui/check-cfg/cfg-select.rs b/tests/ui/check-cfg/cfg-select.rs index ffa5e40bff085..b2638b2529df3 100644 --- a/tests/ui/check-cfg/cfg-select.rs +++ b/tests/ui/check-cfg/cfg-select.rs @@ -1,6 +1,5 @@ //@ check-pass -#![feature(cfg_select)] #![crate_type = "lib"] cfg_select! { diff --git a/tests/ui/check-cfg/cfg-select.stderr b/tests/ui/check-cfg/cfg-select.stderr index 23ed5918e71ce..e8b6fe6eff104 100644 --- a/tests/ui/check-cfg/cfg-select.stderr +++ b/tests/ui/check-cfg/cfg-select.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `invalid_cfg1` - --> $DIR/cfg-select.rs:8:5 + --> $DIR/cfg-select.rs:7:5 | LL | invalid_cfg1 => {} | ^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | invalid_cfg1 => {} = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `invalid_cfg2` - --> $DIR/cfg-select.rs:14:5 + --> $DIR/cfg-select.rs:13:5 | LL | invalid_cfg2 => {} | ^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-cfg-select.rs b/tests/ui/feature-gates/feature-gate-cfg-select.rs deleted file mode 100644 index 0963ed0015082..0000000000000 --- a/tests/ui/feature-gates/feature-gate-cfg-select.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![warn(unreachable_cfg_select_predicates)] -//~^ WARN unknown lint: `unreachable_cfg_select_predicates` - -cfg_select! { - //~^ ERROR use of unstable library feature `cfg_select` - _ => {} - // With the feature enabled, this branch would trip the unreachable_cfg_select_predicate lint. - true => {} -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg-select.stderr b/tests/ui/feature-gates/feature-gate-cfg-select.stderr deleted file mode 100644 index 0fdce49751645..0000000000000 --- a/tests/ui/feature-gates/feature-gate-cfg-select.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0658]: use of unstable library feature `cfg_select` - --> $DIR/feature-gate-cfg-select.rs:4:1 - | -LL | cfg_select! { - | ^^^^^^^^^^ - | - = note: see issue #115585 for more information - = help: add `#![feature(cfg_select)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown lint: `unreachable_cfg_select_predicates` - --> $DIR/feature-gate-cfg-select.rs:1:9 - | -LL | #![warn(unreachable_cfg_select_predicates)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `unreachable_cfg_select_predicates` lint is unstable - = note: see issue #115585 for more information - = help: add `#![feature(cfg_select)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: `#[warn(unknown_lints)]` on by default - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/macros/cfg_select.rs b/tests/ui/macros/cfg_select.rs index 693e27daad7ad..113cff38a3a93 100644 --- a/tests/ui/macros/cfg_select.rs +++ b/tests/ui/macros/cfg_select.rs @@ -1,4 +1,3 @@ -#![feature(cfg_select)] #![crate_type = "lib"] #![warn(unreachable_cfg_select_predicates)] // Unused warnings are disabled by default in UI tests. diff --git a/tests/ui/macros/cfg_select.stderr b/tests/ui/macros/cfg_select.stderr index 2da0c21694972..d2803964e00c2 100644 --- a/tests/ui/macros/cfg_select.stderr +++ b/tests/ui/macros/cfg_select.stderr @@ -1,5 +1,5 @@ error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:162:1 + --> $DIR/cfg_select.rs:161:1 | LL | / cfg_select! { LL | | @@ -8,55 +8,55 @@ LL | | } | |_^ error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:167:1 + --> $DIR/cfg_select.rs:166:1 | LL | cfg_select! {} | ^^^^^^^^^^^^^^ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `=>` - --> $DIR/cfg_select.rs:171:5 + --> $DIR/cfg_select.rs:170:5 | LL | => {} | ^^ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found expression - --> $DIR/cfg_select.rs:176:5 + --> $DIR/cfg_select.rs:175:5 | LL | () => {} | ^^ expressions are not allowed here error[E0539]: malformed `cfg_select` macro input - --> $DIR/cfg_select.rs:181:5 + --> $DIR/cfg_select.rs:180:5 | LL | "str" => {} | ^^^^^ expected a valid identifier here error[E0539]: malformed `cfg_select` macro input - --> $DIR/cfg_select.rs:186:5 + --> $DIR/cfg_select.rs:185:5 | LL | a::b => {} | ^^^^ expected a valid identifier here error[E0537]: invalid predicate `a` - --> $DIR/cfg_select.rs:191:5 + --> $DIR/cfg_select.rs:190:5 | LL | a() => {} | ^^^ error: expected one of `(`, `::`, `=>`, or `=`, found `+` - --> $DIR/cfg_select.rs:196:7 + --> $DIR/cfg_select.rs:195:7 | LL | a + 1 => {} | ^ expected one of `(`, `::`, `=>`, or `=` error: expected one of `(`, `::`, `=>`, or `=`, found `!` - --> $DIR/cfg_select.rs:202:8 + --> $DIR/cfg_select.rs:201:8 | LL | cfg!() => {} | ^ expected one of `(`, `::`, `=>`, or `=` warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:137:5 + --> $DIR/cfg_select.rs:136:5 | LL | _ => {} | - always matches @@ -64,13 +64,13 @@ LL | true => {} | ^^^^ this configuration predicate is never reached | note: the lint level is defined here - --> $DIR/cfg_select.rs:3:9 + --> $DIR/cfg_select.rs:2:9 | LL | #![warn(unreachable_cfg_select_predicates)] // Unused warnings are disabled by default in UI tests. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:143:5 + --> $DIR/cfg_select.rs:142:5 | LL | true => {} | ---- always matches @@ -78,25 +78,25 @@ LL | _ => {} | ^ this configuration predicate is never reached warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:150:5 + --> $DIR/cfg_select.rs:149:5 | LL | _ => {} | ^ this configuration predicate is never reached warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:156:5 + --> $DIR/cfg_select.rs:155:5 | LL | test => {} | ^^^^ this configuration predicate is never reached warning: unreachable configuration predicate - --> $DIR/cfg_select.rs:158:5 + --> $DIR/cfg_select.rs:157:5 | LL | _ => {} | ^ this configuration predicate is never reached warning: unexpected `cfg` condition name: `a` - --> $DIR/cfg_select.rs:196:5 + --> $DIR/cfg_select.rs:195:5 | LL | a + 1 => {} | ^ help: found config with similar value: `target_feature = "a"` @@ -107,7 +107,7 @@ LL | a + 1 => {} = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `cfg` - --> $DIR/cfg_select.rs:202:5 + --> $DIR/cfg_select.rs:201:5 | LL | cfg!() => {} | ^^^ diff --git a/tests/ui/macros/cfg_select_parse_error.rs b/tests/ui/macros/cfg_select_parse_error.rs index 90fcb2309b348..049a87c896564 100644 --- a/tests/ui/macros/cfg_select_parse_error.rs +++ b/tests/ui/macros/cfg_select_parse_error.rs @@ -1,4 +1,3 @@ -#![feature(cfg_select)] #![crate_type = "lib"] // Check that parse errors in arms that are not selected are still reported. diff --git a/tests/ui/macros/cfg_select_parse_error.stderr b/tests/ui/macros/cfg_select_parse_error.stderr index d4c86c3ceade1..d94b5d784866e 100644 --- a/tests/ui/macros/cfg_select_parse_error.stderr +++ b/tests/ui/macros/cfg_select_parse_error.stderr @@ -1,5 +1,5 @@ error: Rust has no postfix increment operator - --> $DIR/cfg_select_parse_error.rs:8:22 + --> $DIR/cfg_select_parse_error.rs:7:22 | LL | false => { 1 ++ 2 } | ^^ not a valid postfix operator @@ -11,7 +11,7 @@ LL + false => { { let tmp = 1 ; 1 += 1; tmp } 2 } | error: Rust has no postfix increment operator - --> $DIR/cfg_select_parse_error.rs:15:29 + --> $DIR/cfg_select_parse_error.rs:14:29 | LL | false => { fn foo() { 1 +++ 2 } } | ^^ not a valid postfix operator