Rollup merge of #85605 - ptrojahn:closure_struct, r=matthewjasper
Replace Local::new(1) with CAPTURE_STRUCT_LOCAL
This commit is contained in:
commit
ad72247833
6 changed files with 20 additions and 19 deletions
|
@ -209,9 +209,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
|
|||
match from_builder.base {
|
||||
PlaceBase::Local(_) => Ok(from_builder),
|
||||
PlaceBase::Upvar { var_hir_id, closure_def_id, closure_kind } => {
|
||||
// Captures are represented using fields inside a structure.
|
||||
// This represents accessing self in the closure structure
|
||||
let mut upvar_resolved_place_builder = PlaceBuilder::from(Local::new(1));
|
||||
let mut upvar_resolved_place_builder = PlaceBuilder::from(ty::CAPTURE_STRUCT_LOCAL);
|
||||
match closure_kind {
|
||||
ty::ClosureKind::Fn | ty::ClosureKind::FnMut => {
|
||||
upvar_resolved_place_builder = upvar_resolved_place_builder.deref();
|
||||
|
|
|
@ -446,7 +446,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
} => {
|
||||
// Not in a closure
|
||||
debug_assert!(
|
||||
local == Local::new(1),
|
||||
local == ty::CAPTURE_STRUCT_LOCAL,
|
||||
"Expected local to be Local(1), found {:?}",
|
||||
local
|
||||
);
|
||||
|
|
|
@ -953,9 +953,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// the given closure and use the necessary information to create upvar
|
||||
// debuginfo and to fill `self.upvar_mutbls`.
|
||||
if hir_typeck_results.closure_min_captures.get(&fn_def_id).is_some() {
|
||||
let closure_env_arg = Local::new(1);
|
||||
let mut closure_env_projs = vec![];
|
||||
let mut closure_ty = self.local_decls[closure_env_arg].ty;
|
||||
let mut closure_ty = self.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty;
|
||||
if let ty::Ref(_, ty, _) = closure_ty.kind() {
|
||||
closure_env_projs.push(ProjectionElem::Deref);
|
||||
closure_ty = ty;
|
||||
|
@ -1001,7 +1000,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
name,
|
||||
source_info: SourceInfo::outermost(tcx_hir.span(var_id)),
|
||||
value: VarDebugInfoContents::Place(Place {
|
||||
local: closure_env_arg,
|
||||
local: ty::CAPTURE_STRUCT_LOCAL,
|
||||
projection: tcx.intern_place_elems(&projs),
|
||||
}),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue