From be80c829fe1ca9191429b658333bcdd5448fc92a Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 31 Jan 2024 21:55:10 +0300 Subject: [PATCH] hir: Add some FIXMEs for future work --- compiler/rustc_ast_lowering/src/lib.rs | 4 ++++ compiler/rustc_hir/src/hir.rs | 1 + compiler/rustc_hir/src/intravisit.rs | 1 + compiler/rustc_middle/src/hir/map/mod.rs | 3 +++ 4 files changed, 9 insertions(+) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index bcd6453523caa..7ccfd51a7c4fe 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -753,6 +753,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_import_res(&mut self, id: NodeId) -> SmallVec<[Res; 3]> { let res = self.resolver.get_import_res(id).present_items(); let res: SmallVec<_> = res.map(|res| self.lower_res(res)).collect(); + // FIXME: The `Res::Err` doesn't necessarily mean an error was reported, it also happens + // for import list stem items with non-empty list. Instead, consider not emitting such + // items into HIR at all, or fill the `import_res_map` tables for them in resolve if that + // is not possible. Then add `span_delayed_bug` here. if !res.is_empty() { res } else { smallvec![Res::Err] } } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 54155dc7a9487..4656b7d75c0d0 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3499,6 +3499,7 @@ pub enum Node<'hir> { Crate(&'hir Mod<'hir>), Infer(&'hir InferArg), WhereBoundPredicate(&'hir WhereBoundPredicate<'hir>), + // FIXME: Merge into `Node::Infer`. ArrayLenInfer(&'hir InferArg), // Span by reference to minimize `Node`'s size #[allow(rustc::pass_by_value)] diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 574b372be2ba5..52e1109ff9215 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -669,6 +669,7 @@ pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<' pub fn walk_array_len<'v, V: Visitor<'v>>(visitor: &mut V, len: &'v ArrayLen) { match len { + // FIXME: Use `visit_infer` here. ArrayLen::Infer(InferArg { hir_id, span: _ }) => visitor.visit_id(*hir_id), ArrayLen::Body(c) => visitor.visit_anon_const(c), } diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index dea61faef4af3..bf72aac10332e 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -222,6 +222,9 @@ impl<'hir> Map<'hir> { /// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`]. pub fn opt_parent_id(self, id: HirId) -> Option { if id.local_id == ItemLocalId::from_u32(0) { + // FIXME: This function never returns `None` right now, and the parent chain end is + // determined by checking for `parent(id) == id`. This function should return `None` + // for the crate root instead. Some(self.tcx.hir_owner_parent(id.owner)) } else { let owner = self.tcx.hir_owner_nodes(id.owner);