rust/compiler
bors 2520ca8566 Auto merge of #117131 - compiler-errors:projection-oops, r=lcnr
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 #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 #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.
2023-11-03 00:02:44 +00:00
..
rustc Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_abi Update MIR tests for offset_of 2023-10-31 23:26:02 +00:00
rustc_arena Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_ast Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_ast_lowering Some more coroutine renamings 2023-10-30 23:46:27 +00:00
rustc_ast_passes Test the multispan case in tests.ui/bounds-lifetime.rs. 2023-10-31 08:01:02 +11:00
rustc_ast_pretty Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_attr Auto merge of #117377 - dtolnay:deprecatedsince, r=cjgillot 2023-10-31 10:42:24 +00:00
rustc_baked_icu_data Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_borrowck prepopulate opaque ty storage before using it :> 2023-10-31 11:50:30 +01:00
rustc_builtin_macros Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_codegen_cranelift Support enum variants in offset_of! 2023-10-31 23:25:54 +00:00
rustc_codegen_gcc Merge commit '09ce29d0591a21e1abae22eac4d41ffd32993af8' into subtree-update_cg_gcc_2023-10-25 2023-10-27 16:07:01 -04:00
rustc_codegen_llvm Merge simd size and type extraction into checking whether a type is simd, as these always go together. 2023-10-31 11:23:39 +00:00
rustc_codegen_ssa Support enum variants in offset_of! 2023-10-31 23:25:54 +00:00
rustc_const_eval Rollup merge of #117441 - cjgillot:diag-noassert, r=oli-obk,RalfJung 2023-11-01 21:40:06 +01:00
rustc_data_structures Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_driver Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_driver_impl Rollup merge of #117376 - nnethercote:rustc_interface-more, r=oli-obk 2023-10-30 17:33:18 +01:00
rustc_error_codes Support enum variants in offset_of! 2023-10-31 23:25:54 +00:00
rustc_error_messages Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_errors Rollup merge of #117397 - compiler-errors:dont-emit-good-path-on-panic, r=TaKO8Ki 2023-11-01 11:29:41 +01:00
rustc_expand Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_feature Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_fluent_macro Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_fs_util Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_graphviz Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_hir Some more coroutine renamings 2023-10-30 23:46:27 +00:00
rustc_hir_analysis Add all RPITITs when augmenting param-env with GAT bounds in check_type_bounds 2023-11-02 20:47:10 +00:00
rustc_hir_pretty Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiser 2023-10-30 17:33:15 +01:00
rustc_hir_typeck Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser 2023-11-01 14:17:56 +00:00
rustc_incremental Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_index Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_infer Don't check for alias bounds in liveness when aliases have escaping bound vars 2023-11-02 10:25:57 +00:00
rustc_interface Remove support for alias -Z symbol-mangling-version 2023-11-02 18:41:33 +11:00
rustc_lexer Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_lint Rollup merge of #117395 - gurry:117380-wrong-parent-sugg, r=Nilstrieb 2023-10-30 17:33:19 +01:00
rustc_lint_defs Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_llvm Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_log Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_macros Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_metadata Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_middle Auto merge of #117134 - lcnr:dropck_outlives-coroutine, r=compiler-errors 2023-11-02 22:03:38 +00:00
rustc_mir_build Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser 2023-11-01 14:17:56 +00:00
rustc_mir_dataflow Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_mir_transform Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser 2023-11-01 14:17:56 +00:00
rustc_monomorphize Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_parse Rollup merge of #117298 - clubby789:fn-missing-params, r=petrochenkov 2023-11-01 21:40:05 +01:00
rustc_parse_format Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_passes Enums in offset_of: update based on est31, scottmcm & llogiq review 2023-10-31 23:26:02 +00:00
rustc_plugin_impl Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_privacy Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_query_impl Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_query_system Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_resolve Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_serialize Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_session Rollup merge of #117509 - Zalathar:zsymbol, r=petrochenkov 2023-11-02 15:31:21 +01:00
rustc_smir Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser 2023-11-01 14:17:56 +00:00
rustc_span Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_symbol_mangling Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_target Auto merge of #117307 - taiki-e:espidf-atomic-64, r=Amanieu 2023-11-01 16:39:22 +00:00
rustc_trait_selection Auto merge of #117134 - lcnr:dropck_outlives-coroutine, r=compiler-errors 2023-11-02 22:03:38 +00:00
rustc_traits dropck_outlives check generator witness needs_drop 2023-11-02 17:20:13 +01:00
rustc_transmute Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_ty_utils review + add tests 2023-11-02 18:16:37 +01:00
rustc_type_ir remove outdated comment 2023-11-02 17:20:13 +01:00
stable_mir Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiser 2023-11-01 14:17:56 +00:00