rust-lang / trait-system-refactor-initiative

The Rustc Trait System Refactor Initiative
21 stars 0 forks source link

super trait bounds equal modulo normalization #84

Closed lcnr closed 6 months ago

lcnr commented 7 months ago
// We try to infer `T::Rigid: Into<?0>` and have 2 candidates from where-clauses:
//
// - `Into<String>`
// - `Into<<T::Rigid as Elaborate>::Assoc>`
//
// This causes ambiguity unless we normalize the alias in the second candidate
// to detect that they actually result in the same constraints.
trait Trait {
    type Rigid: Elaborate<Assoc = String> + Into<String> + Default;
}

trait Elaborate: Into<Self::Assoc> {
    type Assoc;
}

fn test<T: Trait>() {
    let rigid: T::Rigid = Default::default();
    drop(rigid.into());
}

fn main() {}

THis test currently results in ambiguity in the new solver.

Strongly related to

lcnr commented 6 months ago

fixed by https://github.com/rust-lang/rust/pull/119106