rust/compiler
bors 6cd6bad51f Auto merge of #101692 - cjgillot:generator-lazy-witness, r=oli-obk
Compute generator saved locals on MIR

Generators are currently type-checked by introducing a `witness` type variable, which is unified with a `GeneratorWitness(captured types)` whose purpose is to ensure that the auto traits correctly migrate from the captured types to the `witness` type.  This requires computing the captured types on HIR during type-checking, only to re-do it on MIR later.

This PR proposes to drop the HIR-based computation, and only keep the MIR one.  This is done in 3 steps.
1. During type-checking, the `witness` type variable is never unified.  This allows to stall all the obligations that depend on it until the end of type-checking.  Then, the stalled obligations are marked as successful, and saved into the typeck results for later verification.
2. At type-checking writeback, `witness` is replaced by `GeneratorWitnessMIR(def_id, substs)`.  From this point on, all trait selection involving `GeneratorWitnessMIR` will fetch the MIR-computed locals, similar to what opaque types do.  There is no lifetime to be preserved here: we consider all the lifetimes appearing in this witness type to be higher-ranked.
3. After borrowck, the stashed obligations are verified against the actually computed types, in the `check_generator_obligations` query.  If any obligation was wrongly marked as fulfilled in step 1, it should be reported here.

There are still many issues:
- ~I am not too happy having to filter out some locals from the checked bounds, I think this is MIR building that introduces raw pointers polluting the analysis;~ solved by a check specific to static variables.
- the diagnostics for captured types don't show where they are used/dropped;
- I do not attempt to support chalk.

cc `@eholk` `@jyn514` for the drop-tracking work
r? `@oli-obk` as you warned me of potential unsoundness
2023-01-28 01:05:29 +00:00
..
rustc
rustc_abi abi: add AddressSpace field to Primitive::Pointer 2023-01-22 23:41:39 -05:00
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r=Nilstrieb 2023-01-28 00:23:12 +09:00
rustc_ast_lowering Destructure format_options in make_format_spec. 2023-01-27 11:43:38 +01:00
rustc_ast_passes Autoderive ExternBlockSuggestion 2023-01-19 13:52:15 +01:00
rustc_ast_pretty Replace format flags u32 by enums and bools. 2023-01-27 08:53:39 +01:00
rustc_attr Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_baked_icu_data
rustc_borrowck add method_substs to CallKind 2023-01-26 20:28:31 -07:00
rustc_builtin_macros Replace format flags u32 by enums and bools. 2023-01-27 08:53:39 +01:00
rustc_codegen_cranelift Auto merge of #107055 - kylematsuda:eb-fn-sig, r=lcnr 2023-01-27 15:02:44 +00:00
rustc_codegen_gcc create and use GlobalAlloc::address_space 2023-01-25 01:46:19 -05:00
rustc_codegen_llvm Auto merge of #107372 - JohnTitor:rollup-zkl2ges, r=JohnTitor 2023-01-27 17:49:56 +00:00
rustc_codegen_ssa Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
rustc_const_eval Remember where a type was kept in MIR. 2023-01-27 18:59:32 +00:00
rustc_data_structures Rollup merge of #107168 - Nilstrieb:if-a-tait-falls-in-the-forest,can-we-know-it-wasnt-revealed, r=oli-obk 2023-01-26 15:02:21 +01:00
rustc_driver Store the gctxt instead of fetching it twice. 2023-01-23 10:35:21 +00:00
rustc_error_codes compiler: Fix E0587 explanation 2023-01-27 10:59:51 +01:00
rustc_error_messages Rollup merge of #106978 - mejrs:mir_build3, r=davidtwco 2023-01-26 15:02:20 +01:00
rustc_errors Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
rustc_expand Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstrieb 2023-01-20 04:52:28 +00:00
rustc_feature Rollup merge of #106767 - chbaker0:disable-unstable-features, r=Mark-Simulacrum 2023-01-25 17:01:41 +05:30
rustc_fs_util
rustc_graphviz Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_hir Impl HashStable/Encodable/Decodable for ObligationCause. 2023-01-27 18:56:32 +00:00
rustc_hir_analysis Compute generator saved locals on MIR. 2023-01-27 20:10:06 +00:00
rustc_hir_pretty parse const closures 2023-01-12 02:28:37 +00:00
rustc_hir_typeck Compute generator saved locals on MIR. 2023-01-27 20:10:06 +00:00
rustc_incremental Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
rustc_index Fix IndexVec::drain_enumerated 2023-01-19 15:25:33 +00:00
rustc_infer Pacify tidy. 2023-01-27 22:01:25 +00:00
rustc_interface Compute generator saved locals on MIR. 2023-01-27 20:10:06 +00:00
rustc_lexer Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
rustc_lint Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
rustc_lint_defs Auto merge of #107185 - compiler-errors:rollup-wkomjma, r=compiler-errors 2023-01-22 06:53:36 +00:00
rustc_llvm Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikic 2023-01-21 23:20:58 -05:00
rustc_log Add log-backtrace option to show backtraces along with logging 2023-01-12 00:17:48 +09:00
rustc_macros Stop using BREAK & CONTINUE in compiler 2023-01-17 23:17:51 -08:00
rustc_metadata Separate witness type computation from the generator transform. 2023-01-27 19:00:26 +00:00
rustc_middle Restrict amount of ignored locals. 2023-01-27 22:01:12 +00:00
rustc_mir_build Restrict amount of ignored locals. 2023-01-27 22:01:12 +00:00
rustc_mir_dataflow Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
rustc_mir_transform Restrict amount of ignored locals. 2023-01-27 22:01:12 +00:00
rustc_monomorphize add EarlyBinder::no_bound_vars 2023-01-26 20:28:31 -07:00
rustc_parse Rollup merge of #106960 - estebank:parse-anon-enums, r=cjgillot 2023-01-26 06:15:24 +01:00
rustc_parse_format Replace format flags u32 by enums and bools. 2023-01-27 08:53:39 +01:00
rustc_passes fixup new usages of fn_sig, bound_fn_sig after rebasing 2023-01-26 20:33:27 -07:00
rustc_plugin_impl
rustc_privacy Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
rustc_query_impl Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_query_system Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
rustc_resolve suggest qualifying bare associated constants 2023-01-25 08:58:27 -05:00
rustc_save_analysis Avoid an unnecessary allocation 2023-01-16 14:46:44 +00:00
rustc_serialize
rustc_session Add drop_tracking_mir option. 2023-01-27 18:57:34 +00:00
rustc_smir
rustc_span Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk 2023-01-26 12:44:47 +00:00
rustc_symbol_mangling Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
rustc_target Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk 2023-01-26 06:15:27 +01:00
rustc_trait_selection Auto merge of #101692 - cjgillot:generator-lazy-witness, r=oli-obk 2023-01-28 01:05:29 +00:00
rustc_traits Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
rustc_transmute Also remove #![feature(control_flow_enum)] where possible 2023-01-18 10:22:21 -08:00
rustc_ty_utils Pacify tidy. 2023-01-27 22:01:25 +00:00
rustc_type_ir Separate witness type computation from the generator transform. 2023-01-27 19:00:26 +00:00