diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-04-04 16:04:38 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-09-10 20:17:08 +0200 |
| commit | 06f7ca307d7ffdbdafe05eb76cc850eaf716916d (patch) | |
| tree | b68a0c96d03008b7173b4da1c04ef7b20c339de5 /compiler/rustc_resolve | |
| parent | 7bf0736e130e2203c58654f7353dbf9575e49d5c (diff) | |
| download | rust-06f7ca307d7ffdbdafe05eb76cc850eaf716916d.tar.gz rust-06f7ca307d7ffdbdafe05eb76cc850eaf716916d.zip | |
Keep def_spans collected by resolution.
Diffstat (limited to 'compiler/rustc_resolve')
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 6d2961db9e3..ead3ca9fcde 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1012,8 +1012,6 @@ pub struct Resolver<'a> { next_node_id: NodeId, - def_id_to_span: IndexVec<LocalDefId, Span>, - node_id_to_def_id: FxHashMap<ast::NodeId, LocalDefId>, def_id_to_node_id: IndexVec<LocalDefId, ast::NodeId>, @@ -1197,9 +1195,7 @@ impl ResolverAstLowering for Resolver<'_> { disambiguator }; - let def_id = self.definitions.create_def(parent, data, expn_id, next_disambiguator); - - assert_eq!(self.def_id_to_span.push(span), def_id); + let def_id = self.definitions.create_def(parent, data, expn_id, next_disambiguator, span); // Some things for which we allocate `LocalDefId`s don't correspond to // anything in the AST, so they don't have a `NodeId`. For these cases @@ -1269,14 +1265,12 @@ impl<'a> Resolver<'a> { let mut module_map = FxHashMap::default(); module_map.insert(root_local_def_id, graph_root); - let definitions = Definitions::new(session.local_stable_crate_id()); + let definitions = Definitions::new(session.local_stable_crate_id(), krate.span); let root = definitions.get_root_def(); let mut visibilities = FxHashMap::default(); visibilities.insert(root_local_def_id, ty::Visibility::Public); - let mut def_id_to_span = IndexVec::default(); - assert_eq!(def_id_to_span.push(rustc_span::DUMMY_SP), root); let mut def_id_to_node_id = IndexVec::default(); assert_eq!(def_id_to_node_id.push(CRATE_NODE_ID), root); let mut node_id_to_def_id = FxHashMap::default(); @@ -1393,7 +1387,6 @@ impl<'a> Resolver<'a> { .collect(), lint_buffer: LintBuffer::default(), next_node_id: NodeId::from_u32(1), - def_id_to_span, node_id_to_def_id, def_id_to_node_id, placeholder_field_indices: Default::default(), @@ -3360,7 +3353,7 @@ impl<'a> Resolver<'a> { /// Retrieves the span of the given `DefId` if `DefId` is in the local crate. #[inline] pub fn opt_span(&self, def_id: DefId) -> Option<Span> { - if let Some(def_id) = def_id.as_local() { Some(self.def_id_to_span[def_id]) } else { None } + def_id.as_local().map(|def_id| self.definitions.def_span(def_id)) } /// Checks if an expression refers to a function marked with |
