From cdff2f3b3083f602736653e1428b5113dd2e7eee Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 29 Jun 2018 11:49:32 -0700 Subject: [PATCH 01/11] impl Clone for Box, Box, Box Implements #51908. --- src/libstd/ffi/c_str.rs | 8 ++++++++ src/libstd/ffi/os_str.rs | 8 ++++++++ src/libstd/path.rs | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 6513d11dd51..b816f4b7850 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -706,6 +706,14 @@ impl From> for CString { } } +#[stable(feature = "more_box_slice_clone", since = "1.29.0")] +impl Clone for Box { + #[inline] + fn clone(&self) -> Self { + (**self).into() + } +} + #[stable(feature = "box_from_c_string", since = "1.20.0")] impl From for Box { #[inline] diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 0a3148029d0..b522d134837 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -628,6 +628,14 @@ impl From for Box { } } +#[stable(feature = "more_box_slice_clone", since = "1.29.0")] +impl Clone for Box { + #[inline] + fn clone(&self) -> Self { + self.to_os_string().into_boxed_os_str() + } +} + #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From for Arc { #[inline] diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 3dc1e9c3dad..2d868629278 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1410,6 +1410,14 @@ impl From for Box { } } +#[stable(feature = "more_box_slice_clone", since = "1.29.0")] +impl Clone for Box { + #[inline] + fn clone(&self) -> Self { + self.to_path_buf().into_boxed_path() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T: ?Sized + AsRef> From<&'a T> for PathBuf { fn from(s: &'a T) -> PathBuf { From bcb8a06ef7929417f09ed5055692d8afc59b3c70 Mon Sep 17 00:00:00 2001 From: "NODA, Kai" Date: Sat, 23 Jun 2018 16:51:19 +0800 Subject: [PATCH 02/11] bootstrap: write texts to a .tmp file first for atomicity If you are using a hard-linked file as your config.toml, this change will affect the way other instances of the file is modified. The original version would modify all other instances whereas the new version will leave others unchanged, reducing the ref count by one. Signed-off-by: NODA, Kai --- src/bootstrap/bootstrap.py | 14 +++++++++++--- src/bootstrap/configure.py | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 512d4d8c5b7..d1aa32236ae 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -303,6 +303,14 @@ def default_build_triple(): return "{}-{}".format(cputype, ostype) +@contextlib.contextmanager +def output(filepath): + tmp = filepath + '.tmp' + with open(tmp, 'w') as f: + yield f + os.rename(tmp, filepath) + + class RustBuild(object): """Provide all the methods required to build Rust""" def __init__(self): @@ -346,7 +354,7 @@ class RustBuild(object): self._download_stage0_helper(filename, "rustc") self.fix_executable("{}/bin/rustc".format(self.bin_root())) self.fix_executable("{}/bin/rustdoc".format(self.bin_root())) - with open(self.rustc_stamp(), 'w') as rust_stamp: + with output(self.rustc_stamp()) as rust_stamp: rust_stamp.write(self.date) # This is required so that we don't mix incompatible MinGW @@ -363,7 +371,7 @@ class RustBuild(object): filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build) self._download_stage0_helper(filename, "cargo") self.fix_executable("{}/bin/cargo".format(self.bin_root())) - with open(self.cargo_stamp(), 'w') as cargo_stamp: + with output(self.cargo_stamp()) as cargo_stamp: cargo_stamp.write(self.date) def _download_stage0_helper(self, filename, pattern): @@ -776,7 +784,7 @@ def bootstrap(help_triggered): if build.use_vendored_sources: if not os.path.exists('.cargo'): os.makedirs('.cargo') - with open('.cargo/config', 'w') as cargo_config: + with output('.cargo/config') as cargo_config: cargo_config.write(""" [source.crates-io] replace-with = 'vendored-sources' diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 80fa96509bd..9fdba044f4b 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -432,7 +432,7 @@ for section_key in config: # order that we read it in. p("") p("writing `config.toml` in current directory") -with open('config.toml', 'w') as f: +with bootstrap.output('config.toml') as f: for section in section_order: if section == 'target': for target in targets: @@ -442,7 +442,7 @@ with open('config.toml', 'w') as f: for line in sections[section]: f.write(line + "\n") -with open('Makefile', 'w') as f: +with bootstrap.output('Makefile') as f: contents = os.path.join(rust_dir, 'src', 'bootstrap', 'mk', 'Makefile.in') contents = open(contents).read() contents = contents.replace("$(CFG_SRC_DIR)", rust_dir + '/') From 97d0bc3f044a2f105ec760f78da800a1e44c8f05 Mon Sep 17 00:00:00 2001 From: "NODA, Kai" Date: Wed, 27 Jun 2018 03:23:14 +0800 Subject: [PATCH 03/11] bootstrap: our best to achieve atomic rename on Win32 This is a tricky operation to implement on Win32; see https://ci.appveyor.com/project/nodakai/python-win-behavior Signed-off-by: NODA, Kai --- src/bootstrap/bootstrap.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index d1aa32236ae..71c1c61e3d9 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -308,7 +308,12 @@ def output(filepath): tmp = filepath + '.tmp' with open(tmp, 'w') as f: yield f - os.rename(tmp, filepath) + try: + os.remove(filepath) # PermissionError/OSError on Win32 if in use + os.rename(tmp, filepath) + except OSError: + shutil.copy2(tmp, filepath) + os.remove(tmp) class RustBuild(object): From d1e3567250d50d6f2cbb24e35c590e4c1f0cc0f3 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 10 Jul 2018 18:10:05 +0200 Subject: [PATCH 04/11] Deny bare trait objects in `src/bootstrap`. --- src/bootstrap/builder.rs | 2 +- src/bootstrap/cache.rs | 2 +- src/bootstrap/compile.rs | 2 +- src/bootstrap/lib.rs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index fad0a553802..27f7dfa8990 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -44,7 +44,7 @@ pub struct Builder<'a> { pub top_stage: u32, pub kind: Kind, cache: Cache, - stack: RefCell>>, + stack: RefCell>>, time_spent_on_dependencies: Cell, pub paths: Vec, graph_nodes: RefCell>, diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs index d81c6bc28e5..bca5ff85ba2 100644 --- a/src/bootstrap/cache.rs +++ b/src/bootstrap/cache.rs @@ -249,7 +249,7 @@ lazy_static! { pub struct Cache( RefCell, // actually a HashMap> + Box, // actually a HashMap> >> ); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 298bd58c6cd..7d94bac66f7 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1189,7 +1189,7 @@ pub fn run_cargo(builder: &Builder, cargo: &mut Command, stamp: &Path, is_check: pub fn stream_cargo( builder: &Builder, cargo: &mut Command, - cb: &mut FnMut(CargoMessage), + cb: &mut dyn FnMut(CargoMessage), ) -> bool { if builder.config.dry_run { return true; diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 5f66d0b102e..a65c2faa8f0 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -113,7 +113,7 @@ //! More documentation can be found in each respective module below, and you can //! also check out the `src/bootstrap/README.md` file for more information. -#![deny(warnings)] +#![deny(bare_trait_objects)] #![feature(core_intrinsics)] #![feature(drain_filter)] @@ -1174,13 +1174,13 @@ impl Build { /// Copies the `src` directory recursively to `dst`. Both are assumed to exist /// when this function is called. Unwanted files or directories can be skipped /// by returning `false` from the filter function. - pub fn cp_filtered(&self, src: &Path, dst: &Path, filter: &Fn(&Path) -> bool) { + pub fn cp_filtered(&self, src: &Path, dst: &Path, filter: &dyn Fn(&Path) -> bool) { // Immediately recurse with an empty relative path self.recurse_(src, dst, Path::new(""), filter) } // Inner function does the actual work - fn recurse_(&self, src: &Path, dst: &Path, relative: &Path, filter: &Fn(&Path) -> bool) { + fn recurse_(&self, src: &Path, dst: &Path, relative: &Path, filter: &dyn Fn(&Path) -> bool) { for f in self.read_dir(src) { let path = f.path(); let name = path.file_name().unwrap(); From 72b908ffbe42d97dfbad848e0fc53e7e9eecfed9 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 10 Jul 2018 21:20:04 +0200 Subject: [PATCH 05/11] Restore #![deny(warnings)] --- src/bootstrap/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index a65c2faa8f0..cd9a639e82e 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -114,6 +114,7 @@ //! also check out the `src/bootstrap/README.md` file for more information. #![deny(bare_trait_objects)] +#![deny(warnings)] #![feature(core_intrinsics)] #![feature(drain_filter)] From f5f21aa9d6dc2f60a7e4b103055cfd052e732036 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sun, 8 Jul 2018 18:02:33 -0400 Subject: [PATCH 06/11] use proper footnote syntax for references The previous syntax was causing rustdoc to interpret them as links. --- src/libcore/num/flt2dec/strategy/dragon.rs | 11 +++++------ src/libcore/num/flt2dec/strategy/grisu.rs | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/libcore/num/flt2dec/strategy/dragon.rs b/src/libcore/num/flt2dec/strategy/dragon.rs index 9c9e531c593..aa6a08cb205 100644 --- a/src/libcore/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/num/flt2dec/strategy/dragon.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! -Almost direct (but slightly optimized) Rust translation of Figure 3 of \[1\]. - -\[1\] Burger, R. G. and Dybvig, R. K. 1996. Printing floating-point numbers - quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116. -*/ +//! Almost direct (but slightly optimized) Rust translation of Figure 3 of "Printing +//! Floating-Point Numbers Quickly and Accurately"[^1]. +//! +//! [^1]: Burger, R. G. and Dybvig, R. K. 1996. Printing floating-point numbers +//! quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116. use cmp::Ordering; diff --git a/src/libcore/num/flt2dec/strategy/grisu.rs b/src/libcore/num/flt2dec/strategy/grisu.rs index 5c023a191db..f33186e59c2 100644 --- a/src/libcore/num/flt2dec/strategy/grisu.rs +++ b/src/libcore/num/flt2dec/strategy/grisu.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! -Rust adaptation of Grisu3 algorithm described in \[1\]. It uses about -1KB of precomputed table, and in turn, it's very quick for most inputs. - -\[1\] Florian Loitsch. 2010. Printing floating-point numbers quickly and - accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243. -*/ +//! Rust adaptation of the Grisu3 algorithm described in "Printing Floating-Point Numbers Quickly +//! and Accurately with Integers"[^1]. It uses about 1KB of precomputed table, and in turn, it's +//! very quick for most inputs. +//! +//! [^1]: Florian Loitsch. 2010. Printing floating-point numbers quickly and +//! accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243. use num::diy_float::Fp; use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up}; From 7735f45eab4b07a3dcb359ea111911cfb9952a5c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 11 Jul 2018 15:49:23 -0700 Subject: [PATCH 07/11] rustc: Verify #[proc_macro] is only a word ... and perform the same verification for #[proc_macro_attribute], currently neither of these attributes take any arguments. Closes #52273 --- src/libsyntax_ext/proc_macro_registrar.rs | 8 ++-- .../proc-macro/invalid-attributes.rs | 36 ++++++++++++++++++ .../proc-macro/invalid-attributes.stderr | 38 +++++++++++++++++++ 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 src/test/ui-fulldeps/proc-macro/invalid-attributes.rs create mode 100644 src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index ef29e5a6b02..261208556b5 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -200,8 +200,8 @@ impl<'a> CollectProcMacros<'a> { } fn collect_attr_proc_macro(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) { - if let Some(_) = attr.meta_item_list() { - self.handler.span_err(attr.span, "`#[proc_macro_attribute]` attribute + if !attr.is_word() { + self.handler.span_err(attr.span, "`#[proc_macro_attribute]` attribute \ does not take any arguments"); return; } @@ -223,8 +223,8 @@ impl<'a> CollectProcMacros<'a> { } fn collect_bang_proc_macro(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) { - if let Some(_) = attr.meta_item_list() { - self.handler.span_err(attr.span, "`#[proc_macro]` attribute + if !attr.is_word() { + self.handler.span_err(attr.span, "`#[proc_macro]` attribute \ does not take any arguments"); return; } diff --git a/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs b/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs new file mode 100644 index 00000000000..c06f98ed5ff --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs @@ -0,0 +1,36 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro)] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro = "test"] //~ ERROR: does not take any arguments +pub fn a(a: TokenStream) -> TokenStream { a } + +#[proc_macro()] //~ ERROR: does not take any arguments +pub fn c(a: TokenStream) -> TokenStream { a } + +#[proc_macro(x)] //~ ERROR: does not take any arguments +pub fn d(a: TokenStream) -> TokenStream { a } + +#[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments +pub fn e(_: TokenStream, a: TokenStream) -> TokenStream { a } + +#[proc_macro_attribute()] //~ ERROR: does not take any arguments +pub fn g(_: TokenStream, a: TokenStream) -> TokenStream { a } + +#[proc_macro_attribute(x)] //~ ERROR: does not take any arguments +pub fn h(_: TokenStream, a: TokenStream) -> TokenStream { a } diff --git a/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr b/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr new file mode 100644 index 00000000000..c480bcb5df9 --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr @@ -0,0 +1,38 @@ +error: `#[proc_macro]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:20:1 + | +LL | #[proc_macro = "test"] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[proc_macro]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:23:1 + | +LL | #[proc_macro()] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^ + +error: `#[proc_macro]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:26:1 + | +LL | #[proc_macro(x)] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^ + +error: `#[proc_macro_attribute]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:29:1 + | +LL | #[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[proc_macro_attribute]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:32:1 + | +LL | #[proc_macro_attribute()] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[proc_macro_attribute]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:35:1 + | +LL | #[proc_macro_attribute(x)] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + From e488cba6784eebc36b9869239b729a4e41048d3f Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 11 Jul 2018 17:19:41 -0700 Subject: [PATCH 08/11] Uncapitalize "If" --- src/libstd/sync/mpsc/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 2dd3aebe610..cbda5afadcd 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -689,7 +689,7 @@ impl UnsafeFlavor for Receiver { /// only one [`Receiver`] is supported. /// /// If the [`Receiver`] is disconnected while trying to [`send`] with the -/// [`Sender`], the [`send`] method will return a [`SendError`]. Similarly, If the +/// [`Sender`], the [`send`] method will return a [`SendError`]. Similarly, if the /// [`Sender`] is disconnected while trying to [`recv`], the [`recv`] method will /// return a [`RecvError`]. /// From 8fecbe3e78e7c11d5be9ed1cf82f0efefb82cfb5 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 10:15:35 +0200 Subject: [PATCH 09/11] Deny bare trait objects in src/librustc_resolve --- src/librustc_resolve/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 8a47b8ea648..aed70861e33 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] @@ -1292,7 +1294,7 @@ impl PrimitiveTypeTable { /// This is the visitor that walks the whole crate. pub struct Resolver<'a> { session: &'a Session, - cstore: &'a CrateStore, + cstore: &'a dyn CrateStore, pub definitions: Definitions, @@ -1388,7 +1390,7 @@ pub struct Resolver<'a> { /// true if `#![feature(use_extern_macros)]` use_extern_macros: bool, - crate_loader: &'a mut CrateLoader, + crate_loader: &'a mut dyn CrateLoader, macro_names: FxHashSet, global_macros: FxHashMap>, pub all_macros: FxHashMap, @@ -1604,11 +1606,11 @@ impl<'a> Resolver<'a> { impl<'a> Resolver<'a> { pub fn new(session: &'a Session, - cstore: &'a CrateStore, + cstore: &'a dyn CrateStore, krate: &Crate, crate_name: &str, make_glob_map: MakeGlobMap, - crate_loader: &'a mut CrateLoader, + crate_loader: &'a mut dyn CrateLoader, arenas: &'a ResolverArenas<'a>) -> Resolver<'a> { let root_def_id = DefId::local(CRATE_DEF_INDEX); From 08c113abef13bd5ed050f7f8480afcd04eda081f Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 11:58:16 +0200 Subject: [PATCH 10/11] Deny bare trait objects in src/libsyntax_ext --- src/libsyntax_ext/asm.rs | 2 +- src/libsyntax_ext/assert.rs | 2 +- src/libsyntax_ext/cfg.rs | 2 +- src/libsyntax_ext/compile_error.rs | 2 +- src/libsyntax_ext/concat.rs | 2 +- src/libsyntax_ext/concat_idents.rs | 2 +- src/libsyntax_ext/deriving/bounds.rs | 4 ++-- src/libsyntax_ext/deriving/clone.rs | 2 +- src/libsyntax_ext/deriving/cmp/eq.rs | 2 +- src/libsyntax_ext/deriving/cmp/ord.rs | 2 +- src/libsyntax_ext/deriving/cmp/partial_eq.rs | 2 +- src/libsyntax_ext/deriving/cmp/partial_ord.rs | 2 +- src/libsyntax_ext/deriving/debug.rs | 2 +- src/libsyntax_ext/deriving/decodable.rs | 6 +++--- src/libsyntax_ext/deriving/default.rs | 2 +- src/libsyntax_ext/deriving/encodable.rs | 6 +++--- src/libsyntax_ext/deriving/generic/mod.rs | 8 ++++---- src/libsyntax_ext/deriving/hash.rs | 2 +- src/libsyntax_ext/deriving/mod.rs | 2 +- src/libsyntax_ext/env.rs | 4 ++-- src/libsyntax_ext/format.rs | 2 +- src/libsyntax_ext/global_asm.rs | 2 +- src/libsyntax_ext/lib.rs | 4 +++- src/libsyntax_ext/log_syntax.rs | 2 +- src/libsyntax_ext/proc_macro_registrar.rs | 2 +- src/libsyntax_ext/trace_macros.rs | 2 +- 26 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index dd8f79d20ab..4ebb1fcb653 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -50,7 +50,7 @@ const OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"]; pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { if !cx.ecfg.enable_asm() { feature_gate::emit_feature_err(&cx.parse_sess, "asm", diff --git a/src/libsyntax_ext/assert.rs b/src/libsyntax_ext/assert.rs index fe4d599d824..8d0a04831fc 100644 --- a/src/libsyntax_ext/assert.rs +++ b/src/libsyntax_ext/assert.rs @@ -22,7 +22,7 @@ pub fn expand_assert<'cx>( cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree], -) -> Box { +) -> Box { let mut parser = cx.new_parser_from_tts(tts); let cond_expr = panictry!(parser.parse_expr()); let custom_msg_args = if parser.eat(&token::Comma) { diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 6acc578d07e..2384b6a796e 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -23,7 +23,7 @@ use syntax_pos::Span; pub fn expand_cfg<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { let sp = sp.apply_mark(cx.current_expansion.mark); let mut p = cx.new_parser_from_tts(tts); let cfg = panictry!(p.parse_meta_item()); diff --git a/src/libsyntax_ext/compile_error.rs b/src/libsyntax_ext/compile_error.rs index 7bc7afba63c..ce7fb400bd5 100644 --- a/src/libsyntax_ext/compile_error.rs +++ b/src/libsyntax_ext/compile_error.rs @@ -18,7 +18,7 @@ use syntax::tokenstream; pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") { None => return DummyResult::expr(sp), Some(v) => v, diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index 1c6f0089503..69b4a83764e 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -21,7 +21,7 @@ pub fn expand_syntax_ext( cx: &mut base::ExtCtxt, sp: syntax_pos::Span, tts: &[tokenstream::TokenTree], -) -> Box { +) -> Box { let es = match base::get_exprs_from_tts(cx, sp, tts) { Some(e) => e, None => return base::DummyResult::expr(sp), diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index 828c2470841..a3c5c3df66e 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -21,7 +21,7 @@ use syntax::tokenstream::TokenTree; pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box { + -> Box { if !cx.ecfg.enable_concat_idents() { feature_gate::emit_feature_err(&cx.parse_sess, "concat_idents", diff --git a/src/libsyntax_ext/deriving/bounds.rs b/src/libsyntax_ext/deriving/bounds.rs index 7f03001d9c6..41e980b3346 100644 --- a/src/libsyntax_ext/deriving/bounds.rs +++ b/src/libsyntax_ext/deriving/bounds.rs @@ -19,7 +19,7 @@ pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt, span: Span, _: &MetaItem, _: &Annotatable, - _: &mut FnMut(Annotatable)) { + _: &mut dyn FnMut(Annotatable)) { cx.span_err(span, "this unsafe trait should be implemented explicitly"); } @@ -27,7 +27,7 @@ pub fn expand_deriving_copy(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { let trait_def = TraitDef { span, attributes: Vec::new(), diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index 9aeac5b1ddb..ec935b3e72f 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -25,7 +25,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { // check if we can use a short form // // the short form is `fn clone(&self) -> Self { *self }` diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 00ab39032ac..f202bc4e524 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -23,7 +23,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { let inline = cx.meta_word(span, Symbol::intern("inline")); let hidden = cx.meta_list_item_word(span, Symbol::intern("hidden")); let doc = cx.meta_list(span, Symbol::intern("doc"), vec![hidden]); diff --git a/src/libsyntax_ext/deriving/cmp/ord.rs b/src/libsyntax_ext/deriving/cmp/ord.rs index 99b6f752e94..117bedf453e 100644 --- a/src/libsyntax_ext/deriving/cmp/ord.rs +++ b/src/libsyntax_ext/deriving/cmp/ord.rs @@ -23,7 +23,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { let inline = cx.meta_word(span, Symbol::intern("inline")); let attrs = vec![cx.attribute(span, inline)]; let trait_def = TraitDef { diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs index c259733d81a..24a3a7542fb 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs @@ -23,7 +23,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { // structures are equal if all fields are equal, and non equal, if // any fields are not equal or if the enum variants are different fn cs_op(cx: &mut ExtCtxt, diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index 2b3930063f3..3705a245584 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -25,7 +25,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { macro_rules! md { ($name:expr, $op:expr, $equal:expr) => { { let inline = cx.meta_word(span, Symbol::intern("inline")); diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index b546f5df157..c2a7dea3316 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -23,7 +23,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { // &mut ::std::fmt::Formatter let fmtr = Ptr(Box::new(Literal(path_std!(cx, fmt::Formatter))), Borrowed(None, ast::Mutability::Mutable)); diff --git a/src/libsyntax_ext/deriving/decodable.rs b/src/libsyntax_ext/deriving/decodable.rs index 7618fe63ab3..1e04d8fa22a 100644 --- a/src/libsyntax_ext/deriving/decodable.rs +++ b/src/libsyntax_ext/deriving/decodable.rs @@ -27,7 +27,7 @@ pub fn expand_deriving_rustc_decodable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { expand_deriving_decodable_imp(cx, span, mitem, item, push, "rustc_serialize") } @@ -35,7 +35,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { warn_if_deprecated(cx, span, "Decodable"); expand_deriving_decodable_imp(cx, span, mitem, item, push, "serialize") } @@ -44,7 +44,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable), + push: &mut dyn FnMut(Annotatable), krate: &'static str) { let typaram = &*deriving::hygienic_type_parameter(item, "__D"); diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs index cbd6a257b77..958116f7809 100644 --- a/src/libsyntax_ext/deriving/default.rs +++ b/src/libsyntax_ext/deriving/default.rs @@ -23,7 +23,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { let inline = cx.meta_word(span, Symbol::intern("inline")); let attrs = vec![cx.attribute(span, inline)]; let trait_def = TraitDef { diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 8b409df1f09..5438c8b52af 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -108,7 +108,7 @@ pub fn expand_deriving_rustc_encodable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { expand_deriving_encodable_imp(cx, span, mitem, item, push, "rustc_serialize") } @@ -116,7 +116,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { warn_if_deprecated(cx, span, "Encodable"); expand_deriving_encodable_imp(cx, span, mitem, item, push, "serialize") } @@ -125,7 +125,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable), + push: &mut dyn FnMut(Annotatable), krate: &'static str) { let typaram = &*deriving::hygienic_type_parameter(item, "__S"); diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 3ea0eb8bbd8..aad69c109f9 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -330,7 +330,7 @@ pub enum SubstructureFields<'a> { /// Combine the values of all the fields together. The last argument is /// all the fields of all the structures. pub type CombineSubstructureFunc<'a> = - Box P + 'a>; + Box P + 'a>; /// Deal with non-matching enum variants. The tuple is a list of /// identifiers (one for each `Self` argument, which could be any of the @@ -338,7 +338,7 @@ pub type CombineSubstructureFunc<'a> = /// holding the variant index value for each of the `Self` arguments. The /// last argument is all the non-`Self` args of the method being derived. pub type EnumNonMatchCollapsedFunc<'a> = - Box]) -> P + 'a>; + Box]) -> P + 'a>; pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>) -> RefCell> { @@ -398,7 +398,7 @@ impl<'a> TraitDef<'a> { cx: &mut ExtCtxt, mitem: &ast::MetaItem, item: &'a Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { self.expand_ext(cx, mitem, item, push, false); } @@ -406,7 +406,7 @@ impl<'a> TraitDef<'a> { cx: &mut ExtCtxt, mitem: &ast::MetaItem, item: &'a Annotatable, - push: &mut FnMut(Annotatable), + push: &mut dyn FnMut(Annotatable), from_scratch: bool) { match *item { Annotatable::Item(ref item) => { diff --git a/src/libsyntax_ext/deriving/hash.rs b/src/libsyntax_ext/deriving/hash.rs index 67096cdb49a..7d22998487b 100644 --- a/src/libsyntax_ext/deriving/hash.rs +++ b/src/libsyntax_ext/deriving/hash.rs @@ -22,7 +22,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Annotatable, - push: &mut FnMut(Annotatable)) { + push: &mut dyn FnMut(Annotatable)) { let path = Path::new_(pathvec_std!(cx, hash::Hash), None, vec![], PathKind::Std); diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index e6a1434ca9d..2f5e42d2f7b 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -72,7 +72,7 @@ macro_rules! derive_traits { } } - pub fn register_builtin_derives(resolver: &mut Resolver) { + pub fn register_builtin_derives(resolver: &mut dyn Resolver) { $( resolver.add_builtin( ast::Ident::with_empty_ctxt(Symbol::intern($name)), diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index bbc5b03d688..3c34bf496da 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -26,7 +26,7 @@ use std::env; pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") { None => return DummyResult::expr(sp), Some(v) => v, @@ -57,7 +57,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { let mut exprs = match get_exprs_from_tts(cx, sp, tts) { Some(ref exprs) if exprs.is_empty() => { cx.span_err(sp, "env! takes 1 or 2 arguments"); diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 4bf764b1101..8587d11b227 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -679,7 +679,7 @@ impl<'a, 'b> Context<'a, 'b> { pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt, mut sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { Some((efmt, args, names)) => { diff --git a/src/libsyntax_ext/global_asm.rs b/src/libsyntax_ext/global_asm.rs index 642aa0e5b12..40ecd6e1519 100644 --- a/src/libsyntax_ext/global_asm.rs +++ b/src/libsyntax_ext/global_asm.rs @@ -34,7 +34,7 @@ pub const MACRO: &'static str = "global_asm"; pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, - tts: &[tokenstream::TokenTree]) -> Box { + tts: &[tokenstream::TokenTree]) -> Box { if !cx.ecfg.enable_global_asm() { feature_gate::emit_feature_err(&cx.parse_sess, MACRO, diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 31125183266..bdf7a8d7040 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -10,6 +10,8 @@ //! Syntax extensions in the Rust compiler. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] @@ -59,7 +61,7 @@ use syntax::ext::base::{MacroExpanderFn, NormalTT, NamedSyntaxExtension}; use syntax::ext::hygiene; use syntax::symbol::Symbol; -pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver, +pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver, user_exts: Vec, enable_quotes: bool) { deriving::register_builtin_derives(resolver); diff --git a/src/libsyntax_ext/log_syntax.rs b/src/libsyntax_ext/log_syntax.rs index 71f1951d5d4..7b76b1e8914 100644 --- a/src/libsyntax_ext/log_syntax.rs +++ b/src/libsyntax_ext/log_syntax.rs @@ -17,7 +17,7 @@ use syntax_pos; pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt, sp: syntax_pos::Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { if !cx.ecfg.enable_log_syntax() { feature_gate::emit_feature_err(&cx.parse_sess, "log_syntax", diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index ef29e5a6b02..a3dad7eb2be 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -55,7 +55,7 @@ struct CollectProcMacros<'a> { } pub fn modify(sess: &ParseSess, - resolver: &mut ::syntax::ext::base::Resolver, + resolver: &mut dyn (::syntax::ext::base::Resolver), mut krate: ast::Crate, is_proc_macro_crate: bool, is_test_crate: bool, diff --git a/src/libsyntax_ext/trace_macros.rs b/src/libsyntax_ext/trace_macros.rs index 48be8e0c53c..256b525b8be 100644 --- a/src/libsyntax_ext/trace_macros.rs +++ b/src/libsyntax_ext/trace_macros.rs @@ -18,7 +18,7 @@ use syntax::tokenstream::TokenTree; pub fn expand_trace_macros(cx: &mut ExtCtxt, sp: Span, tt: &[TokenTree]) - -> Box { + -> Box { if !cx.ecfg.enable_trace_macros() { feature_gate::emit_feature_err(&cx.parse_sess, "trace_macros", From e9a88eaaf9a42785aa91b67281ab265ba85bc43e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 12 Jul 2018 12:48:10 +0200 Subject: [PATCH 11/11] make reference to dirs crate clickable in terminals --- src/libstd/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index c0e1e2533a0..9066c0b7694 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -541,7 +541,7 @@ impl Error for JoinPathsError { /// ``` #[rustc_deprecated(since = "1.29.0", reason = "This function's behavior is unexpected and probably not what you want. \ - Consider using the home_dir function from crates.io/crates/dirs instead.")] + Consider using the home_dir function from https://crates.io/crates/dirs instead.")] #[stable(feature = "env", since = "1.0.0")] pub fn home_dir() -> Option { os_imp::home_dir()