@@ -329,7 +329,7 @@ impl<'tcx> Cx<'tcx> {
329
329
if let UserType :: TypeOf ( ref mut did, _) = & mut u_ty. value {
330
330
* did = adt_def. did ( ) ;
331
331
}
332
- u_ty
332
+ Box :: new ( u_ty)
333
333
} ) ;
334
334
debug ! ( "make_mirror_unadjusted: (call) user_ty={:?}" , user_ty) ;
335
335
@@ -464,7 +464,7 @@ impl<'tcx> Cx<'tcx> {
464
464
ty:: Adt ( adt, substs) => match adt. adt_kind ( ) {
465
465
AdtKind :: Struct | AdtKind :: Union => {
466
466
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 ) ;
468
468
debug ! ( "make_mirror_unadjusted: (struct/union) user_ty={:?}" , user_ty) ;
469
469
ExprKind :: Adt ( Box :: new ( Adt {
470
470
adt_def : * adt,
@@ -490,7 +490,8 @@ impl<'tcx> Cx<'tcx> {
490
490
let index = adt. variant_index_with_id ( variant_id) ;
491
491
let user_provided_types =
492
492
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) ;
494
495
debug ! ( "make_mirror_unadjusted: (variant) user_ty={:?}" , user_ty) ;
495
496
ExprKind :: Adt ( Box :: new ( Adt {
496
497
adt_def : * adt,
@@ -712,14 +713,17 @@ impl<'tcx> Cx<'tcx> {
712
713
} ) ;
713
714
debug ! ( "make_mirror_unadjusted: (cast) user_ty={:?}" , user_ty) ;
714
715
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
+ }
716
720
} else {
717
721
cast
718
722
}
719
723
}
720
724
hir:: ExprKind :: Type ( ref source, ref ty) => {
721
725
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 ) ;
723
727
debug ! ( "make_mirror_unadjusted: (type) user_ty={:?}" , user_ty) ;
724
728
let mirrored = self . mirror_expr ( source) ;
725
729
if source. is_syntactic_place_expr ( ) {
@@ -748,7 +752,7 @@ impl<'tcx> Cx<'tcx> {
748
752
& mut self ,
749
753
hir_id : hir:: HirId ,
750
754
res : Res ,
751
- ) -> Option < ty:: CanonicalUserType < ' tcx > > {
755
+ ) -> Option < Box < ty:: CanonicalUserType < ' tcx > > > {
752
756
debug ! ( "user_substs_applied_to_res: res={:?}" , res) ;
753
757
let user_provided_type = match res {
754
758
// A reference to something callable -- e.g., a fn, method, or
@@ -759,19 +763,19 @@ impl<'tcx> Cx<'tcx> {
759
763
| Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fn ) , _)
760
764
| Res :: Def ( DefKind :: Const , _)
761
765
| 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 )
763
767
}
764
768
765
769
// A unit struct/variant which is used as a value (e.g.,
766
770
// `None`). This has the type of the enum/struct that defines
767
771
// this variant -- but with the substitutions given by the
768
772
// user.
769
773
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 )
771
775
}
772
776
773
777
// `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 ) ,
775
779
776
780
_ => bug ! ( "user_substs_applied_to_res: unexpected res {:?} at {:?}" , res, hir_id) ,
777
781
} ;
@@ -846,13 +850,13 @@ impl<'tcx> Cx<'tcx> {
846
850
847
851
Res :: Def ( DefKind :: Const , def_id) | Res :: Def ( DefKind :: AssocConst , def_id) => {
848
852
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 }
850
854
}
851
855
852
856
Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Const ) , def_id) => {
853
857
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 ) ;
856
860
let ty = self . typeck_results ( ) . node_type ( expr. hir_id ) ;
857
861
match ty. kind ( ) {
858
862
// A unit struct/variant which is used as a value.
@@ -861,7 +865,7 @@ impl<'tcx> Cx<'tcx> {
861
865
adt_def : * adt_def,
862
866
variant_index : adt_def. variant_index_with_ctor_id ( def_id) ,
863
867
substs,
864
- user_ty : user_provided_type ,
868
+ user_ty,
865
869
fields : Box :: new ( [ ] ) ,
866
870
base : None ,
867
871
} ) ) ,
0 commit comments