Auto merge of #87781 - est31:remove_box, r=oli-obk

Remove box syntax from compiler and tools

Removes box syntax from the compiler and tools. In #49733, the future of box syntax is uncertain and the use in the compiler was listed as one of the reasons to keep it. Removal of box syntax [might affect the code generated](https://github.com/rust-lang/rust/pull/49646#issuecomment-379219615) and slow down the compiler so I'd recommend doing a perf run on this.
This commit is contained in:
bors 2021-08-18 10:43:27 +00:00
commit ba8cda2fa2
72 changed files with 549 additions and 505 deletions

View File

@ -8,7 +8,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/", html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
test(attr(deny(warnings))) test(attr(deny(warnings)))
)] )]
#![feature(box_syntax)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![cfg_attr(bootstrap, feature(const_fn_transmute))] #![cfg_attr(bootstrap, feature(const_fn_transmute))]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]

View File

@ -37,7 +37,7 @@ pub struct P<T: ?Sized> {
/// Construct a `P<T>` from a `T` value. /// Construct a `P<T>` from a `T` value.
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn P<T: 'static>(value: T) -> P<T> { pub fn P<T: 'static>(value: T) -> P<T> {
P { ptr: box value } P { ptr: Box::new(value) }
} }
impl<T: 'static> P<T> { impl<T: 'static> P<T> {

View File

@ -527,12 +527,12 @@ impl<'a> TraitDef<'a> {
tokens: None, tokens: None,
}, },
attrs: Vec::new(), attrs: Vec::new(),
kind: ast::AssocItemKind::TyAlias(box ast::TyAliasKind( kind: ast::AssocItemKind::TyAlias(Box::new(ast::TyAliasKind(
ast::Defaultness::Final, ast::Defaultness::Final,
Generics::default(), Generics::default(),
Vec::new(), Vec::new(),
Some(type_def.to_ty(cx, self.span, type_ident, generics)), Some(type_def.to_ty(cx, self.span, type_ident, generics)),
)), ))),
tokens: None, tokens: None,
}) })
}); });
@ -698,7 +698,7 @@ impl<'a> TraitDef<'a> {
self.span, self.span,
Ident::invalid(), Ident::invalid(),
a, a,
ast::ItemKind::Impl(box ast::ImplKind { ast::ItemKind::Impl(Box::new(ast::ImplKind {
unsafety, unsafety,
polarity: ast::ImplPolarity::Positive, polarity: ast::ImplPolarity::Positive,
defaultness: ast::Defaultness::Final, defaultness: ast::Defaultness::Final,
@ -707,7 +707,7 @@ impl<'a> TraitDef<'a> {
of_trait: opt_trait_ref, of_trait: opt_trait_ref,
self_ty: self_type, self_ty: self_type,
items: methods.into_iter().chain(associated_types).collect(), items: methods.into_iter().chain(associated_types).collect(),
}), })),
) )
} }
@ -940,7 +940,12 @@ impl<'a> MethodDef<'a> {
tokens: None, tokens: None,
}, },
ident: method_ident, ident: method_ident,
kind: ast::AssocItemKind::Fn(box ast::FnKind(def, sig, fn_generics, Some(body_block))), kind: ast::AssocItemKind::Fn(Box::new(ast::FnKind(
def,
sig,
fn_generics,
Some(body_block),
))),
tokens: None, tokens: None,
}) })
} }

View File

@ -179,7 +179,7 @@ fn inject_impl_of_structural_trait(
span, span,
Ident::invalid(), Ident::invalid(),
attrs, attrs,
ItemKind::Impl(box ImplKind { ItemKind::Impl(Box::new(ImplKind {
unsafety: ast::Unsafe::No, unsafety: ast::Unsafe::No,
polarity: ast::ImplPolarity::Positive, polarity: ast::ImplPolarity::Positive,
defaultness: ast::Defaultness::Final, defaultness: ast::Defaultness::Final,
@ -188,7 +188,7 @@ fn inject_impl_of_structural_trait(
of_trait: Some(trait_ref), of_trait: Some(trait_ref),
self_ty: self_type, self_ty: self_type,
items: Vec::new(), items: Vec::new(),
}), })),
); );
push(Annotatable::Item(newitem)); push(Annotatable::Item(newitem));

View File

@ -85,8 +85,12 @@ impl AllocFnFactory<'_, '_> {
let header = FnHeader { unsafety: Unsafe::Yes(self.span), ..FnHeader::default() }; let header = FnHeader { unsafety: Unsafe::Yes(self.span), ..FnHeader::default() };
let sig = FnSig { decl, header, span: self.span }; let sig = FnSig { decl, header, span: self.span };
let block = Some(self.cx.block_expr(output_expr)); let block = Some(self.cx.block_expr(output_expr));
let kind = let kind = ItemKind::Fn(Box::new(FnKind(
ItemKind::Fn(box FnKind(ast::Defaultness::Final, sig, Generics::default(), block)); ast::Defaultness::Final,
sig,
Generics::default(),
block,
)));
let item = self.cx.item( let item = self.cx.item(
self.span, self.span,
Ident::from_str_and_span(&self.kind.fn_name(method.name), self.span), Ident::from_str_and_span(&self.kind.fn_name(method.name), self.span),

View File

@ -3,7 +3,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(decl_macro)] #![feature(decl_macro)]

View File

@ -315,8 +315,12 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
let decl = ecx.fn_decl(vec![], ast::FnRetTy::Ty(main_ret_ty)); let decl = ecx.fn_decl(vec![], ast::FnRetTy::Ty(main_ret_ty));
let sig = ast::FnSig { decl, header: ast::FnHeader::default(), span: sp }; let sig = ast::FnSig { decl, header: ast::FnHeader::default(), span: sp };
let def = ast::Defaultness::Final; let def = ast::Defaultness::Final;
let main = let main = ast::ItemKind::Fn(Box::new(ast::FnKind(
ast::ItemKind::Fn(box ast::FnKind(def, sig, ast::Generics::default(), Some(main_body))); def,
sig,
ast::Generics::default(),
Some(main_body),
)));
// Honor the reexport_test_harness_main attribute // Honor the reexport_test_harness_main attribute
let main_id = match cx.reexport_test_harness_main { let main_id = match cx.reexport_test_harness_main {

View File

@ -1,4 +1,4 @@
#![feature(start, box_syntax, core_intrinsics, alloc_prelude, alloc_error_handler)] #![feature(start, core_intrinsics, alloc_prelude, alloc_error_handler)]
#![no_std] #![no_std]
extern crate alloc; extern crate alloc;

View File

@ -1,4 +1,4 @@
#![feature(no_core, lang_items, box_syntax, never_type, linkage, extern_types, thread_local)] #![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local)]
#![no_core] #![no_core]
#![allow(dead_code, non_camel_case_types)] #![allow(dead_code, non_camel_case_types)]

View File

@ -1,4 +1,4 @@
#![feature(start, box_syntax, core_intrinsics, lang_items)] #![feature(start, core_intrinsics, lang_items)]
#![no_std] #![no_std]
#[cfg_attr(unix, link(name = "c"))] #[cfg_attr(unix, link(name = "c"))]

View File

@ -105,7 +105,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
b: ty::Region<'tcx>, b: ty::Region<'tcx>,
) -> RelateResult<'tcx, ty::Region<'tcx>> { ) -> RelateResult<'tcx, ty::Region<'tcx>> {
debug!("{}.regions({:?}, {:?})", self.tag(), a, b); debug!("{}.regions({:?}, {:?})", self.tag(), a, b);
let origin = Subtype(box self.fields.trace.clone()); let origin = Subtype(Box::new(self.fields.trace.clone()));
self.fields self.fields
.infcx .infcx
.inner .inner

View File

@ -67,7 +67,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
) -> RelateResult<'tcx, ty::Region<'tcx>> { ) -> RelateResult<'tcx, ty::Region<'tcx>> {
debug!("{}.regions({:?}, {:?})", self.tag(), a, b); debug!("{}.regions({:?}, {:?})", self.tag(), a, b);
let origin = Subtype(box self.fields.trace.clone()); let origin = Subtype(Box::new(self.fields.trace.clone()));
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions( Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions(
self.tcx(), self.tcx(),
origin, origin,

View File

@ -67,7 +67,7 @@ impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> {
) -> RelateResult<'tcx, ty::Region<'tcx>> { ) -> RelateResult<'tcx, ty::Region<'tcx>> {
debug!("{}.regions({:?}, {:?})", self.tag(), a, b); debug!("{}.regions({:?}, {:?})", self.tag(), a, b);
let origin = Subtype(box self.fields.trace.clone()); let origin = Subtype(Box::new(self.fields.trace.clone()));
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions( Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions(
self.tcx(), self.tcx(),
origin, origin,

View File

@ -142,7 +142,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
// FIXME -- we have more fine-grained information available // FIXME -- we have more fine-grained information available
// from the "cause" field, we could perhaps give more tailored // from the "cause" field, we could perhaps give more tailored
// error messages. // error messages.
let origin = SubregionOrigin::Subtype(box self.fields.trace.clone()); let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
self.fields self.fields
.infcx .infcx
.inner .inner

View File

@ -15,7 +15,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(extend_one)] #![feature(extend_one)]
#![feature(iter_zip)] #![feature(iter_zip)]
#![feature(never_type)] #![feature(never_type)]

View File

@ -29,7 +29,6 @@
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]
#![feature(array_windows)] #![feature(array_windows)]
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(format_args_capture)] #![feature(format_args_capture)]
@ -246,7 +245,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
macro_rules! register_pass { macro_rules! register_pass {
($method:ident, $ty:ident, $constructor:expr) => { ($method:ident, $ty:ident, $constructor:expr) => {
store.register_lints(&$ty::get_lints()); store.register_lints(&$ty::get_lints());
store.$method(|| box $constructor); store.$method(|| Box::new($constructor));
}; };
} }
@ -478,13 +477,13 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
fn register_internals(store: &mut LintStore) { fn register_internals(store: &mut LintStore) {
store.register_lints(&LintPassImpl::get_lints()); store.register_lints(&LintPassImpl::get_lints());
store.register_early_pass(|| box LintPassImpl); store.register_early_pass(|| Box::new(LintPassImpl));
store.register_lints(&DefaultHashTypes::get_lints()); store.register_lints(&DefaultHashTypes::get_lints());
store.register_late_pass(|| box DefaultHashTypes); store.register_late_pass(|| Box::new(DefaultHashTypes));
store.register_lints(&ExistingDocKeyword::get_lints()); store.register_lints(&ExistingDocKeyword::get_lints());
store.register_late_pass(|| box ExistingDocKeyword); store.register_late_pass(|| Box::new(ExistingDocKeyword));
store.register_lints(&TyTyKind::get_lints()); store.register_lints(&TyTyKind::get_lints());
store.register_late_pass(|| box TyTyKind); store.register_late_pass(|| Box::new(TyTyKind));
store.register_group( store.register_group(
false, false,
"rustc::internal", "rustc::internal",

View File

@ -29,7 +29,6 @@
#![feature(backtrace)] #![feature(backtrace)]
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(discriminant_kind)] #![feature(discriminant_kind)]
#![feature(never_type)] #![feature(never_type)]

View File

@ -2061,11 +2061,11 @@ impl<'tcx> Operand<'tcx> {
span: Span, span: Span,
) -> Self { ) -> Self {
let ty = tcx.type_of(def_id).subst(tcx, substs); let ty = tcx.type_of(def_id).subst(tcx, substs);
Operand::Constant(box Constant { Operand::Constant(Box::new(Constant {
span, span,
user_ty: None, user_ty: None,
literal: ConstantKind::Ty(ty::Const::zero_sized(tcx, ty)), literal: ConstantKind::Ty(ty::Const::zero_sized(tcx, ty)),
}) }))
} }
pub fn is_move(&self) -> bool { pub fn is_move(&self) -> bool {
@ -2092,11 +2092,11 @@ impl<'tcx> Operand<'tcx> {
}; };
scalar_size == type_size scalar_size == type_size
}); });
Operand::Constant(box Constant { Operand::Constant(Box::new(Constant {
span, span,
user_ty: None, user_ty: None,
literal: ConstantKind::Val(ConstValue::Scalar(val), ty), literal: ConstantKind::Val(ConstValue::Scalar(val), ty),
}) }))
} }
pub fn to_copy(&self) -> Self { pub fn to_copy(&self) -> Self {

View File

@ -182,10 +182,10 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
Len(place) => Len(place.fold_with(folder)), Len(place) => Len(place.fold_with(folder)),
Cast(kind, op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)), Cast(kind, op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)),
BinaryOp(op, box (rhs, lhs)) => { BinaryOp(op, box (rhs, lhs)) => {
BinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder))) BinaryOp(op, Box::new((rhs.fold_with(folder), lhs.fold_with(folder))))
} }
CheckedBinaryOp(op, box (rhs, lhs)) => { CheckedBinaryOp(op, box (rhs, lhs)) => {
CheckedBinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder))) CheckedBinaryOp(op, Box::new((rhs.fold_with(folder), lhs.fold_with(folder))))
} }
UnaryOp(op, val) => UnaryOp(op, val.fold_with(folder)), UnaryOp(op, val) => UnaryOp(op, val.fold_with(folder)),
Discriminant(place) => Discriminant(place.fold_with(folder)), Discriminant(place) => Discriminant(place.fold_with(folder)),

View File

@ -464,12 +464,12 @@ fn do_mir_borrowck<'a, 'tcx>(
let body_with_facts = if return_body_with_facts { let body_with_facts = if return_body_with_facts {
let output_facts = mbcx.polonius_output.expect("Polonius output was not computed"); let output_facts = mbcx.polonius_output.expect("Polonius output was not computed");
Some(box BodyWithBorrowckFacts { Some(Box::new(BodyWithBorrowckFacts {
body: body_owned, body: body_owned,
input_facts: *polonius_input.expect("Polonius input facts were not generated"), input_facts: *polonius_input.expect("Polonius input facts were not generated"),
output_facts, output_facts,
location_table: location_table_owned, location_table: location_table_owned,
}) }))
} else { } else {
None None
}; };

View File

@ -11,7 +11,6 @@ Rust MIR: a lowered representation of Rust.
#![cfg_attr(bootstrap, feature(bindings_after_at))] #![cfg_attr(bootstrap, feature(bindings_after_at))]
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(decl_macro)] #![feature(decl_macro)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]

View File

@ -174,7 +174,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
0, 0,
Statement { Statement {
source_info, source_info,
kind: StatementKind::Retag(RetagKind::Raw, box (dropee_ptr)), kind: StatementKind::Retag(RetagKind::Raw, Box::new(dropee_ptr)),
}, },
); );
} }
@ -388,10 +388,10 @@ impl CloneShimBuilder<'tcx> {
fn copy_shim(&mut self) { fn copy_shim(&mut self) {
let rcvr = self.tcx.mk_place_deref(Place::from(Local::new(1 + 0))); let rcvr = self.tcx.mk_place_deref(Place::from(Local::new(1 + 0)));
let ret_statement = self.make_statement(StatementKind::Assign(box ( let ret_statement = self.make_statement(StatementKind::Assign(Box::new((
Place::return_place(), Place::return_place(),
Rvalue::Use(Operand::Copy(rcvr)), Rvalue::Use(Operand::Copy(rcvr)),
))); ))));
self.block(vec![ret_statement], TerminatorKind::Return, false); self.block(vec![ret_statement], TerminatorKind::Return, false);
} }
@ -418,11 +418,11 @@ impl CloneShimBuilder<'tcx> {
// `func == Clone::clone(&ty) -> ty` // `func == Clone::clone(&ty) -> ty`
let func_ty = tcx.mk_fn_def(self.def_id, substs); let func_ty = tcx.mk_fn_def(self.def_id, substs);
let func = Operand::Constant(box Constant { let func = Operand::Constant(Box::new(Constant {
span: self.span, span: self.span,
user_ty: None, user_ty: None,
literal: ty::Const::zero_sized(tcx, func_ty).into(), literal: ty::Const::zero_sized(tcx, func_ty).into(),
}); }));
let ref_loc = self.make_place( let ref_loc = self.make_place(
Mutability::Not, Mutability::Not,
@ -430,10 +430,10 @@ impl CloneShimBuilder<'tcx> {
); );
// `let ref_loc: &ty = &src;` // `let ref_loc: &ty = &src;`
let statement = self.make_statement(StatementKind::Assign(box ( let statement = self.make_statement(StatementKind::Assign(Box::new((
ref_loc, ref_loc,
Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src), Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src),
))); ))));
// `let loc = Clone::clone(ref_loc);` // `let loc = Clone::clone(ref_loc);`
self.block( self.block(
@ -461,10 +461,10 @@ impl CloneShimBuilder<'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let cond = self.make_place(Mutability::Mut, tcx.types.bool); let cond = self.make_place(Mutability::Mut, tcx.types.bool);
let compute_cond = self.make_statement(StatementKind::Assign(box ( let compute_cond = self.make_statement(StatementKind::Assign(Box::new((
cond, cond,
Rvalue::BinaryOp(BinOp::Ne, box (Operand::Copy(end), Operand::Copy(beg))), Rvalue::BinaryOp(BinOp::Ne, Box::new((Operand::Copy(end), Operand::Copy(beg)))),
))); ))));
// `if end != beg { goto loop_body; } else { goto loop_end; }` // `if end != beg { goto loop_body; } else { goto loop_end; }`
self.block( self.block(
@ -475,11 +475,11 @@ impl CloneShimBuilder<'tcx> {
} }
fn make_usize(&self, value: u64) -> Box<Constant<'tcx>> { fn make_usize(&self, value: u64) -> Box<Constant<'tcx>> {
box Constant { Box::new(Constant {
span: self.span, span: self.span,
user_ty: None, user_ty: None,
literal: ty::Const::from_usize(self.tcx, value).into(), literal: ty::Const::from_usize(self.tcx, value).into(),
} })
} }
fn array_shim( fn array_shim(
@ -500,18 +500,18 @@ impl CloneShimBuilder<'tcx> {
// `let end = len;` // `let end = len;`
// `goto #1;` // `goto #1;`
let inits = vec![ let inits = vec![
self.make_statement(StatementKind::Assign(box ( self.make_statement(StatementKind::Assign(Box::new((
Place::from(beg), Place::from(beg),
Rvalue::Use(Operand::Constant(self.make_usize(0))), Rvalue::Use(Operand::Constant(self.make_usize(0))),
))), )))),
self.make_statement(StatementKind::Assign(box ( self.make_statement(StatementKind::Assign(Box::new((
end, end,
Rvalue::Use(Operand::Constant(box Constant { Rvalue::Use(Operand::Constant(Box::new(Constant {
span: self.span, span: self.span,
user_ty: None, user_ty: None,
literal: len.into(), literal: len.into(),
})), }))),
))), )))),
]; ];
self.block(inits, TerminatorKind::Goto { target: BasicBlock::new(1) }, false); self.block(inits, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
@ -532,13 +532,13 @@ impl CloneShimBuilder<'tcx> {
// BB #3 // BB #3
// `beg = beg + 1;` // `beg = beg + 1;`
// `goto #1`; // `goto #1`;
let statements = vec![self.make_statement(StatementKind::Assign(box ( let statements = vec![self.make_statement(StatementKind::Assign(Box::new((
Place::from(beg), Place::from(beg),
Rvalue::BinaryOp( Rvalue::BinaryOp(
BinOp::Add, BinOp::Add,
box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))), Box::new((Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1)))),
), ),
)))]; ))))];
self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false); self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
// BB #4 // BB #4
@ -551,10 +551,10 @@ impl CloneShimBuilder<'tcx> {
// goto #6; // goto #6;
let end = beg; let end = beg;
let beg = self.local_decls.push(LocalDecl::new(tcx.types.usize, span)); let beg = self.local_decls.push(LocalDecl::new(tcx.types.usize, span));
let init = self.make_statement(StatementKind::Assign(box ( let init = self.make_statement(StatementKind::Assign(Box::new((
Place::from(beg), Place::from(beg),
Rvalue::Use(Operand::Constant(self.make_usize(0))), Rvalue::Use(Operand::Constant(self.make_usize(0))),
))); ))));
self.block(vec![init], TerminatorKind::Goto { target: BasicBlock::new(6) }, true); self.block(vec![init], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
// BB #6 (cleanup): loop { // BB #6 (cleanup): loop {
@ -585,13 +585,13 @@ impl CloneShimBuilder<'tcx> {
// BB #8 (cleanup) // BB #8 (cleanup)
// `beg = beg + 1;` // `beg = beg + 1;`
// `goto #6;` // `goto #6;`
let statement = self.make_statement(StatementKind::Assign(box ( let statement = self.make_statement(StatementKind::Assign(Box::new((
Place::from(beg), Place::from(beg),
Rvalue::BinaryOp( Rvalue::BinaryOp(
BinOp::Add, BinOp::Add,
box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))), Box::new((Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1)))),
), ),
))); ))));
self.block(vec![statement], TerminatorKind::Goto { target: BasicBlock::new(6) }, true); self.block(vec![statement], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
// BB #9 (resume) // BB #9 (resume)
@ -748,10 +748,10 @@ fn build_call_shim<'tcx>(
let borrow_kind = BorrowKind::Mut { allow_two_phase_borrow: false }; let borrow_kind = BorrowKind::Mut { allow_two_phase_borrow: false };
statements.push(Statement { statements.push(Statement {
source_info, source_info,
kind: StatementKind::Assign(box ( kind: StatementKind::Assign(Box::new((
Place::from(ref_rcvr), Place::from(ref_rcvr),
Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_place()), Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_place()),
)), ))),
}); });
Operand::Move(Place::from(ref_rcvr)) Operand::Move(Place::from(ref_rcvr))
} }
@ -765,11 +765,11 @@ fn build_call_shim<'tcx>(
CallKind::Direct(def_id) => { CallKind::Direct(def_id) => {
let ty = tcx.type_of(def_id); let ty = tcx.type_of(def_id);
( (
Operand::Constant(box Constant { Operand::Constant(Box::new(Constant {
span, span,
user_ty: None, user_ty: None,
literal: ty::Const::zero_sized(tcx, ty).into(), literal: ty::Const::zero_sized(tcx, ty).into(),
}), })),
rcvr.into_iter().collect::<Vec<_>>(), rcvr.into_iter().collect::<Vec<_>>(),
) )
} }

View File

@ -105,7 +105,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
0..0, 0..0,
places.map(|place| Statement { places.map(|place| Statement {
source_info, source_info,
kind: StatementKind::Retag(RetagKind::FnEntry, box (place)), kind: StatementKind::Retag(RetagKind::FnEntry, Box::new(place)),
}), }),
); );
} }
@ -137,7 +137,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
0, 0,
Statement { Statement {
source_info, source_info,
kind: StatementKind::Retag(RetagKind::Default, box (dest_place)), kind: StatementKind::Retag(RetagKind::Default, Box::new(dest_place)),
}, },
); );
} }
@ -175,7 +175,10 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
let source_info = block_data.statements[i].source_info; let source_info = block_data.statements[i].source_info;
block_data.statements.insert( block_data.statements.insert(
i + 1, i + 1,
Statement { source_info, kind: StatementKind::Retag(retag_kind, box (place)) }, Statement {
source_info,
kind: StatementKind::Retag(retag_kind, Box::new(place)),
},
); );
} }
} }

View File

@ -491,15 +491,19 @@ fn bcb_filtered_successors<'a, 'tcx>(
term_kind: &'tcx TerminatorKind<'tcx>, term_kind: &'tcx TerminatorKind<'tcx>,
) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a> { ) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a> {
let mut successors = term_kind.successors(); let mut successors = term_kind.successors();
box match &term_kind { Box::new(
// SwitchInt successors are never unwind, and all of them should be traversed. match &term_kind {
TerminatorKind::SwitchInt { .. } => successors, // SwitchInt successors are never unwind, and all of them should be traversed.
// For all other kinds, return only the first successor, if any, and ignore unwinds. TerminatorKind::SwitchInt { .. } => successors,
// NOTE: `chain(&[])` is required to coerce the `option::iter` (from // For all other kinds, return only the first successor, if any, and ignore unwinds.
// `next().into_iter()`) into the `mir::Successors` aliased type. // NOTE: `chain(&[])` is required to coerce the `option::iter` (from
_ => successors.next().into_iter().chain(&[]), // `next().into_iter()`) into the `mir::Successors` aliased type.
} _ => successors.next().into_iter().chain(&[]),
.filter(move |&&successor| body[successor].terminator().kind != TerminatorKind::Unreachable) }
.filter(move |&&successor| {
body[successor].terminator().kind != TerminatorKind::Unreachable
}),
)
} }
/// Maintains separate worklists for each loop in the BasicCoverageBlock CFG, plus one for the /// Maintains separate worklists for each loop in the BasicCoverageBlock CFG, plus one for the

View File

@ -478,10 +478,10 @@ fn inject_statement(
let source_info = data.terminator().source_info; let source_info = data.terminator().source_info;
let statement = Statement { let statement = Statement {
source_info, source_info,
kind: StatementKind::Coverage(box Coverage { kind: StatementKind::Coverage(Box::new(Coverage {
kind: counter_kind, kind: counter_kind,
code_region: some_code_region, code_region: some_code_region,
}), })),
}; };
data.statements.insert(0, statement); data.statements.insert(0, statement);
} }
@ -495,7 +495,7 @@ fn inject_intermediate_expression(mir_body: &mut mir::Body<'tcx>, expression: Co
let source_info = data.terminator().source_info; let source_info = data.terminator().source_info;
let statement = Statement { let statement = Statement {
source_info, source_info,
kind: StatementKind::Coverage(box Coverage { kind: expression, code_region: None }), kind: StatementKind::Coverage(Box::new(Coverage { kind: expression, code_region: None })),
}; };
data.statements.push(statement); data.statements.push(statement);
} }

View File

@ -44,11 +44,11 @@ const TEMP_BLOCK: BasicBlock = BasicBlock::MAX;
fn dummy_ty() -> &'static TyS<'static> { fn dummy_ty() -> &'static TyS<'static> {
thread_local! { thread_local! {
static DUMMY_TYS: &'static TyS<'static> = Box::leak(box TyS::make_for_test( static DUMMY_TYS: &'static TyS<'static> = Box::leak(Box::new(TyS::make_for_test(
ty::Bool, ty::Bool,
TypeFlags::empty(), TypeFlags::empty(),
DebruijnIndex::from_usize(0), DebruijnIndex::from_usize(0),
)); )));
} }
&DUMMY_TYS.with(|tys| *tys) &DUMMY_TYS.with(|tys| *tys)

View File

@ -96,14 +96,14 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
opt_to_apply.infos[0].first_switch_info.discr_used_in_switch; opt_to_apply.infos[0].first_switch_info.discr_used_in_switch;
let not_equal_rvalue = Rvalue::BinaryOp( let not_equal_rvalue = Rvalue::BinaryOp(
not_equal, not_equal,
box ( Box::new((
Operand::Copy(Place::from(second_discriminant_temp)), Operand::Copy(Place::from(second_discriminant_temp)),
Operand::Copy(first_descriminant_place), Operand::Copy(first_descriminant_place),
), )),
); );
patch.add_statement( patch.add_statement(
end_of_block_location, end_of_block_location,
StatementKind::Assign(box (Place::from(not_equal_temp), not_equal_rvalue)), StatementKind::Assign(Box::new((Place::from(not_equal_temp), not_equal_rvalue))),
); );
let new_targets = opt_to_apply let new_targets = opt_to_apply

View File

@ -409,7 +409,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported"); assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported");
let assign = Statement { let assign = Statement {
kind: StatementKind::Assign(box (place, Rvalue::Use(value.clone()))), kind: StatementKind::Assign(Box::new((place, Rvalue::Use(value.clone())))),
source_info: terminator.source_info, source_info: terminator.source_info,
}; };

View File

@ -274,7 +274,7 @@ impl TransformVisitor<'tcx> {
Statement { Statement {
source_info, source_info,
kind: StatementKind::SetDiscriminant { kind: StatementKind::SetDiscriminant {
place: box self_place, place: Box::new(self_place),
variant_index: state_disc, variant_index: state_disc,
}, },
} }
@ -289,7 +289,7 @@ impl TransformVisitor<'tcx> {
let self_place = Place::from(SELF_ARG); let self_place = Place::from(SELF_ARG);
let assign = Statement { let assign = Statement {
source_info: SourceInfo::outermost(body.span), source_info: SourceInfo::outermost(body.span),
kind: StatementKind::Assign(box (temp, Rvalue::Discriminant(self_place))), kind: StatementKind::Assign(Box::new((temp, Rvalue::Discriminant(self_place)))),
}; };
(assign, temp) (assign, temp)
} }
@ -954,7 +954,7 @@ fn create_generator_drop_shim<'tcx>(
0, 0,
Statement { Statement {
source_info, source_info,
kind: StatementKind::Retag(RetagKind::Raw, box Place::from(SELF_ARG)), kind: StatementKind::Retag(RetagKind::Raw, Box::new(Place::from(SELF_ARG))),
}, },
) )
} }
@ -984,11 +984,11 @@ fn insert_panic_block<'tcx>(
) -> BasicBlock { ) -> BasicBlock {
let assert_block = BasicBlock::new(body.basic_blocks().len()); let assert_block = BasicBlock::new(body.basic_blocks().len());
let term = TerminatorKind::Assert { let term = TerminatorKind::Assert {
cond: Operand::Constant(box Constant { cond: Operand::Constant(Box::new(Constant {
span: body.span, span: body.span,
user_ty: None, user_ty: None,
literal: ty::Const::from_bool(tcx, false).into(), literal: ty::Const::from_bool(tcx, false).into(),
}), })),
expected: true, expected: true,
msg: message, msg: message,
target: assert_block, target: assert_block,
@ -1207,10 +1207,10 @@ fn create_cases<'tcx>(
let resume_arg = Local::new(2); // 0 = return, 1 = self let resume_arg = Local::new(2); // 0 = return, 1 = self
statements.push(Statement { statements.push(Statement {
source_info, source_info,
kind: StatementKind::Assign(box ( kind: StatementKind::Assign(Box::new((
point.resume_arg, point.resume_arg,
Rvalue::Use(Operand::Move(resume_arg.into())), Rvalue::Use(Operand::Move(resume_arg.into())),
)), ))),
}); });
} }
@ -1287,10 +1287,10 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
0, 0,
Statement { Statement {
source_info, source_info,
kind: StatementKind::Assign(box ( kind: StatementKind::Assign(Box::new((
new_resume_local.into(), new_resume_local.into(),
Rvalue::Use(Operand::Move(resume_local.into())), Rvalue::Use(Operand::Move(resume_local.into())),
)), ))),
}, },
); );

View File

@ -520,7 +520,7 @@ impl Inliner<'tcx> {
let temp = Place::from(self.new_call_temp(caller_body, &callsite, dest_ty)); let temp = Place::from(self.new_call_temp(caller_body, &callsite, dest_ty));
caller_body[callsite.block].statements.push(Statement { caller_body[callsite.block].statements.push(Statement {
source_info: callsite.source_info, source_info: callsite.source_info,
kind: StatementKind::Assign(box (temp, dest)), kind: StatementKind::Assign(Box::new((temp, dest))),
}); });
self.tcx.mk_place_deref(temp) self.tcx.mk_place_deref(temp)
} else { } else {
@ -729,7 +729,7 @@ impl Inliner<'tcx> {
let local = self.new_call_temp(caller_body, callsite, arg_ty); let local = self.new_call_temp(caller_body, callsite, arg_ty);
caller_body[callsite.block].statements.push(Statement { caller_body[callsite.block].statements.push(Statement {
source_info: callsite.source_info, source_info: callsite.source_info,
kind: StatementKind::Assign(box (Place::from(local), Rvalue::Use(arg))), kind: StatementKind::Assign(Box::new((Place::from(local), Rvalue::Use(arg)))),
}); });
local local
} }

View File

@ -124,7 +124,7 @@ impl<'tcx, 'a> InstCombineContext<'tcx, 'a> {
let constant = let constant =
Constant { span: source_info.span, literal: len.into(), user_ty: None }; Constant { span: source_info.span, literal: len.into(), user_ty: None };
*rvalue = Rvalue::Use(Operand::Constant(box constant)); *rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
} }
} }
} }

View File

@ -29,14 +29,14 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
if let Some((destination, target)) = *destination { if let Some((destination, target)) = *destination {
block.statements.push(Statement { block.statements.push(Statement {
source_info: terminator.source_info, source_info: terminator.source_info,
kind: StatementKind::Assign(box ( kind: StatementKind::Assign(Box::new((
destination, destination,
Rvalue::Use(Operand::Constant(box Constant { Rvalue::Use(Operand::Constant(Box::new(Constant {
span: terminator.source_info.span, span: terminator.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(),
})), }))),
)), ))),
}); });
terminator.kind = TerminatorKind::Goto { target }; terminator.kind = TerminatorKind::Goto { target };
} }
@ -46,13 +46,13 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
let mut args = args.drain(..); let mut args = args.drain(..);
block.statements.push(Statement { block.statements.push(Statement {
source_info: terminator.source_info, source_info: terminator.source_info,
kind: StatementKind::CopyNonOverlapping( kind: StatementKind::CopyNonOverlapping(Box::new(
box rustc_middle::mir::CopyNonOverlapping { rustc_middle::mir::CopyNonOverlapping {
src: args.next().unwrap(), src: args.next().unwrap(),
dst: args.next().unwrap(), dst: args.next().unwrap(),
count: args.next().unwrap(), count: args.next().unwrap(),
}, },
), )),
}); });
assert_eq!( assert_eq!(
args.next(), args.next(),
@ -79,10 +79,10 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
}; };
block.statements.push(Statement { block.statements.push(Statement {
source_info: terminator.source_info, source_info: terminator.source_info,
kind: StatementKind::Assign(box ( kind: StatementKind::Assign(Box::new((
destination, destination,
Rvalue::BinaryOp(bin_op, box (lhs, rhs)), Rvalue::BinaryOp(bin_op, Box::new((lhs, rhs))),
)), ))),
}); });
terminator.kind = TerminatorKind::Goto { target }; terminator.kind = TerminatorKind::Goto { target };
} }
@ -97,10 +97,10 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
let tp_ty = substs.type_at(0); let tp_ty = substs.type_at(0);
block.statements.push(Statement { block.statements.push(Statement {
source_info: terminator.source_info, source_info: terminator.source_info,
kind: StatementKind::Assign(box ( kind: StatementKind::Assign(Box::new((
destination, destination,
Rvalue::NullaryOp(NullOp::SizeOf, tp_ty), Rvalue::NullaryOp(NullOp::SizeOf, tp_ty),
)), ))),
}); });
terminator.kind = TerminatorKind::Goto { target }; terminator.kind = TerminatorKind::Goto { target };
} }
@ -112,10 +112,10 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
let arg = tcx.mk_place_deref(arg); let arg = tcx.mk_place_deref(arg);
block.statements.push(Statement { block.statements.push(Statement {
source_info: terminator.source_info, source_info: terminator.source_info,
kind: StatementKind::Assign(box ( kind: StatementKind::Assign(Box::new((
destination, destination,
Rvalue::Discriminant(arg), Rvalue::Discriminant(arg),
)), ))),
}); });
terminator.kind = TerminatorKind::Goto { target }; terminator.kind = TerminatorKind::Goto { target };
} }

View File

@ -140,11 +140,11 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
let op = if f_b { BinOp::Eq } else { BinOp::Ne }; let op = if f_b { BinOp::Eq } else { BinOp::Ne };
let rhs = Rvalue::BinaryOp( let rhs = Rvalue::BinaryOp(
op, op,
box (Operand::Copy(Place::from(discr_local)), const_cmp), Box::new((Operand::Copy(Place::from(discr_local)), const_cmp)),
); );
Statement { Statement {
source_info: f.source_info, source_info: f.source_info,
kind: StatementKind::Assign(box (*lhs, rhs)), kind: StatementKind::Assign(Box::new((*lhs, rhs))),
} }
} }
} }
@ -157,7 +157,10 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
.push(Statement { source_info, kind: StatementKind::StorageLive(discr_local) }); .push(Statement { source_info, kind: StatementKind::StorageLive(discr_local) });
from.statements.push(Statement { from.statements.push(Statement {
source_info, source_info,
kind: StatementKind::Assign(box (Place::from(discr_local), Rvalue::Use(discr))), kind: StatementKind::Assign(Box::new((
Place::from(discr_local),
Rvalue::Use(discr),
))),
}); });
from.statements.extend(new_stmts); from.statements.extend(new_stmts);
from.statements from.statements

View File

@ -719,7 +719,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
let data = &mut self.promoted[last]; let data = &mut self.promoted[last];
data.statements.push(Statement { data.statements.push(Statement {
source_info: SourceInfo::outermost(span), source_info: SourceInfo::outermost(span),
kind: StatementKind::Assign(box (Place::from(dest), rvalue)), kind: StatementKind::Assign(Box::new((Place::from(dest), rvalue))),
}); });
} }
@ -774,11 +774,11 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
if self.keep_original { if self.keep_original {
rhs.clone() rhs.clone()
} else { } else {
let unit = Rvalue::Use(Operand::Constant(box Constant { let unit = Rvalue::Use(Operand::Constant(Box::new(Constant {
span: statement.source_info.span, span: statement.source_info.span,
user_ty: None, user_ty: None,
literal: ty::Const::zero_sized(self.tcx, self.tcx.types.unit).into(), literal: ty::Const::zero_sized(self.tcx, self.tcx.types.unit).into(),
})); })));
mem::replace(rhs, unit) mem::replace(rhs, unit)
}, },
statement.source_info, statement.source_info,

View File

@ -382,10 +382,10 @@ fn save_unreachable_coverage(
for (source_info, code_region) in dropped_coverage { for (source_info, code_region) in dropped_coverage {
start_block.statements.push(Statement { start_block.statements.push(Statement {
source_info, source_info,
kind: StatementKind::Coverage(box Coverage { kind: StatementKind::Coverage(Box::new(Coverage {
kind: CoverageKind::Unreachable, kind: CoverageKind::Unreachable,
code_region: Some(code_region), code_region: Some(code_region),
}), })),
}) })
} }
} }

View File

@ -420,10 +420,10 @@ impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity {
let stmt = &mut bb.statements[opt_info.stmt_to_overwrite]; let stmt = &mut bb.statements[opt_info.stmt_to_overwrite];
stmt.source_info = opt_info.source_info; stmt.source_info = opt_info.source_info;
stmt.kind = StatementKind::Assign(box ( stmt.kind = StatementKind::Assign(Box::new((
opt_info.local_0.into(), opt_info.local_0.into(),
Rvalue::Use(Operand::Move(opt_info.local_1.into())), Rvalue::Use(Operand::Move(opt_info.local_1.into())),
)); )));
bb.statements.retain(|stmt| stmt.kind != StatementKind::Nop); bb.statements.retain(|stmt| stmt.kind != StatementKind::Nop);

View File

@ -25,7 +25,7 @@ pub fn expand_aggregate<'tcx>(
AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => { AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => {
if adt_def.is_enum() { if adt_def.is_enum() {
set_discriminant = Some(Statement { set_discriminant = Some(Statement {
kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index }, kind: StatementKind::SetDiscriminant { place: Box::new(lhs), variant_index },
source_info, source_info,
}); });
lhs = tcx.mk_place_downcast(lhs, adt_def, variant_index); lhs = tcx.mk_place_downcast(lhs, adt_def, variant_index);
@ -37,7 +37,7 @@ pub fn expand_aggregate<'tcx>(
// variant 0 (Unresumed). // variant 0 (Unresumed).
let variant_index = VariantIdx::new(0); let variant_index = VariantIdx::new(0);
set_discriminant = Some(Statement { set_discriminant = Some(Statement {
kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index }, kind: StatementKind::SetDiscriminant { place: Box::new(lhs), variant_index },
source_info, source_info,
}); });
@ -66,7 +66,10 @@ pub fn expand_aggregate<'tcx>(
let field = Field::new(active_field_index.unwrap_or(i)); let field = Field::new(active_field_index.unwrap_or(i));
tcx.mk_place_field(lhs, field, ty) tcx.mk_place_field(lhs, field, ty)
}; };
Statement { source_info, kind: StatementKind::Assign(box (lhs_field, Rvalue::Use(op))) } Statement {
source_info,
kind: StatementKind::Assign(Box::new((lhs_field, Rvalue::Use(op)))),
}
}) })
.chain(set_discriminant) .chain(set_discriminant)
} }

View File

@ -680,12 +680,12 @@ where
let (ptr_next, cur_next) = if ptr_based { let (ptr_next, cur_next) = if ptr_based {
( (
Rvalue::Use(copy(cur.into())), Rvalue::Use(copy(cur.into())),
Rvalue::BinaryOp(BinOp::Offset, box (move_(cur.into()), one)), Rvalue::BinaryOp(BinOp::Offset, Box::new((move_(cur.into()), one))),
) )
} else { } else {
( (
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)), Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
Rvalue::BinaryOp(BinOp::Add, box (move_(cur.into()), one)), Rvalue::BinaryOp(BinOp::Add, Box::new((move_(cur.into()), one))),
) )
}; };
@ -703,7 +703,10 @@ where
let loop_block = BasicBlockData { let loop_block = BasicBlockData {
statements: vec![self.assign( statements: vec![self.assign(
can_go, can_go,
Rvalue::BinaryOp(BinOp::Eq, box (copy(Place::from(cur)), copy(length_or_end))), Rvalue::BinaryOp(
BinOp::Eq,
Box::new((copy(Place::from(cur)), copy(length_or_end))),
),
)], )],
is_cleanup: unwind.is_cleanup(), is_cleanup: unwind.is_cleanup(),
terminator: Some(Terminator { terminator: Some(Terminator {
@ -821,7 +824,7 @@ where
length_or_end, length_or_end,
Rvalue::BinaryOp( Rvalue::BinaryOp(
BinOp::Offset, BinOp::Offset,
box (Operand::Copy(cur), Operand::Move(length)), Box::new((Operand::Copy(cur), Operand::Move(length))),
), ),
), ),
] ]
@ -1032,14 +1035,17 @@ where
} }
fn constant_usize(&self, val: u16) -> Operand<'tcx> { fn constant_usize(&self, val: u16) -> Operand<'tcx> {
Operand::Constant(box Constant { Operand::Constant(Box::new(Constant {
span: self.source_info.span, span: self.source_info.span,
user_ty: None, user_ty: None,
literal: ty::Const::from_usize(self.tcx(), val.into()).into(), literal: ty::Const::from_usize(self.tcx(), val.into()).into(),
}) }))
} }
fn assign(&self, lhs: Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> { fn assign(&self, lhs: Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> {
Statement { source_info: self.source_info, kind: StatementKind::Assign(box (lhs, rhs)) } Statement {
source_info: self.source_info,
kind: StatementKind::Assign(Box::new((lhs, rhs))),
}
} }
} }

View File

@ -112,7 +112,7 @@ impl<'tcx> MirPatch<'tcx> {
} }
pub fn add_assign(&mut self, loc: Location, place: Place<'tcx>, rv: Rvalue<'tcx>) { pub fn add_assign(&mut self, loc: Location, place: Place<'tcx>, rv: Rvalue<'tcx>) {
self.add_statement(loc, StatementKind::Assign(box (place, rv))); self.add_statement(loc, StatementKind::Assign(Box::new((place, rv))));
} }
pub fn apply(self, body: &mut Body<'tcx>) { pub fn apply(self, body: &mut Body<'tcx>) {

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)
} }
} }

View File

@ -3,7 +3,6 @@
#![feature(array_windows)] #![feature(array_windows)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![cfg_attr(bootstrap, feature(bindings_after_at))] #![cfg_attr(bootstrap, feature(bindings_after_at))]
#![feature(box_syntax)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![recursion_limit = "256"] #![recursion_limit = "256"]

View File

@ -221,7 +221,7 @@ impl<'a> Parser<'a> {
} else if self.check_fn_front_matter(def_final) { } else if self.check_fn_front_matter(def_final) {
// FUNCTION ITEM // FUNCTION ITEM
let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?; let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?;
(ident, ItemKind::Fn(box FnKind(def(), sig, generics, body))) (ident, ItemKind::Fn(Box::new(FnKind(def(), sig, generics, body))))
} else if self.eat_keyword(kw::Extern) { } else if self.eat_keyword(kw::Extern) {
if self.eat_keyword(kw::Crate) { if self.eat_keyword(kw::Crate) {
// EXTERN CRATE // EXTERN CRATE
@ -548,7 +548,7 @@ impl<'a> Parser<'a> {
}; };
let trait_ref = TraitRef { path, ref_id: ty_first.id }; let trait_ref = TraitRef { path, ref_id: ty_first.id };
ItemKind::Impl(box ImplKind { ItemKind::Impl(Box::new(ImplKind {
unsafety, unsafety,
polarity, polarity,
defaultness, defaultness,
@ -557,11 +557,11 @@ impl<'a> Parser<'a> {
of_trait: Some(trait_ref), of_trait: Some(trait_ref),
self_ty: ty_second, self_ty: ty_second,
items: impl_items, items: impl_items,
}) }))
} }
None => { None => {
// impl Type // impl Type
ItemKind::Impl(box ImplKind { ItemKind::Impl(Box::new(ImplKind {
unsafety, unsafety,
polarity, polarity,
defaultness, defaultness,
@ -570,7 +570,7 @@ impl<'a> Parser<'a> {
of_trait: None, of_trait: None,
self_ty: ty_first, self_ty: ty_first,
items: impl_items, items: impl_items,
}) }))
} }
}; };
@ -710,7 +710,7 @@ impl<'a> Parser<'a> {
// It's a normal trait. // It's a normal trait.
tps.where_clause = self.parse_where_clause()?; tps.where_clause = self.parse_where_clause()?;
let items = self.parse_item_list(attrs, |p| p.parse_trait_item(ForceCollect::No))?; let items = self.parse_item_list(attrs, |p| p.parse_trait_item(ForceCollect::No))?;
Ok((ident, ItemKind::Trait(box TraitKind(is_auto, unsafety, tps, bounds, items)))) Ok((ident, ItemKind::Trait(Box::new(TraitKind(is_auto, unsafety, tps, bounds, items)))))
} }
} }
@ -769,7 +769,7 @@ impl<'a> Parser<'a> {
let default = if self.eat(&token::Eq) { Some(self.parse_ty()?) } else { None }; let default = if self.eat(&token::Eq) { Some(self.parse_ty()?) } else { None };
self.expect_semi()?; self.expect_semi()?;
Ok((ident, ItemKind::TyAlias(box TyAliasKind(def, generics, bounds, default)))) Ok((ident, ItemKind::TyAlias(Box::new(TyAliasKind(def, generics, bounds, default)))))
} }
/// Parses a `UseTree`. /// Parses a `UseTree`.

View File

@ -9,7 +9,6 @@ Core encoding and decoding interfaces.
html_playground_url = "https://play.rust-lang.org/", html_playground_url = "https://play.rust-lang.org/",
test(attr(allow(unused_variables), deny(warnings))) test(attr(allow(unused_variables), deny(warnings)))
)] )]
#![feature(box_syntax)]
#![feature(never_type)] #![feature(never_type)]
#![feature(nll)] #![feature(nll)]
#![feature(associated_type_bounds)] #![feature(associated_type_bounds)]

View File

@ -679,6 +679,6 @@ impl<S: Encoder, T: ?Sized + Encodable<S>> Encodable<S> for Box<T> {
} }
impl<D: Decoder, T: Decodable<D>> Decodable<D> for Box<T> { impl<D: Decoder, T: Decodable<D>> Decodable<D> for Box<T> {
fn decode(d: &mut D) -> Result<Box<T>, D::Error> { fn decode(d: &mut D) -> Result<Box<T>, D::Error> {
Ok(box Decodable::decode(d)?) Ok(Box::new(Decodable::decode(d)?))
} }
} }

View File

@ -108,7 +108,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
0 => (arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id)), 0 => (arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id)),
_ => ( _ => (
expr.span, expr.span,
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause { ObligationCauseCode::MatchExpressionArm(Box::new(MatchExpressionArmCause {
arm_span, arm_span,
scrut_span: scrut.span, scrut_span: scrut.span,
semi_span, semi_span,
@ -117,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
last_ty: prior_arm_ty.unwrap(), last_ty: prior_arm_ty.unwrap(),
scrut_hir_id: scrut.hir_id, scrut_hir_id: scrut.hir_id,
opt_suggest_box_span, opt_suggest_box_span,
}), })),
), ),
}; };
let cause = self.cause(span, code); let cause = self.cause(span, code);
@ -397,13 +397,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Finally construct the cause: // Finally construct the cause:
self.cause( self.cause(
error_sp, error_sp,
ObligationCauseCode::IfExpression(box IfExpressionCause { ObligationCauseCode::IfExpression(Box::new(IfExpressionCause {
then: then_sp, then: then_sp,
else_sp: error_sp, else_sp: error_sp,
outer: outer_sp, outer: outer_sp,
semicolon: remove_semicolon, semicolon: remove_semicolon,
opt_suggest_box_span, opt_suggest_box_span,
}), })),
) )
} }

View File

@ -58,7 +58,6 @@ This API is completely unstable and subject to change.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![cfg_attr(bootstrap, feature(bindings_after_at))] #![cfg_attr(bootstrap, feature(bindings_after_at))]
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(format_args_capture)] #![feature(format_args_capture)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]

View File

@ -114,7 +114,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
attrs: Default::default(), attrs: Default::default(),
visibility: Inherited, visibility: Inherited,
def_id: ItemId::Auto { trait_: trait_def_id, for_: item_def_id }, def_id: ItemId::Auto { trait_: trait_def_id, for_: item_def_id },
kind: box ImplItem(Impl { kind: Box::new(ImplItem(Impl {
span: Span::dummy(), span: Span::dummy(),
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
generics: new_generics, generics: new_generics,
@ -124,7 +124,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
negative_polarity, negative_polarity,
synthetic: true, synthetic: true,
blanket_impl: None, blanket_impl: None,
}), })),
cfg: None, cfg: None,
}) })
} }

View File

@ -97,7 +97,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
attrs: Default::default(), attrs: Default::default(),
visibility: Inherited, visibility: Inherited,
def_id: ItemId::Blanket { impl_id: impl_def_id, for_: item_def_id }, def_id: ItemId::Blanket { impl_id: impl_def_id, for_: item_def_id },
kind: box ImplItem(Impl { kind: Box::new(ImplItem(Impl {
span: Span::new(self.cx.tcx.def_span(impl_def_id)), span: Span::new(self.cx.tcx.def_span(impl_def_id)),
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,
generics: ( generics: (
@ -118,8 +118,8 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
.clean(self.cx), .clean(self.cx),
negative_polarity: false, negative_polarity: false,
synthetic: false, synthetic: false,
blanket_impl: Some(box trait_ref.self_ty().clean(self.cx)), blanket_impl: Some(Box::new(trait_ref.self_ty().clean(self.cx))),
}), })),
cfg: None, cfg: None,
}); });
} }

View File

@ -124,8 +124,14 @@ crate fn try_inline(
let (attrs, cfg) = merge_attrs(cx, Some(parent_module), load_attrs(cx, did), attrs_clone); let (attrs, cfg) = merge_attrs(cx, Some(parent_module), load_attrs(cx, did), attrs_clone);
cx.inlined.insert(did.into()); cx.inlined.insert(did.into());
let mut item = let mut item = clean::Item::from_def_id_and_attrs_and_parts(
clean::Item::from_def_id_and_attrs_and_parts(did, Some(name), kind, box attrs, cx, cfg); did,
Some(name),
kind,
Box::new(attrs),
cx,
cfg,
);
if let Some(import_def_id) = import_def_id { if let Some(import_def_id) = import_def_id {
// The visibility needs to reflect the one from the reexport and not from the "source" DefId. // The visibility needs to reflect the one from the reexport and not from the "source" DefId.
item.visibility = cx.tcx.visibility(import_def_id).clean(cx); item.visibility = cx.tcx.visibility(import_def_id).clean(cx);
@ -458,7 +464,7 @@ crate fn build_impl(
synthetic: false, synthetic: false,
blanket_impl: None, blanket_impl: None,
}), }),
box merged_attrs, Box::new(merged_attrs),
cx, cx,
cfg, cfg,
)); ));
@ -486,10 +492,10 @@ fn build_module(
let prim_ty = clean::PrimitiveType::from(p); let prim_ty = clean::PrimitiveType::from(p);
items.push(clean::Item { items.push(clean::Item {
name: None, name: None,
attrs: box clean::Attributes::default(), attrs: Box::new(clean::Attributes::default()),
def_id: ItemId::Primitive(prim_ty, did.krate), def_id: ItemId::Primitive(prim_ty, did.krate),
visibility: clean::Public, visibility: clean::Public,
kind: box clean::ImportItem(clean::Import::new_simple( kind: Box::new(clean::ImportItem(clean::Import::new_simple(
item.ident.name, item.ident.name,
clean::ImportSource { clean::ImportSource {
path: clean::Path { path: clean::Path {
@ -506,7 +512,7 @@ fn build_module(
did: None, did: None,
}, },
true, true,
)), ))),
cfg: None, cfg: None,
}); });
} else if let Some(i) = } else if let Some(i) =

View File

@ -403,8 +403,8 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
Type::QPath { Type::QPath {
name: cx.tcx.associated_item(self.item_def_id).ident.name, name: cx.tcx.associated_item(self.item_def_id).ident.name,
self_def_id: self_type.def_id(), self_def_id: self_type.def_id(),
self_type: box self_type, self_type: Box::new(self_type),
trait_: box trait_, trait_: Box::new(trait_),
} }
} }
} }
@ -1305,8 +1305,8 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
Type::QPath { Type::QPath {
name: p.segments.last().expect("segments were empty").ident.name, name: p.segments.last().expect("segments were empty").ident.name,
self_def_id: Some(DefId::local(qself.hir_id.owner.local_def_index)), self_def_id: Some(DefId::local(qself.hir_id.owner.local_def_index)),
self_type: box qself.clean(cx), self_type: Box::new(qself.clean(cx)),
trait_: box resolve_type(cx, trait_path, hir_id), trait_: Box::new(resolve_type(cx, trait_path, hir_id)),
} }
} }
hir::QPath::TypeRelative(ref qself, ref segment) => { hir::QPath::TypeRelative(ref qself, ref segment) => {
@ -1320,8 +1320,8 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
Type::QPath { Type::QPath {
name: segment.ident.name, name: segment.ident.name,
self_def_id: res.opt_def_id(), self_def_id: res.opt_def_id(),
self_type: box qself.clean(cx), self_type: Box::new(qself.clean(cx)),
trait_: box resolve_type(cx, trait_path, hir_id), trait_: Box::new(resolve_type(cx, trait_path, hir_id)),
} }
} }
hir::QPath::LangItem(..) => bug!("clean: requiring documentation of lang item"), hir::QPath::LangItem(..) => bug!("clean: requiring documentation of lang item"),
@ -1334,7 +1334,7 @@ impl Clean<Type> for hir::Ty<'_> {
match self.kind { match self.kind {
TyKind::Never => Never, TyKind::Never => Never,
TyKind::Ptr(ref m) => RawPointer(m.mutbl, box m.ty.clean(cx)), TyKind::Ptr(ref m) => RawPointer(m.mutbl, Box::new(m.ty.clean(cx))),
TyKind::Rptr(ref l, ref m) => { TyKind::Rptr(ref l, ref m) => {
// There are two times a `Fresh` lifetime can be created: // There are two times a `Fresh` lifetime can be created:
// 1. For `&'_ x`, written by the user. This corresponds to `lower_lifetime` in `rustc_ast_lowering`. // 1. For `&'_ x`, written by the user. This corresponds to `lower_lifetime` in `rustc_ast_lowering`.
@ -1346,9 +1346,9 @@ impl Clean<Type> for hir::Ty<'_> {
let elided = let elided =
l.is_elided() || matches!(l.name, LifetimeName::Param(ParamName::Fresh(_))); l.is_elided() || matches!(l.name, LifetimeName::Param(ParamName::Fresh(_)));
let lifetime = if elided { None } else { Some(l.clean(cx)) }; let lifetime = if elided { None } else { Some(l.clean(cx)) };
BorrowedRef { lifetime, mutability: m.mutbl, type_: box m.ty.clean(cx) } BorrowedRef { lifetime, mutability: m.mutbl, type_: Box::new(m.ty.clean(cx)) }
} }
TyKind::Slice(ref ty) => Slice(box ty.clean(cx)), TyKind::Slice(ref ty) => Slice(Box::new(ty.clean(cx))),
TyKind::Array(ref ty, ref length) => { TyKind::Array(ref ty, ref length) => {
let def_id = cx.tcx.hir().local_def_id(length.hir_id); let def_id = cx.tcx.hir().local_def_id(length.hir_id);
// NOTE(min_const_generics): We can't use `const_eval_poly` for constants // NOTE(min_const_generics): We can't use `const_eval_poly` for constants
@ -1361,7 +1361,7 @@ impl Clean<Type> for hir::Ty<'_> {
let ct = ty::Const::from_anon_const(cx.tcx, def_id); let ct = ty::Const::from_anon_const(cx.tcx, def_id);
let param_env = cx.tcx.param_env(def_id); let param_env = cx.tcx.param_env(def_id);
let length = print_const(cx, ct.eval(cx.tcx, param_env)); let length = print_const(cx, ct.eval(cx.tcx, param_env));
Array(box ty.clean(cx), length) Array(Box::new(ty.clean(cx)), length)
} }
TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), TyKind::Tup(ref tys) => Tuple(tys.clean(cx)),
TyKind::OpaqueDef(item_id, _) => { TyKind::OpaqueDef(item_id, _) => {
@ -1378,7 +1378,7 @@ impl Clean<Type> for hir::Ty<'_> {
let lifetime = if !lifetime.is_elided() { Some(lifetime.clean(cx)) } else { None }; let lifetime = if !lifetime.is_elided() { Some(lifetime.clean(cx)) } else { None };
DynTrait(bounds, lifetime) DynTrait(bounds, lifetime)
} }
TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)), TyKind::BareFn(ref barefn) => BareFunction(Box::new(barefn.clean(cx))),
TyKind::Infer | TyKind::Err => Infer, TyKind::Infer | TyKind::Err => Infer,
TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind), TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind),
} }
@ -1428,27 +1428,29 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
ty::Uint(uint_ty) => Primitive(uint_ty.into()), ty::Uint(uint_ty) => Primitive(uint_ty.into()),
ty::Float(float_ty) => Primitive(float_ty.into()), ty::Float(float_ty) => Primitive(float_ty.into()),
ty::Str => Primitive(PrimitiveType::Str), ty::Str => Primitive(PrimitiveType::Str),
ty::Slice(ty) => Slice(box ty.clean(cx)), ty::Slice(ty) => Slice(Box::new(ty.clean(cx))),
ty::Array(ty, n) => { ty::Array(ty, n) => {
let mut n = cx.tcx.lift(n).expect("array lift failed"); let mut n = cx.tcx.lift(n).expect("array lift failed");
n = n.eval(cx.tcx, ty::ParamEnv::reveal_all()); n = n.eval(cx.tcx, ty::ParamEnv::reveal_all());
let n = print_const(cx, n); let n = print_const(cx, n);
Array(box ty.clean(cx), n) Array(Box::new(ty.clean(cx)), n)
}
ty::RawPtr(mt) => RawPointer(mt.mutbl, box mt.ty.clean(cx)),
ty::Ref(r, ty, mutbl) => {
BorrowedRef { lifetime: r.clean(cx), mutability: mutbl, type_: box ty.clean(cx) }
} }
ty::RawPtr(mt) => RawPointer(mt.mutbl, Box::new(mt.ty.clean(cx))),
ty::Ref(r, ty, mutbl) => BorrowedRef {
lifetime: r.clean(cx),
mutability: mutbl,
type_: Box::new(ty.clean(cx)),
},
ty::FnDef(..) | ty::FnPtr(_) => { ty::FnDef(..) | ty::FnPtr(_) => {
let ty = cx.tcx.lift(*self).expect("FnPtr lift failed"); let ty = cx.tcx.lift(*self).expect("FnPtr lift failed");
let sig = ty.fn_sig(cx.tcx); let sig = ty.fn_sig(cx.tcx);
let def_id = DefId::local(CRATE_DEF_INDEX); let def_id = DefId::local(CRATE_DEF_INDEX);
BareFunction(box BareFunctionDecl { BareFunction(Box::new(BareFunctionDecl {
unsafety: sig.unsafety(), unsafety: sig.unsafety(),
generic_params: Vec::new(), generic_params: Vec::new(),
decl: (def_id, sig).clean(cx), decl: (def_id, sig).clean(cx),
abi: sig.abi(), abi: sig.abi(),
}) }))
} }
ty::Adt(def, substs) => { ty::Adt(def, substs) => {
let did = def.did; let did = def.did;
@ -1988,10 +1990,10 @@ fn clean_extern_crate(
// FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason // FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
vec![Item { vec![Item {
name: Some(name), name: Some(name),
attrs: box attrs.clean(cx), attrs: Box::new(attrs.clean(cx)),
def_id: crate_def_id.into(), def_id: crate_def_id.into(),
visibility: krate.vis.clean(cx), visibility: krate.vis.clean(cx),
kind: box ExternCrateItem { src: orig_name }, kind: Box::new(ExternCrateItem { src: orig_name }),
cfg: attrs.cfg(cx.sess()), cfg: attrs.cfg(cx.sess()),
}] }]
} }

View File

@ -416,7 +416,7 @@ impl Item {
def_id, def_id,
name, name,
kind, kind,
box ast_attrs.clean(cx), Box::new(ast_attrs.clean(cx)),
cx, cx,
ast_attrs.cfg(cx.sess()), ast_attrs.cfg(cx.sess()),
) )
@ -434,7 +434,7 @@ impl Item {
Item { Item {
def_id: def_id.into(), def_id: def_id.into(),
kind: box kind, kind: Box::new(kind),
name, name,
attrs, attrs,
visibility: cx.tcx.visibility(def_id).clean(cx), visibility: cx.tcx.visibility(def_id).clean(cx),

View File

@ -265,7 +265,7 @@ crate fn create_config(
stderr: None, stderr: None,
lint_caps, lint_caps,
parse_sess_created: None, parse_sess_created: None,
register_lints: Some(box crate::lint::register_lints), register_lints: Some(Box::new(crate::lint::register_lints)),
override_queries: Some(|_sess, providers, _external_providers| { override_queries: Some(|_sess, providers, _external_providers| {
// Most lints will require typechecking, so just don't run them. // Most lints will require typechecking, so just don't run them.
providers.lint_mod = |_, _| {}; providers.lint_mod = |_, _| {};

View File

@ -99,7 +99,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
stderr: None, stderr: None,
lint_caps, lint_caps,
parse_sess_created: None, parse_sess_created: None,
register_lints: Some(box crate::lint::register_lints), register_lints: Some(Box::new(crate::lint::register_lints)),
override_queries: None, override_queries: None,
make_codegen_backend: None, make_codegen_backend: None,
registry: rustc_driver::diagnostics_registry(), registry: rustc_driver::diagnostics_registry(),
@ -549,10 +549,10 @@ crate fn make_test(
.supports_color(); .supports_color();
let emitter = let emitter =
EmitterWriter::new(box io::sink(), None, false, false, false, None, false); EmitterWriter::new(Box::new(io::sink()), None, false, false, false, None, false);
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser // FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
let handler = Handler::with_emitter(false, None, box emitter); let handler = Handler::with_emitter(false, None, Box::new(emitter));
let sess = ParseSess::with_span_handler(handler, sm); let sess = ParseSess::with_span_handler(handler, sm);
let mut found_main = false; let mut found_main = false;
@ -962,7 +962,7 @@ impl Tester for Collector {
no_run, no_run,
test_type: test::TestType::DocTest, test_type: test::TestType::DocTest,
}, },
testfn: test::DynTestFn(box move || { testfn: test::DynTestFn(Box::new(move || {
let report_unused_externs = |uext| { let report_unused_externs = |uext| {
unused_externs.lock().unwrap().push(uext); unused_externs.lock().unwrap().push(uext);
}; };
@ -1042,9 +1042,9 @@ impl Tester for Collector {
} }
} }
panic::resume_unwind(box ()); panic::resume_unwind(Box::new(()));
} }
}), })),
}); });
} }

View File

@ -2,7 +2,7 @@ use crate::clean::*;
crate fn strip_item(mut item: Item) -> Item { crate fn strip_item(mut item: Item) -> Item {
if !matches!(*item.kind, StrippedItem(..)) { if !matches!(*item.kind, StrippedItem(..)) {
item.kind = box StrippedItem(item.kind); item.kind = Box::new(StrippedItem(item.kind));
} }
item item
} }
@ -65,10 +65,10 @@ crate trait DocFolder: Sized {
/// don't override! /// don't override!
fn fold_item_recur(&mut self, mut item: Item) -> Item { fn fold_item_recur(&mut self, mut item: Item) -> Item {
item.kind = box match *item.kind { item.kind = Box::new(match *item.kind {
StrippedItem(box i) => StrippedItem(box self.fold_inner_recur(i)), StrippedItem(box i) => StrippedItem(Box::new(self.fold_inner_recur(i))),
_ => self.fold_inner_recur(*item.kind), _ => self.fold_inner_recur(*item.kind),
}; });
item item
} }

View File

@ -5,7 +5,6 @@
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(array_methods)] #![feature(array_methods)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(nll)] #![feature(nll)]
#![feature(test)] #![feature(test)]

View File

@ -61,7 +61,7 @@ enum ErrorKind<'a> {
impl<'a> From<ResolutionFailure<'a>> for ErrorKind<'a> { impl<'a> From<ResolutionFailure<'a>> for ErrorKind<'a> {
fn from(err: ResolutionFailure<'a>) -> Self { fn from(err: ResolutionFailure<'a>) -> Self {
ErrorKind::Resolve(box err) ErrorKind::Resolve(Box::new(err))
} }
} }

View File

@ -116,7 +116,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
// prevent folding of `cfg!` macros and the like // prevent folding of `cfg!` macros and the like
if !e.span.from_expansion() { if !e.span.from_expansion() {
match &e.kind { match &e.kind {
ExprKind::Unary(UnOp::Not, inner) => return Ok(Bool::Not(box self.run(inner)?)), ExprKind::Unary(UnOp::Not, inner) => return Ok(Bool::Not(Box::new(self.run(inner)?))),
ExprKind::Binary(binop, lhs, rhs) => match &binop.node { ExprKind::Binary(binop, lhs, rhs) => match &binop.node {
BinOpKind::Or => { BinOpKind::Or => {
return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?)); return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?));

View File

@ -578,8 +578,8 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
let filename = FileName::anon_source_code(&code); let filename = FileName::anon_source_code(&code);
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let emitter = EmitterWriter::new(box io::sink(), None, false, false, false, None, false); let emitter = EmitterWriter::new(Box::new(io::sink()), None, false, false, false, None, false);
let handler = Handler::with_emitter(false, None, box emitter); let handler = Handler::with_emitter(false, None, Box::new(emitter));
let sess = ParseSess::with_span_handler(handler, sm); let sess = ParseSess::with_span_handler(handler, sm);
let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) { let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) {

View File

@ -1,7 +1,6 @@
// error-pattern:cargo-clippy // error-pattern:cargo-clippy
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(drain_filter)] #![feature(drain_filter)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(iter_zip)] #![feature(iter_zip)]
@ -393,9 +392,9 @@ use crate::utils::conf::TryConf;
/// Used in `./src/driver.rs`. /// Used in `./src/driver.rs`.
pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore) { pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore) {
// NOTE: Do not add any more pre-expansion passes. These should be removed eventually. // NOTE: Do not add any more pre-expansion passes. These should be removed eventually.
store.register_pre_expansion_pass(|| box write::Write::default()); store.register_pre_expansion_pass(|| Box::new(write::Write::default()));
store.register_pre_expansion_pass(|| box attrs::EarlyAttributes); store.register_pre_expansion_pass(|| Box::new(attrs::EarlyAttributes));
store.register_pre_expansion_pass(|| box dbg_macro::DbgMacro); store.register_pre_expansion_pass(|| Box::new(dbg_macro::DbgMacro));
} }
#[doc(hidden)] #[doc(hidden)]
@ -1810,7 +1809,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
#[cfg(feature = "metadata-collector-lint")] #[cfg(feature = "metadata-collector-lint")]
{ {
if std::env::var("ENABLE_METADATA_COLLECTION").eq(&Ok("1".to_string())) { if std::env::var("ENABLE_METADATA_COLLECTION").eq(&Ok("1".to_string())) {
store.register_late_pass(|| box utils::internal_lints::metadata_collector::MetadataCollector::new()); store.register_late_pass(|| Box::new(utils::internal_lints::metadata_collector::MetadataCollector::new()));
return; return;
} }
} }
@ -1818,57 +1817,57 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
// all the internal lints // all the internal lints
#[cfg(feature = "internal-lints")] #[cfg(feature = "internal-lints")]
{ {
store.register_early_pass(|| box utils::internal_lints::ClippyLintsInternal); store.register_early_pass(|| Box::new(utils::internal_lints::ClippyLintsInternal));
store.register_early_pass(|| box utils::internal_lints::ProduceIce); store.register_early_pass(|| Box::new(utils::internal_lints::ProduceIce));
store.register_late_pass(|| box utils::inspector::DeepCodeInspector); store.register_late_pass(|| Box::new(utils::inspector::DeepCodeInspector));
store.register_late_pass(|| box utils::internal_lints::CollapsibleCalls); store.register_late_pass(|| Box::new(utils::internal_lints::CollapsibleCalls));
store.register_late_pass(|| box utils::internal_lints::CompilerLintFunctions::new()); store.register_late_pass(|| Box::new(utils::internal_lints::CompilerLintFunctions::new()));
store.register_late_pass(|| box utils::internal_lints::IfChainStyle); store.register_late_pass(|| Box::new(utils::internal_lints::IfChainStyle));
store.register_late_pass(|| box utils::internal_lints::InvalidPaths); store.register_late_pass(|| Box::new(utils::internal_lints::InvalidPaths));
store.register_late_pass(|| box utils::internal_lints::InterningDefinedSymbol::default()); store.register_late_pass(|| Box::new(utils::internal_lints::InterningDefinedSymbol::default()));
store.register_late_pass(|| box utils::internal_lints::LintWithoutLintPass::default()); store.register_late_pass(|| Box::new(utils::internal_lints::LintWithoutLintPass::default()));
store.register_late_pass(|| box utils::internal_lints::MatchTypeOnDiagItem); store.register_late_pass(|| Box::new(utils::internal_lints::MatchTypeOnDiagItem));
store.register_late_pass(|| box utils::internal_lints::OuterExpnDataPass); store.register_late_pass(|| Box::new(utils::internal_lints::OuterExpnDataPass));
} }
store.register_late_pass(|| box utils::author::Author); store.register_late_pass(|| Box::new(utils::author::Author));
store.register_late_pass(|| box await_holding_invalid::AwaitHolding); store.register_late_pass(|| Box::new(await_holding_invalid::AwaitHolding));
store.register_late_pass(|| box serde_api::SerdeApi); store.register_late_pass(|| Box::new(serde_api::SerdeApi));
let vec_box_size_threshold = conf.vec_box_size_threshold; let vec_box_size_threshold = conf.vec_box_size_threshold;
let type_complexity_threshold = conf.type_complexity_threshold; let type_complexity_threshold = conf.type_complexity_threshold;
store.register_late_pass(move || box types::Types::new(vec_box_size_threshold, type_complexity_threshold)); store.register_late_pass(move || Box::new(types::Types::new(vec_box_size_threshold, type_complexity_threshold)));
store.register_late_pass(|| box booleans::NonminimalBool); store.register_late_pass(|| Box::new(booleans::NonminimalBool));
store.register_late_pass(|| box needless_bitwise_bool::NeedlessBitwiseBool); store.register_late_pass(|| Box::new(needless_bitwise_bool::NeedlessBitwiseBool));
store.register_late_pass(|| box eq_op::EqOp); store.register_late_pass(|| Box::new(eq_op::EqOp));
store.register_late_pass(|| box enum_clike::UnportableVariant); store.register_late_pass(|| Box::new(enum_clike::UnportableVariant));
store.register_late_pass(|| box float_literal::FloatLiteral); store.register_late_pass(|| Box::new(float_literal::FloatLiteral));
let verbose_bit_mask_threshold = conf.verbose_bit_mask_threshold; let verbose_bit_mask_threshold = conf.verbose_bit_mask_threshold;
store.register_late_pass(move || box bit_mask::BitMask::new(verbose_bit_mask_threshold)); store.register_late_pass(move || Box::new(bit_mask::BitMask::new(verbose_bit_mask_threshold)));
store.register_late_pass(|| box ptr::Ptr); store.register_late_pass(|| Box::new(ptr::Ptr));
store.register_late_pass(|| box ptr_eq::PtrEq); store.register_late_pass(|| Box::new(ptr_eq::PtrEq));
store.register_late_pass(|| box needless_bool::NeedlessBool); store.register_late_pass(|| Box::new(needless_bool::NeedlessBool));
store.register_late_pass(|| box needless_bool::BoolComparison); store.register_late_pass(|| Box::new(needless_bool::BoolComparison));
store.register_late_pass(|| box needless_for_each::NeedlessForEach); store.register_late_pass(|| Box::new(needless_for_each::NeedlessForEach));
store.register_late_pass(|| box approx_const::ApproxConstant); store.register_late_pass(|| Box::new(approx_const::ApproxConstant));
store.register_late_pass(|| box misc::MiscLints); store.register_late_pass(|| Box::new(misc::MiscLints));
store.register_late_pass(|| box eta_reduction::EtaReduction); store.register_late_pass(|| Box::new(eta_reduction::EtaReduction));
store.register_late_pass(|| box identity_op::IdentityOp); store.register_late_pass(|| Box::new(identity_op::IdentityOp));
store.register_late_pass(|| box erasing_op::ErasingOp); store.register_late_pass(|| Box::new(erasing_op::ErasingOp));
store.register_late_pass(|| box mut_mut::MutMut); store.register_late_pass(|| Box::new(mut_mut::MutMut));
store.register_late_pass(|| box mut_reference::UnnecessaryMutPassed); store.register_late_pass(|| Box::new(mut_reference::UnnecessaryMutPassed));
store.register_late_pass(|| box len_zero::LenZero); store.register_late_pass(|| Box::new(len_zero::LenZero));
store.register_late_pass(|| box attrs::Attributes); store.register_late_pass(|| Box::new(attrs::Attributes));
store.register_late_pass(|| box blocks_in_if_conditions::BlocksInIfConditions); store.register_late_pass(|| Box::new(blocks_in_if_conditions::BlocksInIfConditions));
store.register_late_pass(|| box collapsible_match::CollapsibleMatch); store.register_late_pass(|| Box::new(collapsible_match::CollapsibleMatch));
store.register_late_pass(|| box unicode::Unicode); store.register_late_pass(|| Box::new(unicode::Unicode));
store.register_late_pass(|| box unit_return_expecting_ord::UnitReturnExpectingOrd); store.register_late_pass(|| Box::new(unit_return_expecting_ord::UnitReturnExpectingOrd));
store.register_late_pass(|| box strings::StringAdd); store.register_late_pass(|| Box::new(strings::StringAdd));
store.register_late_pass(|| box implicit_return::ImplicitReturn); store.register_late_pass(|| Box::new(implicit_return::ImplicitReturn));
store.register_late_pass(|| box implicit_saturating_sub::ImplicitSaturatingSub); store.register_late_pass(|| Box::new(implicit_saturating_sub::ImplicitSaturatingSub));
store.register_late_pass(|| box default_numeric_fallback::DefaultNumericFallback); store.register_late_pass(|| Box::new(default_numeric_fallback::DefaultNumericFallback));
store.register_late_pass(|| box inconsistent_struct_constructor::InconsistentStructConstructor); store.register_late_pass(|| Box::new(inconsistent_struct_constructor::InconsistentStructConstructor));
store.register_late_pass(|| box non_octal_unix_permissions::NonOctalUnixPermissions); store.register_late_pass(|| Box::new(non_octal_unix_permissions::NonOctalUnixPermissions));
store.register_early_pass(|| box unnecessary_self_imports::UnnecessarySelfImports); store.register_early_pass(|| Box::new(unnecessary_self_imports::UnnecessarySelfImports));
let msrv = conf.msrv.as_ref().and_then(|s| { let msrv = conf.msrv.as_ref().and_then(|s| {
parse_msrv(s, None, None).or_else(|| { parse_msrv(s, None, None).or_else(|| {
@ -1878,231 +1877,231 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
}); });
let avoid_breaking_exported_api = conf.avoid_breaking_exported_api; let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
store.register_late_pass(move || box methods::Methods::new(avoid_breaking_exported_api, msrv)); store.register_late_pass(move || Box::new(methods::Methods::new(avoid_breaking_exported_api, msrv)));
store.register_late_pass(move || box matches::Matches::new(msrv)); store.register_late_pass(move || Box::new(matches::Matches::new(msrv)));
store.register_early_pass(move || box manual_non_exhaustive::ManualNonExhaustive::new(msrv)); store.register_early_pass(move || Box::new(manual_non_exhaustive::ManualNonExhaustive::new(msrv)));
store.register_late_pass(move || box manual_strip::ManualStrip::new(msrv)); store.register_late_pass(move || Box::new(manual_strip::ManualStrip::new(msrv)));
store.register_early_pass(move || box redundant_static_lifetimes::RedundantStaticLifetimes::new(msrv)); store.register_early_pass(move || Box::new(redundant_static_lifetimes::RedundantStaticLifetimes::new(msrv)));
store.register_early_pass(move || box redundant_field_names::RedundantFieldNames::new(msrv)); store.register_early_pass(move || Box::new(redundant_field_names::RedundantFieldNames::new(msrv)));
store.register_late_pass(move || box checked_conversions::CheckedConversions::new(msrv)); store.register_late_pass(move || Box::new(checked_conversions::CheckedConversions::new(msrv)));
store.register_late_pass(move || box mem_replace::MemReplace::new(msrv)); store.register_late_pass(move || Box::new(mem_replace::MemReplace::new(msrv)));
store.register_late_pass(move || box ranges::Ranges::new(msrv)); store.register_late_pass(move || Box::new(ranges::Ranges::new(msrv)));
store.register_late_pass(move || box from_over_into::FromOverInto::new(msrv)); store.register_late_pass(move || Box::new(from_over_into::FromOverInto::new(msrv)));
store.register_late_pass(move || box use_self::UseSelf::new(msrv)); store.register_late_pass(move || Box::new(use_self::UseSelf::new(msrv)));
store.register_late_pass(move || box missing_const_for_fn::MissingConstForFn::new(msrv)); store.register_late_pass(move || Box::new(missing_const_for_fn::MissingConstForFn::new(msrv)));
store.register_late_pass(move || box needless_question_mark::NeedlessQuestionMark); store.register_late_pass(move || Box::new(needless_question_mark::NeedlessQuestionMark));
store.register_late_pass(move || box casts::Casts::new(msrv)); store.register_late_pass(move || Box::new(casts::Casts::new(msrv)));
store.register_early_pass(move || box unnested_or_patterns::UnnestedOrPatterns::new(msrv)); store.register_early_pass(move || Box::new(unnested_or_patterns::UnnestedOrPatterns::new(msrv)));
store.register_late_pass(|| box size_of_in_element_count::SizeOfInElementCount); store.register_late_pass(|| Box::new(size_of_in_element_count::SizeOfInElementCount));
store.register_late_pass(|| box map_clone::MapClone); store.register_late_pass(|| Box::new(map_clone::MapClone));
store.register_late_pass(|| box map_err_ignore::MapErrIgnore); store.register_late_pass(|| Box::new(map_err_ignore::MapErrIgnore));
store.register_late_pass(|| box shadow::Shadow); store.register_late_pass(|| Box::new(shadow::Shadow));
store.register_late_pass(|| box unit_types::UnitTypes); store.register_late_pass(|| Box::new(unit_types::UnitTypes));
store.register_late_pass(|| box loops::Loops); store.register_late_pass(|| Box::new(loops::Loops));
store.register_late_pass(|| box main_recursion::MainRecursion::default()); store.register_late_pass(|| Box::new(main_recursion::MainRecursion::default()));
store.register_late_pass(|| box lifetimes::Lifetimes); store.register_late_pass(|| Box::new(lifetimes::Lifetimes));
store.register_late_pass(|| box entry::HashMapPass); store.register_late_pass(|| Box::new(entry::HashMapPass));
store.register_late_pass(|| box minmax::MinMaxPass); store.register_late_pass(|| Box::new(minmax::MinMaxPass));
store.register_late_pass(|| box open_options::OpenOptions); store.register_late_pass(|| Box::new(open_options::OpenOptions));
store.register_late_pass(|| box zero_div_zero::ZeroDiv); store.register_late_pass(|| Box::new(zero_div_zero::ZeroDiv));
store.register_late_pass(|| box mutex_atomic::Mutex); store.register_late_pass(|| Box::new(mutex_atomic::Mutex));
store.register_late_pass(|| box needless_update::NeedlessUpdate); store.register_late_pass(|| Box::new(needless_update::NeedlessUpdate));
store.register_late_pass(|| box needless_borrow::NeedlessBorrow::default()); store.register_late_pass(|| Box::new(needless_borrow::NeedlessBorrow::default()));
store.register_late_pass(|| box needless_borrowed_ref::NeedlessBorrowedRef); store.register_late_pass(|| Box::new(needless_borrowed_ref::NeedlessBorrowedRef));
store.register_late_pass(|| box no_effect::NoEffect); store.register_late_pass(|| Box::new(no_effect::NoEffect));
store.register_late_pass(|| box temporary_assignment::TemporaryAssignment); store.register_late_pass(|| Box::new(temporary_assignment::TemporaryAssignment));
store.register_late_pass(|| box transmute::Transmute); store.register_late_pass(|| Box::new(transmute::Transmute));
let cognitive_complexity_threshold = conf.cognitive_complexity_threshold; let cognitive_complexity_threshold = conf.cognitive_complexity_threshold;
store.register_late_pass(move || box cognitive_complexity::CognitiveComplexity::new(cognitive_complexity_threshold)); store.register_late_pass(move || Box::new(cognitive_complexity::CognitiveComplexity::new(cognitive_complexity_threshold)));
let too_large_for_stack = conf.too_large_for_stack; let too_large_for_stack = conf.too_large_for_stack;
store.register_late_pass(move || box escape::BoxedLocal{too_large_for_stack}); store.register_late_pass(move || Box::new(escape::BoxedLocal{too_large_for_stack}));
store.register_late_pass(move || box vec::UselessVec{too_large_for_stack}); store.register_late_pass(move || Box::new(vec::UselessVec{too_large_for_stack}));
store.register_late_pass(|| box panic_unimplemented::PanicUnimplemented); store.register_late_pass(|| Box::new(panic_unimplemented::PanicUnimplemented));
store.register_late_pass(|| box strings::StringLitAsBytes); store.register_late_pass(|| Box::new(strings::StringLitAsBytes));
store.register_late_pass(|| box derive::Derive); store.register_late_pass(|| Box::new(derive::Derive));
store.register_late_pass(|| box get_last_with_len::GetLastWithLen); store.register_late_pass(|| Box::new(get_last_with_len::GetLastWithLen));
store.register_late_pass(|| box drop_forget_ref::DropForgetRef); store.register_late_pass(|| Box::new(drop_forget_ref::DropForgetRef));
store.register_late_pass(|| box empty_enum::EmptyEnum); store.register_late_pass(|| Box::new(empty_enum::EmptyEnum));
store.register_late_pass(|| box absurd_extreme_comparisons::AbsurdExtremeComparisons); store.register_late_pass(|| Box::new(absurd_extreme_comparisons::AbsurdExtremeComparisons));
store.register_late_pass(|| box invalid_upcast_comparisons::InvalidUpcastComparisons); store.register_late_pass(|| Box::new(invalid_upcast_comparisons::InvalidUpcastComparisons));
store.register_late_pass(|| box regex::Regex::default()); store.register_late_pass(|| Box::new(regex::Regex::default()));
store.register_late_pass(|| box copies::CopyAndPaste); store.register_late_pass(|| Box::new(copies::CopyAndPaste));
store.register_late_pass(|| box copy_iterator::CopyIterator); store.register_late_pass(|| Box::new(copy_iterator::CopyIterator));
store.register_late_pass(|| box format::UselessFormat); store.register_late_pass(|| Box::new(format::UselessFormat));
store.register_late_pass(|| box swap::Swap); store.register_late_pass(|| Box::new(swap::Swap));
store.register_late_pass(|| box overflow_check_conditional::OverflowCheckConditional); store.register_late_pass(|| Box::new(overflow_check_conditional::OverflowCheckConditional));
store.register_late_pass(|| box new_without_default::NewWithoutDefault::default()); store.register_late_pass(|| Box::new(new_without_default::NewWithoutDefault::default()));
let blacklisted_names = conf.blacklisted_names.iter().cloned().collect::<FxHashSet<_>>(); let blacklisted_names = conf.blacklisted_names.iter().cloned().collect::<FxHashSet<_>>();
store.register_late_pass(move || box blacklisted_name::BlacklistedName::new(blacklisted_names.clone())); store.register_late_pass(move || Box::new(blacklisted_name::BlacklistedName::new(blacklisted_names.clone())));
let too_many_arguments_threshold = conf.too_many_arguments_threshold; let too_many_arguments_threshold = conf.too_many_arguments_threshold;
let too_many_lines_threshold = conf.too_many_lines_threshold; let too_many_lines_threshold = conf.too_many_lines_threshold;
store.register_late_pass(move || box functions::Functions::new(too_many_arguments_threshold, too_many_lines_threshold)); store.register_late_pass(move || Box::new(functions::Functions::new(too_many_arguments_threshold, too_many_lines_threshold)));
let doc_valid_idents = conf.doc_valid_idents.iter().cloned().collect::<FxHashSet<_>>(); let doc_valid_idents = conf.doc_valid_idents.iter().cloned().collect::<FxHashSet<_>>();
store.register_late_pass(move || box doc::DocMarkdown::new(doc_valid_idents.clone())); store.register_late_pass(move || Box::new(doc::DocMarkdown::new(doc_valid_idents.clone())));
store.register_late_pass(|| box neg_multiply::NegMultiply); store.register_late_pass(|| Box::new(neg_multiply::NegMultiply));
store.register_late_pass(|| box mem_discriminant::MemDiscriminant); store.register_late_pass(|| Box::new(mem_discriminant::MemDiscriminant));
store.register_late_pass(|| box mem_forget::MemForget); store.register_late_pass(|| Box::new(mem_forget::MemForget));
store.register_late_pass(|| box arithmetic::Arithmetic::default()); store.register_late_pass(|| Box::new(arithmetic::Arithmetic::default()));
store.register_late_pass(|| box assign_ops::AssignOps); store.register_late_pass(|| Box::new(assign_ops::AssignOps));
store.register_late_pass(|| box let_if_seq::LetIfSeq); store.register_late_pass(|| Box::new(let_if_seq::LetIfSeq));
store.register_late_pass(|| box eval_order_dependence::EvalOrderDependence); store.register_late_pass(|| Box::new(eval_order_dependence::EvalOrderDependence));
store.register_late_pass(|| box missing_doc::MissingDoc::new()); store.register_late_pass(|| Box::new(missing_doc::MissingDoc::new()));
store.register_late_pass(|| box missing_inline::MissingInline); store.register_late_pass(|| Box::new(missing_inline::MissingInline));
store.register_late_pass(move || box exhaustive_items::ExhaustiveItems); store.register_late_pass(move || Box::new(exhaustive_items::ExhaustiveItems));
store.register_late_pass(|| box if_let_some_result::OkIfLet); store.register_late_pass(|| Box::new(if_let_some_result::OkIfLet));
store.register_late_pass(|| box partialeq_ne_impl::PartialEqNeImpl); store.register_late_pass(|| Box::new(partialeq_ne_impl::PartialEqNeImpl));
store.register_late_pass(|| box unused_io_amount::UnusedIoAmount); store.register_late_pass(|| Box::new(unused_io_amount::UnusedIoAmount));
let enum_variant_size_threshold = conf.enum_variant_size_threshold; let enum_variant_size_threshold = conf.enum_variant_size_threshold;
store.register_late_pass(move || box large_enum_variant::LargeEnumVariant::new(enum_variant_size_threshold)); store.register_late_pass(move || Box::new(large_enum_variant::LargeEnumVariant::new(enum_variant_size_threshold)));
store.register_late_pass(|| box explicit_write::ExplicitWrite); store.register_late_pass(|| Box::new(explicit_write::ExplicitWrite));
store.register_late_pass(|| box needless_pass_by_value::NeedlessPassByValue); store.register_late_pass(|| Box::new(needless_pass_by_value::NeedlessPassByValue));
let pass_by_ref_or_value = pass_by_ref_or_value::PassByRefOrValue::new( let pass_by_ref_or_value = pass_by_ref_or_value::PassByRefOrValue::new(
conf.trivial_copy_size_limit, conf.trivial_copy_size_limit,
conf.pass_by_value_size_limit, conf.pass_by_value_size_limit,
conf.avoid_breaking_exported_api, conf.avoid_breaking_exported_api,
&sess.target, &sess.target,
); );
store.register_late_pass(move || box pass_by_ref_or_value); store.register_late_pass(move || Box::new(pass_by_ref_or_value));
store.register_late_pass(|| box ref_option_ref::RefOptionRef); store.register_late_pass(|| Box::new(ref_option_ref::RefOptionRef));
store.register_late_pass(|| box try_err::TryErr); store.register_late_pass(|| Box::new(try_err::TryErr));
store.register_late_pass(|| box bytecount::ByteCount); store.register_late_pass(|| Box::new(bytecount::ByteCount));
store.register_late_pass(|| box infinite_iter::InfiniteIter); store.register_late_pass(|| Box::new(infinite_iter::InfiniteIter));
store.register_late_pass(|| box inline_fn_without_body::InlineFnWithoutBody); store.register_late_pass(|| Box::new(inline_fn_without_body::InlineFnWithoutBody));
store.register_late_pass(|| box useless_conversion::UselessConversion::default()); store.register_late_pass(|| Box::new(useless_conversion::UselessConversion::default()));
store.register_late_pass(|| box implicit_hasher::ImplicitHasher); store.register_late_pass(|| Box::new(implicit_hasher::ImplicitHasher));
store.register_late_pass(|| box fallible_impl_from::FallibleImplFrom); store.register_late_pass(|| Box::new(fallible_impl_from::FallibleImplFrom));
store.register_late_pass(|| box double_comparison::DoubleComparisons); store.register_late_pass(|| Box::new(double_comparison::DoubleComparisons));
store.register_late_pass(|| box question_mark::QuestionMark); store.register_late_pass(|| Box::new(question_mark::QuestionMark));
store.register_early_pass(|| box suspicious_operation_groupings::SuspiciousOperationGroupings); store.register_early_pass(|| Box::new(suspicious_operation_groupings::SuspiciousOperationGroupings));
store.register_late_pass(|| box suspicious_trait_impl::SuspiciousImpl); store.register_late_pass(|| Box::new(suspicious_trait_impl::SuspiciousImpl));
store.register_late_pass(|| box map_unit_fn::MapUnit); store.register_late_pass(|| Box::new(map_unit_fn::MapUnit));
store.register_late_pass(|| box inherent_impl::MultipleInherentImpl); store.register_late_pass(|| Box::new(inherent_impl::MultipleInherentImpl));
store.register_late_pass(|| box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd); store.register_late_pass(|| Box::new(neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd));
store.register_late_pass(|| box unwrap::Unwrap); store.register_late_pass(|| Box::new(unwrap::Unwrap));
store.register_late_pass(|| box duration_subsec::DurationSubsec); store.register_late_pass(|| Box::new(duration_subsec::DurationSubsec));
store.register_late_pass(|| box indexing_slicing::IndexingSlicing); store.register_late_pass(|| Box::new(indexing_slicing::IndexingSlicing));
store.register_late_pass(|| box non_copy_const::NonCopyConst); store.register_late_pass(|| Box::new(non_copy_const::NonCopyConst));
store.register_late_pass(|| box ptr_offset_with_cast::PtrOffsetWithCast); store.register_late_pass(|| Box::new(ptr_offset_with_cast::PtrOffsetWithCast));
store.register_late_pass(|| box redundant_clone::RedundantClone); store.register_late_pass(|| Box::new(redundant_clone::RedundantClone));
store.register_late_pass(|| box slow_vector_initialization::SlowVectorInit); store.register_late_pass(|| Box::new(slow_vector_initialization::SlowVectorInit));
store.register_late_pass(|| box unnecessary_sort_by::UnnecessarySortBy); store.register_late_pass(|| Box::new(unnecessary_sort_by::UnnecessarySortBy));
store.register_late_pass(move || box unnecessary_wraps::UnnecessaryWraps::new(avoid_breaking_exported_api)); store.register_late_pass(move || Box::new(unnecessary_wraps::UnnecessaryWraps::new(avoid_breaking_exported_api)));
store.register_late_pass(|| box assertions_on_constants::AssertionsOnConstants); store.register_late_pass(|| Box::new(assertions_on_constants::AssertionsOnConstants));
store.register_late_pass(|| box transmuting_null::TransmutingNull); store.register_late_pass(|| Box::new(transmuting_null::TransmutingNull));
store.register_late_pass(|| box path_buf_push_overwrite::PathBufPushOverwrite); store.register_late_pass(|| Box::new(path_buf_push_overwrite::PathBufPushOverwrite));
store.register_late_pass(|| box integer_division::IntegerDivision); store.register_late_pass(|| Box::new(integer_division::IntegerDivision));
store.register_late_pass(|| box inherent_to_string::InherentToString); store.register_late_pass(|| Box::new(inherent_to_string::InherentToString));
let max_trait_bounds = conf.max_trait_bounds; let max_trait_bounds = conf.max_trait_bounds;
store.register_late_pass(move || box trait_bounds::TraitBounds::new(max_trait_bounds)); store.register_late_pass(move || Box::new(trait_bounds::TraitBounds::new(max_trait_bounds)));
store.register_late_pass(|| box comparison_chain::ComparisonChain); store.register_late_pass(|| Box::new(comparison_chain::ComparisonChain));
store.register_late_pass(|| box mut_key::MutableKeyType); store.register_late_pass(|| Box::new(mut_key::MutableKeyType));
store.register_late_pass(|| box modulo_arithmetic::ModuloArithmetic); store.register_late_pass(|| Box::new(modulo_arithmetic::ModuloArithmetic));
store.register_early_pass(|| box reference::DerefAddrOf); store.register_early_pass(|| Box::new(reference::DerefAddrOf));
store.register_early_pass(|| box reference::RefInDeref); store.register_early_pass(|| Box::new(reference::RefInDeref));
store.register_early_pass(|| box double_parens::DoubleParens); store.register_early_pass(|| Box::new(double_parens::DoubleParens));
store.register_late_pass(|| box to_string_in_display::ToStringInDisplay::new()); store.register_late_pass(|| Box::new(to_string_in_display::ToStringInDisplay::new()));
store.register_early_pass(|| box unsafe_removed_from_name::UnsafeNameRemoval); store.register_early_pass(|| Box::new(unsafe_removed_from_name::UnsafeNameRemoval));
store.register_early_pass(|| box if_not_else::IfNotElse); store.register_early_pass(|| Box::new(if_not_else::IfNotElse));
store.register_early_pass(|| box else_if_without_else::ElseIfWithoutElse); store.register_early_pass(|| Box::new(else_if_without_else::ElseIfWithoutElse));
store.register_early_pass(|| box int_plus_one::IntPlusOne); store.register_early_pass(|| Box::new(int_plus_one::IntPlusOne));
store.register_early_pass(|| box formatting::Formatting); store.register_early_pass(|| Box::new(formatting::Formatting));
store.register_early_pass(|| box misc_early::MiscEarlyLints); store.register_early_pass(|| Box::new(misc_early::MiscEarlyLints));
store.register_early_pass(|| box redundant_closure_call::RedundantClosureCall); store.register_early_pass(|| Box::new(redundant_closure_call::RedundantClosureCall));
store.register_late_pass(|| box redundant_closure_call::RedundantClosureCall); store.register_late_pass(|| Box::new(redundant_closure_call::RedundantClosureCall));
store.register_early_pass(|| box unused_unit::UnusedUnit); store.register_early_pass(|| Box::new(unused_unit::UnusedUnit));
store.register_late_pass(|| box returns::Return); store.register_late_pass(|| Box::new(returns::Return));
store.register_early_pass(|| box collapsible_if::CollapsibleIf); store.register_early_pass(|| Box::new(collapsible_if::CollapsibleIf));
store.register_early_pass(|| box items_after_statements::ItemsAfterStatements); store.register_early_pass(|| Box::new(items_after_statements::ItemsAfterStatements));
store.register_early_pass(|| box precedence::Precedence); store.register_early_pass(|| Box::new(precedence::Precedence));
store.register_early_pass(|| box needless_continue::NeedlessContinue); store.register_early_pass(|| Box::new(needless_continue::NeedlessContinue));
store.register_early_pass(|| box redundant_else::RedundantElse); store.register_early_pass(|| Box::new(redundant_else::RedundantElse));
store.register_late_pass(|| box create_dir::CreateDir); store.register_late_pass(|| Box::new(create_dir::CreateDir));
store.register_early_pass(|| box needless_arbitrary_self_type::NeedlessArbitrarySelfType); store.register_early_pass(|| Box::new(needless_arbitrary_self_type::NeedlessArbitrarySelfType));
let cargo_ignore_publish = conf.cargo_ignore_publish; let cargo_ignore_publish = conf.cargo_ignore_publish;
store.register_late_pass(move || box cargo_common_metadata::CargoCommonMetadata::new(cargo_ignore_publish)); store.register_late_pass(move || Box::new(cargo_common_metadata::CargoCommonMetadata::new(cargo_ignore_publish)));
store.register_late_pass(|| box multiple_crate_versions::MultipleCrateVersions); store.register_late_pass(|| Box::new(multiple_crate_versions::MultipleCrateVersions));
store.register_late_pass(|| box wildcard_dependencies::WildcardDependencies); store.register_late_pass(|| Box::new(wildcard_dependencies::WildcardDependencies));
let literal_representation_lint_fraction_readability = conf.unreadable_literal_lint_fractions; let literal_representation_lint_fraction_readability = conf.unreadable_literal_lint_fractions;
store.register_early_pass(move || box literal_representation::LiteralDigitGrouping::new(literal_representation_lint_fraction_readability)); store.register_early_pass(move || Box::new(literal_representation::LiteralDigitGrouping::new(literal_representation_lint_fraction_readability)));
let literal_representation_threshold = conf.literal_representation_threshold; let literal_representation_threshold = conf.literal_representation_threshold;
store.register_early_pass(move || box literal_representation::DecimalLiteralRepresentation::new(literal_representation_threshold)); store.register_early_pass(move || Box::new(literal_representation::DecimalLiteralRepresentation::new(literal_representation_threshold)));
let enum_variant_name_threshold = conf.enum_variant_name_threshold; let enum_variant_name_threshold = conf.enum_variant_name_threshold;
store.register_late_pass(move || box enum_variants::EnumVariantNames::new(enum_variant_name_threshold, avoid_breaking_exported_api)); store.register_late_pass(move || Box::new(enum_variants::EnumVariantNames::new(enum_variant_name_threshold, avoid_breaking_exported_api)));
store.register_early_pass(|| box tabs_in_doc_comments::TabsInDocComments); store.register_early_pass(|| Box::new(tabs_in_doc_comments::TabsInDocComments));
let upper_case_acronyms_aggressive = conf.upper_case_acronyms_aggressive; let upper_case_acronyms_aggressive = conf.upper_case_acronyms_aggressive;
store.register_late_pass(move || box upper_case_acronyms::UpperCaseAcronyms::new(avoid_breaking_exported_api, upper_case_acronyms_aggressive)); store.register_late_pass(move || Box::new(upper_case_acronyms::UpperCaseAcronyms::new(avoid_breaking_exported_api, upper_case_acronyms_aggressive)));
store.register_late_pass(|| box default::Default::default()); store.register_late_pass(|| Box::new(default::Default::default()));
store.register_late_pass(|| box unused_self::UnusedSelf); store.register_late_pass(|| Box::new(unused_self::UnusedSelf));
store.register_late_pass(|| box mutable_debug_assertion::DebugAssertWithMutCall); store.register_late_pass(|| Box::new(mutable_debug_assertion::DebugAssertWithMutCall));
store.register_late_pass(|| box exit::Exit); store.register_late_pass(|| Box::new(exit::Exit));
store.register_late_pass(|| box to_digit_is_some::ToDigitIsSome); store.register_late_pass(|| Box::new(to_digit_is_some::ToDigitIsSome));
let array_size_threshold = conf.array_size_threshold; let array_size_threshold = conf.array_size_threshold;
store.register_late_pass(move || box large_stack_arrays::LargeStackArrays::new(array_size_threshold)); store.register_late_pass(move || Box::new(large_stack_arrays::LargeStackArrays::new(array_size_threshold)));
store.register_late_pass(move || box large_const_arrays::LargeConstArrays::new(array_size_threshold)); store.register_late_pass(move || Box::new(large_const_arrays::LargeConstArrays::new(array_size_threshold)));
store.register_late_pass(|| box floating_point_arithmetic::FloatingPointArithmetic); store.register_late_pass(|| Box::new(floating_point_arithmetic::FloatingPointArithmetic));
store.register_early_pass(|| box as_conversions::AsConversions); store.register_early_pass(|| Box::new(as_conversions::AsConversions));
store.register_late_pass(|| box let_underscore::LetUnderscore); store.register_late_pass(|| Box::new(let_underscore::LetUnderscore));
store.register_early_pass(|| box single_component_path_imports::SingleComponentPathImports); store.register_early_pass(|| Box::new(single_component_path_imports::SingleComponentPathImports));
let max_fn_params_bools = conf.max_fn_params_bools; let max_fn_params_bools = conf.max_fn_params_bools;
let max_struct_bools = conf.max_struct_bools; let max_struct_bools = conf.max_struct_bools;
store.register_early_pass(move || box excessive_bools::ExcessiveBools::new(max_struct_bools, max_fn_params_bools)); store.register_early_pass(move || Box::new(excessive_bools::ExcessiveBools::new(max_struct_bools, max_fn_params_bools)));
store.register_early_pass(|| box option_env_unwrap::OptionEnvUnwrap); store.register_early_pass(|| Box::new(option_env_unwrap::OptionEnvUnwrap));
let warn_on_all_wildcard_imports = conf.warn_on_all_wildcard_imports; let warn_on_all_wildcard_imports = conf.warn_on_all_wildcard_imports;
store.register_late_pass(move || box wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports)); store.register_late_pass(move || Box::new(wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports)));
store.register_late_pass(|| box verbose_file_reads::VerboseFileReads); store.register_late_pass(|| Box::new(verbose_file_reads::VerboseFileReads));
store.register_late_pass(|| box redundant_pub_crate::RedundantPubCrate::default()); store.register_late_pass(|| Box::new(redundant_pub_crate::RedundantPubCrate::default()));
store.register_late_pass(|| box unnamed_address::UnnamedAddress); store.register_late_pass(|| Box::new(unnamed_address::UnnamedAddress));
store.register_late_pass(|| box dereference::Dereferencing::default()); store.register_late_pass(|| Box::new(dereference::Dereferencing::default()));
store.register_late_pass(|| box option_if_let_else::OptionIfLetElse); store.register_late_pass(|| Box::new(option_if_let_else::OptionIfLetElse));
store.register_late_pass(|| box future_not_send::FutureNotSend); store.register_late_pass(|| Box::new(future_not_send::FutureNotSend));
store.register_late_pass(|| box if_let_mutex::IfLetMutex); store.register_late_pass(|| Box::new(if_let_mutex::IfLetMutex));
store.register_late_pass(|| box mut_mutex_lock::MutMutexLock); store.register_late_pass(|| Box::new(mut_mutex_lock::MutMutexLock));
store.register_late_pass(|| box match_on_vec_items::MatchOnVecItems); store.register_late_pass(|| Box::new(match_on_vec_items::MatchOnVecItems));
store.register_late_pass(|| box manual_async_fn::ManualAsyncFn); store.register_late_pass(|| Box::new(manual_async_fn::ManualAsyncFn));
store.register_late_pass(|| box vec_resize_to_zero::VecResizeToZero); store.register_late_pass(|| Box::new(vec_resize_to_zero::VecResizeToZero));
store.register_late_pass(|| box panic_in_result_fn::PanicInResultFn); store.register_late_pass(|| Box::new(panic_in_result_fn::PanicInResultFn));
let single_char_binding_names_threshold = conf.single_char_binding_names_threshold; let single_char_binding_names_threshold = conf.single_char_binding_names_threshold;
store.register_early_pass(move || box non_expressive_names::NonExpressiveNames { store.register_early_pass(move || Box::new(non_expressive_names::NonExpressiveNames {
single_char_binding_names_threshold, single_char_binding_names_threshold,
}); }));
let macro_matcher = conf.standard_macro_braces.iter().cloned().collect::<FxHashSet<_>>(); let macro_matcher = conf.standard_macro_braces.iter().cloned().collect::<FxHashSet<_>>();
store.register_early_pass(move || box nonstandard_macro_braces::MacroBraces::new(&macro_matcher)); store.register_early_pass(move || Box::new(nonstandard_macro_braces::MacroBraces::new(&macro_matcher)));
store.register_late_pass(|| box macro_use::MacroUseImports::default()); store.register_late_pass(|| Box::new(macro_use::MacroUseImports::default()));
store.register_late_pass(|| box pattern_type_mismatch::PatternTypeMismatch); store.register_late_pass(|| Box::new(pattern_type_mismatch::PatternTypeMismatch));
store.register_late_pass(|| box stable_sort_primitive::StableSortPrimitive); store.register_late_pass(|| Box::new(stable_sort_primitive::StableSortPrimitive));
store.register_late_pass(|| box repeat_once::RepeatOnce); store.register_late_pass(|| Box::new(repeat_once::RepeatOnce));
store.register_late_pass(|| box unwrap_in_result::UnwrapInResult); store.register_late_pass(|| Box::new(unwrap_in_result::UnwrapInResult));
store.register_late_pass(|| box self_assignment::SelfAssignment); store.register_late_pass(|| Box::new(self_assignment::SelfAssignment));
store.register_late_pass(|| box manual_unwrap_or::ManualUnwrapOr); store.register_late_pass(|| Box::new(manual_unwrap_or::ManualUnwrapOr));
store.register_late_pass(|| box manual_ok_or::ManualOkOr); store.register_late_pass(|| Box::new(manual_ok_or::ManualOkOr));
store.register_late_pass(|| box float_equality_without_abs::FloatEqualityWithoutAbs); store.register_late_pass(|| Box::new(float_equality_without_abs::FloatEqualityWithoutAbs));
store.register_late_pass(|| box semicolon_if_nothing_returned::SemicolonIfNothingReturned); store.register_late_pass(|| Box::new(semicolon_if_nothing_returned::SemicolonIfNothingReturned));
store.register_late_pass(|| box async_yields_async::AsyncYieldsAsync); store.register_late_pass(|| Box::new(async_yields_async::AsyncYieldsAsync));
let disallowed_methods = conf.disallowed_methods.iter().cloned().collect::<FxHashSet<_>>(); let disallowed_methods = conf.disallowed_methods.iter().cloned().collect::<FxHashSet<_>>();
store.register_late_pass(move || box disallowed_method::DisallowedMethod::new(&disallowed_methods)); store.register_late_pass(move || Box::new(disallowed_method::DisallowedMethod::new(&disallowed_methods)));
store.register_early_pass(|| box asm_syntax::InlineAsmX86AttSyntax); store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86AttSyntax));
store.register_early_pass(|| box asm_syntax::InlineAsmX86IntelSyntax); store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86IntelSyntax));
store.register_late_pass(|| box undropped_manually_drops::UndroppedManuallyDrops); store.register_late_pass(|| Box::new(undropped_manually_drops::UndroppedManuallyDrops));
store.register_late_pass(|| box strings::StrToString); store.register_late_pass(|| Box::new(strings::StrToString));
store.register_late_pass(|| box strings::StringToString); store.register_late_pass(|| Box::new(strings::StringToString));
store.register_late_pass(|| box zero_sized_map_values::ZeroSizedMapValues); store.register_late_pass(|| Box::new(zero_sized_map_values::ZeroSizedMapValues));
store.register_late_pass(|| box vec_init_then_push::VecInitThenPush::default()); store.register_late_pass(|| Box::new(vec_init_then_push::VecInitThenPush::default()));
store.register_late_pass(|| box case_sensitive_file_extension_comparisons::CaseSensitiveFileExtensionComparisons); store.register_late_pass(|| Box::new(case_sensitive_file_extension_comparisons::CaseSensitiveFileExtensionComparisons));
store.register_late_pass(|| box redundant_slicing::RedundantSlicing); store.register_late_pass(|| Box::new(redundant_slicing::RedundantSlicing));
store.register_late_pass(|| box from_str_radix_10::FromStrRadix10); store.register_late_pass(|| Box::new(from_str_radix_10::FromStrRadix10));
store.register_late_pass(|| box manual_map::ManualMap); store.register_late_pass(|| Box::new(manual_map::ManualMap));
store.register_late_pass(move || box if_then_some_else_none::IfThenSomeElseNone::new(msrv)); store.register_late_pass(move || Box::new(if_then_some_else_none::IfThenSomeElseNone::new(msrv)));
store.register_early_pass(|| box bool_assert_comparison::BoolAssertComparison); store.register_early_pass(|| Box::new(bool_assert_comparison::BoolAssertComparison));
store.register_late_pass(|| box unused_async::UnusedAsync); store.register_late_pass(|| Box::new(unused_async::UnusedAsync));
let disallowed_types = conf.disallowed_types.iter().cloned().collect::<FxHashSet<_>>(); let disallowed_types = conf.disallowed_types.iter().cloned().collect::<FxHashSet<_>>();
store.register_late_pass(move || box disallowed_type::DisallowedType::new(&disallowed_types)); store.register_late_pass(move || Box::new(disallowed_type::DisallowedType::new(&disallowed_types)));
let import_renames = conf.enforced_import_renames.clone(); let import_renames = conf.enforced_import_renames.clone();
store.register_late_pass(move || box missing_enforced_import_rename::ImportRename::new(import_renames.clone())); store.register_late_pass(move || Box::new(missing_enforced_import_rename::ImportRename::new(import_renames.clone())));
let scripts = conf.allowed_scripts.clone(); let scripts = conf.allowed_scripts.clone();
store.register_early_pass(move || box disallowed_script_idents::DisallowedScriptIdents::new(&scripts)); store.register_early_pass(move || Box::new(disallowed_script_idents::DisallowedScriptIdents::new(&scripts)));
store.register_late_pass(|| box strlen_on_c_strings::StrlenOnCStrings); store.register_late_pass(|| Box::new(strlen_on_c_strings::StrlenOnCStrings));
store.register_late_pass(move || box self_named_constructors::SelfNamedConstructors); store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors));
} }
#[rustfmt::skip] #[rustfmt::skip]