Rollup merge of #112759 - cjgillot:closure-names, r=oli-obk
Make closure_saved_names_of_captured_variables a query. As we will start removing debuginfo during MIR optimizations, we need to keep them somewhere.
This commit is contained in:
commit
34c8e53d7a
17 changed files with 100 additions and 102 deletions
|
@ -36,6 +36,22 @@ pub(crate) fn mir_built(
|
|||
tcx.alloc_steal_mir(mir_build(tcx, def))
|
||||
}
|
||||
|
||||
pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
) -> IndexVec<FieldIdx, Symbol> {
|
||||
tcx.closure_captures(def_id)
|
||||
.iter()
|
||||
.map(|captured_place| {
|
||||
let name = captured_place.to_symbol();
|
||||
match captured_place.info.capture_kind {
|
||||
ty::UpvarCapture::ByValue => name,
|
||||
ty::UpvarCapture::ByRef(..) => Symbol::intern(&format!("_ref__{name}")),
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Construct the MIR for a given `DefId`.
|
||||
fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
|
||||
// Ensure unsafeck and abstract const building is ran before we steal the THIR.
|
||||
|
|
|
@ -33,6 +33,8 @@ pub fn provide(providers: &mut Providers) {
|
|||
providers.check_match = thir::pattern::check_match;
|
||||
providers.lit_to_const = thir::constant::lit_to_const;
|
||||
providers.mir_built = build::mir_built;
|
||||
providers.closure_saved_names_of_captured_variables =
|
||||
build::closure_saved_names_of_captured_variables;
|
||||
providers.thir_check_unsafety = check_unsafety::thir_check_unsafety;
|
||||
providers.thir_body = thir::cx::thir_body;
|
||||
providers.thir_tree = thir::print::thir_tree;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue