diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 5d994dbad4d1f..73d698218205e 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -141,7 +141,7 @@ pub struct LazyTokenStream(Lrc>); impl LazyTokenStream { pub fn new(inner: impl CreateTokenStream + 'static) -> LazyTokenStream { - LazyTokenStream(Lrc::new(Box::new(inner))) + LazyTokenStream(Lrc::new(box (inner))) } pub fn create_token_stream(&self) -> AttrAnnotatedTokenStream { diff --git a/compiler/rustc_builtin_macros/src/concat_idents.rs b/compiler/rustc_builtin_macros/src/concat_idents.rs index 209158ce39206..74b043bf397cb 100644 --- a/compiler/rustc_builtin_macros/src/concat_idents.rs +++ b/compiler/rustc_builtin_macros/src/concat_idents.rs @@ -66,5 +66,5 @@ pub fn expand_concat_idents<'cx>( } } - Box::new(ConcatIdentsResult { ident }) + box (ConcatIdentsResult { ident }) } diff --git a/compiler/rustc_builtin_macros/src/deriving/clone.rs b/compiler/rustc_builtin_macros/src/deriving/clone.rs index 2e5ad66c60bb8..63e8e6b30a094 100644 --- a/compiler/rustc_builtin_macros/src/deriving/clone.rs +++ b/compiler/rustc_builtin_macros/src/deriving/clone.rs @@ -45,28 +45,27 @@ pub fn expand_deriving_clone( { bounds = vec![]; is_shallow = true; - substructure = combine_substructure(Box::new(|c, s, sub| { - cs_clone_shallow("Clone", c, s, sub, false) - })); + substructure = combine_substructure( + box (|c, s, sub| cs_clone_shallow("Clone", c, s, sub, false)), + ); } else { bounds = vec![]; is_shallow = false; substructure = - combine_substructure(Box::new(|c, s, sub| cs_clone("Clone", c, s, sub))); + combine_substructure(box (|c, s, sub| cs_clone("Clone", c, s, sub))); } } ItemKind::Union(..) => { bounds = vec![Literal(path_std!(marker::Copy))]; is_shallow = true; - substructure = combine_substructure(Box::new(|c, s, sub| { - cs_clone_shallow("Clone", c, s, sub, true) - })); + substructure = combine_substructure( + box (|c, s, sub| cs_clone_shallow("Clone", c, s, sub, true)), + ); } _ => { bounds = vec![]; is_shallow = false; - substructure = - combine_substructure(Box::new(|c, s, sub| cs_clone("Clone", c, s, sub))); + substructure = combine_substructure(box (|c, s, sub| cs_clone("Clone", c, s, sub))); } }, diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs index 54ab88dc3ffc9..0695e1ba945e0 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs @@ -38,9 +38,7 @@ pub fn expand_deriving_eq( attributes: attrs, is_unsafe: false, unify_fieldless_variants: true, - combine_substructure: combine_substructure(Box::new(|a, b, c| { - cs_total_eq_assert(a, b, c) - })), + combine_substructure: combine_substructure(box (|a, b, c| cs_total_eq_assert(a, b, c))), }], associated_types: Vec::new(), }; diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs index f84e6e0762012..1cf56d389b8c3 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs @@ -34,7 +34,7 @@ pub fn expand_deriving_ord( attributes: attrs, is_unsafe: false, unify_fieldless_variants: true, - combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))), + combine_substructure: combine_substructure(box (|a, b, c| cs_cmp(a, b, c))), }], associated_types: Vec::new(), }; @@ -100,7 +100,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P< cx.expr_match(span, new, vec![eq_arm, neq_arm]) }, cx.expr_path(equals_path.clone()), - Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { + box (|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`") } else { diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs index 8e9f15743cc34..1194f86ddc959 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs @@ -49,7 +49,7 @@ pub fn expand_deriving_partial_eq( None => cx.expr_bool(span, base), } }, - Box::new(|cx, span, _, _| cx.expr_bool(span, !base)), + box (|cx, span, _, _| cx.expr_bool(span, !base)), cx, span, substr, @@ -76,7 +76,7 @@ pub fn expand_deriving_partial_eq( attributes: attrs, is_unsafe: false, unify_fieldless_variants: true, - combine_substructure: combine_substructure(Box::new(|a, b, c| $f(a, b, c))), + combine_substructure: combine_substructure(box (|a, b, c| $f(a, b, c))), } }}; } diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs index 151a919e0293b..a58a86f8d51a9 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs @@ -19,7 +19,7 @@ pub fn expand_deriving_partial_ord( let ret_ty = Literal(Path::new_( pathvec_std!(option::Option), None, - vec![Box::new(ordering_ty)], + vec![box (ordering_ty)], PathKind::Std, )); @@ -35,9 +35,9 @@ pub fn expand_deriving_partial_ord( attributes: attrs, is_unsafe: false, unify_fieldless_variants: true, - combine_substructure: combine_substructure(Box::new(|cx, span, substr| { - cs_partial_cmp(cx, span, substr) - })), + combine_substructure: combine_substructure( + box (|cx, span, substr| cs_partial_cmp(cx, span, substr)), + ), }; let trait_def = TraitDef { @@ -103,7 +103,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_ cx.expr_match(span, new, vec![eq_arm, neq_arm]) }, equals_expr, - Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { + box (|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") } else { diff --git a/compiler/rustc_builtin_macros/src/deriving/debug.rs b/compiler/rustc_builtin_macros/src/deriving/debug.rs index cc6dac52d7663..22fc3bdb81592 100644 --- a/compiler/rustc_builtin_macros/src/deriving/debug.rs +++ b/compiler/rustc_builtin_macros/src/deriving/debug.rs @@ -20,8 +20,7 @@ pub fn expand_deriving_debug( push: &mut dyn FnMut(Annotatable), ) { // &mut ::std::fmt::Formatter - let fmtr = - Ptr(Box::new(Literal(path_std!(fmt::Formatter))), Borrowed(None, ast::Mutability::Mut)); + let fmtr = Ptr(box (Literal(path_std!(fmt::Formatter))), Borrowed(None, ast::Mutability::Mut)); let trait_def = TraitDef { span, @@ -40,9 +39,7 @@ pub fn expand_deriving_debug( attributes: Vec::new(), is_unsafe: false, unify_fieldless_variants: false, - combine_substructure: combine_substructure(Box::new(|a, b, c| { - show_substructure(a, b, c) - })), + combine_substructure: combine_substructure(box (|a, b, c| show_substructure(a, b, c))), }], associated_types: Vec::new(), }; diff --git a/compiler/rustc_builtin_macros/src/deriving/decodable.rs b/compiler/rustc_builtin_macros/src/deriving/decodable.rs index 1d892b20729d5..9f941b7f03cbc 100644 --- a/compiler/rustc_builtin_macros/src/deriving/decodable.rs +++ b/compiler/rustc_builtin_macros/src/deriving/decodable.rs @@ -38,15 +38,15 @@ pub fn expand_deriving_rustc_decodable( }, explicit_self: None, args: vec![( - Ptr(Box::new(Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)), + Ptr(box (Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)), sym::d, )], ret_ty: Literal(Path::new_( pathvec_std!(result::Result), None, vec![ - Box::new(Self_), - Box::new(Literal(Path::new_( + box (Self_), + box (Literal(Path::new_( vec![typaram, sym::Error], None, vec![], @@ -58,9 +58,9 @@ pub fn expand_deriving_rustc_decodable( attributes: Vec::new(), is_unsafe: false, unify_fieldless_variants: false, - combine_substructure: combine_substructure(Box::new(|a, b, c| { - decodable_substructure(a, b, c, krate) - })), + combine_substructure: combine_substructure( + box (|a, b, c| decodable_substructure(a, b, c, krate)), + ), }], associated_types: Vec::new(), }; diff --git a/compiler/rustc_builtin_macros/src/deriving/default.rs b/compiler/rustc_builtin_macros/src/deriving/default.rs index 8c53094b62496..53d7f733b58c2 100644 --- a/compiler/rustc_builtin_macros/src/deriving/default.rs +++ b/compiler/rustc_builtin_macros/src/deriving/default.rs @@ -41,8 +41,8 @@ pub fn expand_deriving_default( attributes: attrs, is_unsafe: false, unify_fieldless_variants: false, - combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| { - match substr.fields { + combine_substructure: combine_substructure( + box (|cx, trait_span, substr| match substr.fields { StaticStruct(_, fields) => { default_struct_substructure(cx, trait_span, substr, fields) } @@ -59,8 +59,8 @@ pub fn expand_deriving_default( default_enum_substructure(cx, trait_span, enum_def) } _ => cx.span_bug(trait_span, "method in `derive(Default)`"), - } - })), + }), + ), }], associated_types: Vec::new(), }; diff --git a/compiler/rustc_builtin_macros/src/deriving/encodable.rs b/compiler/rustc_builtin_macros/src/deriving/encodable.rs index c5f3a9d3379a7..6d4be3d3c5e3d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/encodable.rs +++ b/compiler/rustc_builtin_macros/src/deriving/encodable.rs @@ -123,15 +123,15 @@ pub fn expand_deriving_rustc_encodable( }, explicit_self: borrowed_explicit_self(), args: vec![( - Ptr(Box::new(Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)), + Ptr(box (Literal(Path::new_local(typaram))), Borrowed(None, Mutability::Mut)), sym::s, )], ret_ty: Literal(Path::new_( pathvec_std!(result::Result), None, vec![ - Box::new(Tuple(Vec::new())), - Box::new(Literal(Path::new_( + box (Tuple(Vec::new())), + box (Literal(Path::new_( vec![typaram, sym::Error], None, vec![], @@ -143,9 +143,9 @@ pub fn expand_deriving_rustc_encodable( attributes: Vec::new(), is_unsafe: false, unify_fieldless_variants: false, - combine_substructure: combine_substructure(Box::new(|a, b, c| { - encodable_substructure(a, b, c, krate) - })), + combine_substructure: combine_substructure( + box (|a, b, c| encodable_substructure(a, b, c, krate)), + ), }], associated_types: Vec::new(), }; diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs index 00d75be439964..b23b95968545a 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs @@ -113,7 +113,7 @@ pub fn borrowed_explicit_self() -> Option> { } pub fn borrowed_self() -> Ty { - borrowed(Box::new(Self_)) + borrowed(box (Self_)) } pub fn nil_ty() -> Ty { diff --git a/compiler/rustc_builtin_macros/src/deriving/hash.rs b/compiler/rustc_builtin_macros/src/deriving/hash.rs index 7114b98768091..0e07e98ebb010 100644 --- a/compiler/rustc_builtin_macros/src/deriving/hash.rs +++ b/compiler/rustc_builtin_macros/src/deriving/hash.rs @@ -32,14 +32,12 @@ pub fn expand_deriving_hash( name: sym::hash, generics: Bounds { bounds: vec![(typaram, vec![path_std!(hash::Hasher)])] }, explicit_self: borrowed_explicit_self(), - args: vec![(Ptr(Box::new(Literal(arg)), Borrowed(None, Mutability::Mut)), sym::state)], + args: vec![(Ptr(box (Literal(arg)), Borrowed(None, Mutability::Mut)), sym::state)], ret_ty: nil_ty(), attributes: vec![], is_unsafe: false, unify_fieldless_variants: true, - combine_substructure: combine_substructure(Box::new(|a, b, c| { - hash_substructure(a, b, c) - })), + combine_substructure: combine_substructure(box (|a, b, c| hash_substructure(a, b, c))), }], associated_types: Vec::new(), }; diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index b1be50b0bf990..3e7af5dd42f93 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -51,13 +51,13 @@ pub mod test_harness; pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { let mut register = |name, kind| resolver.register_builtin_macro(name, kind); macro register_bang($($name:ident: $f:expr,)*) { - $(register(sym::$name, SyntaxExtensionKind::LegacyBang(Box::new($f as MacroExpanderFn)));)* + $(register(sym::$name, SyntaxExtensionKind::LegacyBang(box ($f as MacroExpanderFn)));)* } macro register_attr($($name:ident: $f:expr,)*) { - $(register(sym::$name, SyntaxExtensionKind::LegacyAttr(Box::new($f)));)* + $(register(sym::$name, SyntaxExtensionKind::LegacyAttr(box ($f)));)* } macro register_derive($($name:ident: $f:expr,)*) { - $(register(sym::$name, SyntaxExtensionKind::LegacyDerive(Box::new(BuiltinDerive($f))));)* + $(register(sym::$name, SyntaxExtensionKind::LegacyDerive(box (BuiltinDerive($f))));)* } register_bang! { @@ -113,5 +113,5 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { } let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote); - register(sym::quote, SyntaxExtensionKind::Bang(Box::new(BangProcMacro { client }))); + register(sym::quote, SyntaxExtensionKind::Bang(box (BangProcMacro { client }))); } diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index 1ea2c8843d6d7..afdeaa3a02391 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -159,7 +159,7 @@ pub fn expand_include<'cx>( } } - Box::new(ExpandResult { p, node_id: cx.current_expansion.lint_node_id }) + box (ExpandResult { p, node_id: cx.current_expansion.lint_node_id }) } // include_str! : read the given file, insert it as a literal string expr diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 6ac7093b7dee8..91fcd5c2b5e79 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -284,7 +284,7 @@ impl<'a> LlvmArchiveBuilder<'a> { self.additions.push(Addition::Archive { path: archive.to_path_buf(), archive: archive_ro, - skip: Box::new(skip), + skip: box (skip), }); Ok(()) } diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 5b4a187a1d56f..a7fc619ae8e00 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -249,7 +249,7 @@ impl<'a> DiagnosticHandlers<'a> { handler: &'a Handler, llcx: &'a llvm::Context, ) -> Self { - let data = Box::into_raw(Box::new((cgcx, handler))); + let data = Box::into_raw(box ((cgcx, handler))); unsafe { llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data.cast()); llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data.cast()); diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index aa4db1622b233..a461ee8e021e2 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -7,6 +7,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(bool_to_option)] #![feature(const_cstr_unchecked)] +#![feature(box_syntax)] #![feature(crate_visibility_modifier)] #![feature(extern_types)] #![feature(in_band_lifetimes)] @@ -197,7 +198,7 @@ unsafe impl Sync for LlvmCodegenBackend {} impl LlvmCodegenBackend { pub fn new() -> Box { - Box::new(LlvmCodegenBackend(())) + box (LlvmCodegenBackend(())) } } @@ -253,7 +254,7 @@ impl CodegenBackend for LlvmCodegenBackend { metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box { - Box::new(rustc_codegen_ssa::base::codegen_crate( + box (rustc_codegen_ssa::base::codegen_crate( LlvmCodegenBackend(()), tcx, crate::llvm_util::target_cpu(tcx.sess).to_string(), diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 9e1c6a169f152..65ab9e01ceac8 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -130,26 +130,26 @@ pub fn get_linker<'a>( match flavor { LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => { - Box::new(MsvcLinker { cmd, sess }) as Box + box (MsvcLinker { cmd, sess }) as Box } - LinkerFlavor::Em => Box::new(EmLinker { cmd, sess }) as Box, + LinkerFlavor::Em => box (EmLinker { cmd, sess }) as Box, LinkerFlavor::Gcc => { - Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: false }) + box (GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: false }) as Box } LinkerFlavor::Lld(LldFlavor::Ld) | LinkerFlavor::Lld(LldFlavor::Ld64) | LinkerFlavor::Ld => { - Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: true }) + box (GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: true }) as Box } - LinkerFlavor::Lld(LldFlavor::Wasm) => Box::new(WasmLd::new(cmd, sess)) as Box, + LinkerFlavor::Lld(LldFlavor::Wasm) => box (WasmLd::new(cmd, sess)) as Box, - LinkerFlavor::PtxLinker => Box::new(PtxLinker { cmd, sess }) as Box, + LinkerFlavor::PtxLinker => box (PtxLinker { cmd, sess }) as Box, - LinkerFlavor::BpfLinker => Box::new(BpfLinker { cmd, sess }) as Box, + LinkerFlavor::BpfLinker => box (BpfLinker { cmd, sess }) as Box, } } diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 41823f7d80d69..9c7701ab52179 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -342,7 +342,7 @@ pub struct CodegenContext { impl CodegenContext { pub fn create_diag_handler(&self) -> Handler { - Handler::with_emitter(true, None, Box::new(self.diag_emitter.clone())) + Handler::with_emitter(true, None, box (self.diag_emitter.clone())) } pub fn config(&self, kind: ModuleKind) -> &ModuleConfig { @@ -1007,7 +1007,7 @@ fn start_executing_work( let coordinator_send2 = coordinator_send.clone(); let helper = jobserver .into_helper_thread(move |token| { - drop(coordinator_send2.send(Box::new(Message::Token::(token)))); + drop(coordinator_send2.send(box (Message::Token::(token)))); }) .expect("failed to spawn helper thread"); @@ -1642,7 +1642,7 @@ fn spawn_work(cgcx: CodegenContext, work: WorkItem } None => Message::Done:: { result: Err(None), worker_id }, }; - drop(self.coordinator_send.send(Box::new(msg))); + drop(self.coordinator_send.send(box (msg))); } } @@ -1864,7 +1864,7 @@ impl OngoingCodegen { pub fn codegen_finished(&self, tcx: TyCtxt<'_>) { self.wait_for_signal_to_codegen_item(); self.check_for_errors(tcx.sess); - drop(self.coordinator_send.send(Box::new(Message::CodegenComplete::))); + drop(self.coordinator_send.send(box (Message::CodegenComplete::))); } /// Consumes this context indicating that codegen was entirely aborted, and @@ -1876,7 +1876,7 @@ impl OngoingCodegen { pub fn codegen_aborted(self) { // Signal to the coordinator it should spawn no more work and start // shutdown. - drop(self.coordinator_send.send(Box::new(Message::CodegenAborted::))); + drop(self.coordinator_send.send(box (Message::CodegenAborted::))); drop(self.future.join()); } @@ -1905,7 +1905,7 @@ pub fn submit_codegened_module_to_llvm( cost: u64, ) { let llvm_work_item = WorkItem::Optimize(module); - drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone:: { llvm_work_item, cost }))); + drop(tx_to_llvm_workers.send(box (Message::CodegenDone:: { llvm_work_item, cost }))); } pub fn submit_post_lto_module_to_llvm( @@ -1914,7 +1914,7 @@ pub fn submit_post_lto_module_to_llvm( module: CachedModuleCodegen, ) { let llvm_work_item = WorkItem::CopyPostLtoArtifacts(module); - drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone:: { llvm_work_item, cost: 0 }))); + drop(tx_to_llvm_workers.send(box (Message::CodegenDone:: { llvm_work_item, cost: 0 }))); } pub fn submit_pre_lto_module_to_llvm( @@ -1934,10 +1934,12 @@ pub fn submit_pre_lto_module_to_llvm( }) }; // Schedule the module to be loaded - drop(tx_to_llvm_workers.send(Box::new(Message::AddImportOnlyModule:: { - module_data: SerializedModule::FromUncompressedFile(mmap), - work_product: module.source, - }))); + drop(tx_to_llvm_workers.send( + box (Message::AddImportOnlyModule:: { + module_data: SerializedModule::FromUncompressedFile(mmap), + work_product: module.source, + }), + )); } pub fn pre_lto_bitcode_filename(module_name: &str) -> String { diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index b6ee70c419b16..bc704a929b1b9 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -1,6 +1,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(bool_to_option)] #![feature(box_patterns)] +#![feature(box_syntax)] #![feature(try_blocks)] #![feature(in_band_lifetimes)] #![feature(nll)] diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index dc4146ec7b58d..156d12ffe5bfe 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -68,7 +68,7 @@ pub trait CodegenBackend { /// Alternative codegen backends may want to use different rlib or dylib formats than the /// default native static archives and dynamic libraries. fn metadata_loader(&self) -> Box { - Box::new(crate::back::metadata::DefaultMetadataLoader) + box (crate::back::metadata::DefaultMetadataLoader) } fn provide(&self, _providers: &mut Providers) {} diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 18bc2f896f2f2..1941d2d7c0e8c 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -10,6 +10,7 @@ #![feature(allow_internal_unstable)] #![feature(array_windows)] #![feature(associated_type_bounds)] +#![feature(box_syntax)] #![feature(auto_traits)] #![feature(bool_to_option)] #![feature(const_panic)] diff --git a/compiler/rustc_data_structures/src/owning_ref/mod.rs b/compiler/rustc_data_structures/src/owning_ref/mod.rs index ad4b79de2361d..f35e5c7d1a722 100644 --- a/compiler/rustc_data_structures/src/owning_ref/mod.rs +++ b/compiler/rustc_data_structures/src/owning_ref/mod.rs @@ -61,7 +61,7 @@ use owning_ref::BoxRef; fn main() { // Create an array owned by a Box. - let arr = Box::new([1, 2, 3, 4]) as Box<[i32]>; + let arr = box ([1, 2, 3, 4]) as Box<[i32]>; // Transfer into a BoxRef. let arr: BoxRef<[i32]> = BoxRef::new(arr); @@ -90,7 +90,7 @@ fn main() { } let foo = Foo { tag: 1, x: 100, y: 200, z: 300 }; - let or = BoxRef::new(Box::new(foo)).map(|foo| { + let or = BoxRef::new(box (foo)).map(|foo| { match foo.tag { 0 => &foo.x, 1 => &foo.y, @@ -330,7 +330,7 @@ impl OwningRef { /// use owning_ref::OwningRef; /// /// fn main() { - /// let owning_ref = OwningRef::new(Box::new(42)); + /// let owning_ref = OwningRef::new(box (42)); /// assert_eq!(*owning_ref, 42); /// } /// ``` @@ -366,7 +366,7 @@ impl OwningRef { /// use owning_ref::OwningRef; /// /// fn main() { - /// let owning_ref = OwningRef::new(Box::new([1, 2, 3, 4])); + /// let owning_ref = OwningRef::new(box ([1, 2, 3, 4])); /// /// // create a owning reference that points at the /// // third element of the array. @@ -394,7 +394,7 @@ impl OwningRef { /// use owning_ref::OwningRef; /// /// fn main() { - /// let owning_ref = OwningRef::new(Box::new([1, 2, 3, 4])); + /// let owning_ref = OwningRef::new(box ([1, 2, 3, 4])); /// /// // create a owning reference that points at the /// // third element of the array. @@ -432,7 +432,7 @@ impl OwningRef { /// This can be used to safely erase the owner of any `OwningRef` /// to a `OwningRef, T>`. pub fn map_owner_box(self) -> OwningRef, T> { - OwningRef { reference: self.reference, owner: Box::new(self.owner) } + OwningRef { reference: self.reference, owner: box (self.owner) } } /// Erases the concrete base type of the owner with a trait object. @@ -449,10 +449,10 @@ impl OwningRef { /// // For less verbose code type aliases like `BoxRef` are provided. /// /// let owning_ref_a: OwningRef, [i32; 4]> - /// = OwningRef::new(Box::new([1, 2, 3, 4])); + /// = OwningRef::new(box ([1, 2, 3, 4])); /// /// let owning_ref_b: OwningRef>, Vec<(i32, bool)>> - /// = OwningRef::new(Box::new(vec![(0, false), (1, true)])); + /// = OwningRef::new(box (vec![(0, false), (1, true)])); /// /// let owning_ref_a: OwningRef, i32> /// = owning_ref_a.map(|a| &a[0]); @@ -520,7 +520,7 @@ impl OwningRefMut { /// use owning_ref::OwningRefMut; /// /// fn main() { - /// let owning_ref_mut = OwningRefMut::new(Box::new(42)); + /// let owning_ref_mut = OwningRefMut::new(box (42)); /// assert_eq!(*owning_ref_mut, 42); /// } /// ``` @@ -556,7 +556,7 @@ impl OwningRefMut { /// use owning_ref::OwningRefMut; /// /// fn main() { - /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// let owning_ref_mut = OwningRefMut::new(box ([1, 2, 3, 4])); /// /// // create a owning reference that points at the /// // third element of the array. @@ -584,7 +584,7 @@ impl OwningRefMut { /// use owning_ref::OwningRefMut; /// /// fn main() { - /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// let owning_ref_mut = OwningRefMut::new(box ([1, 2, 3, 4])); /// /// // create a owning reference that points at the /// // third element of the array. @@ -612,7 +612,7 @@ impl OwningRefMut { /// use owning_ref::OwningRefMut; /// /// fn main() { - /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// let owning_ref_mut = OwningRefMut::new(box ([1, 2, 3, 4])); /// /// // create a owning reference that points at the /// // third element of the array. @@ -642,7 +642,7 @@ impl OwningRefMut { /// use owning_ref::OwningRefMut; /// /// fn main() { - /// let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// let owning_ref_mut = OwningRefMut::new(box ([1, 2, 3, 4])); /// /// // create a owning reference that points at the /// // third element of the array. @@ -680,7 +680,7 @@ impl OwningRefMut { /// This can be used to safely erase the owner of any `OwningRefMut` /// to a `OwningRefMut, T>`. pub fn map_owner_box(self) -> OwningRefMut, T> { - OwningRefMut { reference: self.reference, owner: Box::new(self.owner) } + OwningRefMut { reference: self.reference, owner: box (self.owner) } } /// Erases the concrete base type of the owner with a trait object. @@ -697,10 +697,10 @@ impl OwningRefMut { /// // For less verbose code type aliases like `BoxRef` are provided. /// /// let owning_ref_mut_a: OwningRefMut, [i32; 4]> - /// = OwningRefMut::new(Box::new([1, 2, 3, 4])); + /// = OwningRefMut::new(box ([1, 2, 3, 4])); /// /// let owning_ref_mut_b: OwningRefMut>, Vec<(i32, bool)>> - /// = OwningRefMut::new(Box::new(vec![(0, false), (1, true)])); + /// = OwningRefMut::new(box (vec![(0, false), (1, true)])); /// /// let owning_ref_mut_a: OwningRefMut, i32> /// = owning_ref_mut_a.map_mut(|a| &mut a[0]); diff --git a/compiler/rustc_data_structures/src/thin_vec.rs b/compiler/rustc_data_structures/src/thin_vec.rs index 00e304734983f..d0974edce4d8d 100644 --- a/compiler/rustc_data_structures/src/thin_vec.rs +++ b/compiler/rustc_data_structures/src/thin_vec.rs @@ -24,7 +24,7 @@ impl ThinVec { impl From> for ThinVec { fn from(vec: Vec) -> Self { - if vec.is_empty() { ThinVec(None) } else { ThinVec(Some(Box::new(vec))) } + if vec.is_empty() { ThinVec(None) } else { ThinVec(Some(box (vec))) } } } @@ -60,7 +60,7 @@ impl FromIterator for ThinVec { fn from_iter>(iter: I) -> Self { // `Vec::from_iter()` should not allocate if the iterator is empty. let vec: Vec<_> = iter.into_iter().collect(); - if vec.is_empty() { ThinVec(None) } else { ThinVec(Some(Box::new(vec))) } + if vec.is_empty() { ThinVec(None) } else { ThinVec(Some(box (vec))) } } } diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 84dd69ebd9634..282a1fe2d2dbe 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -7,6 +7,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(nll)] #![feature(once_cell)] +#![feature(box_syntax)] #![recursion_limit = "256"] #[macro_use] @@ -1163,16 +1164,18 @@ pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 { static DEFAULT_HOOK: SyncLazy) + Sync + Send + 'static>> = SyncLazy::new(|| { let hook = panic::take_hook(); - panic::set_hook(Box::new(|info| { - // Invoke the default handler, which prints the actual panic message and optionally a backtrace - (*DEFAULT_HOOK)(info); + panic::set_hook( + box (|info| { + // Invoke the default handler, which prints the actual panic message and optionally a backtrace + (*DEFAULT_HOOK)(info); - // Separate the output with an empty line - eprintln!(); + // Separate the output with an empty line + eprintln!(); - // Print the ICE message - report_ice(info, BUG_REPORT_URL); - })); + // Print the ICE message + report_ice(info, BUG_REPORT_URL); + }), + ); hook }); @@ -1183,7 +1186,7 @@ static DEFAULT_HOOK: SyncLazy) + Sync + Send + /// When `install_ice_hook` is called, this function will be called as the panic /// hook. pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { - let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr( + let emitter = box (rustc_errors::emitter::EmitterWriter::stderr( rustc_errors::ColorConfig::Auto, None, false, diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index d35b29248033f..86cee70ae918a 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -409,11 +409,9 @@ impl<'a> DiagnosticBuilder<'a> { /// diagnostic. crate fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) -> DiagnosticBuilder<'a> { debug!("Created new diagnostic"); - DiagnosticBuilder(Box::new(DiagnosticBuilderInner { - handler, - diagnostic, - allow_suggestions: true, - })) + DiagnosticBuilder( + box (DiagnosticBuilderInner { handler, diagnostic, allow_suggestions: true }), + ) } } diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 1b6cd04cca642..98986846b176b 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -53,7 +53,7 @@ impl JsonEmitter { macro_backtrace: bool, ) -> JsonEmitter { JsonEmitter { - dst: Box::new(io::BufWriter::new(io::stderr())), + dst: box (io::BufWriter::new(io::stderr())), registry, sm: source_map, pretty, @@ -373,7 +373,7 @@ impl Diagnostic { let output = buf.clone(); je.json_rendered .new_emitter( - Box::new(buf), + box (buf), Some(je.sm.clone()), false, je.terminal_width, @@ -456,7 +456,7 @@ impl DiagnosticSpan { let call_site = Self::from_span_full(bt.call_site, false, None, None, backtrace, je); let def_site_span = Self::from_span_full(bt.def_site, false, None, None, vec![].into_iter(), je); - Box::new(DiagnosticSpanMacroExpansion { + box (DiagnosticSpanMacroExpansion { span: call_site, macro_decl_name: bt.kind.descr(), def_site_span, diff --git a/compiler/rustc_errors/src/json/tests.rs b/compiler/rustc_errors/src/json/tests.rs index d055937ac36e3..1a930f0bdf26d 100644 --- a/compiler/rustc_errors/src/json/tests.rs +++ b/compiler/rustc_errors/src/json/tests.rs @@ -49,7 +49,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) { let output = Arc::new(Mutex::new(Vec::new())); let je = JsonEmitter::new( - Box::new(Shared { data: output.clone() }), + box (Shared { data: output.clone() }), None, sm, true, @@ -59,7 +59,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) { ); let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1)); - let handler = Handler::with_emitter(true, None, Box::new(je)); + let handler = Handler::with_emitter(true, None, box (je)); handler.span_err(span, "foo"); let bytes = output.lock().unwrap(); diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 993a7c2c162c6..85fc28f919401 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -7,6 +7,7 @@ #![feature(backtrace)] #![feature(format_args_capture)] #![feature(iter_zip)] +#![feature(box_syntax)] #![feature(nll)] #[macro_use] @@ -414,7 +415,7 @@ impl Handler { sm: Option>, flags: HandlerFlags, ) -> Self { - let emitter = Box::new(EmitterWriter::stderr( + let emitter = box (EmitterWriter::stderr( color_config, sm, false, diff --git a/compiler/rustc_errors/src/lock.rs b/compiler/rustc_errors/src/lock.rs index a73472021d412..7654433e39d04 100644 --- a/compiler/rustc_errors/src/lock.rs +++ b/compiler/rustc_errors/src/lock.rs @@ -83,11 +83,11 @@ pub fn acquire_global_lock(name: &str) -> Box { } // Return a guard which will call `ReleaseMutex` when dropped. - Box::new(Guard(mutex)) + box (Guard(mutex)) } } #[cfg(not(windows))] pub fn acquire_global_lock(_name: &str) -> Box { - Box::new(()) + box (()) } diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index b454737fb8077..cefe4ef9e7f1c 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -434,7 +434,7 @@ macro_rules! make_MacEager { impl MacEager { $( pub fn $fld(v: $t) -> Box { - Box::new(MacEager { + box (MacEager { $fld: Some(v), ..Default::default() }) @@ -519,12 +519,12 @@ impl DummyResult { /// Use this as a return value after hitting any errors and /// calling `span_err`. pub fn any(span: Span) -> Box { - Box::new(DummyResult { is_error: true, span }) + box (DummyResult { is_error: true, span }) } /// Same as `any`, but must be a valid fragment, not error. pub fn any_valid(span: Span) -> Box { - Box::new(DummyResult { is_error: false, span }) + box (DummyResult { is_error: false, span }) } /// A plain dummy expression. @@ -796,7 +796,7 @@ impl SyntaxExtension { ) -> Box { DummyResult::any(span) } - SyntaxExtension::default(SyntaxExtensionKind::LegacyBang(Box::new(expander)), edition) + SyntaxExtension::default(SyntaxExtensionKind::LegacyBang(box (expander)), edition) } pub fn dummy_derive(edition: Edition) -> SyntaxExtension { @@ -808,7 +808,7 @@ impl SyntaxExtension { ) -> Vec { Vec::new() } - SyntaxExtension::default(SyntaxExtensionKind::Derive(Box::new(expander)), edition) + SyntaxExtension::default(SyntaxExtensionKind::Derive(box (expander)), edition) } pub fn non_macro_attr(mark_used: bool, edition: Edition) -> SyntaxExtension { diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index efed41de23a89..e5c69989c2995 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -3,6 +3,7 @@ #![feature(destructuring_assignment)] #![feature(format_args_capture)] #![feature(iter_zip)] +#![feature(box_syntax)] #![feature(proc_macro_diagnostic)] #![feature(proc_macro_internals)] #![feature(proc_macro_span)] diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index a7434d73abe68..bc238abf923e1 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -233,7 +233,7 @@ impl<'root, 'tt> Clone for MatcherPosHandle<'root, 'tt> { // This always produces a new Box. fn clone(&self) -> Self { MatcherPosHandle::Box(match *self { - MatcherPosHandle::Ref(ref r) => Box::new((**r).clone()), + MatcherPosHandle::Ref(ref r) => box ((**r).clone()), MatcherPosHandle::Box(ref b) => b.clone(), }) } @@ -544,18 +544,20 @@ fn inner_parse_loop<'root, 'tt>( } let matches = create_matches(item.matches.len()); - cur_items.push(MatcherPosHandle::Box(Box::new(MatcherPos { - stack: smallvec![], - sep: seq.separator.clone(), - seq_op: Some(seq.kleene.op), - idx: 0, - matches, - match_lo: item.match_cur, - match_cur: item.match_cur, - match_hi: item.match_cur + seq.num_captures, - up: Some(item), - top_elts: Tt(TokenTree::Sequence(sp, seq)), - }))); + cur_items.push(MatcherPosHandle::Box( + box (MatcherPos { + stack: smallvec![], + sep: seq.separator.clone(), + seq_op: Some(seq.kleene.op), + idx: 0, + matches, + match_lo: item.match_cur, + match_cur: item.match_cur, + match_hi: item.match_cur + seq.num_captures, + up: Some(item), + top_elts: Tt(TokenTree::Sequence(sp, seq)), + }), + )); } // We need to match a metavar (but the identifier is invalid)... this is an error diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 9aee86c9e57dd..52d4e6819b636 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -308,7 +308,7 @@ fn generic_extension<'cx>( // Let the context choose how to interpret the result. // Weird, but useful for X-macros. - return Box::new(ParserAnyMacro { + return box (ParserAnyMacro { parser: p, // Pass along the original expansion site and the name of the macro @@ -457,17 +457,17 @@ pub fn compile_declarative_macro( let s = parse_failure_msg(&token); let sp = token.span.substitute_dummy(def.span); sess.parse_sess.span_diagnostic.struct_span_err(sp, &s).span_label(sp, msg).emit(); - return mk_syn_ext(Box::new(macro_rules_dummy_expander)); + return mk_syn_ext(box (macro_rules_dummy_expander)); } Error(sp, msg) => { sess.parse_sess .span_diagnostic .struct_span_err(sp.substitute_dummy(def.span), &msg) .emit(); - return mk_syn_ext(Box::new(macro_rules_dummy_expander)); + return mk_syn_ext(box (macro_rules_dummy_expander)); } ErrorReported => { - return mk_syn_ext(Box::new(macro_rules_dummy_expander)); + return mk_syn_ext(box (macro_rules_dummy_expander)); } }; @@ -546,17 +546,19 @@ pub fn compile_declarative_macro( None => {} } - mk_syn_ext(Box::new(MacroRulesMacroExpander { - name: def.ident, - span: def.span, - transparency, - lhses, - rhses, - valid, - // Macros defined in the current crate have a real node id, - // whereas macros from an external crate have a dummy id. - is_local: def.id != DUMMY_NODE_ID, - })) + mk_syn_ext( + box (MacroRulesMacroExpander { + name: def.ident, + span: def.span, + transparency, + lhses, + rhses, + valid, + // Macros defined in the current crate have a real node id, + // whereas macros from an external crate have a dummy id. + is_local: def.id != DUMMY_NODE_ID, + }), + ) } fn check_lhs_nt_follows( diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index fb7479eafc86f..47302f7a1ee86 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -151,10 +151,10 @@ fn parse_tree( let mut next = outer_trees.next(); let mut trees: Box>; if let Some(tokenstream::TokenTree::Delimited(_, token::NoDelim, tts)) = next { - trees = Box::new(tts.into_trees()); + trees = box (tts.into_trees()); next = trees.next(); } else { - trees = Box::new(outer_trees); + trees = box (outer_trees); } match next { diff --git a/compiler/rustc_expand/src/tests.rs b/compiler/rustc_expand/src/tests.rs index ed3aa1eaca84e..615a222622f15 100644 --- a/compiler/rustc_expand/src/tests.rs +++ b/compiler/rustc_expand/src/tests.rs @@ -140,7 +140,7 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & } let emitter = EmitterWriter::new( - Box::new(Shared { data: output.clone() }), + box (Shared { data: output.clone() }), Some(source_map.clone()), false, false, @@ -148,7 +148,7 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & None, false, ); - let handler = Handler::with_emitter(true, None, Box::new(emitter)); + let handler = Handler::with_emitter(true, None, box (emitter)); handler.span_err(msp, "foo"); assert!( diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 3816888db1062..e224c5a236253 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -288,7 +288,7 @@ pub enum Res { /// /// ``` /// impl Foo for Bar { - /// fn foo() -> Box { Box::new(Bar) } + /// fn foo() -> Box { box (Bar) } /// } /// ``` /// diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index fde4ec05ffc86..a059190e014c8 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -138,7 +138,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { // error: cannot infer an appropriate lifetime // --> $DIR/must_outlive_least_region_or_bound.rs:18:50 // | - // LL | fn foo(x: &i32) -> Box { Box::new(x) } + // LL | fn foo(x: &i32) -> Box { box (x) } // | ---- ---------^- // // and instead show: @@ -146,7 +146,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { // error: cannot infer an appropriate lifetime // --> $DIR/must_outlive_least_region_or_bound.rs:18:50 // | - // LL | fn foo(x: &i32) -> Box { Box::new(x) } + // LL | fn foo(x: &i32) -> Box { box (x) } // | ---- ^ err.span_label( sup_origin.span(), diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index f69212c599b62..1d2b2e86118d6 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -167,7 +167,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { // involved). vb } else { - VerifyBound::IfEq(ty, Box::new(vb)) + VerifyBound::IfEq(ty, box (vb)) } }); diff --git a/compiler/rustc_interface/src/lib.rs b/compiler/rustc_interface/src/lib.rs index c7424b9e2a120..b0c405bf1f5ca 100644 --- a/compiler/rustc_interface/src/lib.rs +++ b/compiler/rustc_interface/src/lib.rs @@ -1,5 +1,6 @@ #![feature(bool_to_option)] #![feature(box_patterns)] +#![feature(box_syntax)] #![feature(internal_output_capture)] #![feature(nll)] #![feature(once_cell)] diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 5db027fb5b473..ad386e3bfb439 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -113,7 +113,7 @@ mod boxed_resolver { session: Lrc, make_resolver: impl for<'a> FnOnce(&'a Session, &'a ResolverArenas<'a>) -> Resolver<'a>, ) -> BoxedResolver { - let mut boxed_resolver = Box::new(BoxedResolverInner { + let mut boxed_resolver = box (BoxedResolverInner { session, resolver_arenas: Some(Resolver::arenas()), resolver: None, diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 77741c7240b0d..befe2a737ffe9 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { // Peel all `Box<_>` layers. We have to special case `Box` here as // `Box` is the only thing that values can be moved out of via - // method call. `Box::new([1]).into_iter()` should trigger this + // method call. `box ([1]).into_iter()` should trigger this // lint. let mut recv_ty = cx.typeck_results().expr_ty(receiver_arg); let mut num_box_derefs = 0; diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 4a646013ff891..812d368f61e4e 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -176,7 +176,7 @@ impl LintStore { &mut self, pass: impl Fn() -> EarlyLintPassObject + 'static + sync::Send + sync::Sync, ) { - self.early_passes.push(Box::new(pass)); + self.early_passes.push(box (pass)); } /// Used by clippy. @@ -184,21 +184,21 @@ impl LintStore { &mut self, pass: impl Fn() -> EarlyLintPassObject + 'static + sync::Send + sync::Sync, ) { - self.pre_expansion_passes.push(Box::new(pass)); + self.pre_expansion_passes.push(box (pass)); } pub fn register_late_pass( &mut self, pass: impl Fn() -> LateLintPassObject + 'static + sync::Send + sync::Sync, ) { - self.late_passes.push(Box::new(pass)); + self.late_passes.push(box (pass)); } pub fn register_late_mod_pass( &mut self, pass: impl Fn() -> LateLintPassObject + 'static + sync::Send + sync::Sync, ) { - self.late_module_passes.push(Box::new(pass)); + self.late_module_passes.push(box (pass)); } // Helper method for register_early/late_pass diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 2c9bad7e5cedb..9d3a45b11a570 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -7,6 +7,7 @@ #![feature(proc_macro_internals)] #![feature(min_specialization)] #![feature(try_blocks)] +#![feature(box_syntax)] #![feature(never_type)] #![recursion_limit = "256"] diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 8bdd4313de4c3..38aae224c0ba0 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -738,15 +738,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { attributes.iter().cloned().map(Symbol::intern).collect::>(); ( trait_name, - SyntaxExtensionKind::Derive(Box::new(ProcMacroDerive { client })), + SyntaxExtensionKind::Derive(box (ProcMacroDerive { client })), helper_attrs, ) } ProcMacro::Attr { name, client } => { - (name, SyntaxExtensionKind::Attr(Box::new(AttrProcMacro { client })), Vec::new()) + (name, SyntaxExtensionKind::Attr(box (AttrProcMacro { client })), Vec::new()) } ProcMacro::Bang { name, client } => { - (name, SyntaxExtensionKind::Bang(Box::new(BangProcMacro { client })), Vec::new()) + (name, SyntaxExtensionKind::Bang(box (BangProcMacro { client })), Vec::new()) } }; diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 6ad68877235dc..4f21074b3c29e 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -378,7 +378,7 @@ pub fn struct_lint_level<'s, 'd>( // Finally, run `decorate`. This function is also responsible for emitting the diagnostic. decorate(LintDiagnosticBuilder::new(err)); } - struct_lint_level_impl(sess, lint, level, src, span, Box::new(decorate)) + struct_lint_level_impl(sess, lint, level, src, span, box (decorate)) } /// Returns whether `span` originates in a foreign crate's external macro. diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 4826c96000cc2..e77bdd03f7878 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -115,7 +115,7 @@ impl<'tcx> From> for InterpErrorInfo<'tcx> { let backtrace = match capture_backtrace { CtfeBacktrace::Disabled => None, - CtfeBacktrace::Capture => Some(Box::new(Backtrace::force_capture())), + CtfeBacktrace::Capture => Some(box (Backtrace::force_capture())), CtfeBacktrace::Immediate => { // Print it now. let backtrace = Backtrace::force_capture(); @@ -124,7 +124,7 @@ impl<'tcx> From> for InterpErrorInfo<'tcx> { } }; - InterpErrorInfo(Box::new(InterpErrorInfoInner { kind, backtrace })) + InterpErrorInfo(box (InterpErrorInfoInner { kind, backtrace })) } } diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index dd9ac7f5c3955..c16aab8493bb5 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -49,7 +49,7 @@ macro_rules! err_exhaust { #[macro_export] macro_rules! err_machine_stop { ($($tt:tt)*) => { - $crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)) + $crate::mir::interpret::InterpError::MachineStop(box ($($tt)*)) }; } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index da0d2575dcbe3..12d02ae4c1c1d 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -266,7 +266,7 @@ impl<'tcx> Body<'tcx> { basic_blocks, source_scopes, generator: generator_kind.map(|generator_kind| { - Box::new(GeneratorInfo { + box (GeneratorInfo { yield_ty: None, generator_drop: None, generator_layout: None, diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index 4fb737f463a86..67cdac67a64c7 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -156,7 +156,7 @@ impl Debug for GeneratorLayout<'_> { struct MapPrinter<'a, K, V>(Cell + 'a>>>); impl<'a, K, V> MapPrinter<'a, K, V> { fn new(iter: impl Iterator + 'a) -> Self { - Self(Cell::new(Some(Box::new(iter)))) + Self(Cell::new(Some(box (iter)))) } } impl<'a, K: Debug, V: Debug> Debug for MapPrinter<'a, K, V> { diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index cdefc9effa1e9..53326a4b81d18 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -531,7 +531,7 @@ pub struct Pat<'tcx> { impl<'tcx> Pat<'tcx> { pub fn wildcard_from_ty(ty: Ty<'tcx>) -> Self { - Pat { ty, span: DUMMY_SP, kind: Box::new(PatKind::Wild) } + Pat { ty, span: DUMMY_SP, kind: box (PatKind::Wild) } } } diff --git a/compiler/rustc_middle/src/traits/chalk.rs b/compiler/rustc_middle/src/traits/chalk.rs index 74873778f74ba..0d925266070e6 100644 --- a/compiler/rustc_middle/src/traits/chalk.rs +++ b/compiler/rustc_middle/src/traits/chalk.rs @@ -207,7 +207,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { } fn intern_ty(&self, ty: chalk_ir::TyData) -> Self::InternedType { - Box::new(ty) + box (ty) } fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData { @@ -215,7 +215,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { } fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData) -> Self::InternedLifetime { - Box::new(lifetime) + box (lifetime) } fn lifetime_data<'a>( @@ -226,7 +226,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { } fn intern_const(&self, constant: chalk_ir::ConstData) -> Self::InternedConst { - Box::new(constant) + box (constant) } fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData { @@ -243,7 +243,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { } fn intern_generic_arg(&self, data: chalk_ir::GenericArgData) -> Self::InternedGenericArg { - Box::new(data) + box (data) } fn generic_arg_data<'a>( @@ -254,7 +254,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { } fn intern_goal(&self, goal: chalk_ir::GoalData) -> Self::InternedGoal { - Box::new(goal) + box (goal) } fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a chalk_ir::GoalData { @@ -290,7 +290,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { &self, data: chalk_ir::ProgramClauseData, ) -> Self::InternedProgramClause { - Box::new(data) + box (data) } fn program_clause_data<'a>( diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index dc94124e62ab6..2f108cfc605a0 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1304,19 +1304,21 @@ impl DerefMut for FmtPrinter<'_, '_, F> { impl FmtPrinter<'a, 'tcx, F> { pub fn new(tcx: TyCtxt<'tcx>, fmt: F, ns: Namespace) -> Self { - FmtPrinter(Box::new(FmtPrinterData { - tcx, - fmt, - empty_path: false, - in_value: ns == Namespace::ValueNS, - print_alloc_ids: false, - used_region_names: Default::default(), - region_index: 0, - binder_depth: 0, - printed_type_count: 0, - region_highlight_mode: RegionHighlightMode::default(), - name_resolver: None, - })) + FmtPrinter( + box (FmtPrinterData { + tcx, + fmt, + empty_path: false, + in_value: ns == Namespace::ValueNS, + print_alloc_ids: false, + used_region_names: Default::default(), + region_index: 0, + binder_depth: 0, + printed_type_count: 0, + region_highlight_mode: RegionHighlightMode::default(), + name_resolver: None, + }), + ) } } diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs index a3ea170063468..ce475eee6d930 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs @@ -955,7 +955,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // // let x = 0; // let y = &x; - // Box::new(|| y) as Box &'static i32> + // box (|| y) as Box &'static i32> // // then just use the normal error. The closure isn't escaping // and `move` will not help here. diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index 3fb06cd2f5f44..e43844302e0b7 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -1241,7 +1241,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { /// type Foo = impl Debug; /// /// fn foo(t: T) -> Box> { - /// Box::new((t, 22_u32)) + /// box ((t, 22_u32)) /// } /// ``` /// diff --git a/compiler/rustc_mir/src/dataflow/framework/engine.rs b/compiler/rustc_mir/src/dataflow/framework/engine.rs index 3f9f558223bb0..5ffa343c30638 100644 --- a/compiler/rustc_mir/src/dataflow/framework/engine.rs +++ b/compiler/rustc_mir/src/dataflow/framework/engine.rs @@ -111,7 +111,7 @@ where A::Direction::gen_kill_effects_in_block(&analysis, trans, block, block_data); } - let apply_trans = Box::new(move |bb: BasicBlock, state: &mut A::Domain| { + let apply_trans = box (move |bb: BasicBlock, state: &mut A::Domain| { trans_for_block[bb].apply(state.borrow_mut()); }); diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs index 6ed0ab8be41ee..2e80238b04c88 100644 --- a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs +++ b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs @@ -147,7 +147,7 @@ fn get_partitioner<'tcx>(tcx: TyCtxt<'tcx>) -> Box> { }; match strategy { - "default" => Box::new(default::DefaultPartitioning), + "default" => box (default::DefaultPartitioning), _ => tcx.sess.fatal("unknown partitioning strategy"), } } diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index e02e41d62061a..3bc999d50b2b4 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -798,11 +798,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { /// Creates a new `Operand::Constant` from a `Scalar` value fn operand_from_scalar(&self, scalar: Scalar, ty: Ty<'tcx>, span: Span) -> Operand<'tcx> { - Operand::Constant(Box::new(Constant { - span, - user_ty: None, - literal: ty::Const::from_scalar(self.tcx, scalar, ty).into(), - })) + Operand::Constant( + box (Constant { + span, + user_ty: None, + literal: ty::Const::from_scalar(self.tcx, scalar, ty).into(), + }), + ) } fn replace_with_const( @@ -881,21 +883,23 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { if let Some(Some(alloc)) = alloc { // Assign entire constant in a single statement. // We can't use aggregates, as we run after the aggregate-lowering `MirPhase`. - *rval = Rvalue::Use(Operand::Constant(Box::new(Constant { - span: source_info.span, - user_ty: None, - literal: self - .ecx - .tcx - .mk_const(ty::Const { - ty, - val: ty::ConstKind::Value(ConstValue::ByRef { - alloc, - offset: Size::ZERO, - }), - }) - .into(), - }))); + *rval = Rvalue::Use(Operand::Constant( + box (Constant { + span: source_info.span, + user_ty: None, + literal: self + .ecx + .tcx + .mk_const(ty::Const { + ty, + val: ty::ConstKind::Value(ConstValue::ByRef { + alloc, + offset: Size::ZERO, + }), + }) + .into(), + }), + )); } } } diff --git a/compiler/rustc_mir/src/transform/elaborate_drops.rs b/compiler/rustc_mir/src/transform/elaborate_drops.rs index c0fcfb620ff76..03d1bbd34ecb4 100644 --- a/compiler/rustc_mir/src/transform/elaborate_drops.rs +++ b/compiler/rustc_mir/src/transform/elaborate_drops.rs @@ -468,11 +468,13 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { } fn constant_bool(&self, span: Span, val: bool) -> Rvalue<'tcx> { - Rvalue::Use(Operand::Constant(Box::new(Constant { - span, - user_ty: None, - literal: ty::Const::from_bool(self.tcx, val).into(), - }))) + Rvalue::Use(Operand::Constant( + box (Constant { + span, + user_ty: None, + literal: ty::Const::from_bool(self.tcx, val).into(), + }), + )) } fn set_drop_flag(&mut self, loc: Location, path: MovePathIndex, val: DropFlagState) { diff --git a/compiler/rustc_mir/src/transform/lower_slice_len.rs b/compiler/rustc_mir/src/transform/lower_slice_len.rs index c3eb2d9f921b3..0387356bfe13e 100644 --- a/compiler/rustc_mir/src/transform/lower_slice_len.rs +++ b/compiler/rustc_mir/src/transform/lower_slice_len.rs @@ -74,7 +74,7 @@ fn lower_slice_len_call<'tcx>( // make new RValue for Len let deref_arg = tcx.mk_place_deref(arg); let r_value = Rvalue::Len(deref_arg); - let len_statement_kind = StatementKind::Assign(Box::new((*dest, r_value))); + let len_statement_kind = StatementKind::Assign(box ((*dest, r_value))); let add_statement = Statement { kind: len_statement_kind, source_info: terminator.source_info.clone(), diff --git a/compiler/rustc_mir/src/transform/promote_consts.rs b/compiler/rustc_mir/src/transform/promote_consts.rs index 78e84419c62cd..f5e5b755e07ac 100644 --- a/compiler/rustc_mir/src/transform/promote_consts.rs +++ b/compiler/rustc_mir/src/transform/promote_consts.rs @@ -851,26 +851,28 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { promoted.span = span; promoted.local_decls[RETURN_PLACE] = LocalDecl::new(ty, span); - Operand::Constant(Box::new(Constant { - span, - user_ty: None, - literal: tcx - .mk_const(ty::Const { - ty, - val: ty::ConstKind::Unevaluated(ty::Unevaluated { - def, - substs: InternalSubsts::for_item(tcx, def.did, |param, _| { - if let ty::GenericParamDefKind::Lifetime = param.kind { - tcx.lifetimes.re_erased.into() - } else { - tcx.mk_param_from_def(param) - } + Operand::Constant( + box (Constant { + span, + user_ty: None, + literal: tcx + .mk_const(ty::Const { + ty, + val: ty::ConstKind::Unevaluated(ty::Unevaluated { + def, + substs: InternalSubsts::for_item(tcx, def.did, |param, _| { + if let ty::GenericParamDefKind::Lifetime = param.kind { + tcx.lifetimes.re_erased.into() + } else { + tcx.mk_param_from_def(param) + } + }), + promoted: Some(promoted_id), }), - promoted: Some(promoted_id), - }), - }) - .into(), - })) + }) + .into(), + }), + ) }; let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut(); match candidate { @@ -906,10 +908,12 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { let promoted_ref_statement = Statement { source_info: statement.source_info, - kind: StatementKind::Assign(Box::new(( - Place::from(promoted_ref), - Rvalue::Use(promoted_operand(ref_ty, span)), - ))), + kind: StatementKind::Assign( + box (( + Place::from(promoted_ref), + Rvalue::Use(promoted_operand(ref_ty, span)), + )), + ), }; self.extra_statements.push((loc, promoted_ref_statement)); diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 496db58758cdc..e45555b0faf93 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -744,7 +744,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// As another example, if the second argument diverges: /// - /// foo(Box::new(2), panic!()) + /// foo(box (2), panic!()) /// /// We would allocate the box but then free it on the unwinding /// path; we would also emit a free on the 'success' path from diff --git a/compiler/rustc_mir_build/src/thir/cx/block.rs b/compiler/rustc_mir_build/src/thir/cx/block.rs index 2d9b5c1d98aab..bc0c0beaddf0d 100644 --- a/compiler/rustc_mir_build/src/thir/cx/block.rs +++ b/compiler/rustc_mir_build/src/thir/cx/block.rs @@ -83,7 +83,7 @@ impl<'tcx> Cx<'tcx> { pattern = Pat { ty: pattern.ty, span: pattern.span, - kind: Box::new(PatKind::AscribeUserType { + kind: box (PatKind::AscribeUserType { ascription: Ascription { user_ty: PatTyProj::from_user_type(user_ty), user_ty_span: ty.span, diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index c3908ddd4fbe8..abff8c58f3134 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -228,14 +228,16 @@ impl<'tcx> Cx<'tcx> { expr: self.mirror_expr(e), }) .collect(); - ExprKind::Adt(Box::new(Adt { - adt_def, - substs, - variant_index: index, - fields: field_refs, - user_ty, - base: None, - })) + ExprKind::Adt( + box (Adt { + adt_def, + substs, + variant_index: index, + fields: field_refs, + user_ty, + base: None, + }), + ) } else { ExprKind::Call { ty: self.typeck_results().node_type(fun.hir_id), @@ -362,20 +364,23 @@ impl<'tcx> Cx<'tcx> { let user_provided_types = self.typeck_results().user_provided_types(); let user_ty = user_provided_types.get(expr.hir_id).copied(); debug!("make_mirror_unadjusted: (struct/union) user_ty={:?}", user_ty); - ExprKind::Adt(Box::new(Adt { - adt_def: adt, - variant_index: VariantIdx::new(0), - substs, - user_ty, - fields: self.field_refs(fields), - base: base.as_ref().map(|base| FruInfo { - base: self.mirror_expr(base), - field_types: self.typeck_results().fru_field_types()[expr.hir_id] - .iter() - .copied() - .collect(), + ExprKind::Adt( + box (Adt { + adt_def: adt, + variant_index: VariantIdx::new(0), + substs, + user_ty, + fields: self.field_refs(fields), + base: base.as_ref().map(|base| FruInfo { + base: self.mirror_expr(base), + field_types: self.typeck_results().fru_field_types() + [expr.hir_id] + .iter() + .copied() + .collect(), + }), }), - })) + ) } AdtKind::Enum => { let res = self.typeck_results().qpath_res(qpath, expr.hir_id); @@ -388,14 +393,16 @@ impl<'tcx> Cx<'tcx> { self.typeck_results().user_provided_types(); let user_ty = user_provided_types.get(expr.hir_id).copied(); debug!("make_mirror_unadjusted: (variant) user_ty={:?}", user_ty); - ExprKind::Adt(Box::new(Adt { - adt_def: adt, - variant_index: index, - substs, - user_ty, - fields: self.field_refs(fields), - base: None, - })) + ExprKind::Adt( + box (Adt { + adt_def: adt, + variant_index: index, + substs, + user_ty, + fields: self.field_refs(fields), + base: None, + }), + ) } _ => { span_bug!(expr.span, "unexpected res: {:?}", res); @@ -906,14 +913,16 @@ impl<'tcx> Cx<'tcx> { match ty.kind() { // A unit struct/variant which is used as a value. // We return a completely different ExprKind here to account for this special case. - ty::Adt(adt_def, substs) => ExprKind::Adt(Box::new(Adt { - adt_def, - variant_index: adt_def.variant_index_with_ctor_id(def_id), - substs, - user_ty: user_provided_type, - fields: box [], - base: None, - })), + ty::Adt(adt_def, substs) => ExprKind::Adt( + box (Adt { + adt_def, + variant_index: adt_def.variant_index_with_ctor_id(def_id), + substs, + user_ty: user_provided_type, + fields: box [], + base: None, + }), + ), _ => bug!("unexpected ty: {:?}", ty), } } diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 926bd830da0ac..0d73817a8acb1 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -406,7 +406,7 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> { let array = tcx.deref_const(self.param_env.and(cv)); let val = PatKind::Deref { subpattern: Pat { - kind: Box::new(PatKind::Array { + kind: box (PatKind::Array { prefix: tcx .destructure_const(param_env.and(array)) .fields @@ -432,7 +432,7 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> { let array = tcx.deref_const(self.param_env.and(cv)); let val = PatKind::Deref { subpattern: Pat { - kind: Box::new(PatKind::Slice { + kind: box (PatKind::Slice { prefix: tcx .destructure_const(param_env.and(array)) .fields @@ -574,6 +574,6 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> { ); } - Ok(Pat { span, ty: cv.ty, kind: Box::new(kind) }) + Ok(Pat { span, ty: cv.ty, kind: box (kind) }) } } diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index ace13ea44624d..48e8eabaa7554 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -219,7 +219,7 @@ impl IntRange { PatKind::Range(PatRange { lo: lo_const, hi: hi_const, end: RangeEnd::Included }) }; - Pat { ty, span: DUMMY_SP, kind: Box::new(kind) } + Pat { ty, span: DUMMY_SP, kind: box (kind) } } /// Lint on likely incorrect range patterns (#63987) @@ -1270,7 +1270,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> { ), }; - Pat { ty: pcx.ty, span: DUMMY_SP, kind: Box::new(pat) } + Pat { ty: pcx.ty, span: DUMMY_SP, kind: box (pat) } } /// Returns the number of patterns. This is the same as the arity of the constructor used to diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index dd265d881e6c4..edd11cfcbca39 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -97,11 +97,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { unadjusted_pat, |pat, ref_ty| { debug!("{:?}: wrapping pattern with type {:?}", pat, ref_ty); - Pat { - span: pat.span, - ty: ref_ty, - kind: Box::new(PatKind::Deref { subpattern: pat }), - } + Pat { span: pat.span, ty: ref_ty, kind: box (PatKind::Deref { subpattern: pat }) } }, ) } @@ -224,7 +220,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // constants somewhere. Have them on the range pattern. for end in &[lo, hi] { if let Some((_, Some(ascription))) = end { - let subpattern = Pat { span: pat.span, ty, kind: Box::new(kind) }; + let subpattern = Pat { span: pat.span, ty, kind: box (kind) }; kind = PatKind::AscribeUserType { ascription: *ascription, subpattern }; } } @@ -319,7 +315,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { hir::PatKind::Or(ref pats) => PatKind::Or { pats: self.lower_patterns(pats) }, }; - Pat { span: pat.span, ty, kind: Box::new(kind) } + Pat { span: pat.span, ty, kind: box (kind) } } fn lower_tuple_subpats( @@ -433,7 +429,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) { debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span); kind = PatKind::AscribeUserType { - subpattern: Pat { span, ty, kind: Box::new(kind) }, + subpattern: Pat { span, ty, kind: box (kind) }, ascription: Ascription { user_ty: PatTyProj::from_user_type(user_ty), user_ty_span: span, @@ -452,7 +448,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let ty = self.typeck_results.node_type(id); let res = self.typeck_results.qpath_res(qpath, id); - let pat_from_kind = |kind| Pat { span, ty, kind: Box::new(kind) }; + let pat_from_kind = |kind| Pat { span, ty, kind: box (kind) }; let (def_id, is_associated_const) = match res { Res::Def(DefKind::Const, def_id) => (def_id, false), @@ -504,7 +500,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let user_ty = PatTyProj::from_user_type(*u_ty); Pat { span, - kind: Box::new(PatKind::AscribeUserType { + kind: box (PatKind::AscribeUserType { subpattern: pattern, ascription: Ascription { /// Note that use `Contravariant` here. See the diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index 5d4eb75155a67..fcf2d09551411 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -372,7 +372,7 @@ impl<'tcx> PatternFolder<'tcx> for LiteralExpander { // constant value still knows it is of type `&str`. new_pat.ty = t; Pat { - kind: Box::new(PatKind::Deref { subpattern: new_pat }), + kind: box (PatKind::Deref { subpattern: new_pat }), span: pat.span, ty: pat.ty, } diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index e1d0b84f4193f..4b57ed7160a10 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -316,7 +316,7 @@ impl<'a> Parser<'a> { // If we have no attributes, then we will never need to // use any replace ranges. let replace_ranges: Box<[ReplaceRange]> = if ret.attrs().is_empty() && !self.capture_cfg { - Box::new([]) + box ([]) } else { // Grab any replace ranges that occur *inside* the current AST node. // We will perform the actual replacement when we convert the `LazyTokenStream` diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs index 5022bf265328a..018331a774fee 100644 --- a/compiler/rustc_query_impl/src/lib.rs +++ b/compiler/rustc_query_impl/src/lib.rs @@ -5,6 +5,7 @@ #![feature(in_band_lifetimes)] #![feature(nll)] #![feature(min_specialization)] +#![feature(box_syntax)] #![feature(once_cell)] #![feature(rustc_attrs)] #![recursion_limit = "256"] diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 5774d021373bb..ec89091751a1d 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -511,8 +511,8 @@ macro_rules! define_queries_struct { on_disk_cache: Option>, ) -> Self { Queries { - local_providers: Box::new(local_providers), - extern_providers: Box::new(extern_providers), + local_providers: box (local_providers), + extern_providers: box (extern_providers), on_disk_cache, $($name: Default::default()),* } diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index e3ab858541af4..bcbf15ba1e502 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2069,22 +2069,26 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { for (snippet, (_, count)) in snippets.iter().zip(spans_with_counts.iter().copied()) { suggs.push(match snippet.as_deref() { - Some("&") => Some(Box::new(|name| format!("&{} ", name))), - Some("'_") => Some(Box::new(|n| n.to_string())), - Some("") => Some(Box::new(move |n| format!("{}, ", n).repeat(count))), - Some("<") => Some(Box::new(move |n| { - std::iter::repeat(n).take(count).collect::>().join(", ") - })), - Some(snippet) if !snippet.ends_with('>') => Some(Box::new(move |name| { - format!( - "{}<{}>", - snippet, - std::iter::repeat(name.to_string()) - .take(count) - .collect::>() - .join(", ") - ) - })), + Some("&") => Some(box (|name| format!("&{} ", name))), + Some("'_") => Some(box (|n| n.to_string())), + Some("") => Some(box (move |n| format!("{}, ", n).repeat(count))), + Some("<") => Some( + box (move |n| { + std::iter::repeat(n).take(count).collect::>().join(", ") + }), + ), + Some(snippet) if !snippet.ends_with('>') => Some( + box (move |name| { + format!( + "{}<{}>", + snippet, + std::iter::repeat(name.to_string()) + .take(count) + .collect::>() + .join(", ") + ) + }), + ), _ => None, }); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 7114fd33188d9..62ed258b69d19 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -10,6 +10,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(box_patterns)] +#![feature(box_syntax)] #![feature(bool_to_option)] #![feature(crate_visibility_modifier)] #![feature(format_args_capture)] @@ -1437,7 +1438,7 @@ impl<'a> Resolver<'a> { let main_def = self.main_def; ResolverOutputs { definitions, - cstore: Box::new(self.crate_loader.into_cstore()), + cstore: box (self.crate_loader.into_cstore()), visibilities, extern_crate_map, export_map, @@ -1456,7 +1457,7 @@ impl<'a> Resolver<'a> { pub fn clone_outputs(&self) -> ResolverOutputs { ResolverOutputs { definitions: self.definitions.clone(), - cstore: Box::new(self.cstore().clone()), + cstore: box (self.cstore().clone()), visibilities: self.visibilities.clone(), extern_crate_map: self.extern_crate_map.clone(), export_map: self.export_map.clone(), diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index ebf4b2b01c568..daa41c9fe1a61 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -953,14 +953,14 @@ impl RustcOptGroup { where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static, { - RustcOptGroup { name, apply: Box::new(f), stability: OptionStability::Stable } + RustcOptGroup { name, apply: box (f), stability: OptionStability::Stable } } pub fn unstable(name: &'static str, f: F) -> RustcOptGroup where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static, { - RustcOptGroup { name, apply: Box::new(f), stability: OptionStability::Unstable } + RustcOptGroup { name, apply: box (f), stability: OptionStability::Unstable } } } diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index 9a82ae3fc1090..e2939cb7d1237 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -1,5 +1,6 @@ #![feature(crate_visibility_modifier)] #![feature(once_cell)] +#![feature(box_syntax)] #![recursion_limit = "256"] #[macro_use] diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index a007b53030271..93dfd9907f084 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -176,7 +176,7 @@ impl ParseSess { pub fn with_silent_emitter() -> Self { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); - let handler = Handler::with_emitter(false, None, Box::new(SilentEmitter)); + let handler = Handler::with_emitter(false, None, box (SilentEmitter)); ParseSess::with_span_handler(handler, sm) } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 9ab6dbb1ea906..b64e49d6b10ce 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1145,7 +1145,7 @@ fn default_emitter( if let HumanReadableErrorType::AnnotateSnippet(_) = kind { let emitter = AnnotateSnippetEmitterWriter::new(Some(source_map), short, macro_backtrace); - Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing)) + box (emitter.ui_testing(sopts.debugging_opts.ui_testing)) } else { let emitter = match dst { None => EmitterWriter::stderr( @@ -1166,11 +1166,11 @@ fn default_emitter( macro_backtrace, ), }; - Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing)) + box (emitter.ui_testing(sopts.debugging_opts.ui_testing)) } } - (config::ErrorOutputType::Json { pretty, json_rendered }, None) => Box::new( - JsonEmitter::stderr( + (config::ErrorOutputType::Json { pretty, json_rendered }, None) => { + box (JsonEmitter::stderr( Some(registry), source_map, pretty, @@ -1178,10 +1178,10 @@ fn default_emitter( sopts.debugging_opts.terminal_width, macro_backtrace, ) - .ui_testing(sopts.debugging_opts.ui_testing), - ), - (config::ErrorOutputType::Json { pretty, json_rendered }, Some(dst)) => Box::new( - JsonEmitter::new( + .ui_testing(sopts.debugging_opts.ui_testing)) + } + (config::ErrorOutputType::Json { pretty, json_rendered }, Some(dst)) => { + box (JsonEmitter::new( dst, Some(registry), source_map, @@ -1190,8 +1190,8 @@ fn default_emitter( sopts.debugging_opts.terminal_width, macro_backtrace, ) - .ui_testing(sopts.debugging_opts.ui_testing), - ), + .ui_testing(sopts.debugging_opts.ui_testing)) + } } } @@ -1241,7 +1241,7 @@ pub fn build_session( early_warn(sopts.error_format, &warning) } - let loader = file_loader.unwrap_or_else(|| Box::new(RealFileLoader)); + let loader = file_loader.unwrap_or_else(|| box (RealFileLoader)); let hash_kind = sopts.debugging_opts.src_hash_algorithm.unwrap_or_else(|| { if target_cfg.is_like_msvc { SourceFileHashAlgorithm::Sha1 @@ -1474,10 +1474,10 @@ pub fn early_error_no_abort(output: config::ErrorOutputType, msg: &str) { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); - Box::new(EmitterWriter::stderr(color_config, None, short, false, None, false)) + box (EmitterWriter::stderr(color_config, None, short, false, None, false)) } config::ErrorOutputType::Json { pretty, json_rendered } => { - Box::new(JsonEmitter::basic(pretty, json_rendered, None, false)) + box (JsonEmitter::basic(pretty, json_rendered, None, false)) } }; let handler = rustc_errors::Handler::with_emitter(true, None, emitter); @@ -1493,10 +1493,10 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); - Box::new(EmitterWriter::stderr(color_config, None, short, false, None, false)) + box (EmitterWriter::stderr(color_config, None, short, false, None, false)) } config::ErrorOutputType::Json { pretty, json_rendered } => { - Box::new(JsonEmitter::basic(pretty, json_rendered, None, false)) + box (JsonEmitter::basic(pretty, json_rendered, None, false)) } }; let handler = rustc_errors::Handler::with_emitter(true, None, emitter); diff --git a/compiler/rustc_span/src/fatal_error.rs b/compiler/rustc_span/src/fatal_error.rs index 718c0ddbc63ea..c8e9bf639f396 100644 --- a/compiler/rustc_span/src/fatal_error.rs +++ b/compiler/rustc_span/src/fatal_error.rs @@ -13,7 +13,7 @@ impl !Send for FatalError {} impl FatalError { pub fn raise(self) -> ! { - std::panic::resume_unwind(Box::new(FatalErrorMarker)) + std::panic::resume_unwind(box (FatalErrorMarker)) } } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 1c95cc91208d3..5b60b4a17c0d8 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -15,6 +15,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(array_windows)] +#![feature(box_syntax)] #![feature(crate_visibility_modifier)] #![feature(negative_impls)] #![feature(nll)] diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 77a3ad931d571..1d3344fcdd92d 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -183,7 +183,7 @@ pub struct SourceMap { impl SourceMap { pub fn new(path_mapping: FilePathMapping) -> SourceMap { Self::with_file_loader_and_hash_kind( - Box::new(RealFileLoader), + box (RealFileLoader), path_mapping, SourceFileHashAlgorithm::Md5, ) diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 017a7c45bbf9d..4a53213c6f88b 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -13,6 +13,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(bool_to_option)] #![feature(box_patterns)] +#![feature(box_syntax)] #![feature(drain_filter)] #![feature(hash_drain_filter)] #![feature(in_band_lifetimes)] diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 4d4778869794b..8fa07e8317dfb 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -10,9 +10,9 @@ pub trait TraitEngineExt<'tcx> { impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> { fn new(tcx: TyCtxt<'tcx>) -> Box { if tcx.sess.opts.debugging_opts.chalk { - Box::new(ChalkFulfillmentContext::new()) + box (ChalkFulfillmentContext::new()) } else { - Box::new(FulfillmentContext::new()) + box (FulfillmentContext::new()) } } } diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index e95884ae23b93..cd3b0c29922c5 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -439,7 +439,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // &raw const REF.0; // OK, same as &raw const (*REF).0; // // This is maybe too permissive, since it allows - // `let u = &raw const Box::new((1,)).0`, which creates an + // `let u = &raw const box ((1,)).0`, which creates an // immediately dangling raw pointer. self.typeck_results .borrow() diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs index 0acf1d26e257d..bf712d92f4dd9 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs @@ -280,7 +280,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// When encountering the expected boxed value allocated in the stack, suggest allocating it - /// in the heap by calling `Box::new()`. + /// in the heap by calling `box ()`. pub(in super::super) fn suggest_boxing_when_appropriate( &self, err: &mut DiagnosticBuilder<'_>, diff --git a/compiler/rustc_typeck/src/check/method/confirm.rs b/compiler/rustc_typeck/src/check/method/confirm.rs index 3aceaba882d6c..038a12e9d7f4a 100644 --- a/compiler/rustc_typeck/src/check/method/confirm.rs +++ b/compiler/rustc_typeck/src/check/method/confirm.rs @@ -410,11 +410,13 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { ); let cause = self.cause( self.span, - ObligationCauseCode::UnifyReceiver(Box::new(UnifyReceiverContext { - assoc_item: pick.item, - param_env: self.param_env, - substs, - })), + ObligationCauseCode::UnifyReceiver( + box (UnifyReceiverContext { + assoc_item: pick.item, + param_env: self.param_env, + substs, + }), + ), ); match self.at(&cause, self.param_env).sup(method_self_ty, self_ty) { Ok(InferOk { obligations, value: () }) => {