Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obk
Encode even more metadata through tables instead of EntryKind This should move us closer to getting rid of `EntryKind`.
This commit is contained in:
commit
eb82facb16
11 changed files with 131 additions and 212 deletions
|
@ -559,7 +559,7 @@ rustc_queries! {
|
|||
///
|
||||
/// **Do not call this function manually.** It is only meant to cache the base data for the
|
||||
/// `is_const_fn` function.
|
||||
query is_const_fn_raw(key: DefId) -> bool {
|
||||
query impl_constness(key: DefId) -> hir::Constness {
|
||||
desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
|
||||
separate_provide_extern
|
||||
}
|
||||
|
@ -1329,11 +1329,6 @@ rustc_queries! {
|
|||
separate_provide_extern
|
||||
}
|
||||
|
||||
query impl_constness(def_id: DefId) -> hir::Constness {
|
||||
desc { |tcx| "looking up whether `{}` is a const impl", tcx.def_path_str(def_id) }
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query check_item_well_formed(key: LocalDefId) -> () {
|
||||
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
|
||||
}
|
||||
|
|
|
@ -289,6 +289,11 @@ pub struct ClosureSizeProfileData<'tcx> {
|
|||
pub trait DefIdTree: Copy {
|
||||
fn parent(self, id: DefId) -> Option<DefId>;
|
||||
|
||||
#[inline]
|
||||
fn local_parent(self, id: LocalDefId) -> Option<LocalDefId> {
|
||||
Some(self.parent(id.to_def_id())?.expect_local())
|
||||
}
|
||||
|
||||
fn is_descendant_of(self, mut descendant: DefId, ancestor: DefId) -> bool {
|
||||
if descendant.krate != ancestor.krate {
|
||||
return false;
|
||||
|
@ -2256,6 +2261,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
pub fn is_object_safe(self, key: DefId) -> bool {
|
||||
self.object_safety_violations(key).is_empty()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_const_fn_raw(self, def_id: DefId) -> bool {
|
||||
matches!(self.def_kind(def_id), DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..))
|
||||
&& self.impl_constness(def_id) == hir::Constness::Const
|
||||
}
|
||||
}
|
||||
|
||||
/// Yields the parent function's `LocalDefId` if `def_id` is an `impl Trait` definition.
|
||||
|
|
|
@ -5,7 +5,6 @@ use crate::ty::{Ident, Ty, TyCtxt};
|
|||
use hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use std::iter;
|
||||
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
|
@ -13,10 +12,8 @@ use rustc_errors::ErrorGuaranteed;
|
|||
use rustc_macros::HashStable;
|
||||
|
||||
/// A trait's definition with type information.
|
||||
#[derive(HashStable)]
|
||||
#[derive(HashStable, Encodable, Decodable)]
|
||||
pub struct TraitDef {
|
||||
// We already have the def_path_hash below, no need to hash it twice
|
||||
#[stable_hasher(ignore)]
|
||||
pub def_id: DefId,
|
||||
|
||||
pub unsafety: hir::Unsafety,
|
||||
|
@ -43,10 +40,6 @@ pub struct TraitDef {
|
|||
/// on this trait.
|
||||
pub specialization_kind: TraitSpecializationKind,
|
||||
|
||||
/// The ICH of this trait's DefPath, cached here so it doesn't have to be
|
||||
/// recomputed all the time.
|
||||
pub def_path_hash: DefPathHash,
|
||||
|
||||
/// List of functions from `#[rustc_must_implement_one_of]` attribute one of which
|
||||
/// must be implemented.
|
||||
pub must_implement_one_of: Option<Box<[Ident]>>,
|
||||
|
@ -54,7 +47,7 @@ pub struct TraitDef {
|
|||
|
||||
/// Whether this trait is treated specially by the standard library
|
||||
/// specialization lint.
|
||||
#[derive(HashStable, PartialEq, Clone, Copy, TyEncodable, TyDecodable)]
|
||||
#[derive(HashStable, PartialEq, Clone, Copy, Encodable, Decodable)]
|
||||
pub enum TraitSpecializationKind {
|
||||
/// The default. Specializing on this trait is not allowed.
|
||||
None,
|
||||
|
@ -92,7 +85,6 @@ impl<'tcx> TraitDef {
|
|||
is_marker: bool,
|
||||
skip_array_during_method_dispatch: bool,
|
||||
specialization_kind: TraitSpecializationKind,
|
||||
def_path_hash: DefPathHash,
|
||||
must_implement_one_of: Option<Box<[Ident]>>,
|
||||
) -> TraitDef {
|
||||
TraitDef {
|
||||
|
@ -103,7 +95,6 @@ impl<'tcx> TraitDef {
|
|||
is_marker,
|
||||
skip_array_during_method_dispatch,
|
||||
specialization_kind,
|
||||
def_path_hash,
|
||||
must_implement_one_of,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue