Skip to content

Commit

Permalink
hir: Add some FIXMEs for future work
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jan 31, 2024
1 parent e292423 commit be80c82
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] }
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HirId> {
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);
Expand Down

0 comments on commit be80c82

Please sign in to comment.