Change:
This is a pretty common use case, so this bug has probably already been registered, but I couldn't find anything while searching around, so I'm reporting this here just in case. I ran this code: When running this code, I expect to simply get a not yet implemented error on the function. Instead, I get this: : returns an , and is not a trait method–it's just a regular method. Therefore, AFAIK, this should compile. Notably, making either or as makes it compile fine.
Regression in . cc
oli's on leave so cc-ing PR 's reviewer
WG-prioritization assigning priority (). label -I-prioritize +P-high

Discussion:
return ControlFlow::Continue(()); } <del> let kind = match kind { ty::Inherent | ty::Projection => "associated type", ty::Weak => "type alias", ty::Opaque => unreachable!(), }; </del> self.def_id_visitor.visit_def_id( data.def_id, <del> kind, </del> <ins> match kind { ty::Inherent | ty::Projection => "associated type", ty::Weak => "type alias", ty::Opaque => unreachable!(), }, </ins> &LazyDefPathStr { def_id: data.def_id, tcx }, )?; // This will also visit args if necessary, so we don't need to recurse. return if V::SHALLOW { ControlFlow::Continue(()) <ins> } else if kind == ty::Projection { self.visit_projection_ty(data) </ins> } else { data.args.iter().try_for_each(|subst| subst.visit_with(self)) };

<ins> // no-prefer-dynamic // compile-flags: --crate-type=rlib pub use impl_mod::TraitImplementer as Implementer; pub use trait_mod::get_assoc; mod impl_mod { use crate::trait_mod::TraitWithAssocType; pub struct TraitImplementer {} pub struct AssociatedType {} impl AssociatedType { pub fn method_on_assoc(&self) -> i32 { todo!() } } impl TraitWithAssocType for TraitImplementer { type AssocType = AssociatedType; } } mod trait_mod { use crate::Implementer; pub fn get_assoc() -> <Implementer as TraitWithAssocType>::AssocType { todo!() } pub trait TraitWithAssocType { type AssocType; } } </ins>

<ins> // aux-build:issue-117997.rs // build-pass extern crate issue_117997; pub fn main() { issue_117997::get_assoc().method_on_assoc(); } </ins>

pub fn f3(arg: <Priv as PrivTr>::Assoc) {} //~^ WARNING type `aliases_pub::Priv` is more private than the item `aliases_pub::f3` //~| WARNING associated type `aliases_pub::PrivTr::Assoc` is more private than the item `aliases_pub::f3` <ins> //~^^^ WARNING trait `aliases_pub::PrivTr` is more private than the item `aliases_pub::f3` </ins> impl PrivUseAlias { pub fn f(arg: Priv) {}

pub fn f3(arg: <Priv as PrivTr>::Assoc) {} //~^ WARNING type `aliases_priv::Priv` is more private than the item `aliases_priv::f3` //~| WARNING associated type `aliases_priv::PrivTr::Assoc` is more private than the item `aliases_priv::f3` <ins> //~^^^ WARNING trait `aliases_priv::PrivTr` is more private than the item `aliases_priv::f3` </ins> } mod aliases_params {

LL |         type Assoc = m::Pub3; |         ^^^^^^^^^^ <ins> warning: trait `aliases_pub::PrivTr` is more private than the item `aliases_pub::f3` --> $DIR/private-in-public.rs:106:5 | LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_pub::f3` is reachable at visibility `pub(crate)` | note: but trait `aliases_pub::PrivTr` is only usable at visibility `pub(self)` --> $DIR/private-in-public.rs:100:5 | LL |     trait PrivTr { |     ^^^^^^^^^^^^ </ins> warning: type `aliases_pub::Priv` is more private than the item `aliases_pub::f3` --> $DIR/private-in-public.rs:106:5 |

|     ^^^^^^^^^^^ warning: type `Priv1` is more private than the item `aliases_priv::f1` <del> --> $DIR/private-in-public.rs:133:5 </del> <ins> --> $DIR/private-in-public.rs:134:5 </ins> | LL |     pub fn f1(arg: PrivUseAlias) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f1` is reachable at visibility `pub(crate)` | note: but type `Priv1` is only usable at visibility `pub(self)` <del> --> $DIR/private-in-public.rs:118:5 </del> <ins> --> $DIR/private-in-public.rs:119:5 </ins> | LL |     struct Priv1; |     ^^^^^^^^^^^^ warning: type `Priv2` is more private than the item `aliases_priv::f2` <del> --> $DIR/private-in-public.rs:134:5 </del> <ins> --> $DIR/private-in-public.rs:135:5 </ins> | LL |     pub fn f2(arg: PrivAlias) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f2` is reachable at visibility `pub(crate)` | note: but type `Priv2` is only usable at visibility `pub(self)` <del> --> $DIR/private-in-public.rs:119:5 </del> <ins> --> $DIR/private-in-public.rs:120:5 </ins> | LL |     struct Priv2; |     ^^^^^^^^^^^^ warning: associated type `aliases_priv::PrivTr::Assoc` is more private than the item `aliases_priv::f3` <del> --> $DIR/private-in-public.rs:135:5 </del> <ins> --> $DIR/private-in-public.rs:136:5 </ins> | LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f3` is reachable at visibility `pub(crate)` | note: but associated type `aliases_priv::PrivTr::Assoc` is only usable at visibility `pub(self)` <del> --> $DIR/private-in-public.rs:129:9 </del> <ins> --> $DIR/private-in-public.rs:130:9 </ins> | LL |         type Assoc = Priv3; |         ^^^^^^^^^^ <ins> warning: trait `aliases_priv::PrivTr` is more private than the item `aliases_priv::f3` --> $DIR/private-in-public.rs:136:5 | LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f3` is reachable at visibility `pub(crate)` | note: but trait `aliases_priv::PrivTr` is only usable at visibility `pub(self)` --> $DIR/private-in-public.rs:129:5 | LL |     trait PrivTr { |     ^^^^^^^^^^^^ </ins> warning: type `aliases_priv::Priv` is more private than the item `aliases_priv::f3` <del> --> $DIR/private-in-public.rs:135:5 </del> <ins> --> $DIR/private-in-public.rs:136:5 </ins> | LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f3` is reachable at visibility `pub(crate)` | note: but type `aliases_priv::Priv` is only usable at visibility `pub(self)` <del> --> $DIR/private-in-public.rs:116:5 </del> <ins> --> $DIR/private-in-public.rs:117:5 </ins> | LL |     struct Priv; |     ^^^^^^^^^^^ warning: type `aliases_params::Priv` is more private than the item `aliases_params::f2` <del> --> $DIR/private-in-public.rs:145:5 </del> <ins> --> $DIR/private-in-public.rs:147:5 </ins> | LL |     pub fn f2(arg: PrivAliasGeneric) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_params::f2` is reachable at visibility `pub(crate)` | note: but type `aliases_params::Priv` is only usable at visibility `pub(self)` <del> --> $DIR/private-in-public.rs:141:5 </del> <ins> --> $DIR/private-in-public.rs:143:5 </ins> | LL |     struct Priv; |     ^^^^^^^^^^^ warning: type `aliases_params::Priv` is more private than the item `aliases_params::f3` <del> --> $DIR/private-in-public.rs:147:5 </del> <ins> --> $DIR/private-in-public.rs:149:5 </ins> | LL |     pub fn f3(arg: Result<u8>) {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_params::f3` is reachable at visibility `pub(crate)` | note: but type `aliases_params::Priv` is only usable at visibility `pub(self)` <del> --> $DIR/private-in-public.rs:141:5 </del> <ins> --> $DIR/private-in-public.rs:143:5 </ins> | LL |     struct Priv; |     ^^^^^^^^^^^ <del> warning: 31 warnings emitted </del> <ins> warning: 33 warnings emitted </ins>