@@ -43,6 +43,9 @@ use rustc_trait_selection::traits::{self, ObligationCause, PredicateObligations}
4343use crate :: dataflow:: impls:: MaybeInitializedPlaces ;
4444use crate :: dataflow:: move_paths:: MoveData ;
4545use crate :: dataflow:: ResultsCursor ;
46+ use crate :: transform:: {
47+ check_consts:: ConstCx , promote_consts:: is_const_fn_in_array_repeat_expression,
48+ } ;
4649
4750use crate :: borrow_check:: {
4851 borrow_set:: BorrowSet ,
@@ -1988,18 +1991,24 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19881991 Operand :: Copy ( ..) | Operand :: Constant ( ..) => {
19891992 // These are always okay: direct use of a const, or a value that can evidently be copied.
19901993 }
1991- Operand :: Move ( _ ) => {
1994+ Operand :: Move ( place ) => {
19921995 // Make sure that repeated elements implement `Copy`.
19931996 let span = body. source_info ( location) . span ;
19941997 let ty = operand. ty ( body, tcx) ;
19951998 if !self . infcx . type_is_copy_modulo_regions ( self . param_env , ty, span) {
1999+ let ccx = ConstCx :: new_with_param_env ( tcx, body, self . param_env ) ;
2000+ let is_const_fn =
2001+ is_const_fn_in_array_repeat_expression ( & ccx, & place, & body) ;
2002+
2003+ debug ! ( "check_rvalue: is_const_fn={:?}" , is_const_fn) ;
2004+
19962005 let def_id = body. source . def_id ( ) . expect_local ( ) ;
19972006 self . infcx . report_selection_error (
19982007 & traits:: Obligation :: new (
19992008 ObligationCause :: new (
20002009 span,
20012010 self . tcx ( ) . hir ( ) . local_def_id_to_hir_id ( def_id) ,
2002- traits:: ObligationCauseCode :: RepeatVec ,
2011+ traits:: ObligationCauseCode :: RepeatVec ( is_const_fn ) ,
20032012 ) ,
20042013 self . param_env ,
20052014 ty:: Binder :: bind ( ty:: TraitRef :: new (
0 commit comments