Rollup merge of #62168 - ljedrz:the_culmination_of_hiridification, r=Zoxc
The (almost) culmination of HirIdification It's finally over. This PR removes old `FIXME`s and renames some functions so that the `HirId` variant has the shorter name. All that remains (and rightfully so) is stuff in `resolve`, `save_analysis` and (as far as I can tell) in a few places where we can't replace `NodeId` with `HirId`.
This commit is contained in:
commit
2e86c006f7
83 changed files with 309 additions and 321 deletions
|
|
@ -281,14 +281,14 @@ impl Clean<ExternalCrate> for CrateNum {
|
|||
hir::ItemKind::Mod(_) => {
|
||||
as_primitive(Res::Def(
|
||||
DefKind::Mod,
|
||||
cx.tcx.hir().local_def_id_from_hir_id(id.id),
|
||||
cx.tcx.hir().local_def_id(id.id),
|
||||
))
|
||||
}
|
||||
hir::ItemKind::Use(ref path, hir::UseKind::Single)
|
||||
if item.vis.node.is_pub() => {
|
||||
as_primitive(path.res).map(|(_, prim, attrs)| {
|
||||
// Pretend the primitive is local.
|
||||
(cx.tcx.hir().local_def_id_from_hir_id(id.id), prim, attrs)
|
||||
(cx.tcx.hir().local_def_id(id.id), prim, attrs)
|
||||
})
|
||||
}
|
||||
_ => None
|
||||
|
|
@ -325,13 +325,13 @@ impl Clean<ExternalCrate> for CrateNum {
|
|||
hir::ItemKind::Mod(_) => {
|
||||
as_keyword(Res::Def(
|
||||
DefKind::Mod,
|
||||
cx.tcx.hir().local_def_id_from_hir_id(id.id),
|
||||
cx.tcx.hir().local_def_id(id.id),
|
||||
))
|
||||
}
|
||||
hir::ItemKind::Use(ref path, hir::UseKind::Single)
|
||||
if item.vis.node.is_pub() => {
|
||||
as_keyword(path.res).map(|(_, prim, attrs)| {
|
||||
(cx.tcx.hir().local_def_id_from_hir_id(id.id), prim, attrs)
|
||||
(cx.tcx.hir().local_def_id(id.id), prim, attrs)
|
||||
})
|
||||
}
|
||||
_ => None
|
||||
|
|
@ -654,7 +654,7 @@ impl Clean<Item> for doctree::Module<'_> {
|
|||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_node_id(self.id),
|
||||
inner: ModuleItem(Module {
|
||||
is_crate: self.is_crate,
|
||||
items,
|
||||
|
|
@ -1588,7 +1588,7 @@ impl Clean<GenericParamDef> for hir::GenericParam {
|
|||
}
|
||||
hir::GenericParamKind::Type { ref default, synthetic } => {
|
||||
(self.name.ident().name.clean(cx), GenericParamDefKind::Type {
|
||||
did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
|
||||
did: cx.tcx.hir().local_def_id(self.hir_id),
|
||||
bounds: self.bounds.clean(cx),
|
||||
default: default.clean(cx),
|
||||
synthetic: synthetic,
|
||||
|
|
@ -1596,7 +1596,7 @@ impl Clean<GenericParamDef> for hir::GenericParam {
|
|||
}
|
||||
hir::GenericParamKind::Const { ref ty } => {
|
||||
(self.name.ident().name.clean(cx), GenericParamDefKind::Const {
|
||||
did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
|
||||
did: cx.tcx.hir().local_def_id(self.hir_id),
|
||||
ty: ty.clean(cx),
|
||||
})
|
||||
}
|
||||
|
|
@ -1926,7 +1926,7 @@ impl Clean<Item> for doctree::Function<'_> {
|
|||
(self.generics.clean(cx), (self.decl, self.body).clean(cx))
|
||||
});
|
||||
|
||||
let did = cx.tcx.hir().local_def_id_from_hir_id(self.id);
|
||||
let did = cx.tcx.hir().local_def_id(self.id);
|
||||
let constness = if cx.tcx.is_min_const_fn(did) {
|
||||
hir::Constness::Const
|
||||
} else {
|
||||
|
|
@ -2136,7 +2136,7 @@ impl Clean<Item> for doctree::Trait<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: attrs,
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -2166,7 +2166,7 @@ impl Clean<Item> for doctree::TraitAlias<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs,
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -2229,7 +2229,7 @@ impl Clean<Item> for hir::TraitItem {
|
|||
AssocTypeItem(bounds.clean(cx), default.clean(cx))
|
||||
}
|
||||
};
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
let local_did = cx.tcx.hir().local_def_id(self.hir_id);
|
||||
Item {
|
||||
name: Some(self.ident.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
|
|
@ -2262,7 +2262,7 @@ impl Clean<Item> for hir::ImplItem {
|
|||
generics: Generics::default(),
|
||||
}, true),
|
||||
};
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
let local_did = cx.tcx.hir().local_def_id(self.hir_id);
|
||||
Item {
|
||||
name: Some(self.ident.name.clean(cx)),
|
||||
source: self.span.clean(cx),
|
||||
|
|
@ -2757,7 +2757,7 @@ impl Clean<Type> for hir::Ty {
|
|||
}
|
||||
TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
|
||||
TyKind::Array(ref ty, ref length) => {
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(length.hir_id);
|
||||
let def_id = cx.tcx.hir().local_def_id(length.hir_id);
|
||||
let param_env = cx.tcx.param_env(def_id);
|
||||
let substs = InternalSubsts::identity_for_item(cx.tcx, def_id);
|
||||
let cid = GlobalId {
|
||||
|
|
@ -2829,7 +2829,7 @@ impl Clean<Type> for hir::Ty {
|
|||
if let Some(lt) = lifetime.cloned() {
|
||||
if !lt.is_elided() {
|
||||
let lt_def_id =
|
||||
cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
|
||||
cx.tcx.hir().local_def_id(param.hir_id);
|
||||
lt_substs.insert(lt_def_id, lt.clean(cx));
|
||||
}
|
||||
}
|
||||
|
|
@ -2837,7 +2837,7 @@ impl Clean<Type> for hir::Ty {
|
|||
}
|
||||
hir::GenericParamKind::Type { ref default, .. } => {
|
||||
let ty_param_def_id =
|
||||
cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
|
||||
cx.tcx.hir().local_def_id(param.hir_id);
|
||||
let mut j = 0;
|
||||
let type_ = generic_args.args.iter().find_map(|arg| {
|
||||
match arg {
|
||||
|
|
@ -2861,7 +2861,7 @@ impl Clean<Type> for hir::Ty {
|
|||
}
|
||||
hir::GenericParamKind::Const { .. } => {
|
||||
let const_param_def_id =
|
||||
cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
|
||||
cx.tcx.hir().local_def_id(param.hir_id);
|
||||
let mut j = 0;
|
||||
let const_ = generic_args.args.iter().find_map(|arg| {
|
||||
match arg {
|
||||
|
|
@ -2982,10 +2982,11 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||
ty::FnPtr(_) => {
|
||||
let ty = cx.tcx.lift(self).expect("FnPtr lift failed");
|
||||
let sig = ty.fn_sig(cx.tcx);
|
||||
let local_def_id = cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID);
|
||||
BareFunction(box BareFunctionDecl {
|
||||
unsafety: sig.unsafety(),
|
||||
generic_params: Vec::new(),
|
||||
decl: (cx.tcx.hir().local_def_id(ast::CRATE_NODE_ID), sig).clean(cx),
|
||||
decl: (local_def_id, sig).clean(cx),
|
||||
abi: sig.abi(),
|
||||
})
|
||||
}
|
||||
|
|
@ -3158,7 +3159,7 @@ impl<'tcx> Clean<Constant> for ty::Const<'tcx> {
|
|||
|
||||
impl Clean<Item> for hir::StructField {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
let local_did = cx.tcx.hir().local_def_id(self.hir_id);
|
||||
|
||||
Item {
|
||||
name: Some(self.ident.name).clean(cx),
|
||||
|
|
@ -3239,7 +3240,7 @@ impl Clean<Item> for doctree::Struct<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3259,7 +3260,7 @@ impl Clean<Item> for doctree::Union<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3306,7 +3307,7 @@ impl Clean<Item> for doctree::Enum<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3333,7 +3334,7 @@ impl Clean<Item> for doctree::Variant<'_> {
|
|||
visibility: None,
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
inner: VariantItem(Variant {
|
||||
kind: self.def.clean(cx),
|
||||
}),
|
||||
|
|
@ -3634,7 +3635,7 @@ impl Clean<Item> for doctree::Typedef<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3658,7 +3659,7 @@ impl Clean<Item> for doctree::Existential<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3709,7 +3710,7 @@ impl Clean<Item> for doctree::Static<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3734,7 +3735,7 @@ impl Clean<Item> for doctree::Constant<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3821,7 +3822,7 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> {
|
|||
name: None,
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -3991,7 +3992,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
|
|||
name: None,
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(ast::CRATE_NODE_ID),
|
||||
def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
|
|
@ -4052,7 +4053,7 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
|
|||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
|
|
@ -4268,7 +4269,7 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
|
|||
visibility: Some(Public),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
inner: ProcMacroItem(ProcMacro {
|
||||
kind: self.kind,
|
||||
helpers: self.helpers.clean(cx),
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
|||
// to the map from defid -> hirid
|
||||
let access_levels = AccessLevels {
|
||||
map: access_levels.map.iter()
|
||||
.map(|(&k, &v)| (tcx.hir().local_def_id_from_hir_id(k), v))
|
||||
.map(|(&k, &v)| (tcx.hir().local_def_id(k), v))
|
||||
.collect()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
|||
// doesn't work with it anyway, so pull them from the HIR map instead
|
||||
for &trait_did in cx.all_traits.iter() {
|
||||
for &impl_node in cx.tcx.hir().trait_impls(trait_did) {
|
||||
let impl_did = cx.tcx.hir().local_def_id_from_hir_id(impl_node);
|
||||
let impl_did = cx.tcx.hir().local_def_id(impl_node);
|
||||
inline::build_impl(cx, impl_did, &mut new_items);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn stability(&self, id: hir::HirId) -> Option<attr::Stability> {
|
||||
self.cx.tcx.hir().opt_local_def_id_from_hir_id(id)
|
||||
self.cx.tcx.hir().opt_local_def_id(id)
|
||||
.and_then(|def_id| self.cx.tcx.lookup_stability(def_id)).cloned()
|
||||
}
|
||||
|
||||
fn deprecation(&self, id: hir::HirId) -> Option<attr::Deprecation> {
|
||||
self.cx.tcx.hir().opt_local_def_id_from_hir_id(id)
|
||||
self.cx.tcx.hir().opt_local_def_id(id)
|
||||
.and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id))
|
||||
}
|
||||
|
||||
|
|
@ -375,7 +375,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
let ident = renamed.unwrap_or(item.ident);
|
||||
|
||||
if item.vis.node.is_pub() {
|
||||
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let def_id = self.cx.tcx.hir().local_def_id(item.hir_id);
|
||||
self.store_path(def_id);
|
||||
}
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
_ if self.inlining && !item.vis.node.is_pub() => {}
|
||||
hir::ItemKind::GlobalAsm(..) => {}
|
||||
hir::ItemKind::ExternCrate(orig_name) => {
|
||||
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let def_id = self.cx.tcx.hir().local_def_id(item.hir_id);
|
||||
om.extern_crates.push(ExternCrate {
|
||||
cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id)
|
||||
.unwrap_or(LOCAL_CRATE),
|
||||
|
|
@ -618,7 +618,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
|
||||
Macro {
|
||||
|
||||
def_id: self.cx.tcx.hir().local_def_id_from_hir_id(def.hir_id),
|
||||
def_id: self.cx.tcx.hir().local_def_id(def.hir_id),
|
||||
attrs: &def.attrs,
|
||||
name: renamed.unwrap_or(def.name),
|
||||
whence: def.span,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue