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

Inherent associated types defined on non-ADTs don't resolve successfully #106719

Open
fmease opened this issue Jan 11, 2023 · 2 comments
Open

Inherent associated types defined on non-ADTs don't resolve successfully #106719

fmease opened this issue Jan 11, 2023 · 2 comments
Assignees
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Jan 11, 2023

Inherent associated types where the self type isn't an ADT (e.g. a trait object type or a primitive type like bool or i32) are currently not resolved successfully.

On Trait Object Types

I expected to see the following code compile successfully:

#![feature(inherent_associated_types)]

trait Tr {}

impl dyn Tr {
    type Pr = ();
}

const _: <dyn Tr>::Pr = ();

Instead, the following error was emitted:

error[E0223]: ambiguous associated type
  --> src/lib.rs:10:10
   |
10 | const _: <dyn Tr>::Pr = ();
   |          ^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn Tr + 'static) as Trait>::Pr`

For comparison, the analogous code involving inherent associated constants works flawlessly.

On Primitive Types

I expected to see the following code compile successfully (#![no_core] is representative for the core crate)

#![feature(inherent_associated_types, no_core)]
#![allow(incomplete_features)]
#![no_core]

impl bool {
    type Pr = ();
}

const _: bool::Pr = ();

Instead, the following error was emitted:

error[E0223]: ambiguous associated type
 --> src/lib.rs:9:10
  |
9 | const _: bool::Pr = ();
  |          ^^^^^^^^ help: use fully-qualified syntax: `<bool as Trait>::Pr`

I'd like to see #105961 merged first. Thus I consider this issue blocked for now.

@rustbot label T-compiler F-inherent_associated_types requires-nightly S-blocked
@rustbot claim

@fmease fmease added the C-bug Category: This is a bug. label Jan 11, 2023
@rustbot rustbot added F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-nightly This issue requires a nightly compiler in some way. S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 11, 2023
@fmease fmease changed the title Inherent associated types defined on trait object types don't resolve successfully Inherent associated types defined on non-ADTs don't resolve successfully Jan 11, 2023
@fmease

This comment was marked as resolved.

@rustbot rustbot removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Feb 20, 2023
@compiler-errors
Copy link
Member

Copied from the other issue:

my understanding is that this just requires to assemble candidates for incoherent impls as well, just like method candidate assembly does.

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-nightly This issue requires a nightly compiler in some way. 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

3 participants