diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2021-09-01 08:19:58 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2021-09-09 05:21:28 +0000 |
| commit | d9797d23d5e03aeafeac4eed6e147045af65783b (patch) | |
| tree | c5f260c6ae61e9f9ecb78b2c8696cd0cf0ea428e | |
| parent | 9c1a91628bb502deec644173d21830822a0f786a (diff) | |
| download | rust-d9797d23d5e03aeafeac4eed6e147045af65783b.tar.gz rust-d9797d23d5e03aeafeac4eed6e147045af65783b.zip | |
Remove unused query
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/fn_queries.rs | 32 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 8 |
2 files changed, 10 insertions, 30 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs index 40419a4d201..10afd9560fa 100644 --- a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs @@ -1,5 +1,5 @@ use rustc_hir as hir; -use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_hir::def_id::DefId; use rustc_middle::hir::map::blocks::FnLikeNode; use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; @@ -34,8 +34,14 @@ pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> { } pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool { - let parent_id = tcx.hir().get_parent_did(hir_id); - if !parent_id.is_top_level_module() { is_const_impl_raw(tcx, parent_id) } else { false } + let parent_id = tcx.hir().get_parent_node(hir_id); + matches!( + tcx.hir().get(parent_id), + hir::Node::Item(hir::Item { + kind: hir::ItemKind::Impl(hir::Impl { constness: hir::Constness::Const, .. }), + .. + }) + ) } /// Checks whether the function has a `const` modifier or, in case it is an intrinsic, whether @@ -70,19 +76,6 @@ fn is_const_fn_raw(tcx: TyCtxt<'_>, def_id: DefId) -> bool { } } -/// Checks whether the given item is an `impl` that has a `const` modifier. -fn is_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { - let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); - let node = tcx.hir().get(hir_id); - matches!( - node, - hir::Node::Item(hir::Item { - kind: hir::ItemKind::Impl(hir::Impl { constness: hir::Constness::Const, .. }), - .. - }) - ) -} - fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool { is_const_fn(tcx, def_id) && match tcx.lookup_const_stability(def_id) { @@ -103,10 +96,5 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool { } pub fn provide(providers: &mut Providers) { - *providers = Providers { - is_const_fn_raw, - is_const_impl_raw: |tcx, def_id| is_const_impl_raw(tcx, def_id.expect_local()), - is_promotable_const_fn, - ..*providers - }; + *providers = Providers { is_const_fn_raw, is_promotable_const_fn, ..*providers }; } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index c93996162e3..dd5753e95d0 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -544,14 +544,6 @@ rustc_queries! { desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) } } - /// Returns `true` if this is a const `impl`. **Do not call this function manually.** - /// - /// This query caches the base data for the `is_const_impl` helper function, which also - /// takes into account stability attributes (e.g., `#[rustc_const_unstable]`). - query is_const_impl_raw(key: DefId) -> bool { - desc { |tcx| "checking if item is const impl: `{}`", tcx.def_path_str(key) } - } - query asyncness(key: DefId) -> hir::IsAsync { desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) } } |
