Skip to content

Commit 0f08183

Browse files
hellow554est31
authored andcommitted
remove box_syntax uses from cranelift and tools
1 parent dd4cc0c commit 0f08183

File tree

16 files changed

+304
-298
lines changed

16 files changed

+304
-298
lines changed

compiler/rustc_codegen_cranelift/example/alloc_example.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, box_syntax, core_intrinsics, alloc_prelude, alloc_error_handler)]
1+
#![feature(start, core_intrinsics, alloc_prelude, alloc_error_handler)]
22
#![no_std]
33

44
extern crate alloc;

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(no_core, lang_items, box_syntax, never_type, linkage, extern_types, thread_local)]
1+
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local)]
22
#![no_core]
33
#![allow(dead_code, non_camel_case_types)]
44

compiler/rustc_codegen_cranelift/example/mod_bench.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, box_syntax, core_intrinsics, lang_items)]
1+
#![feature(start, core_intrinsics, lang_items)]
22
#![no_std]
33

44
#[cfg_attr(unix, link(name = "c"))]

src/librustdoc/clean/auto_trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
114114
attrs: Default::default(),
115115
visibility: Inherited,
116116
def_id: ItemId::Auto { trait_: trait_def_id, for_: item_def_id },
117-
kind: box ImplItem(Impl {
117+
kind: Box::new(ImplItem(Impl {
118118
span: Span::dummy(),
119119
unsafety: hir::Unsafety::Normal,
120120
generics: new_generics,
@@ -124,7 +124,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
124124
negative_polarity,
125125
synthetic: true,
126126
blanket_impl: None,
127-
}),
127+
})),
128128
cfg: None,
129129
})
130130
}

src/librustdoc/clean/blanket_impl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
9797
attrs: Default::default(),
9898
visibility: Inherited,
9999
def_id: ItemId::Blanket { impl_id: impl_def_id, for_: item_def_id },
100-
kind: box ImplItem(Impl {
100+
kind: Box::new(ImplItem(Impl {
101101
span: Span::new(self.cx.tcx.def_span(impl_def_id)),
102102
unsafety: hir::Unsafety::Normal,
103103
generics: (
@@ -118,8 +118,8 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
118118
.clean(self.cx),
119119
negative_polarity: false,
120120
synthetic: false,
121-
blanket_impl: Some(box trait_ref.self_ty().clean(self.cx)),
122-
}),
121+
blanket_impl: Some(Box::new(trait_ref.self_ty().clean(self.cx))),
122+
})),
123123
cfg: None,
124124
});
125125
}

src/librustdoc/clean/inline.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@ crate fn try_inline(
124124

125125
let (attrs, cfg) = merge_attrs(cx, Some(parent_module), load_attrs(cx, did), attrs_clone);
126126
cx.inlined.insert(did.into());
127-
let mut item =
128-
clean::Item::from_def_id_and_attrs_and_parts(did, Some(name), kind, box attrs, cx, cfg);
127+
let mut item = clean::Item::from_def_id_and_attrs_and_parts(
128+
did,
129+
Some(name),
130+
kind,
131+
Box::new(attrs),
132+
cx,
133+
cfg,
134+
);
129135
if let Some(import_def_id) = import_def_id {
130136
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
131137
item.visibility = cx.tcx.visibility(import_def_id).clean(cx);
@@ -458,7 +464,7 @@ crate fn build_impl(
458464
synthetic: false,
459465
blanket_impl: None,
460466
}),
461-
box merged_attrs,
467+
Box::new(merged_attrs),
462468
cx,
463469
cfg,
464470
));
@@ -486,10 +492,10 @@ fn build_module(
486492
let prim_ty = clean::PrimitiveType::from(p);
487493
items.push(clean::Item {
488494
name: None,
489-
attrs: box clean::Attributes::default(),
495+
attrs: Box::new(clean::Attributes::default()),
490496
def_id: ItemId::Primitive(prim_ty, did.krate),
491497
visibility: clean::Public,
492-
kind: box clean::ImportItem(clean::Import::new_simple(
498+
kind: Box::new(clean::ImportItem(clean::Import::new_simple(
493499
item.ident.name,
494500
clean::ImportSource {
495501
path: clean::Path {
@@ -506,7 +512,7 @@ fn build_module(
506512
did: None,
507513
},
508514
true,
509-
)),
515+
))),
510516
cfg: None,
511517
});
512518
} else if let Some(i) =

src/librustdoc/clean/mod.rs

+23-21
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
403403
Type::QPath {
404404
name: cx.tcx.associated_item(self.item_def_id).ident.name,
405405
self_def_id: self_type.def_id(),
406-
self_type: box self_type,
407-
trait_: box trait_,
406+
self_type: Box::new(self_type),
407+
trait_: Box::new(trait_),
408408
}
409409
}
410410
}
@@ -1305,8 +1305,8 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
13051305
Type::QPath {
13061306
name: p.segments.last().expect("segments were empty").ident.name,
13071307
self_def_id: Some(DefId::local(qself.hir_id.owner.local_def_index)),
1308-
self_type: box qself.clean(cx),
1309-
trait_: box resolve_type(cx, trait_path, hir_id),
1308+
self_type: Box::new(qself.clean(cx)),
1309+
trait_: Box::new(resolve_type(cx, trait_path, hir_id)),
13101310
}
13111311
}
13121312
hir::QPath::TypeRelative(ref qself, ref segment) => {
@@ -1320,8 +1320,8 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
13201320
Type::QPath {
13211321
name: segment.ident.name,
13221322
self_def_id: res.opt_def_id(),
1323-
self_type: box qself.clean(cx),
1324-
trait_: box resolve_type(cx, trait_path, hir_id),
1323+
self_type: Box::new(qself.clean(cx)),
1324+
trait_: Box::new(resolve_type(cx, trait_path, hir_id)),
13251325
}
13261326
}
13271327
hir::QPath::LangItem(..) => bug!("clean: requiring documentation of lang item"),
@@ -1334,7 +1334,7 @@ impl Clean<Type> for hir::Ty<'_> {
13341334

13351335
match self.kind {
13361336
TyKind::Never => Never,
1337-
TyKind::Ptr(ref m) => RawPointer(m.mutbl, box m.ty.clean(cx)),
1337+
TyKind::Ptr(ref m) => RawPointer(m.mutbl, Box::new(m.ty.clean(cx))),
13381338
TyKind::Rptr(ref l, ref m) => {
13391339
// There are two times a `Fresh` lifetime can be created:
13401340
// 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<'_> {
13461346
let elided =
13471347
l.is_elided() || matches!(l.name, LifetimeName::Param(ParamName::Fresh(_)));
13481348
let lifetime = if elided { None } else { Some(l.clean(cx)) };
1349-
BorrowedRef { lifetime, mutability: m.mutbl, type_: box m.ty.clean(cx) }
1349+
BorrowedRef { lifetime, mutability: m.mutbl, type_: Box::new(m.ty.clean(cx)) }
13501350
}
1351-
TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
1351+
TyKind::Slice(ref ty) => Slice(Box::new(ty.clean(cx))),
13521352
TyKind::Array(ref ty, ref length) => {
13531353
let def_id = cx.tcx.hir().local_def_id(length.hir_id);
13541354
// NOTE(min_const_generics): We can't use `const_eval_poly` for constants
@@ -1361,7 +1361,7 @@ impl Clean<Type> for hir::Ty<'_> {
13611361
let ct = ty::Const::from_anon_const(cx.tcx, def_id);
13621362
let param_env = cx.tcx.param_env(def_id);
13631363
let length = print_const(cx, ct.eval(cx.tcx, param_env));
1364-
Array(box ty.clean(cx), length)
1364+
Array(Box::new(ty.clean(cx)), length)
13651365
}
13661366
TyKind::Tup(ref tys) => Tuple(tys.clean(cx)),
13671367
TyKind::OpaqueDef(item_id, _) => {
@@ -1378,7 +1378,7 @@ impl Clean<Type> for hir::Ty<'_> {
13781378
let lifetime = if !lifetime.is_elided() { Some(lifetime.clean(cx)) } else { None };
13791379
DynTrait(bounds, lifetime)
13801380
}
1381-
TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
1381+
TyKind::BareFn(ref barefn) => BareFunction(Box::new(barefn.clean(cx))),
13821382
TyKind::Infer | TyKind::Err => Infer,
13831383
TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind),
13841384
}
@@ -1428,27 +1428,29 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14281428
ty::Uint(uint_ty) => Primitive(uint_ty.into()),
14291429
ty::Float(float_ty) => Primitive(float_ty.into()),
14301430
ty::Str => Primitive(PrimitiveType::Str),
1431-
ty::Slice(ty) => Slice(box ty.clean(cx)),
1431+
ty::Slice(ty) => Slice(Box::new(ty.clean(cx))),
14321432
ty::Array(ty, n) => {
14331433
let mut n = cx.tcx.lift(n).expect("array lift failed");
14341434
n = n.eval(cx.tcx, ty::ParamEnv::reveal_all());
14351435
let n = print_const(cx, n);
1436-
Array(box ty.clean(cx), n)
1437-
}
1438-
ty::RawPtr(mt) => RawPointer(mt.mutbl, box mt.ty.clean(cx)),
1439-
ty::Ref(r, ty, mutbl) => {
1440-
BorrowedRef { lifetime: r.clean(cx), mutability: mutbl, type_: box ty.clean(cx) }
1436+
Array(Box::new(ty.clean(cx)), n)
14411437
}
1438+
ty::RawPtr(mt) => RawPointer(mt.mutbl, Box::new(mt.ty.clean(cx))),
1439+
ty::Ref(r, ty, mutbl) => BorrowedRef {
1440+
lifetime: r.clean(cx),
1441+
mutability: mutbl,
1442+
type_: Box::new(ty.clean(cx)),
1443+
},
14421444
ty::FnDef(..) | ty::FnPtr(_) => {
14431445
let ty = cx.tcx.lift(*self).expect("FnPtr lift failed");
14441446
let sig = ty.fn_sig(cx.tcx);
14451447
let def_id = DefId::local(CRATE_DEF_INDEX);
1446-
BareFunction(box BareFunctionDecl {
1448+
BareFunction(Box::new(BareFunctionDecl {
14471449
unsafety: sig.unsafety(),
14481450
generic_params: Vec::new(),
14491451
decl: (def_id, sig).clean(cx),
14501452
abi: sig.abi(),
1451-
})
1453+
}))
14521454
}
14531455
ty::Adt(def, substs) => {
14541456
let did = def.did;
@@ -1988,10 +1990,10 @@ fn clean_extern_crate(
19881990
// FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
19891991
vec![Item {
19901992
name: Some(name),
1991-
attrs: box attrs.clean(cx),
1993+
attrs: Box::new(attrs.clean(cx)),
19921994
def_id: crate_def_id.into(),
19931995
visibility: krate.vis.clean(cx),
1994-
kind: box ExternCrateItem { src: orig_name },
1996+
kind: Box::new(ExternCrateItem { src: orig_name }),
19951997
cfg: attrs.cfg(cx.sess()),
19961998
}]
19971999
}

src/librustdoc/clean/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl Item {
416416
def_id,
417417
name,
418418
kind,
419-
box ast_attrs.clean(cx),
419+
Box::new(ast_attrs.clean(cx)),
420420
cx,
421421
ast_attrs.cfg(cx.sess()),
422422
)
@@ -434,7 +434,7 @@ impl Item {
434434

435435
Item {
436436
def_id: def_id.into(),
437-
kind: box kind,
437+
kind: Box::new(kind),
438438
name,
439439
attrs,
440440
visibility: cx.tcx.visibility(def_id).clean(cx),

src/librustdoc/core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ crate fn create_config(
265265
stderr: None,
266266
lint_caps,
267267
parse_sess_created: None,
268-
register_lints: Some(box crate::lint::register_lints),
268+
register_lints: Some(Box::new(crate::lint::register_lints)),
269269
override_queries: Some(|_sess, providers, _external_providers| {
270270
// Most lints will require typechecking, so just don't run them.
271271
providers.lint_mod = |_, _| {};

src/librustdoc/doctest.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
9999
stderr: None,
100100
lint_caps,
101101
parse_sess_created: None,
102-
register_lints: Some(box crate::lint::register_lints),
102+
register_lints: Some(Box::new(crate::lint::register_lints)),
103103
override_queries: None,
104104
make_codegen_backend: None,
105105
registry: rustc_driver::diagnostics_registry(),
@@ -549,10 +549,10 @@ crate fn make_test(
549549
.supports_color();
550550

551551
let emitter =
552-
EmitterWriter::new(box io::sink(), None, false, false, false, None, false);
552+
EmitterWriter::new(Box::new(io::sink()), None, false, false, false, None, false);
553553

554554
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
555-
let handler = Handler::with_emitter(false, None, box emitter);
555+
let handler = Handler::with_emitter(false, None, Box::new(emitter));
556556
let sess = ParseSess::with_span_handler(handler, sm);
557557

558558
let mut found_main = false;
@@ -962,7 +962,7 @@ impl Tester for Collector {
962962
no_run,
963963
test_type: test::TestType::DocTest,
964964
},
965-
testfn: test::DynTestFn(box move || {
965+
testfn: test::DynTestFn(Box::new(move || {
966966
let report_unused_externs = |uext| {
967967
unused_externs.lock().unwrap().push(uext);
968968
};
@@ -1042,9 +1042,9 @@ impl Tester for Collector {
10421042
}
10431043
}
10441044

1045-
panic::resume_unwind(box ());
1045+
panic::resume_unwind(Box::new(()));
10461046
}
1047-
}),
1047+
})),
10481048
});
10491049
}
10501050

src/librustdoc/fold.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::clean::*;
22

33
crate fn strip_item(mut item: Item) -> Item {
44
if !matches!(*item.kind, StrippedItem(..)) {
5-
item.kind = box StrippedItem(item.kind);
5+
item.kind = Box::new(StrippedItem(item.kind));
66
}
77
item
88
}
@@ -65,10 +65,10 @@ crate trait DocFolder: Sized {
6565

6666
/// don't override!
6767
fn fold_item_recur(&mut self, mut item: Item) -> Item {
68-
item.kind = box match *item.kind {
69-
StrippedItem(box i) => StrippedItem(box self.fold_inner_recur(i)),
68+
item.kind = Box::new(match *item.kind {
69+
StrippedItem(box i) => StrippedItem(Box::new(self.fold_inner_recur(i))),
7070
_ => self.fold_inner_recur(*item.kind),
71-
};
71+
});
7272
item
7373
}
7474

src/librustdoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(rustc_private)]
66
#![feature(array_methods)]
77
#![feature(box_patterns)]
8-
#![feature(box_syntax)]
98
#![feature(in_band_lifetimes)]
109
#![feature(nll)]
1110
#![feature(test)]

src/librustdoc/passes/collect_intra_doc_links.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ enum ErrorKind<'a> {
6161

6262
impl<'a> From<ResolutionFailure<'a>> for ErrorKind<'a> {
6363
fn from(err: ResolutionFailure<'a>) -> Self {
64-
ErrorKind::Resolve(box err)
64+
ErrorKind::Resolve(Box::new(err))
6565
}
6666
}
6767

src/tools/clippy/clippy_lints/src/booleans.rs

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

src/tools/clippy/clippy_lints/src/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
578578
let filename = FileName::anon_source_code(&code);
579579

580580
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
581-
let emitter = EmitterWriter::new(box io::sink(), None, false, false, false, None, false);
582-
let handler = Handler::with_emitter(false, None, box emitter);
581+
let emitter = EmitterWriter::new(Box::new(io::sink()), None, false, false, false, None, false);
582+
let handler = Handler::with_emitter(false, None, Box::new(emitter));
583583
let sess = ParseSess::with_span_handler(handler, sm);
584584

585585
let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) {

0 commit comments

Comments
 (0)