Skip to content

Commit eeb5ed3

Browse files
committed
Merge associated types with the other alias types
1 parent d5c0f4d commit eeb5ed3

File tree

1 file changed

+10
-22
lines changed
  • compiler/rustc_privacy/src

1 file changed

+10
-22
lines changed

compiler/rustc_privacy/src/lib.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,7 @@ where
210210
}
211211
}
212212
}
213-
ty::Alias(ty::Projection, proj) => {
214-
if V::SKIP_ASSOC_TYS {
215-
// Visitors searching for minimal visibility/reachability want to
216-
// conservatively approximate associated types like `<Type as Trait>::Alias`
217-
// as visible/reachable even if both `Type` and `Trait` are private.
218-
// Ideally, associated types should be substituted in the same way as
219-
// free type aliases, but this isn't done yet.
220-
return ControlFlow::Continue(());
221-
}
222-
// This will also visit args if necessary, so we don't need to recurse.
223-
return self.visit_projection_ty(proj);
224-
}
225-
ty::Alias(kind @ (ty::Inherent | ty::Weak), data) => {
213+
ty::Alias(kind @ (ty::Inherent | ty::Weak | ty::Projection), data) => {
226214
if V::SKIP_ASSOC_TYS {
227215
// Visitors searching for minimal visibility/reachability want to
228216
// conservatively approximate associated types like `Type::Alias`
@@ -232,15 +220,15 @@ where
232220
return ControlFlow::Continue(());
233221
}
234222

235-
self.def_id_visitor.visit_def_id(
236-
data.def_id,
237-
match kind {
238-
ty::Inherent => "associated type",
239-
ty::Weak => "type alias",
240-
_ => unreachable!(),
241-
},
242-
&LazyDefPathStr { def_id: data.def_id, tcx },
243-
)?;
223+
let (def_id, kind) = match kind {
224+
ty::Inherent => (data.def_id, "associated type"),
225+
ty::Weak => (data.def_id, "type alias"),
226+
// Trait associated types don't have visibility, they are
227+
// visible if their parent trait is.
228+
ty::Projection => (tcx.parent(data.def_id), "trait"),
229+
_ => unreachable!(),
230+
};
231+
self.def_id_visitor.visit_def_id(def_id, kind, &LazyDefPathStr { def_id, tcx })?;
244232

245233
// This will also visit args if necessary, so we don't need to recurse.
246234
return if V::SHALLOW {

0 commit comments

Comments
 (0)