@@ -35,7 +35,7 @@ use rustc::mir::*;
3535use rustc:: traits:: query:: type_op;
3636use rustc:: traits:: query:: type_op:: custom:: CustomTypeOp ;
3737use rustc:: traits:: query:: { Fallible , NoSolution } ;
38- use rustc:: traits:: { ObligationCause , PredicateObligations } ;
38+ use rustc:: traits:: { self , ObligationCause , PredicateObligations } ;
3939use rustc:: ty:: adjustment:: { PointerCast } ;
4040use rustc:: ty:: fold:: TypeFoldable ;
4141use rustc:: ty:: subst:: { Subst , SubstsRef , UnpackedKind , UserSubsts } ;
@@ -1968,25 +1968,25 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19681968 // a required check to make sure that repeated elements implement `Copy`.
19691969 let span = body. source_info ( location) . span ;
19701970 let ty = operand. ty ( body, tcx) ;
1971- let is_copy = self . infcx . type_is_copy_modulo_regions ( self . param_env , ty, span) ;
1972- if !is_copy {
1973- let copy_path = self . tcx ( ) . def_path_str (
1974- self . tcx ( ) . lang_items ( ) . copy_trait ( ) . unwrap ( ) ) ;
1975- self . tcx ( ) . sess
1976- . struct_span_err (
1977- span ,
1978- & format ! ( "repeated expression does not implement `{}`" , copy_path ) ,
1979- )
1980- . span_label ( span , & format ! (
1981- "the trait `{}` is not implemented for `{}`" ,
1982- copy_path , ty ,
1983- ) )
1984- . note ( & format ! (
1985- "the `{}` trait is required because the repeated element will be \
1986- copied" ,
1987- copy_path ,
1988- ) )
1989- . emit ( ) ;
1971+ if ! self . infcx . type_is_copy_modulo_regions ( self . param_env , ty, span) {
1972+ self . infcx . report_selection_error (
1973+ & traits :: Obligation :: new (
1974+ ObligationCause :: new (
1975+ span ,
1976+ self . tcx ( ) . hir ( ) . def_index_to_hir_id ( self . mir_def_id . index ) ,
1977+ traits :: ObligationCauseCode :: RepeatVec ,
1978+ ) ,
1979+ self . param_env ,
1980+ ty :: Predicate :: Trait ( ty :: Binder :: bind ( ty :: TraitPredicate {
1981+ trait_ref : ty :: TraitRef :: new (
1982+ self . tcx ( ) . lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
1983+ tcx . mk_substs_trait ( ty , & [ ] ) ,
1984+ ) ,
1985+ } ) ) ,
1986+ ) ,
1987+ & traits :: SelectionError :: Unimplemented ,
1988+ false ,
1989+ ) ;
19901990 }
19911991 }
19921992 } ,
0 commit comments