-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
nested impl Trait in trait with default definition does not compile #117104
Comments
The error message on the playground is a bit different, seems to be correlating with the actual problem more, but even more confusing:
Expected and found are the same! |
Minimal:
Something funky going on with the default projection predicate installed for the GAT. I'll look into it 🤔 |
I'm impressed by the speedy handling of this issue! Was hoping this would get a fix in a few weeks . You're awesome! |
Once the pr is merged, it will be available the next day on nightly, correct? Btw, the pr failed some tests. |
Add all RPITITs when augmenting param-env with GAT bounds in `check_type_bounds` When checking that associated type definitions actually satisfy their associated type bounds in `check_type_bounds`, we construct a "`normalize_param_env`" which adds a projection predicate that allows us to assume that we can project the GAT to the definition we're checking. For example, in: ```rust type Foo { type Bar: Display = i32; } ``` We would add `<Self as Foo>::Bar = i32` as a projection predicate when checking that `i32: Display` holds. That `normalize_param_env` was, for some reason, only being used to normalize the predicate before it was registered. This is sketchy, because a nested obligation may require the GAT bound to hold, and also the projection cache is broken and doesn't differentiate projection cache keys that differ by param-envs 😿. This `normalize_param_env` is also not sufficient when we have nested RPITITs and default trait methods, since we need to be able to assume we can normalize both the RPITIT and all of its child RPITITs to sufficiently prove all of its bounds. This is the cause of rust-lang#117104, which only starts to fail for RPITITs that are nested 3 and above due to the projection-cache bug above.[^1] ## First fix Use the `normalize_param_env` everywhere in `check_type_bounds`. This is reflected in a test I've constructed that fixes a GAT-only failure. ## Second fix For RPITITs, install projection predicates for each RPITIT in the same function in `check_type_bounds`. This fixes rust-lang#117104. not sure who to request, so... r? `@lcnr` hehe feel free to reassign :3 [^1]: The projection cache bug specifically occurs because we try normalizing the `assumed_wf_types` with the non-normalization param-env. This causes us to insert a projection cache entry that keeps the outermost RPITIT rigid, and it trivially satisifes all its own bounds. Super sketchy![^2] [^2]: I haven't actually gone and fixed the projection cache bug because it's only marginally related, but I could, and it should no longer be triggered here.
I tried this code:
I expected to see this happen: compiles, or a helpful error message
Instead, this happened: Confusing error message, there doesn't seem to be a future that could be awaited?...
Interestingly if the default implementation is removed, it compiles. Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=6d9d947523afbecf604d1971f58bbc48
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: