Skip to content

Commit 3e461f9

Browse files
committed
Feed visibilities for trait impl items as well
1 parent 5eb2a32 commit 3e461f9

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

compiler/rustc_privacy/src/lib.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,23 +1816,6 @@ fn local_visibility(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Visibility {
18161816
| hir::ItemKind::OpaqueTy(..),
18171817
..
18181818
}) => ty::Visibility::Restricted(tcx.parent_module(hir_id).to_local_def_id()),
1819-
// Visibilities of trait impl items are inherited from their traits
1820-
// and are not filled in resolve.
1821-
Node::ImplItem(impl_item) => {
1822-
match tcx.hir().get_by_def_id(tcx.hir().get_parent_item(hir_id).def_id) {
1823-
Node::Item(hir::Item {
1824-
kind: hir::ItemKind::Impl(hir::Impl { of_trait: Some(tr), .. }),
1825-
..
1826-
}) => tr.path.res.opt_def_id().map_or_else(
1827-
|| {
1828-
tcx.sess.span_delayed_bug(tr.path.span, "trait without a def-id");
1829-
ty::Visibility::Public
1830-
},
1831-
|def_id| tcx.visibility(def_id).expect_local(),
1832-
),
1833-
_ => span_bug!(impl_item.span, "the parent is not a trait impl"),
1834-
}
1835-
}
18361819
_ => span_bug!(
18371820
tcx.def_span(def_id),
18381821
"visibility table unexpectedly missing a def-id: {:?}",

compiler/rustc_resolve/src/late.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,6 +3108,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
31083108
| (DefKind::AssocFn, AssocItemKind::Fn(..))
31093109
| (DefKind::AssocConst, AssocItemKind::Const(..)) => {
31103110
self.r.record_partial_res(id, PartialRes::new(res));
3111+
let vis = self.r.tcx.visibility(id_in_trait).expect_local();
3112+
self.r.feed_visibility(self.r.local_def_id(id), vis);
31113113
return;
31123114
}
31133115
_ => {}

0 commit comments

Comments
 (0)