1
Fork 0

Box CanonicalUserTypeAnnotation::CanonicalUserType.

This shrinks `Ascription`, which shrinks `PatKind::AscribeUserType`,
which shrinks `Pat`.
This commit is contained in:
Nicholas Nethercote 2022-08-26 11:53:54 +10:00
parent 2c4c8eb1a3
commit a40124e01c
7 changed files with 18 additions and 18 deletions

View file

@ -809,8 +809,8 @@ mod size_asserts {
static_assert_size!(Block, 56); static_assert_size!(Block, 56);
static_assert_size!(Expr<'_>, 64); static_assert_size!(Expr<'_>, 64);
static_assert_size!(ExprKind<'_>, 40); static_assert_size!(ExprKind<'_>, 40);
static_assert_size!(Pat<'_>, 112); static_assert_size!(Pat<'_>, 80);
static_assert_size!(PatKind<'_>, 96); static_assert_size!(PatKind<'_>, 64);
static_assert_size!(Stmt<'_>, 56); static_assert_size!(Stmt<'_>, 56);
static_assert_size!(StmtKind<'_>, 48); static_assert_size!(StmtKind<'_>, 48);
} }

View file

@ -874,7 +874,7 @@ pub type CanonicalUserTypeAnnotations<'tcx> =
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable, Lift)] #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct CanonicalUserTypeAnnotation<'tcx> { pub struct CanonicalUserTypeAnnotation<'tcx> {
pub user_ty: CanonicalUserType<'tcx>, pub user_ty: Box<CanonicalUserType<'tcx>>,
pub span: Span, pub span: Span,
pub inferred_ty: Ty<'tcx>, pub inferred_ty: Ty<'tcx>,
} }

View file

@ -42,10 +42,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Constant { span, user_ty: None, literal } Constant { span, user_ty: None, literal }
} }
ExprKind::NonHirLiteral { lit, ref user_ty } => { ExprKind::NonHirLiteral { lit, ref user_ty } => {
let user_ty = user_ty.as_ref().map(|box user_ty| { let user_ty = user_ty.as_ref().map(|user_ty| {
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation { this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
span, span,
user_ty: *user_ty, user_ty: user_ty.clone(),
inferred_ty: ty, inferred_ty: ty,
}) })
}); });
@ -54,10 +54,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Constant { span, user_ty: user_ty, literal } Constant { span, user_ty: user_ty, literal }
} }
ExprKind::ZstLiteral { ref user_ty } => { ExprKind::ZstLiteral { ref user_ty } => {
let user_ty = user_ty.as_ref().map(|box user_ty| { let user_ty = user_ty.as_ref().map(|user_ty| {
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation { this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
span, span,
user_ty: *user_ty, user_ty: user_ty.clone(),
inferred_ty: ty, inferred_ty: ty,
}) })
}); });
@ -66,10 +66,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Constant { span, user_ty: user_ty, literal } Constant { span, user_ty: user_ty, literal }
} }
ExprKind::NamedConst { def_id, substs, ref user_ty } => { ExprKind::NamedConst { def_id, substs, ref user_ty } => {
let user_ty = user_ty.as_ref().map(|box user_ty| { let user_ty = user_ty.as_ref().map(|user_ty| {
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation { this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
span, span,
user_ty: *user_ty, user_ty: user_ty.clone(),
inferred_ty: ty, inferred_ty: ty,
}) })
}); });

View file

@ -522,11 +522,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fake_borrow_temps, fake_borrow_temps,
) )
); );
if let Some(box user_ty) = user_ty { if let Some(user_ty) = user_ty {
let annotation_index = let annotation_index =
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation { this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
span: source_info.span, span: source_info.span,
user_ty: *user_ty, user_ty: user_ty.clone(),
inferred_ty: expr.ty, inferred_ty: expr.ty,
}); });
@ -551,11 +551,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let source = &this.thir[source]; let source = &this.thir[source];
let temp = let temp =
unpack!(block = this.as_temp(block, source.temp_lifetime, source, mutability)); unpack!(block = this.as_temp(block, source.temp_lifetime, source, mutability));
if let Some(box user_ty) = user_ty { if let Some(user_ty) = user_ty {
let annotation_index = let annotation_index =
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation { this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
span: source_info.span, span: source_info.span,
user_ty: *user_ty, user_ty: user_ty.clone(),
inferred_ty: expr.ty, inferred_ty: expr.ty,
}); });
this.cfg.push( this.cfg.push(

View file

@ -378,10 +378,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}; };
let inferred_ty = expr.ty; let inferred_ty = expr.ty;
let user_ty = user_ty.as_ref().map(|box user_ty| { let user_ty = user_ty.as_ref().map(|user_ty| {
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation { this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
span: source_info.span, span: source_info.span,
user_ty: *user_ty, user_ty: user_ty.clone(),
inferred_ty, inferred_ty,
}) })
}); });

View file

@ -87,7 +87,7 @@ impl<'tcx> Cx<'tcx> {
{ {
debug!("mirror_stmts: user_ty={:?}", user_ty); debug!("mirror_stmts: user_ty={:?}", user_ty);
let annotation = CanonicalUserTypeAnnotation { let annotation = CanonicalUserTypeAnnotation {
user_ty, user_ty: Box::new(user_ty),
span: ty.span, span: ty.span,
inferred_ty: self.typeck_results.node_type(ty.hir_id), inferred_ty: self.typeck_results.node_type(ty.hir_id),
}; };

View file

@ -443,7 +443,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) { if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) {
debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span); debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span);
let annotation = CanonicalUserTypeAnnotation { let annotation = CanonicalUserTypeAnnotation {
user_ty, user_ty: Box::new(user_ty),
span, span,
inferred_ty: self.typeck_results.node_type(hir_id), inferred_ty: self.typeck_results.node_type(hir_id),
}; };
@ -512,7 +512,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
let user_provided_types = self.typeck_results().user_provided_types(); let user_provided_types = self.typeck_results().user_provided_types();
if let Some(&user_ty) = user_provided_types.get(id) { if let Some(&user_ty) = user_provided_types.get(id) {
let annotation = CanonicalUserTypeAnnotation { let annotation = CanonicalUserTypeAnnotation {
user_ty, user_ty: Box::new(user_ty),
span, span,
inferred_ty: self.typeck_results().node_type(id), inferred_ty: self.typeck_results().node_type(id),
}; };