+ ty::TyClosure(def_id, closure_substs)
+ if !self.mir.upvar_decls.is_empty()
+ && {
+ match place {
+ Place::Projection(ref proj) => {
+ proj.base == Place::Local(Local::new(1))
+ }
+ Place::Local(_) | Place::Static(_) => unreachable!(),
+ }
+ } =>
+ {
+ let closure_kind_ty =
+ closure_substs.closure_kind_ty(def_id, self.tcx);
+ let closure_kind = closure_kind_ty.to_opt_closure_kind();
+ let place_description = match closure_kind {
+ Some(ty::ClosureKind::Fn) => {
+ "captured variable in an `Fn` closure"
+ }
+ Some(ty::ClosureKind::FnMut) => {
+ "captured variable in an `FnMut` closure"
+ }
+ Some(ty::ClosureKind::FnOnce) => {
+ bug!("closure kind does not match first argument type")
+ }
+ None => bug!("closure kind not inferred by borrowck"),
+ };
+ self.tcx.cannot_move_out_of(span, place_description, origin)
+ }