@@ -329,7 +329,7 @@ impl<'tcx> Cx<'tcx> {
329329 if let UserType :: TypeOf ( ref mut did, _) = & mut u_ty. value {
330330 * did = adt_def. did ( ) ;
331331 }
332- u_ty
332+ Box :: new ( u_ty)
333333 } ) ;
334334 debug ! ( "make_mirror_unadjusted: (call) user_ty={:?}" , user_ty) ;
335335
@@ -464,7 +464,7 @@ impl<'tcx> Cx<'tcx> {
464464 ty:: Adt ( adt, substs) => match adt. adt_kind ( ) {
465465 AdtKind :: Struct | AdtKind :: Union => {
466466 let user_provided_types = self . typeck_results ( ) . user_provided_types ( ) ;
467- let user_ty = user_provided_types. get ( expr. hir_id ) . copied ( ) ;
467+ let user_ty = user_provided_types. get ( expr. hir_id ) . copied ( ) . map ( Box :: new ) ;
468468 debug ! ( "make_mirror_unadjusted: (struct/union) user_ty={:?}" , user_ty) ;
469469 ExprKind :: Adt ( Box :: new ( Adt {
470470 adt_def : * adt,
@@ -490,7 +490,8 @@ impl<'tcx> Cx<'tcx> {
490490 let index = adt. variant_index_with_id ( variant_id) ;
491491 let user_provided_types =
492492 self . typeck_results ( ) . user_provided_types ( ) ;
493- let user_ty = user_provided_types. get ( expr. hir_id ) . copied ( ) ;
493+ let user_ty =
494+ user_provided_types. get ( expr. hir_id ) . copied ( ) . map ( Box :: new) ;
494495 debug ! ( "make_mirror_unadjusted: (variant) user_ty={:?}" , user_ty) ;
495496 ExprKind :: Adt ( Box :: new ( Adt {
496497 adt_def : * adt,
@@ -712,14 +713,17 @@ impl<'tcx> Cx<'tcx> {
712713 } ) ;
713714 debug ! ( "make_mirror_unadjusted: (cast) user_ty={:?}" , user_ty) ;
714715
715- ExprKind :: ValueTypeAscription { source : cast_expr, user_ty : Some ( * user_ty) }
716+ ExprKind :: ValueTypeAscription {
717+ source : cast_expr,
718+ user_ty : Some ( Box :: new ( * user_ty) ) ,
719+ }
716720 } else {
717721 cast
718722 }
719723 }
720724 hir:: ExprKind :: Type ( ref source, ref ty) => {
721725 let user_provided_types = self . typeck_results . user_provided_types ( ) ;
722- let user_ty = user_provided_types. get ( ty. hir_id ) . copied ( ) ;
726+ let user_ty = user_provided_types. get ( ty. hir_id ) . copied ( ) . map ( Box :: new ) ;
723727 debug ! ( "make_mirror_unadjusted: (type) user_ty={:?}" , user_ty) ;
724728 let mirrored = self . mirror_expr ( source) ;
725729 if source. is_syntactic_place_expr ( ) {
@@ -748,7 +752,7 @@ impl<'tcx> Cx<'tcx> {
748752 & mut self ,
749753 hir_id : hir:: HirId ,
750754 res : Res ,
751- ) -> Option < ty:: CanonicalUserType < ' tcx > > {
755+ ) -> Option < Box < ty:: CanonicalUserType < ' tcx > > > {
752756 debug ! ( "user_substs_applied_to_res: res={:?}" , res) ;
753757 let user_provided_type = match res {
754758 // A reference to something callable -- e.g., a fn, method, or
@@ -759,19 +763,19 @@ impl<'tcx> Cx<'tcx> {
759763 | Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fn ) , _)
760764 | Res :: Def ( DefKind :: Const , _)
761765 | Res :: Def ( DefKind :: AssocConst , _) => {
762- self . typeck_results ( ) . user_provided_types ( ) . get ( hir_id) . copied ( )
766+ self . typeck_results ( ) . user_provided_types ( ) . get ( hir_id) . copied ( ) . map ( Box :: new )
763767 }
764768
765769 // A unit struct/variant which is used as a value (e.g.,
766770 // `None`). This has the type of the enum/struct that defines
767771 // this variant -- but with the substitutions given by the
768772 // user.
769773 Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Const ) , _) => {
770- self . user_substs_applied_to_ty_of_hir_id ( hir_id)
774+ self . user_substs_applied_to_ty_of_hir_id ( hir_id) . map ( Box :: new )
771775 }
772776
773777 // `Self` is used in expression as a tuple struct constructor or a unit struct constructor
774- Res :: SelfCtor ( _) => self . user_substs_applied_to_ty_of_hir_id ( hir_id) ,
778+ Res :: SelfCtor ( _) => self . user_substs_applied_to_ty_of_hir_id ( hir_id) . map ( Box :: new ) ,
775779
776780 _ => bug ! ( "user_substs_applied_to_res: unexpected res {:?} at {:?}" , res, hir_id) ,
777781 } ;
@@ -846,13 +850,13 @@ impl<'tcx> Cx<'tcx> {
846850
847851 Res :: Def ( DefKind :: Const , def_id) | Res :: Def ( DefKind :: AssocConst , def_id) => {
848852 let user_ty = self . user_substs_applied_to_res ( expr. hir_id , res) ;
849- ExprKind :: NamedConst { def_id, substs, user_ty : user_ty }
853+ ExprKind :: NamedConst { def_id, substs, user_ty }
850854 }
851855
852856 Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Const ) , def_id) => {
853857 let user_provided_types = self . typeck_results . user_provided_types ( ) ;
854- let user_provided_type = user_provided_types. get ( expr. hir_id ) . copied ( ) ;
855- debug ! ( "convert_path_expr: user_provided_type ={:?}" , user_provided_type ) ;
858+ let user_ty = user_provided_types. get ( expr. hir_id ) . copied ( ) . map ( Box :: new ) ;
859+ debug ! ( "convert_path_expr: user_ty ={:?}" , user_ty ) ;
856860 let ty = self . typeck_results ( ) . node_type ( expr. hir_id ) ;
857861 match ty. kind ( ) {
858862 // A unit struct/variant which is used as a value.
@@ -861,7 +865,7 @@ impl<'tcx> Cx<'tcx> {
861865 adt_def : * adt_def,
862866 variant_index : adt_def. variant_index_with_ctor_id ( def_id) ,
863867 substs,
864- user_ty : user_provided_type ,
868+ user_ty,
865869 fields : Box :: new ( [ ] ) ,
866870 base : None ,
867871 } ) ) ,
0 commit comments