@@ -207,19 +207,7 @@ where
207207 }
208208 }
209209 }
210- ty:: Alias ( ty:: Projection , proj) => {
211- if V :: SKIP_ASSOC_TYS {
212- // Visitors searching for minimal visibility/reachability want to
213- // conservatively approximate associated types like `<Type as Trait>::Alias`
214- // as visible/reachable even if both `Type` and `Trait` are private.
215- // Ideally, associated types should be substituted in the same way as
216- // free type aliases, but this isn't done yet.
217- return ControlFlow :: Continue ( ( ) ) ;
218- }
219- // This will also visit args if necessary, so we don't need to recurse.
220- return self . visit_projection_ty ( proj) ;
221- }
222- ty:: Alias ( kind @ ( ty:: Inherent | ty:: Weak ) , data) => {
210+ ty:: Alias ( kind @ ( ty:: Inherent | ty:: Weak | ty:: Projection ) , data) => {
223211 if V :: SKIP_ASSOC_TYS {
224212 // Visitors searching for minimal visibility/reachability want to
225213 // conservatively approximate associated types like `Type::Alias`
@@ -229,15 +217,15 @@ where
229217 return ControlFlow :: Continue ( ( ) ) ;
230218 }
231219
232- self . def_id_visitor . visit_def_id (
233- data. def_id ,
234- match kind {
235- ty :: Inherent => "associated type" ,
236- ty :: Weak => "type alias" ,
237- _ => unreachable ! ( ) ,
238- } ,
239- & LazyDefPathStr { def_id : data . def_id , tcx } ,
240- ) ?;
220+ let ( def_id , kind ) = match kind {
221+ ty :: Inherent => ( data. def_id , "associated type" ) ,
222+ ty :: Weak => ( data . def_id , "type alias" ) ,
223+ // Trait associated types don't have visibility, they are
224+ // visible if their parent trait is.
225+ ty :: Projection => ( tcx . parent ( data . def_id ) , "trait" ) ,
226+ _ => unreachable ! ( ) ,
227+ } ;
228+ self . def_id_visitor . visit_def_id ( def_id , kind , & LazyDefPathStr { def_id , tcx } ) ?;
241229
242230 // This will also visit args if necessary, so we don't need to recurse.
243231 return if V :: SHALLOW {
0 commit comments