Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot chain inherent associated types #122584

Open
MikeWalrus opened this issue Mar 16, 2024 · 1 comment
Open

Cannot chain inherent associated types #122584

MikeWalrus opened this issue Mar 16, 2024 · 1 comment
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-incomplete-features This issue requires the use of incomplete features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@MikeWalrus
Copy link
Contributor

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
@MikeWalrus MikeWalrus added the C-bug Category: This is a bug. label Mar 16, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 16, 2024
@jieyouxu jieyouxu added the F-inherent_associated_types `#![feature(inherent_associated_types)]` label Mar 16, 2024
@fmease fmease added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 16, 2024
@fmease
Copy link
Member

fmease commented Mar 16, 2024

Ah, right. So this is basically another instance of us currently not resolving IATs with non-ADT self types (#106719). In this case the self type is an inherent projection.

@fmease fmease added the requires-incomplete-features This issue requires the use of incomplete features. label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-incomplete-features This issue requires the use of incomplete features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants