Closed
Description
Code
trait Identity {
type Identity;
}
impl<T> Identity for T {
type Identity = T;
}
trait Trait {
type Assoc: Identity;
fn tokenize(&self) -> <Self::Assoc as Identity>::Identity;
}
impl Trait for () {
type Assoc = DoesNotExist;
fn tokenize(&self) -> <Self::Assoc as Identity>::Identity {
unimplemented!()
}
}
Current output
error[E0412]: cannot find type `DoesNotExist` in this scope
--> issue.rs:14:18
|
14 | type Assoc = DoesNotExist;
| ^^^^^^^^^^^^ not found in this scope
error: impl method assumes more implied bounds than the corresponding trait method
--> issue.rs:15:5
|
15 | fn tokenize(&self) -> <Self::Assoc as Identity>::Identity {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572>
= note: `#[deny(implied_bounds_entailment)]` on by default
Desired output
error[E0412]: cannot find type `DoesNotExist` in this scope
--> issue.rs:14:18
|
14 | type Assoc = DoesNotExist;
| ^^^^^^^^^^^^ not found in this scope
Rationale and extra context
When implementing the trait, if the associated type is set to something that is not in scope / doesn't exist, the compiler emits a implied_bounds_entailment
diagnostic. I don't think this should be emitted because there is no way to calculate a type's trait bounds when it doesn't even exist.
Might be related to #108544, but I decided to file a separate issue because this does not involve any lifetimes.
Other cases
No response
Anything else?
Tested with stable 1.70.0, beta 1.71.0-beta.1 and nightly 1.72.0-nightly (d59363a 2023-06-01)