Revert "Auto merge of #101620 - cjgillot:compute_lint_levels_by_def, r=oli-obk"
This reverts commit2cb9a65684
, reversing changes made to750bd1a7ff
.
This commit is contained in:
parent
381bd2a836
commit
fc43df0333
18 changed files with 497 additions and 679 deletions
|
@ -62,7 +62,7 @@ use crate::ty::TyCtxt;
|
|||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use rustc_hir::{HirId, ItemLocalId};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_query_system::dep_graph::FingerprintStyle;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use std::hash::Hash;
|
||||
|
@ -280,7 +280,7 @@ impl DepNodeExt for DepNode {
|
|||
let kind = dep_kind_from_label_string(label)?;
|
||||
|
||||
match kind.fingerprint_style(tcx) {
|
||||
FingerprintStyle::Opaque | FingerprintStyle::HirId => Err(()),
|
||||
FingerprintStyle::Opaque => Err(()),
|
||||
FingerprintStyle::Unit => Ok(DepNode::new_no_params(tcx, kind)),
|
||||
FingerprintStyle::DefPathHash => {
|
||||
Ok(DepNode::from_def_path_hash(tcx, def_path_hash, kind))
|
||||
|
@ -408,7 +408,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
|
|||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::HirId
|
||||
FingerprintStyle::Opaque
|
||||
}
|
||||
|
||||
// We actually would not need to specialize the implementation of this
|
||||
|
@ -417,36 +417,10 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
|
|||
#[inline(always)]
|
||||
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
|
||||
let HirId { owner, local_id } = *self;
|
||||
|
||||
let def_path_hash = tcx.def_path_hash(owner.to_def_id());
|
||||
Fingerprint::new(
|
||||
// `owner` is local, so is completely defined by the local hash
|
||||
def_path_hash.local_hash(),
|
||||
local_id.as_u32().into(),
|
||||
)
|
||||
}
|
||||
let local_id = Fingerprint::from_smaller_hash(local_id.as_u32().into());
|
||||
|
||||
#[inline(always)]
|
||||
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
|
||||
let HirId { owner, local_id } = *self;
|
||||
format!("{}.{}", tcx.def_path_str(owner.to_def_id()), local_id.as_u32())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
|
||||
if dep_node.kind.fingerprint_style(tcx) == FingerprintStyle::HirId {
|
||||
let (local_hash, local_id) = Fingerprint::from(dep_node.hash).as_value();
|
||||
let def_path_hash = DefPathHash::new(tcx.sess.local_stable_crate_id(), local_hash);
|
||||
let owner = tcx
|
||||
.def_path_hash_to_def_id(def_path_hash, &mut || {
|
||||
panic!("Failed to extract HirId: {:?} {}", dep_node.kind, dep_node.hash)
|
||||
})
|
||||
.expect_local();
|
||||
let local_id = local_id
|
||||
.try_into()
|
||||
.unwrap_or_else(|_| panic!("local id should be u32, found {:?}", local_id));
|
||||
Some(HirId { owner, local_id: ItemLocalId::from_u32(local_id) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
def_path_hash.0.combine(local_id)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue