- let ty = operand.ty(body, tcx);
- if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty, span) {
- let ccx = ConstCx::new_with_param_env(tcx, body, self.param_env);
- let is_const_fn =
- is_const_fn_in_array_repeat_expression(&ccx, &place, &body);
-
- debug!("check_rvalue: is_const_fn={:?}", is_const_fn);
-
- let def_id = body.source.def_id().expect_local();
- let obligation = traits::Obligation::new(
- ObligationCause::new(
- span,
- self.tcx().hir().local_def_id_to_hir_id(def_id),
- traits::ObligationCauseCode::RepeatElementCopy {
- is_const_fn,
- },
- ),
- self.param_env,
- ty::Binder::dummy(ty::TraitRef::new(
- self.tcx().require_lang_item(
- LangItem::Copy,
- Some(self.last_span),
- ),
- tcx.mk_substs_trait(ty, &[]),
- ))
- .without_const()
- .to_predicate(self.tcx()),
- );
- self.infcx.report_selection_error(
- obligation.clone(),
- &obligation,
- &traits::SelectionError::Unimplemented,
- false,
- );
- }
+ let ty = place.ty(body, tcx).ty;
+ let trait_ref = ty::TraitRef::new(
+ tcx.require_lang_item(LangItem::Copy, Some(span)),
+ tcx.mk_substs_trait(ty, &[]),
+ );
+
+ self.prove_trait_ref(
+ trait_ref,
+ Locations::Single(location),
+ ConstraintCategory::CopyBound,
+ );