-
Notifications
You must be signed in to change notification settings - Fork 0
normalization may result in unconstrained regions #15
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
Comments
Because proving alias-outlives bounds checks for equality between regions, this results in the undesirable errors: trait Super {
type SAssoc;
}
trait Trait<'a>: Super<SAssoc = <Self as Trait<'a>>::TAssoc> {
type TAssoc;
}
fn test<'a, T: 'a>() {}
fn unconstrained_lt<'arg, T: for<'a> Trait<'a>>(x: &'arg <T as Super>::SAssoc) {
test::<'arg, <T as Super>::SAssoc>();
} normalizing "through" the alias with unconstrained regions does compile: trait Super {
type SAssoc;
}
trait Trait<'a>: Super<SAssoc = <Self as Trait<'a>>::TAssoc> {
type TAssoc;
}
fn test<'a, T: 'a>() {}
fn unconstrained_lt<'arg, T: for<'a> Trait<'a, TAssoc = T>>(x: &'arg <T as Super>::SAssoc) {
test::<'arg, <T as Super>::SAssoc>();
} |
via alias-bound instead trait Super {
type SAssoc;
}
trait Trait<'a>: Super<SAssoc = <Self as Trait<'a>>::TAssoc> {
type TAssoc;
}
trait AliasBound {
type WithBound: for<'a> Trait<'a>;
}
fn unconstrained_lt<T: AliasBound>(x: <T::WithBound as Super>::SAssoc) {} |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Jan 30, 2025
… r=<try> elaborate: avoid projections with unconstrained bound regions Should only do this for where-bounds and item bounds. Gonna rewrite later I think. This means we'll no longer need to support unconstrained regions in implied bounds, see lcnr/random-rust-snippets#15. This fixes ```rust trait Super { type SAssoc; } trait Trait<'a>: Super<SAssoc = <Self as Trait<'a>>::TAssoc> { type TAssoc; } fn test<'a, T: 'a>() {} fn unconstrained_lt<'arg, T: for<'a> Trait<'a>>(x: &'arg <T as Super>::SAssoc) { test::<'arg, <T as Super>::SAssoc>(); } ``` but breaks ```rust trait Super { type SAssoc; } trait Trait<'a>: Super<SAssoc = <Self as Trait<'a>>::TAssoc> { type TAssoc; } fn test<'a, T: 'a>() {} fn unconstrained_lt<'arg, T: for<'a> Trait<'a, TAssoc = usize>>(x: <T as Super>::SAssoc) -> usize { x } ``` r? `@compiler-errors`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The function argument of
unconstrained_lt
normalizes to<T as Trait<'unconstrained>>::TAssoc
The text was updated successfully, but these errors were encountered: