1
Fork 0

Remove box syntax from rustc_mir_build

This commit is contained in:
est31 2021-08-05 03:16:19 +02:00
parent cbe3afece5
commit 8b0b7ef812
14 changed files with 74 additions and 59 deletions

View file

@ -40,7 +40,7 @@ impl<'tcx> CFG<'tcx> {
) { ) {
self.push( self.push(
block, block,
Statement { source_info, kind: StatementKind::Assign(box (place, rvalue)) }, Statement { source_info, kind: StatementKind::Assign(Box::new((place, rvalue))) },
); );
} }
@ -51,7 +51,12 @@ impl<'tcx> CFG<'tcx> {
temp: Place<'tcx>, temp: Place<'tcx>,
constant: Constant<'tcx>, constant: Constant<'tcx>,
) { ) {
self.push_assign(block, source_info, temp, Rvalue::Use(Operand::Constant(box constant))); self.push_assign(
block,
source_info,
temp,
Rvalue::Use(Operand::Constant(Box::new(constant))),
);
} }
crate fn push_assign_unit( crate fn push_assign_unit(
@ -65,11 +70,11 @@ impl<'tcx> CFG<'tcx> {
block, block,
source_info, source_info,
place, place,
Rvalue::Use(Operand::Constant(box Constant { Rvalue::Use(Operand::Constant(Box::new(Constant {
span: source_info.span, span: source_info.span,
user_ty: None, user_ty: None,
literal: ty::Const::zero_sized(tcx, tcx.types.unit).into(), literal: ty::Const::zero_sized(tcx, tcx.types.unit).into(),
})), }))),
); );
} }
@ -80,7 +85,7 @@ impl<'tcx> CFG<'tcx> {
cause: FakeReadCause, cause: FakeReadCause,
place: Place<'tcx>, place: Place<'tcx>,
) { ) {
let kind = StatementKind::FakeRead(box (cause, place)); let kind = StatementKind::FakeRead(Box::new((cause, place)));
let stmt = Statement { source_info, kind }; let stmt = Statement { source_info, kind };
self.push(block, stmt); self.push(block, stmt);
} }

View file

@ -111,7 +111,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
match category { match category {
Category::Constant => { Category::Constant => {
let constant = this.as_constant(expr); let constant = this.as_constant(expr);
block.and(Operand::Constant(box constant)) block.and(Operand::Constant(Box::new(constant)))
} }
Category::Place | Category::Rvalue(..) => { Category::Place | Category::Rvalue(..) => {
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut)); let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));

View file

@ -507,10 +507,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Statement { Statement {
source_info, source_info,
kind: StatementKind::AscribeUserType( kind: StatementKind::AscribeUserType(
box ( Box::new((
place, place,
UserTypeProjection { base: annotation_index, projs: vec![] }, UserTypeProjection { base: annotation_index, projs: vec![] },
), )),
Variance::Invariant, Variance::Invariant,
), ),
}, },
@ -534,10 +534,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Statement { Statement {
source_info, source_info,
kind: StatementKind::AscribeUserType( kind: StatementKind::AscribeUserType(
box ( Box::new((
Place::from(temp), Place::from(temp),
UserTypeProjection { base: annotation_index, projs: vec![] }, UserTypeProjection { base: annotation_index, projs: vec![] },
), )),
Variance::Invariant, Variance::Invariant,
), ),
}, },
@ -691,7 +691,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
lt, lt,
Rvalue::BinaryOp( Rvalue::BinaryOp(
BinOp::Lt, BinOp::Lt,
box (Operand::Copy(Place::from(index)), Operand::Copy(len)), Box::new((Operand::Copy(Place::from(index)), Operand::Copy(len))),
), ),
); );
let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) }; let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) };

View file

@ -73,7 +73,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
is_min, is_min,
Rvalue::BinaryOp(BinOp::Eq, box (arg.to_copy(), minval)), Rvalue::BinaryOp(BinOp::Eq, Box::new((arg.to_copy(), minval))),
); );
block = this.assert( block = this.assert(
@ -158,7 +158,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f]))) .map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
.collect(); .collect();
block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields)) block.and(Rvalue::Aggregate(Box::new(AggregateKind::Array(el_ty)), fields))
} }
ExprKind::Tuple { ref fields } => { ExprKind::Tuple { ref fields } => {
// see (*) above // see (*) above
@ -169,7 +169,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f]))) .map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
.collect(); .collect();
block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields)) block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
} }
ExprKind::Closure { closure_id, substs, ref upvars, movability, ref fake_reads } => { ExprKind::Closure { closure_id, substs, ref upvars, movability, ref fake_reads } => {
// Convert the closure fake reads, if any, from `ExprRef` to mir `Place` // Convert the closure fake reads, if any, from `ExprRef` to mir `Place`
@ -254,19 +254,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// We implicitly set the discriminant to 0. See // We implicitly set the discriminant to 0. See
// librustc_mir/transform/deaggregator.rs for details. // librustc_mir/transform/deaggregator.rs for details.
let movability = movability.unwrap(); let movability = movability.unwrap();
box AggregateKind::Generator(closure_id, substs, movability) Box::new(AggregateKind::Generator(closure_id, substs, movability))
}
UpvarSubsts::Closure(substs) => {
Box::new(AggregateKind::Closure(closure_id, substs))
} }
UpvarSubsts::Closure(substs) => box AggregateKind::Closure(closure_id, substs),
}; };
block.and(Rvalue::Aggregate(result, operands)) block.and(Rvalue::Aggregate(result, operands))
} }
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => { ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {
block = unpack!(this.stmt_expr(block, expr, None)); block = unpack!(this.stmt_expr(block, expr, None));
block.and(Rvalue::Use(Operand::Constant(box Constant { block.and(Rvalue::Use(Operand::Constant(Box::new(Constant {
span: expr_span, span: expr_span,
user_ty: None, user_ty: None,
literal: ty::Const::zero_sized(this.tcx, this.tcx.types.unit).into(), literal: ty::Const::zero_sized(this.tcx, this.tcx.types.unit).into(),
}))) }))))
} }
ExprKind::Yield { .. } ExprKind::Yield { .. }
| ExprKind::Literal { .. } | ExprKind::Literal { .. }
@ -327,7 +329,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
result_value, result_value,
Rvalue::CheckedBinaryOp(op, box (lhs.to_copy(), rhs.to_copy())), Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))),
); );
let val_fld = Field::new(0); let val_fld = Field::new(0);
let of_fld = Field::new(1); let of_fld = Field::new(1);
@ -360,7 +362,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
is_zero, is_zero,
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), zero)), Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), zero))),
); );
block = self.assert(block, Operand::Move(is_zero), false, zero_err, span); block = self.assert(block, Operand::Move(is_zero), false, zero_err, span);
@ -381,13 +383,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
is_neg_1, is_neg_1,
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), neg_1)), Rvalue::BinaryOp(BinOp::Eq, Box::new((rhs.to_copy(), neg_1))),
); );
self.cfg.push_assign( self.cfg.push_assign(
block, block,
source_info, source_info,
is_min, is_min,
Rvalue::BinaryOp(BinOp::Eq, box (lhs.to_copy(), min)), Rvalue::BinaryOp(BinOp::Eq, Box::new((lhs.to_copy(), min))),
); );
let is_neg_1 = Operand::Move(is_neg_1); let is_neg_1 = Operand::Move(is_neg_1);
@ -396,14 +398,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
of, of,
Rvalue::BinaryOp(BinOp::BitAnd, box (is_neg_1, is_min)), Rvalue::BinaryOp(BinOp::BitAnd, Box::new((is_neg_1, is_min))),
); );
block = self.assert(block, Operand::Move(of), false, overflow_err, span); block = self.assert(block, Operand::Move(of), false, overflow_err, span);
} }
} }
block.and(Rvalue::BinaryOp(op, box (lhs, rhs))) block.and(Rvalue::BinaryOp(op, Box::new((lhs, rhs))))
} }
} }

View file

@ -62,16 +62,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
assert!(!this.tcx.is_thread_local_static(def_id)); assert!(!this.tcx.is_thread_local_static(def_id));
local_decl.internal = true; local_decl.internal = true;
local_decl.local_info = local_decl.local_info =
Some(box LocalInfo::StaticRef { def_id, is_thread_local: false }); Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: false }));
} }
ExprKind::ThreadLocalRef(def_id) => { ExprKind::ThreadLocalRef(def_id) => {
assert!(this.tcx.is_thread_local_static(def_id)); assert!(this.tcx.is_thread_local_static(def_id));
local_decl.internal = true; local_decl.internal = true;
local_decl.local_info = local_decl.local_info =
Some(box LocalInfo::StaticRef { def_id, is_thread_local: true }); Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: true }));
} }
ExprKind::Literal { const_id: Some(def_id), .. } => { ExprKind::Literal { const_id: Some(def_id), .. } => {
local_decl.local_info = Some(box LocalInfo::ConstRef { def_id }); local_decl.local_info = Some(Box::new(LocalInfo::ConstRef { def_id }));
} }
_ => {} _ => {}
} }

View file

@ -346,13 +346,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
inferred_ty, inferred_ty,
}) })
}); });
let adt = box AggregateKind::Adt( let adt = Box::new(AggregateKind::Adt(
adt_def, adt_def,
variant_index, variant_index,
substs, substs,
user_ty, user_ty,
active_field_index, active_field_index,
); ));
this.cfg.push_assign( this.cfg.push_assign(
block, block,
source_info, source_info,
@ -403,11 +403,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
} }
thir::InlineAsmOperand::Const { value, span } => { thir::InlineAsmOperand::Const { value, span } => {
mir::InlineAsmOperand::Const { mir::InlineAsmOperand::Const {
value: box Constant { span, user_ty: None, literal: value.into() }, value: Box::new(Constant {
span,
user_ty: None,
literal: value.into(),
}),
} }
} }
thir::InlineAsmOperand::SymFn { expr } => mir::InlineAsmOperand::SymFn { thir::InlineAsmOperand::SymFn { expr } => mir::InlineAsmOperand::SymFn {
value: box this.as_constant(&this.thir[expr]), value: Box::new(this.as_constant(&this.thir[expr])),
}, },
thir::InlineAsmOperand::SymStatic { def_id } => { thir::InlineAsmOperand::SymStatic { def_id } => {
mir::InlineAsmOperand::SymStatic { def_id } mir::InlineAsmOperand::SymStatic { def_id }

View file

@ -123,11 +123,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
Statement { Statement {
source_info, source_info,
kind: StatementKind::LlvmInlineAsm(box LlvmInlineAsm { kind: StatementKind::LlvmInlineAsm(Box::new(LlvmInlineAsm {
asm: asm.clone(), asm: asm.clone(),
outputs, outputs,
inputs, inputs,
}), })),
}, },
); );
this.block_context.pop(); this.block_context.pop();

View file

@ -494,7 +494,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Statement { Statement {
source_info: ty_source_info, source_info: ty_source_info,
kind: StatementKind::AscribeUserType( kind: StatementKind::AscribeUserType(
box (place, user_ty), Box::new((place, user_ty)),
// We always use invariant as the variance here. This is because the // We always use invariant as the variance here. This is because the
// variance field from the ascription refers to the variance to use // variance field from the ascription refers to the variance to use
// when applying the type to the value being matched, but this // when applying the type to the value being matched, but this
@ -2004,7 +2004,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Statement { Statement {
source_info, source_info,
kind: StatementKind::AscribeUserType( kind: StatementKind::AscribeUserType(
box (ascription.source, user_ty), Box::new((ascription.source, user_ty)),
ascription.variance, ascription.variance,
), ),
}, },
@ -2133,11 +2133,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let local = LocalDecl::<'tcx> { let local = LocalDecl::<'tcx> {
mutability, mutability,
ty: var_ty, ty: var_ty,
user_ty: if user_ty.is_empty() { None } else { Some(box user_ty) }, user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
source_info, source_info,
internal: false, internal: false,
is_block_tail: None, is_block_tail: None,
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var( local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
VarBindingForm { VarBindingForm {
binding_mode, binding_mode,
// hypothetically, `visit_primary_bindings` could try to unzip // hypothetically, `visit_primary_bindings` could try to unzip
@ -2148,7 +2148,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
opt_match_place, opt_match_place,
pat_span, pat_span,
}, },
)))), ))))),
}; };
let for_arm_body = self.local_decls.push(local); let for_arm_body = self.local_decls.push(local);
self.var_debug_info.push(VarDebugInfo { self.var_debug_info.push(VarDebugInfo {
@ -2166,9 +2166,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
source_info, source_info,
internal: false, internal: false,
is_block_tail: None, is_block_tail: None,
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set( local_info: Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
BindingForm::RefForGuard, BindingForm::RefForGuard,
))), )))),
}); });
self.var_debug_info.push(VarDebugInfo { self.var_debug_info.push(VarDebugInfo {
name, name,

View file

@ -346,7 +346,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let result = self.temp(bool_ty, source_info.span); let result = self.temp(bool_ty, source_info.span);
// result = op(left, right) // result = op(left, right)
self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, box (left, right))); self.cfg.push_assign(
block,
source_info,
result,
Rvalue::BinaryOp(op, Box::new((left, right))),
);
// branch based on result // branch based on result
self.cfg.terminate( self.cfg.terminate(
@ -429,7 +434,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
TerminatorKind::Call { TerminatorKind::Call {
func: Operand::Constant(box Constant { func: Operand::Constant(Box::new(Constant {
span: source_info.span, span: source_info.span,
// FIXME(#54571): This constant comes from user input (a // FIXME(#54571): This constant comes from user input (a
@ -439,7 +444,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
user_ty: None, user_ty: None,
literal: method.into(), literal: method.into(),
}), })),
args: vec![val, expect], args: vec![val, expect],
destination: Some((eq_result, eq_block)), destination: Some((eq_result, eq_block)),
cleanup: None, cleanup: None,

View file

@ -31,7 +31,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
literal: &'tcx ty::Const<'tcx>, literal: &'tcx ty::Const<'tcx>,
) -> Operand<'tcx> { ) -> Operand<'tcx> {
let literal = literal.into(); let literal = literal.into();
let constant = box Constant { span, user_ty: None, literal }; let constant = Box::new(Constant { span, user_ty: None, literal });
Operand::Constant(constant) Operand::Constant(constant)
} }

View file

@ -980,19 +980,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.local_decls[local].mutability = mutability; self.local_decls[local].mutability = mutability;
self.local_decls[local].source_info.scope = self.source_scope; self.local_decls[local].source_info.scope = self.source_scope;
self.local_decls[local].local_info = if let Some(kind) = self_binding { self.local_decls[local].local_info = if let Some(kind) = self_binding {
Some(box LocalInfo::User(ClearCrossCrate::Set( Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
BindingForm::ImplicitSelf(*kind), BindingForm::ImplicitSelf(*kind),
))) ))))
} else { } else {
let binding_mode = ty::BindingMode::BindByValue(mutability); let binding_mode = ty::BindingMode::BindByValue(mutability);
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var( Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
VarBindingForm { VarBindingForm {
binding_mode, binding_mode,
opt_ty_info, opt_ty_info,
opt_match_place: Some((Some(place), span)), opt_match_place: Some((Some(place), span)),
pat_span: span, pat_span: span,
}, },
)))) )))))
}; };
self.var_indices.insert(var, LocalsForNode::One(local)); self.var_indices.insert(var, LocalsForNode::One(local));
} }

View file

@ -2,7 +2,6 @@
//! //!
//! This crate also contains the match exhaustiveness and usefulness checking. //! This crate also contains the match exhaustiveness and usefulness checking.
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(control_flow_enum)] #![feature(control_flow_enum)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(bool_to_option)] #![feature(bool_to_option)]

View file

@ -132,7 +132,7 @@ impl<'tcx> Cx<'tcx> {
}, },
}; };
let expr = box [self.thir.exprs.push(expr)]; let expr = Box::new([self.thir.exprs.push(expr)]);
self.overloaded_place(hir_expr, adjustment.target, Some(call), expr, deref.span) self.overloaded_place(hir_expr, adjustment.target, Some(call), expr, deref.span)
} }
@ -190,7 +190,7 @@ impl<'tcx> Cx<'tcx> {
ExprKind::Call { ExprKind::Call {
ty: method.ty, ty: method.ty,
fun: self.thir.exprs.push(method), fun: self.thir.exprs.push(method),
args: box [self.mirror_expr(fun), tupled_args], args: Box::new([self.mirror_expr(fun), tupled_args]),
from_hir_call: true, from_hir_call: true,
fn_span: expr.span, fn_span: expr.span,
} }
@ -266,7 +266,7 @@ impl<'tcx> Cx<'tcx> {
if self.typeck_results().is_method_call(expr) { if self.typeck_results().is_method_call(expr) {
let lhs = self.mirror_expr(lhs); let lhs = self.mirror_expr(lhs);
let rhs = self.mirror_expr(rhs); let rhs = self.mirror_expr(rhs);
self.overloaded_operator(expr, box [lhs, rhs]) self.overloaded_operator(expr, Box::new([lhs, rhs]))
} else { } else {
ExprKind::AssignOp { ExprKind::AssignOp {
op: bin_op(op.node), op: bin_op(op.node),
@ -286,7 +286,7 @@ impl<'tcx> Cx<'tcx> {
if self.typeck_results().is_method_call(expr) { if self.typeck_results().is_method_call(expr) {
let lhs = self.mirror_expr(lhs); let lhs = self.mirror_expr(lhs);
let rhs = self.mirror_expr(rhs); let rhs = self.mirror_expr(rhs);
self.overloaded_operator(expr, box [lhs, rhs]) self.overloaded_operator(expr, Box::new([lhs, rhs]))
} else { } else {
// FIXME overflow // FIXME overflow
match op.node { match op.node {
@ -317,7 +317,7 @@ impl<'tcx> Cx<'tcx> {
if self.typeck_results().is_method_call(expr) { if self.typeck_results().is_method_call(expr) {
let lhs = self.mirror_expr(lhs); let lhs = self.mirror_expr(lhs);
let index = self.mirror_expr(index); let index = self.mirror_expr(index);
self.overloaded_place(expr, expr_ty, None, box [lhs, index], expr.span) self.overloaded_place(expr, expr_ty, None, Box::new([lhs, index]), expr.span)
} else { } else {
ExprKind::Index { lhs: self.mirror_expr(lhs), index: self.mirror_expr(index) } ExprKind::Index { lhs: self.mirror_expr(lhs), index: self.mirror_expr(index) }
} }
@ -326,7 +326,7 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::Unary(hir::UnOp::Deref, ref arg) => { hir::ExprKind::Unary(hir::UnOp::Deref, ref arg) => {
if self.typeck_results().is_method_call(expr) { if self.typeck_results().is_method_call(expr) {
let arg = self.mirror_expr(arg); let arg = self.mirror_expr(arg);
self.overloaded_place(expr, expr_ty, None, box [arg], expr.span) self.overloaded_place(expr, expr_ty, None, Box::new([arg]), expr.span)
} else { } else {
ExprKind::Deref { arg: self.mirror_expr(arg) } ExprKind::Deref { arg: self.mirror_expr(arg) }
} }
@ -335,7 +335,7 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::Unary(hir::UnOp::Not, ref arg) => { hir::ExprKind::Unary(hir::UnOp::Not, ref arg) => {
if self.typeck_results().is_method_call(expr) { if self.typeck_results().is_method_call(expr) {
let arg = self.mirror_expr(arg); let arg = self.mirror_expr(arg);
self.overloaded_operator(expr, box [arg]) self.overloaded_operator(expr, Box::new([arg]))
} else { } else {
ExprKind::Unary { op: UnOp::Not, arg: self.mirror_expr(arg) } ExprKind::Unary { op: UnOp::Not, arg: self.mirror_expr(arg) }
} }
@ -344,7 +344,7 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::Unary(hir::UnOp::Neg, ref arg) => { hir::ExprKind::Unary(hir::UnOp::Neg, ref arg) => {
if self.typeck_results().is_method_call(expr) { if self.typeck_results().is_method_call(expr) {
let arg = self.mirror_expr(arg); let arg = self.mirror_expr(arg);
self.overloaded_operator(expr, box [arg]) self.overloaded_operator(expr, Box::new([arg]))
} else if let hir::ExprKind::Lit(ref lit) = arg.kind { } else if let hir::ExprKind::Lit(ref lit) = arg.kind {
ExprKind::Literal { ExprKind::Literal {
literal: self.const_eval_literal(&lit.node, expr_ty, lit.span, true), literal: self.const_eval_literal(&lit.node, expr_ty, lit.span, true),
@ -914,7 +914,7 @@ impl<'tcx> Cx<'tcx> {
variant_index: adt_def.variant_index_with_ctor_id(def_id), variant_index: adt_def.variant_index_with_ctor_id(def_id),
substs, substs,
user_ty: user_provided_type, user_ty: user_provided_type,
fields: box [], fields: Box::new([]),
base: None, base: None,
})), })),
_ => bug!("unexpected ty: {:?}", ty), _ => bug!("unexpected ty: {:?}", ty),

View file

@ -600,7 +600,7 @@ crate trait PatternFolder<'tcx>: Sized {
impl<'tcx, T: PatternFoldable<'tcx>> PatternFoldable<'tcx> for Box<T> { impl<'tcx, T: PatternFoldable<'tcx>> PatternFoldable<'tcx> for Box<T> {
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
let content: T = (**self).fold_with(folder); let content: T = (**self).fold_with(folder);
box content Box::new(content)
} }
} }