Skip to content

Cannot chain inherent associated types #122584

Open

Description

I tried this code:

#![feature(inherent_associated_types)]
struct A<const N: usize> {}

struct B<const N: usize> {}

impl<const N: usize> B<N> {
    type C_ = C<N>;
}

struct C<const N: usize> {}

impl<const N: usize> A<N> {
    type B_ = B<N>;

    fn fun() -> Self::B_::C_ {
        todo!()
    }
}

fn main() {}

rustc says:

error[E0223]: ambiguous associated type
  --> src/lib.rs:15:17
   |
15 |     fn fun() -> Self::B_::C_ {
   |                 ^^^^^^^^^^^^
   |
help: if there were a trait named `Example` with associated type `C_` implemented for `A<N>::B_`, you could use the fully-qualified path
   |
15 |     fn fun() -> <A<N>::B_ as Example>::C_ {
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (4a0cc881d 2024-03-11)
binary: rustc
commit-hash: 4a0cc881dcc4d800f10672747f61a94377ff6662
commit-date: 2024-03-11
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-inherent_associated_types`#![feature(inherent_associated_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions