Skip to content

Rollup of 9 pull requests #52303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cdff2f3
impl Clone for Box<CStr>, Box<OsStr>, Box<Path>
mbrubeck Jun 29, 2018
bcb8a06
bootstrap: write texts to a .tmp file first for atomicity
nodakai Jun 23, 2018
97d0bc3
bootstrap: our best to achieve atomic rename on Win32
nodakai Jun 26, 2018
d1e3567
Deny bare trait objects in `src/bootstrap`.
ljedrz Jul 10, 2018
72b908f
Restore #![deny(warnings)]
ljedrz Jul 10, 2018
f5f21aa
use proper footnote syntax for references
euclio Jul 8, 2018
7735f45
rustc: Verify #[proc_macro] is only a word
alexcrichton Jul 11, 2018
e488cba
Uncapitalize "If"
kraai Jul 12, 2018
8fecbe3
Deny bare trait objects in src/librustc_resolve
ljedrz Jul 12, 2018
08c113a
Deny bare trait objects in src/libsyntax_ext
ljedrz Jul 12, 2018
e9a88ea
make reference to dirs crate clickable in terminals
RalfJung Jul 12, 2018
c87e3fe
Rollup merge of #51816 - nodakai:conf-py-tmpfile, r=kennytm
kennytm Jul 12, 2018
b317ab1
Rollup merge of #51912 - mbrubeck:more_box_slice_clone, r=alexcrichton
kennytm Jul 12, 2018
8fba84f
Rollup merge of #52164 - euclio:references, r=TimNN
kennytm Jul 12, 2018
c2c6986
Rollup merge of #52220 - ljedrz:dyn_bootstrap, r=kennytm
kennytm Jul 12, 2018
63cc55b
Rollup merge of #52276 - alexcrichton:validate-proc-macro-attr, r=pet…
kennytm Jul 12, 2018
eb1728b
Rollup merge of #52277 - kraai:patch-2, r=kennytm
kennytm Jul 12, 2018
9fc126c
Rollup merge of #52287 - ljedrz:dyn_librustc_resolve, r=petrochenkov
kennytm Jul 12, 2018
019dc2a
Rollup merge of #52295 - ljedrz:dyn_libsyntax_ext, r=petrochenkov
kennytm Jul 12, 2018
a7c2c68
Rollup merge of #52298 - RalfJung:dirs, r=Mark-Simulacrum
kennytm Jul 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,19 @@ def default_build_triple():
return "{}-{}".format(cputype, ostype)


@contextlib.contextmanager
def output(filepath):
tmp = filepath + '.tmp'
with open(tmp, 'w') as f:
yield f
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):
"""Provide all the methods required to build Rust"""
def __init__(self):
Expand Down Expand Up @@ -346,7 +359,7 @@ def download_stage0(self):
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
Expand All @@ -363,7 +376,7 @@ def download_stage0(self):
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):
Expand Down Expand Up @@ -776,7 +789,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'
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Builder<'a> {
pub top_stage: u32,
pub kind: Kind,
cache: Cache,
stack: RefCell<Vec<Box<Any>>>,
stack: RefCell<Vec<Box<dyn Any>>>,
time_spent_on_dependencies: Cell<Duration>,
pub paths: Vec<PathBuf>,
graph_nodes: RefCell<HashMap<String, NodeIndex>>,
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ lazy_static! {
pub struct Cache(
RefCell<HashMap<
TypeId,
Box<Any>, // actually a HashMap<Step, Interned<Step::Output>>
Box<dyn Any>, // actually a HashMap<Step, Interned<Step::Output>>
>>
);

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def configure_section(lines, 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:
Expand All @@ -442,7 +442,7 @@ def configure_section(lines, config):
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 + '/')
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +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(bare_trait_objects)]
#![deny(warnings)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
Expand Down Expand Up @@ -1174,13 +1175,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();
Expand Down
11 changes: 5 additions & 6 deletions src/libcore/num/flt2dec/strategy/dragon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 6 additions & 7 deletions src/libcore/num/flt2dec/strategy/grisu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/")]
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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<Ident>,
global_macros: FxHashMap<Name, &'a NameBinding<'a>>,
pub all_macros: FxHashMap<Name, Def>,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf> {
os_imp::home_dir()
Expand Down
8 changes: 8 additions & 0 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,14 @@ impl From<Box<CStr>> for CString {
}
}

#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<CStr> {
#[inline]
fn clone(&self) -> Self {
(**self).into()
}
}

#[stable(feature = "box_from_c_string", since = "1.20.0")]
impl From<CString> for Box<CStr> {
#[inline]
Expand Down
8 changes: 8 additions & 0 deletions src/libstd/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,14 @@ impl From<OsString> for Box<OsStr> {
}
}

#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<OsStr> {
#[inline]
fn clone(&self) -> Self {
self.to_os_string().into_boxed_os_str()
}
}

#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<OsString> for Arc<OsStr> {
#[inline]
Expand Down
8 changes: 8 additions & 0 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,14 @@ impl From<PathBuf> for Box<Path> {
}
}

#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<Path> {
#[inline]
fn clone(&self) -> Self {
self.to_path_buf().into_boxed_path()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
fn from(s: &'a T) -> PathBuf {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
/// 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`].
///
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
if !cx.ecfg.enable_asm() {
feature_gate::emit_feature_err(&cx.parse_sess,
"asm",
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn expand_assert<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[TokenTree],
) -> Box<MacResult + 'cx> {
) -> Box<dyn MacResult + 'cx> {
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) {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use syntax_pos::Span;
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'static> {
-> Box<dyn base::MacResult + 'static> {
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());
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use syntax::tokenstream;
pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") {
None => return DummyResult::expr(sp),
Some(v) => v,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn expand_syntax_ext(
cx: &mut base::ExtCtxt,
sp: syntax_pos::Span,
tts: &[tokenstream::TokenTree],
) -> Box<base::MacResult + 'static> {
) -> Box<dyn base::MacResult + 'static> {
let es = match base::get_exprs_from_tts(cx, sp, tts) {
Some(e) => e,
None => return base::DummyResult::expr(sp),
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/concat_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use syntax::tokenstream::TokenTree;
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
if !cx.ecfg.enable_concat_idents() {
feature_gate::emit_feature_err(&cx.parse_sess,
"concat_idents",
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax_ext/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ 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");
}

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(),
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }`
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/cmp/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/cmp/partial_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading