Skip to content

Fix confused unreachable_pub lint on globs and multiple items #87112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)],
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)| {
Expand Down Expand Up @@ -186,6 +187,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
explicit_owner: Option<NodeId>,
) -> &'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(
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Res>,
/// The segments in the path: the things separated by `::`.
pub segments: &'hir [PathSegment<'hir>],
}
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ struct EmbargoVisitor<'tcx> {
macro_reachable: FxHashSet<(hir::HirId, DefId)>,
/// Previous accessibility level; `None` means unreachable.
prev_level: Option<AccessLevel>,
/// Has something changed in the level map?
/// has something changed in the level map?
changed: bool,
}

Expand Down Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down