Skip to content
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

GATs can weaken where clauses in impl #151

Closed
compiler-errors opened this issue Jan 22, 2025 · 3 comments · Fixed by rust-lang/rust#137000
Closed

GATs can weaken where clauses in impl #151

compiler-errors opened this issue Jan 22, 2025 · 3 comments · Fixed by rust-lang/rust#137000
Assignees

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Jan 22, 2025

trait Foo {
    type T<'a>: Sized where Self: 'a;
}

impl Foo for &() {
    type T<'a> = ();
}

This fails in the old solver, passes in the new solver. This fails in the old solver because in check_type_bounds we normalize the item bound like <&() as Foo>::T<'a>: Sized into (): Sized, but when normalizing we also require proving the GAT where clauses hold.

In the new solver we simply structurally replace instances of GATs with their definition type using the ReplaceTy folder, which is a kind of "normalization" but which doesn't require that the GAT where clauses hold.

For now, we could just register the GAT bounds in check_type_bounds to paper over this problem, though I think we could think harder about how and where GAT where clauses are required to hold in normalization...

@lcnr
Copy link
Contributor

lcnr commented Jan 29, 2025

I remembered mentioning this somewhere already 😅 #116 (comment)

@lcnr lcnr moved this from toduu to todo in -Znext-solver=globally Jan 29, 2025
@lcnr lcnr moved this from todo to in progress in -Znext-solver=globally Feb 17, 2025
Zalathar added a commit to Zalathar/rust that referenced this issue Feb 18, 2025
…tem-bounds, r=lcnr

Deeply normalize item bounds in new solver

Built on rust-lang#136863.

Fixes rust-lang/trait-system-refactor-initiative#142.
Fixes rust-lang/trait-system-refactor-initiative#151.

cc rust-lang/trait-system-refactor-initiative#116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 18, 2025
…tem-bounds, r=lcnr

Deeply normalize item bounds in new solver

Built on rust-lang#136863.

Fixes rust-lang/trait-system-refactor-initiative#142.
Fixes rust-lang/trait-system-refactor-initiative#151.

cc rust-lang/trait-system-refactor-initiative#116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
@lcnr
Copy link
Contributor

lcnr commented Feb 18, 2025

likely also the underlying reasons for

  • tests/ui/generic-associated-types/bugs/issue-87755.rs
  • tests/ui/generic-associated-types/issue-90014.rs

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Feb 18, 2025
…tem-bounds, r=lcnr

Deeply normalize item bounds in new solver

Built on rust-lang#136863.

Fixes rust-lang/trait-system-refactor-initiative#142.
Fixes rust-lang/trait-system-refactor-initiative#151.

cc rust-lang/trait-system-refactor-initiative#116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 18, 2025
…tem-bounds, r=lcnr

Deeply normalize item bounds in new solver

Built on rust-lang#136863.

Fixes rust-lang/trait-system-refactor-initiative#142.
Fixes rust-lang/trait-system-refactor-initiative#151.

cc rust-lang/trait-system-refactor-initiative#116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 18, 2025
…tem-bounds, r=lcnr

Deeply normalize item bounds in new solver

Built on rust-lang#136863.

Fixes rust-lang/trait-system-refactor-initiative#142.
Fixes rust-lang/trait-system-refactor-initiative#151.

cc rust-lang/trait-system-refactor-initiative#116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 19, 2025
Rollup merge of rust-lang#137000 - compiler-errors:deeply-normalize-item-bounds, r=lcnr

Deeply normalize item bounds in new solver

Built on rust-lang#136863.

Fixes rust-lang/trait-system-refactor-initiative#142.
Fixes rust-lang/trait-system-refactor-initiative#151.

cc rust-lang/trait-system-refactor-initiative#116

First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env.

Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out.

r? lcnr
@lcnr
Copy link
Contributor

lcnr commented Feb 19, 2025

fixed by rust-lang/rust#137000

@lcnr lcnr closed this as completed Feb 19, 2025
@lcnr lcnr moved this from in progress to done in -Znext-solver=globally Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants