rust/src/librustdoc
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
..
clean Auto merge of #101692 - cjgillot:generator-lazy-witness, r=oli-obk 2023-01-28 01:05:29 +00:00
doctest Rename TestOptions to GlobalTestOptions 2021-12-12 17:46:19 -08:00
formats rustdoc: Use DefId(Map,Set) instead of FxHash(Map,Set) 2023-01-22 02:12:05 +04:00
html Rollup merge of #107336 - notriddle:notriddle/import-item-module-item, r=GuillaumeGomez 2023-01-27 12:57:57 +09:00
json rustdoc: Use DefId(Map,Set) instead of FxHash(Map,Set) 2023-01-22 02:12:05 +04:00
passes Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
theme Correctly handle parens 2022-09-15 13:53:20 +02:00
askama.toml Move back templates into html folder 2022-01-19 11:13:24 +01:00
Cargo.toml update cpufeatures, swap difference to dissimilar 2022-11-29 19:59:37 +03:00
config.rs Revert crate_types change, add new bin_crate field 2022-12-07 09:08:43 -08:00
core.rs rustdoc: Collect rustdoc-reachable items during early doc link resolution 2023-01-25 23:14:09 +04:00
docfs.rs Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
doctest.rs rustdoc: Stop using HirIds 2023-01-26 16:45:49 +04:00
error.rs Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
externalfiles.rs Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
fold.rs clean: Always store enum disriminant. 2023-01-01 18:11:53 +00:00
lib.rs Store the gctxt instead of fetching it twice. 2023-01-23 10:35:21 +00:00
lint.rs Change default lint level of INVALID_HTML_TAGS to warning 2022-10-10 18:28:29 +02:00
markdown.rs rustdoc: remove `type="text/css" from stylesheet links 2022-12-12 15:17:49 -07:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
scrape_examples.rs Revert crate_types change, add new bin_crate field 2022-12-07 09:08:43 -08:00
theme.rs Correctly handle parens 2022-09-15 13:53:20 +02:00
visit.rs clean: Always store enum disriminant. 2023-01-01 18:11:53 +00:00
visit_ast.rs rustdoc: Stop using HirIds 2023-01-26 16:45:49 +04:00
visit_lib.rs rustdoc: Collect rustdoc-reachable items during early doc link resolution 2023-01-25 23:14:09 +04:00

For more information about how librustdoc works, see the rustc dev guide.