match place {
PlaceRef {
base: PlaceBase::Local(local),
- projection: None,
+ projection: [],
} => {
self.append_local_to_string(*local, buf)?;
}
kind: StaticKind::Promoted(..),
..
}),
- projection: None,
+ projection: [],
} => {
buf.push_str("promoted");
}
def_id,
..
}),
- projection: None,
+ projection: [],
} => {
buf.push_str(&self.infcx.tcx.item_name(*def_id).to_string());
}
PlaceRef {
base,
- projection: Some(ref proj),
+ projection: [.., elem],
} => {
- match proj.elem {
+ let proj_base = &place.projection[..place.projection.len() - 1];
+
+ match elem {
ProjectionElem::Deref => {
let upvar_field_projection =
self.is_upvar_field_projection(place);
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
&including_downcast,
)?;
} else {
- match (&proj.base, base) {
- (None, PlaceBase::Local(local)) => {
+ match (proj_base, base) {
+ ([], PlaceBase::Local(local)) => {
if self.body.local_decls[*local].is_ref_for_guard() {
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
} else {
let field_name = self.describe_field(PlaceRef {
base,
- projection: &proj.base,
- }, field);
+ projection: proj_base,
+ }, *field);
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
&including_downcast,
)?;
buf.push_str("[");
- if self.append_local_to_string(index, buf).is_err() {
+ if self.append_local_to_string(*index, buf).is_err() {
buf.push_str("_");
}
buf.push_str("]");
self.append_place_to_string(
PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
},
buf,
autoderef,
let local = &self.body.local_decls[local_index];
match local.name {
Some(name) if !local.from_compiler_desugaring() => {
- buf.push_str(name.as_str().get());
+ buf.push_str(&name.as_str());
Ok(())
}
_ => Err(()),
match place {
PlaceRef {
base: PlaceBase::Local(local),
- projection: None,
+ projection: [],
} => {
let local = &self.body.local_decls[*local];
self.describe_field_from_ty(&local.ty, field, None)
}
PlaceRef {
base: PlaceBase::Static(static_),
- projection: None,
+ projection: [],
} =>
self.describe_field_from_ty(&static_.ty, field, None),
PlaceRef {
base,
- projection: Some(proj),
- } => match proj.elem {
- ProjectionElem::Deref => self.describe_field(PlaceRef {
- base,
- projection: &proj.base,
- }, field),
+ projection: [.., elem],
+ } => match elem {
+ ProjectionElem::Deref => {
+ let proj_base = &place.projection[..place.projection.len() - 1];
+
+ self.describe_field(PlaceRef {
+ base,
+ projection: proj_base,
+ }, field)
+ }
ProjectionElem::Downcast(_, variant_index) => {
let base_ty =
Place::ty_from(place.base, place.projection, self.body, self.infcx.tcx).ty;
- self.describe_field_from_ty(&base_ty, field, Some(variant_index))
+ self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
}
ProjectionElem::Field(_, field_type) => {
self.describe_field_from_ty(&field_type, field, None)
ProjectionElem::Index(..)
| ProjectionElem::ConstantIndex { .. }
| ProjectionElem::Subslice { .. } => {
+ let proj_base = &place.projection[..place.projection.len() - 1];
+
self.describe_field(PlaceRef {
base,
- projection: &proj.base,
+ projection: proj_base,
}, field)
}
},
def_id,
..
}),
- projection: None,
+ projection: [],
} = place_ref {
let attrs = self.infcx.tcx.get_attrs(*def_id);
let is_thread_local = attrs.iter().any(|attr| attr.check_name(sym::thread_local));
Some(&Statement {
kind: StatementKind::Assign(Place {
base: PlaceBase::Local(local),
- projection: None,
+ projection: box [],
}, _),
..
}) => local,