Skip to content

Commit d9797d2

Browse files
committed
Remove unused query
1 parent 9c1a916 commit d9797d2

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

compiler/rustc_const_eval/src/const_eval/fn_queries.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_hir as hir;
2-
use rustc_hir::def_id::{DefId, LocalDefId};
2+
use rustc_hir::def_id::DefId;
33
use rustc_middle::hir::map::blocks::FnLikeNode;
44
use rustc_middle::ty::query::Providers;
55
use rustc_middle::ty::TyCtxt;
@@ -34,8 +34,14 @@ pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
3434
}
3535

3636
pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
37-
let parent_id = tcx.hir().get_parent_did(hir_id);
38-
if !parent_id.is_top_level_module() { is_const_impl_raw(tcx, parent_id) } else { false }
37+
let parent_id = tcx.hir().get_parent_node(hir_id);
38+
matches!(
39+
tcx.hir().get(parent_id),
40+
hir::Node::Item(hir::Item {
41+
kind: hir::ItemKind::Impl(hir::Impl { constness: hir::Constness::Const, .. }),
42+
..
43+
})
44+
)
3945
}
4046

4147
/// 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 {
7076
}
7177
}
7278

73-
/// Checks whether the given item is an `impl` that has a `const` modifier.
74-
fn is_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
75-
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
76-
let node = tcx.hir().get(hir_id);
77-
matches!(
78-
node,
79-
hir::Node::Item(hir::Item {
80-
kind: hir::ItemKind::Impl(hir::Impl { constness: hir::Constness::Const, .. }),
81-
..
82-
})
83-
)
84-
}
85-
8679
fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
8780
is_const_fn(tcx, def_id)
8881
&& match tcx.lookup_const_stability(def_id) {
@@ -103,10 +96,5 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
10396
}
10497

10598
pub fn provide(providers: &mut Providers) {
106-
*providers = Providers {
107-
is_const_fn_raw,
108-
is_const_impl_raw: |tcx, def_id| is_const_impl_raw(tcx, def_id.expect_local()),
109-
is_promotable_const_fn,
110-
..*providers
111-
};
99+
*providers = Providers { is_const_fn_raw, is_promotable_const_fn, ..*providers };
112100
}

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,6 @@ rustc_queries! {
544544
desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
545545
}
546546

547-
/// Returns `true` if this is a const `impl`. **Do not call this function manually.**
548-
///
549-
/// This query caches the base data for the `is_const_impl` helper function, which also
550-
/// takes into account stability attributes (e.g., `#[rustc_const_unstable]`).
551-
query is_const_impl_raw(key: DefId) -> bool {
552-
desc { |tcx| "checking if item is const impl: `{}`", tcx.def_path_str(key) }
553-
}
554-
555547
query asyncness(key: DefId) -> hir::IsAsync {
556548
desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
557549
}

0 commit comments

Comments
 (0)