// FIXME(eddyb) perhaps move this somewhere more centrally.
#[derive(Debug)]
crate struct Upvar<'tcx> {
- // FIXME(project-rfc_2229#36): print capture precisely here.
- name: Symbol,
-
place: CapturedPlace<'tcx>,
/// If true, the capture is behind a reference.
let upvars: Vec<_> = tables
.closure_min_captures_flattened(def.did.to_def_id())
.map(|captured_place| {
- let var_hir_id = captured_place.get_root_variable();
let capture = captured_place.info.capture_kind;
let by_ref = match capture {
ty::UpvarCapture::ByValue(_) => false,
ty::UpvarCapture::ByRef(..) => true,
};
- Upvar { name: tcx.hir().name(var_hir_id), place: captured_place.clone(), by_ref }
+ Upvar { place: captured_place.clone(), by_ref }
})
.collect();
// no move out from an earlier location) then this is an attempt at initialization
// of the union - we should error in that case.
let tcx = this.infcx.tcx;
- if let ty::Adt(def, _) = base.ty(this.body(), tcx).ty.kind() {
- if def.is_union() {
- if this.move_data.path_map[mpi].iter().any(|moi| {
- this.move_data.moves[*moi].source.is_predecessor_of(location, this.body)
- }) {
- return;
- }
+ if base.ty(this.body(), tcx).ty.is_union() {
+ if this.move_data.path_map[mpi].iter().any(|moi| {
+ this.move_data.moves[*moi].source.is_predecessor_of(location, this.body)
+ }) {
+ return;
}
}