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
|
|
@ -123,7 +123,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
where
|
||||
F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, O>),
|
||||
{
|
||||
let item_def_id = self.tcx.hir().local_def_id(item_id);
|
||||
let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);
|
||||
if self.tcx.has_typeck_tables(item_def_id) {
|
||||
let tables = self.tcx.typeck_tables_of(item_def_id);
|
||||
let old_tables = self.save_ctxt.tables;
|
||||
|
|
@ -436,7 +436,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
attrs: &'l [Attribute],
|
||||
) {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
|
||||
|
||||
if !self.span.filter_generated(ident.span) {
|
||||
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
|
||||
|
|
@ -481,7 +481,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
debug!("process_struct {:?} {:?}", item, item.span);
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
|
||||
let kind = match item.node {
|
||||
ast::ItemKind::Struct(_, _) => DefKind::Struct,
|
||||
|
|
@ -683,7 +683,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
self.process_generic_params(generics, "", item.id);
|
||||
for impl_item in impl_items {
|
||||
let map = &self.tcx.hir();
|
||||
self.process_impl_item(impl_item, map.local_def_id(item.id));
|
||||
self.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -696,7 +696,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
) {
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
let mut val = name.clone();
|
||||
if !generics.params.is_empty() {
|
||||
val.push_str(&generic_params_to_string(&generics.params));
|
||||
|
|
@ -764,7 +764,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
self.process_generic_params(generics, &qualname, item.id);
|
||||
for method in methods {
|
||||
let map = &self.tcx.hir();
|
||||
self.process_trait_item(method, map.local_def_id(item.id))
|
||||
self.process_trait_item(method, map.local_def_id_from_node_id(item.id))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1109,7 +1109,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
// FIXME do something with _bounds (for type refs)
|
||||
let name = trait_item.ident.name.to_string();
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(trait_item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(trait_item.id)));
|
||||
|
||||
if !self.span.filter_generated(trait_item.ident.span) {
|
||||
let span = self.span_from_span(trait_item.ident.span);
|
||||
|
|
@ -1217,7 +1217,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
let access = access_from!(self.save_ctxt, root_item, hir_id);
|
||||
|
||||
// The parent `DefId` of a given use tree is always the enclosing item.
|
||||
let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id)
|
||||
let parent = self.save_ctxt.tcx.hir().opt_local_def_id_from_node_id(id)
|
||||
.and_then(|id| self.save_ctxt.tcx.parent(id))
|
||||
.map(id_from_def_id);
|
||||
|
||||
|
|
@ -1261,7 +1261,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
};
|
||||
|
||||
// Make a comma-separated list of names of imported modules.
|
||||
let def_id = self.tcx.hir().local_def_id(id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_node_id(id);
|
||||
let names = self.tcx.names_imported_by_glob_use(def_id);
|
||||
let names: Vec<_> = names.iter().map(|n| n.to_string()).collect();
|
||||
|
||||
|
|
@ -1318,7 +1318,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
|
|||
assert_eq!(id, ast::CRATE_NODE_ID);
|
||||
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
|
||||
|
||||
let cm = self.tcx.sess.source_map();
|
||||
let filename = cm.span_to_filename(span);
|
||||
|
|
@ -1367,7 +1367,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
|
|||
let name_span = item.ident.span;
|
||||
if !self.span.filter_generated(name_span) {
|
||||
let span = self.span_from_span(name_span);
|
||||
let parent = self.save_ctxt.tcx.hir().opt_local_def_id(item.id)
|
||||
let parent = self.save_ctxt.tcx.hir().opt_local_def_id_from_node_id(item.id)
|
||||
.and_then(|id| self.save_ctxt.tcx.parent(id))
|
||||
.map(id_from_def_id);
|
||||
self.dumper.import(
|
||||
|
|
@ -1408,7 +1408,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
|
|||
}
|
||||
Ty(ref ty, ref ty_params) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
let value = ty_to_string(&ty);
|
||||
if !self.span.filter_generated(item.ident.span) {
|
||||
let span = self.span_from_span(item.ident.span);
|
||||
|
|
@ -1439,7 +1439,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
|
|||
}
|
||||
Existential(ref _bounds, ref ty_params) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
// FIXME do something with _bounds
|
||||
let value = String::new();
|
||||
if !self.span.filter_generated(item.ident.span) {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
|
||||
pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
match item.node {
|
||||
ast::ForeignItemKind::Fn(ref decl, ref generics) => {
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
|
|
@ -185,7 +185,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
match item.node {
|
||||
ast::ItemKind::Fn(ref decl, .., ref generics, _) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
Some(Data::DefData(Def {
|
||||
kind: DefKind::Function,
|
||||
|
|
@ -204,7 +204,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
ast::ItemKind::Static(ref typ, ..) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
ast::ItemKind::Const(ref typ, _) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
|
||||
let id = id_from_node_id(item.id, self);
|
||||
|
|
@ -251,7 +251,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
ast::ItemKind::Mod(ref m) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
|
||||
let cm = self.tcx.sess.source_map();
|
||||
let filename = cm.span_to_filename(m.inner);
|
||||
|
|
@ -279,7 +279,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
ast::ItemKind::Enum(ref def, _) => {
|
||||
let name = item.ident.to_string();
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
let variants_str = def.variants
|
||||
.iter()
|
||||
|
|
@ -364,10 +364,10 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
if let Some(ident) = field.ident {
|
||||
let name = ident.to_string();
|
||||
let qualname = format!("::{}::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id(scope)),
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(scope)),
|
||||
ident);
|
||||
filter!(self.span_utils, ident.span);
|
||||
let def_id = self.tcx.hir().local_def_id(field.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_node_id(field.id);
|
||||
let typ = self.tcx.type_of(def_id).to_string();
|
||||
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
// The qualname for a method is the trait name or name of the struct in an impl in
|
||||
// which the method is declared in, followed by the method's name.
|
||||
let (qualname, parent_scope, decl_id, docs, attributes) =
|
||||
match self.tcx.impl_of_method(self.tcx.hir().local_def_id(id)) {
|
||||
match self.tcx.impl_of_method(self.tcx.hir().local_def_id_from_node_id(id)) {
|
||||
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
|
||||
Some(Node::Item(item)) => match item.node {
|
||||
hir::ItemKind::Impl(.., ref ty, _) => {
|
||||
|
|
@ -450,7 +450,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
);
|
||||
}
|
||||
},
|
||||
None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id(id)) {
|
||||
None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id_from_node_id(id)) {
|
||||
Some(def_id) => {
|
||||
let mut docs = String::new();
|
||||
let mut attrs = vec![];
|
||||
|
|
@ -1192,7 +1192,7 @@ fn id_from_def_id(id: DefId) -> rls_data::Id {
|
|||
}
|
||||
|
||||
fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id {
|
||||
let def_id = scx.tcx.hir().opt_local_def_id(id);
|
||||
let def_id = scx.tcx.hir().opt_local_def_id_from_node_id(id);
|
||||
def_id.map(|id| id_from_def_id(id)).unwrap_or_else(|| {
|
||||
// Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId`
|
||||
// out of the maximum u32 value. This will work unless you have *billions*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue