Open
Description
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