diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index eb8e92f07eacc..981d10379fe79 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -1800,6 +1800,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let expr_path = hir::ExprKind::Path(hir::QPath::Resolved( None, self.arena.alloc(hir::Path { + intermediate_res: None, span, res: Res::Local(binding), segments: arena_vec![self; hir::PathSegment::from_ident(ident)], diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 292643d6d7510..06fd836317892 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -684,7 +684,12 @@ impl<'hir> LoweringContext<'_, 'hir> { args: None, infer_args: seg.infer_args, })); - self.arena.alloc(hir::Path { span: path.span, res: path.res, segments }) + self.arena.alloc(hir::Path { + intermediate_res: None, + span: path.span, + res: path.res, + segments, + }) } fn rebuild_vis(&mut self, vis: &hir::Visibility<'hir>) -> hir::Visibility<'hir> { diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7a4e39376a86d..0db1f00ee1303 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1319,6 +1319,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir::TyKind::Path(hir::QPath::Resolved( None, self.arena.alloc(hir::Path { + intermediate_res: None, res, segments: arena_vec![self; hir::PathSegment::from_ident( Ident::with_dummy_span(kw::SelfUpper) @@ -1418,6 +1419,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir::TyKind::Path(hir::QPath::Resolved( None, self.arena.alloc(hir::Path { + intermediate_res: None, span, res: Res::Def(DefKind::TyParam, def_id.to_def_id()), segments: arena_vec![self; hir::PathSegment::from_ident(ident)], diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index 66e623528f3bd..8d705611c28e9 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -250,6 +250,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { Some(res) => hir::PatKind::Path(hir::QPath::Resolved( None, self.arena.alloc(hir::Path { + intermediate_res: None, span: ident.span, res: self.lower_res(res), segments: arena_vec![self; hir::PathSegment::from_ident(ident)], diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index fe9f1fb20f056..5178da1907f37 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -34,6 +34,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let path_span_lo = p.span.shrink_to_lo(); let proj_start = p.segments.len() - partial_res.unresolved_segments(); let path = self.arena.alloc(hir::Path { + intermediate_res: None, res: self.lower_res(partial_res.base_res()), segments: self.arena.alloc_from_iter(p.segments[..proj_start].iter().enumerate().map( |(i, segment)| { @@ -186,6 +187,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { explicit_owner: Option, ) -> &'hir hir::Path<'hir> { self.arena.alloc(hir::Path { + intermediate_res: None, res, segments: self.arena.alloc_from_iter(p.segments.iter().map(|segment| { self.lower_path_segment( diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index a7ce92ea57917..5adad41d03522 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -186,8 +186,10 @@ impl Lifetime { #[derive(Debug, HashStable_Generic)] pub struct Path<'hir> { pub span: Span, - /// The resolution for the path. + /// The full resolution for the path. pub res: Res, + /// Intermediate resolution of the path (when we reexport another export) + pub intermediate_res: Option, /// The segments in the path: the things separated by `::`. pub segments: &'hir [PathSegment<'hir>], } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 5a79a9cc6ecfd..e68352420013c 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -419,7 +419,7 @@ struct EmbargoVisitor<'tcx> { macro_reachable: FxHashSet<(hir::HirId, DefId)>, /// Previous accessibility level; `None` means unreachable. prev_level: Option, - /// Has something changed in the level map? + /// has something changed in the level map? changed: bool, } @@ -664,6 +664,14 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> { } }; + tracing::trace!( + "item: {:#?}\ninherited_item_level: {:#?}\nprev_level: {:#?}\naccess_levels: {:#?}", + item, + inherited_item_level, + self.prev_level, + self.access_levels + ); + // Update level of the item itself. let item_level = self.update(item.hir_id(), inherited_item_level); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index cc086427dd0cd..aa7fdcf963aac 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1335,7 +1335,8 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type { } else { Res::Err }; - let trait_path = hir::Path { span, res, segments: &[] }.clean(cx); + let trait_path = + hir::Path { intermediate_res: None, span, res, segments: &[] }.clean(cx); Type::QPath { name: segment.ident.name, self_def_id: res.opt_def_id(),