Skip to content

Commit a40124e

Browse files
committed
Box CanonicalUserTypeAnnotation::CanonicalUserType.
This shrinks `Ascription`, which shrinks `PatKind::AscribeUserType`, which shrinks `Pat`.
1 parent 2c4c8eb commit a40124e

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

compiler/rustc_middle/src/thir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ mod size_asserts {
809809
static_assert_size!(Block, 56);
810810
static_assert_size!(Expr<'_>, 64);
811811
static_assert_size!(ExprKind<'_>, 40);
812-
static_assert_size!(Pat<'_>, 112);
813-
static_assert_size!(PatKind<'_>, 96);
812+
static_assert_size!(Pat<'_>, 80);
813+
static_assert_size!(PatKind<'_>, 64);
814814
static_assert_size!(Stmt<'_>, 56);
815815
static_assert_size!(StmtKind<'_>, 48);
816816
}

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ pub type CanonicalUserTypeAnnotations<'tcx> =
874874

875875
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable, Lift)]
876876
pub struct CanonicalUserTypeAnnotation<'tcx> {
877-
pub user_ty: CanonicalUserType<'tcx>,
877+
pub user_ty: Box<CanonicalUserType<'tcx>>,
878878
pub span: Span,
879879
pub inferred_ty: Ty<'tcx>,
880880
}

compiler/rustc_mir_build/src/build/expr/as_constant.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4242
Constant { span, user_ty: None, literal }
4343
}
4444
ExprKind::NonHirLiteral { lit, ref user_ty } => {
45-
let user_ty = user_ty.as_ref().map(|box user_ty| {
45+
let user_ty = user_ty.as_ref().map(|user_ty| {
4646
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
4747
span,
48-
user_ty: *user_ty,
48+
user_ty: user_ty.clone(),
4949
inferred_ty: ty,
5050
})
5151
});
@@ -54,10 +54,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5454
Constant { span, user_ty: user_ty, literal }
5555
}
5656
ExprKind::ZstLiteral { ref user_ty } => {
57-
let user_ty = user_ty.as_ref().map(|box user_ty| {
57+
let user_ty = user_ty.as_ref().map(|user_ty| {
5858
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
5959
span,
60-
user_ty: *user_ty,
60+
user_ty: user_ty.clone(),
6161
inferred_ty: ty,
6262
})
6363
});
@@ -66,10 +66,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6666
Constant { span, user_ty: user_ty, literal }
6767
}
6868
ExprKind::NamedConst { def_id, substs, ref user_ty } => {
69-
let user_ty = user_ty.as_ref().map(|box user_ty| {
69+
let user_ty = user_ty.as_ref().map(|user_ty| {
7070
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
7171
span,
72-
user_ty: *user_ty,
72+
user_ty: user_ty.clone(),
7373
inferred_ty: ty,
7474
})
7575
});

compiler/rustc_mir_build/src/build/expr/as_place.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
522522
fake_borrow_temps,
523523
)
524524
);
525-
if let Some(box user_ty) = user_ty {
525+
if let Some(user_ty) = user_ty {
526526
let annotation_index =
527527
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
528528
span: source_info.span,
529-
user_ty: *user_ty,
529+
user_ty: user_ty.clone(),
530530
inferred_ty: expr.ty,
531531
});
532532

@@ -551,11 +551,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
551551
let source = &this.thir[source];
552552
let temp =
553553
unpack!(block = this.as_temp(block, source.temp_lifetime, source, mutability));
554-
if let Some(box user_ty) = user_ty {
554+
if let Some(user_ty) = user_ty {
555555
let annotation_index =
556556
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
557557
span: source_info.span,
558-
user_ty: *user_ty,
558+
user_ty: user_ty.clone(),
559559
inferred_ty: expr.ty,
560560
});
561561
this.cfg.push(

compiler/rustc_mir_build/src/build/expr/into.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
378378
};
379379

380380
let inferred_ty = expr.ty;
381-
let user_ty = user_ty.as_ref().map(|box user_ty| {
381+
let user_ty = user_ty.as_ref().map(|user_ty| {
382382
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
383383
span: source_info.span,
384-
user_ty: *user_ty,
384+
user_ty: user_ty.clone(),
385385
inferred_ty,
386386
})
387387
});

compiler/rustc_mir_build/src/thir/cx/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'tcx> Cx<'tcx> {
8787
{
8888
debug!("mirror_stmts: user_ty={:?}", user_ty);
8989
let annotation = CanonicalUserTypeAnnotation {
90-
user_ty,
90+
user_ty: Box::new(user_ty),
9191
span: ty.span,
9292
inferred_ty: self.typeck_results.node_type(ty.hir_id),
9393
};

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
443443
if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) {
444444
debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span);
445445
let annotation = CanonicalUserTypeAnnotation {
446-
user_ty,
446+
user_ty: Box::new(user_ty),
447447
span,
448448
inferred_ty: self.typeck_results.node_type(hir_id),
449449
};
@@ -512,7 +512,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
512512
let user_provided_types = self.typeck_results().user_provided_types();
513513
if let Some(&user_ty) = user_provided_types.get(id) {
514514
let annotation = CanonicalUserTypeAnnotation {
515-
user_ty,
515+
user_ty: Box::new(user_ty),
516516
span,
517517
inferred_ty: self.typeck_results().node_type(id),
518518
};

0 commit comments

Comments
 (0)