rust-lang / trait-system-refactor-initiative

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

non-defining use in defining scope: region params #74

Open lcnr opened 11 months ago

lcnr commented 11 months ago
#![feature(type_alias_impl_trait)]

type Tait<'a> = impl Sized;

fn define<'a>(x: &'a ()) -> Tait<'a> {
    ()
}

fn x<'a>(x: &'a (), t: Tait<'a>) -> Tait<'a> {
    t
}

This example fails with overflow in the new solver right now

error[E0275]: overflow evaluating the requirement `Tait<'a> <: Tait<'a>`
  --> src/main.rs:9:46
   |
9  |   fn x<'a>(x: &'a (), t: Tait<'a>) -> Tait<'a> {
   |  ______________________________________________^
10 | |     t
11 | | }
   | |_^

Changing alias relate or the way we define opaque types can cause this to result in ambiguity instead. Fundamentally we want exists<'0, '1> alias-relate(Tait<'0>, Tait<'1>) to hold inside of the defining scope of Tait, regardless of whether we actually define Tait.

lcnr commented 1 month ago

fixed by our decision in rust-lang/rust#117861 to forbid non-defining uses. Needs test