Skip to content

Commit 7db82cc

Browse files
committed
Auto merge of #52303 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests Successful merges: - #51816 (bootstrap: write texts to a .tmp file first for atomicity) - #51912 (impl Clone for Box<CStr>, Box<OsStr>, Box<Path>) - #52164 (use proper footnote syntax for references) - #52220 (Deny bare trait objects in `src/bootstrap`) - #52276 (rustc: Verify #[proc_macro] is only a word) - #52277 (Uncapitalize "If") - #52287 (Deny bare trait objects in src/librustc_resolve) - #52295 (Deny bare trait objects in src/libsyntax_ext) - #52298 (make reference to dirs crate clickable in terminals) Failed merges: r? @ghost
2 parents d334027 + a7c2c68 commit 7db82cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+182
-68
lines changed

Diff for: src/bootstrap/bootstrap.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,19 @@ def default_build_triple():
303303
return "{}-{}".format(cputype, ostype)
304304

305305

306+
@contextlib.contextmanager
307+
def output(filepath):
308+
tmp = filepath + '.tmp'
309+
with open(tmp, 'w') as f:
310+
yield f
311+
try:
312+
os.remove(filepath) # PermissionError/OSError on Win32 if in use
313+
os.rename(tmp, filepath)
314+
except OSError:
315+
shutil.copy2(tmp, filepath)
316+
os.remove(tmp)
317+
318+
306319
class RustBuild(object):
307320
"""Provide all the methods required to build Rust"""
308321
def __init__(self):
@@ -346,7 +359,7 @@ def download_stage0(self):
346359
self._download_stage0_helper(filename, "rustc")
347360
self.fix_executable("{}/bin/rustc".format(self.bin_root()))
348361
self.fix_executable("{}/bin/rustdoc".format(self.bin_root()))
349-
with open(self.rustc_stamp(), 'w') as rust_stamp:
362+
with output(self.rustc_stamp()) as rust_stamp:
350363
rust_stamp.write(self.date)
351364

352365
# This is required so that we don't mix incompatible MinGW
@@ -363,7 +376,7 @@ def download_stage0(self):
363376
filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build)
364377
self._download_stage0_helper(filename, "cargo")
365378
self.fix_executable("{}/bin/cargo".format(self.bin_root()))
366-
with open(self.cargo_stamp(), 'w') as cargo_stamp:
379+
with output(self.cargo_stamp()) as cargo_stamp:
367380
cargo_stamp.write(self.date)
368381

369382
def _download_stage0_helper(self, filename, pattern):
@@ -776,7 +789,7 @@ def bootstrap(help_triggered):
776789
if build.use_vendored_sources:
777790
if not os.path.exists('.cargo'):
778791
os.makedirs('.cargo')
779-
with open('.cargo/config', 'w') as cargo_config:
792+
with output('.cargo/config') as cargo_config:
780793
cargo_config.write("""
781794
[source.crates-io]
782795
replace-with = 'vendored-sources'

Diff for: src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct Builder<'a> {
4444
pub top_stage: u32,
4545
pub kind: Kind,
4646
cache: Cache,
47-
stack: RefCell<Vec<Box<Any>>>,
47+
stack: RefCell<Vec<Box<dyn Any>>>,
4848
time_spent_on_dependencies: Cell<Duration>,
4949
pub paths: Vec<PathBuf>,
5050
graph_nodes: RefCell<HashMap<String, NodeIndex>>,

Diff for: src/bootstrap/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ lazy_static! {
249249
pub struct Cache(
250250
RefCell<HashMap<
251251
TypeId,
252-
Box<Any>, // actually a HashMap<Step, Interned<Step::Output>>
252+
Box<dyn Any>, // actually a HashMap<Step, Interned<Step::Output>>
253253
>>
254254
);
255255

Diff for: src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ pub fn run_cargo(builder: &Builder, cargo: &mut Command, stamp: &Path, is_check:
11891189
pub fn stream_cargo(
11901190
builder: &Builder,
11911191
cargo: &mut Command,
1192-
cb: &mut FnMut(CargoMessage),
1192+
cb: &mut dyn FnMut(CargoMessage),
11931193
) -> bool {
11941194
if builder.config.dry_run {
11951195
return true;

Diff for: src/bootstrap/configure.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def configure_section(lines, config):
432432
# order that we read it in.
433433
p("")
434434
p("writing `config.toml` in current directory")
435-
with open('config.toml', 'w') as f:
435+
with bootstrap.output('config.toml') as f:
436436
for section in section_order:
437437
if section == 'target':
438438
for target in targets:
@@ -442,7 +442,7 @@ def configure_section(lines, config):
442442
for line in sections[section]:
443443
f.write(line + "\n")
444444

445-
with open('Makefile', 'w') as f:
445+
with bootstrap.output('Makefile') as f:
446446
contents = os.path.join(rust_dir, 'src', 'bootstrap', 'mk', 'Makefile.in')
447447
contents = open(contents).read()
448448
contents = contents.replace("$(CFG_SRC_DIR)", rust_dir + '/')

Diff for: src/bootstrap/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
//! More documentation can be found in each respective module below, and you can
114114
//! also check out the `src/bootstrap/README.md` file for more information.
115115
116+
#![deny(bare_trait_objects)]
116117
#![deny(warnings)]
117118
#![feature(core_intrinsics)]
118119
#![feature(drain_filter)]
@@ -1174,13 +1175,13 @@ impl Build {
11741175
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
11751176
/// when this function is called. Unwanted files or directories can be skipped
11761177
/// by returning `false` from the filter function.
1177-
pub fn cp_filtered(&self, src: &Path, dst: &Path, filter: &Fn(&Path) -> bool) {
1178+
pub fn cp_filtered(&self, src: &Path, dst: &Path, filter: &dyn Fn(&Path) -> bool) {
11781179
// Immediately recurse with an empty relative path
11791180
self.recurse_(src, dst, Path::new(""), filter)
11801181
}
11811182

11821183
// Inner function does the actual work
1183-
fn recurse_(&self, src: &Path, dst: &Path, relative: &Path, filter: &Fn(&Path) -> bool) {
1184+
fn recurse_(&self, src: &Path, dst: &Path, relative: &Path, filter: &dyn Fn(&Path) -> bool) {
11841185
for f in self.read_dir(src) {
11851186
let path = f.path();
11861187
let name = path.file_name().unwrap();

Diff for: src/libcore/num/flt2dec/strategy/dragon.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
12-
Almost direct (but slightly optimized) Rust translation of Figure 3 of \[1\].
13-
14-
\[1\] Burger, R. G. and Dybvig, R. K. 1996. Printing floating-point numbers
15-
quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116.
16-
*/
11+
//! Almost direct (but slightly optimized) Rust translation of Figure 3 of "Printing
12+
//! Floating-Point Numbers Quickly and Accurately"[^1].
13+
//!
14+
//! [^1]: Burger, R. G. and Dybvig, R. K. 1996. Printing floating-point numbers
15+
//! quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116.
1716
1817
use cmp::Ordering;
1918

Diff for: src/libcore/num/flt2dec/strategy/grisu.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
12-
Rust adaptation of Grisu3 algorithm described in \[1\]. It uses about
13-
1KB of precomputed table, and in turn, it's very quick for most inputs.
14-
15-
\[1\] Florian Loitsch. 2010. Printing floating-point numbers quickly and
16-
accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243.
17-
*/
11+
//! Rust adaptation of the Grisu3 algorithm described in "Printing Floating-Point Numbers Quickly
12+
//! and Accurately with Integers"[^1]. It uses about 1KB of precomputed table, and in turn, it's
13+
//! very quick for most inputs.
14+
//!
15+
//! [^1]: Florian Loitsch. 2010. Printing floating-point numbers quickly and
16+
//! accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243.
1817
1918
use num::diy_float::Fp;
2019
use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up};

Diff for: src/librustc_resolve/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(bare_trait_objects)]
12+
1113
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1214
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1315
html_root_url = "https://doc.rust-lang.org/nightly/")]
@@ -1292,7 +1294,7 @@ impl PrimitiveTypeTable {
12921294
/// This is the visitor that walks the whole crate.
12931295
pub struct Resolver<'a> {
12941296
session: &'a Session,
1295-
cstore: &'a CrateStore,
1297+
cstore: &'a dyn CrateStore,
12961298

12971299
pub definitions: Definitions,
12981300

@@ -1388,7 +1390,7 @@ pub struct Resolver<'a> {
13881390
/// true if `#![feature(use_extern_macros)]`
13891391
use_extern_macros: bool,
13901392

1391-
crate_loader: &'a mut CrateLoader,
1393+
crate_loader: &'a mut dyn CrateLoader,
13921394
macro_names: FxHashSet<Ident>,
13931395
global_macros: FxHashMap<Name, &'a NameBinding<'a>>,
13941396
pub all_macros: FxHashMap<Name, Def>,
@@ -1604,11 +1606,11 @@ impl<'a> Resolver<'a> {
16041606

16051607
impl<'a> Resolver<'a> {
16061608
pub fn new(session: &'a Session,
1607-
cstore: &'a CrateStore,
1609+
cstore: &'a dyn CrateStore,
16081610
krate: &Crate,
16091611
crate_name: &str,
16101612
make_glob_map: MakeGlobMap,
1611-
crate_loader: &'a mut CrateLoader,
1613+
crate_loader: &'a mut dyn CrateLoader,
16121614
arenas: &'a ResolverArenas<'a>)
16131615
-> Resolver<'a> {
16141616
let root_def_id = DefId::local(CRATE_DEF_INDEX);

Diff for: src/libstd/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ impl Error for JoinPathsError {
541541
/// ```
542542
#[rustc_deprecated(since = "1.29.0",
543543
reason = "This function's behavior is unexpected and probably not what you want. \
544-
Consider using the home_dir function from crates.io/crates/dirs instead.")]
544+
Consider using the home_dir function from https://crates.io/crates/dirs instead.")]
545545
#[stable(feature = "env", since = "1.0.0")]
546546
pub fn home_dir() -> Option<PathBuf> {
547547
os_imp::home_dir()

Diff for: src/libstd/ffi/c_str.rs

+8
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,14 @@ impl From<Box<CStr>> for CString {
706706
}
707707
}
708708

709+
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
710+
impl Clone for Box<CStr> {
711+
#[inline]
712+
fn clone(&self) -> Self {
713+
(**self).into()
714+
}
715+
}
716+
709717
#[stable(feature = "box_from_c_string", since = "1.20.0")]
710718
impl From<CString> for Box<CStr> {
711719
#[inline]

Diff for: src/libstd/ffi/os_str.rs

+8
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,14 @@ impl From<OsString> for Box<OsStr> {
642642
}
643643
}
644644

645+
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
646+
impl Clone for Box<OsStr> {
647+
#[inline]
648+
fn clone(&self) -> Self {
649+
self.to_os_string().into_boxed_os_str()
650+
}
651+
}
652+
645653
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
646654
impl From<OsString> for Arc<OsStr> {
647655
#[inline]

Diff for: src/libstd/path.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,14 @@ impl From<PathBuf> for Box<Path> {
14101410
}
14111411
}
14121412

1413+
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
1414+
impl Clone for Box<Path> {
1415+
#[inline]
1416+
fn clone(&self) -> Self {
1417+
self.to_path_buf().into_boxed_path()
1418+
}
1419+
}
1420+
14131421
#[stable(feature = "rust1", since = "1.0.0")]
14141422
impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
14151423
fn from(s: &'a T) -> PathBuf {

Diff for: src/libstd/sync/mpsc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
689689
/// only one [`Receiver`] is supported.
690690
///
691691
/// If the [`Receiver`] is disconnected while trying to [`send`] with the
692-
/// [`Sender`], the [`send`] method will return a [`SendError`]. Similarly, If the
692+
/// [`Sender`], the [`send`] method will return a [`SendError`]. Similarly, if the
693693
/// [`Sender`] is disconnected while trying to [`recv`], the [`recv`] method will
694694
/// return a [`RecvError`].
695695
///

Diff for: src/libsyntax_ext/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"];
5050
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
5151
sp: Span,
5252
tts: &[tokenstream::TokenTree])
53-
-> Box<base::MacResult + 'cx> {
53+
-> Box<dyn base::MacResult + 'cx> {
5454
if !cx.ecfg.enable_asm() {
5555
feature_gate::emit_feature_err(&cx.parse_sess,
5656
"asm",

Diff for: src/libsyntax_ext/assert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn expand_assert<'cx>(
2222
cx: &'cx mut ExtCtxt,
2323
sp: Span,
2424
tts: &[TokenTree],
25-
) -> Box<MacResult + 'cx> {
25+
) -> Box<dyn MacResult + 'cx> {
2626
let mut parser = cx.new_parser_from_tts(tts);
2727
let cond_expr = panictry!(parser.parse_expr());
2828
let custom_msg_args = if parser.eat(&token::Comma) {

Diff for: src/libsyntax_ext/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use syntax_pos::Span;
2323
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
2424
sp: Span,
2525
tts: &[tokenstream::TokenTree])
26-
-> Box<base::MacResult + 'static> {
26+
-> Box<dyn base::MacResult + 'static> {
2727
let sp = sp.apply_mark(cx.current_expansion.mark);
2828
let mut p = cx.new_parser_from_tts(tts);
2929
let cfg = panictry!(p.parse_meta_item());

Diff for: src/libsyntax_ext/compile_error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use syntax::tokenstream;
1818
pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt,
1919
sp: Span,
2020
tts: &[tokenstream::TokenTree])
21-
-> Box<base::MacResult + 'cx> {
21+
-> Box<dyn base::MacResult + 'cx> {
2222
let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") {
2323
None => return DummyResult::expr(sp),
2424
Some(v) => v,

Diff for: src/libsyntax_ext/concat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn expand_syntax_ext(
2121
cx: &mut base::ExtCtxt,
2222
sp: syntax_pos::Span,
2323
tts: &[tokenstream::TokenTree],
24-
) -> Box<base::MacResult + 'static> {
24+
) -> Box<dyn base::MacResult + 'static> {
2525
let es = match base::get_exprs_from_tts(cx, sp, tts) {
2626
Some(e) => e,
2727
None => return base::DummyResult::expr(sp),

Diff for: src/libsyntax_ext/concat_idents.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use syntax::tokenstream::TokenTree;
2121
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
2222
sp: Span,
2323
tts: &[TokenTree])
24-
-> Box<base::MacResult + 'cx> {
24+
-> Box<dyn base::MacResult + 'cx> {
2525
if !cx.ecfg.enable_concat_idents() {
2626
feature_gate::emit_feature_err(&cx.parse_sess,
2727
"concat_idents",

Diff for: src/libsyntax_ext/deriving/bounds.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
1919
span: Span,
2020
_: &MetaItem,
2121
_: &Annotatable,
22-
_: &mut FnMut(Annotatable)) {
22+
_: &mut dyn FnMut(Annotatable)) {
2323
cx.span_err(span, "this unsafe trait should be implemented explicitly");
2424
}
2525

2626
pub fn expand_deriving_copy(cx: &mut ExtCtxt,
2727
span: Span,
2828
mitem: &MetaItem,
2929
item: &Annotatable,
30-
push: &mut FnMut(Annotatable)) {
30+
push: &mut dyn FnMut(Annotatable)) {
3131
let trait_def = TraitDef {
3232
span,
3333
attributes: Vec::new(),

Diff for: src/libsyntax_ext/deriving/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
2525
span: Span,
2626
mitem: &MetaItem,
2727
item: &Annotatable,
28-
push: &mut FnMut(Annotatable)) {
28+
push: &mut dyn FnMut(Annotatable)) {
2929
// check if we can use a short form
3030
//
3131
// the short form is `fn clone(&self) -> Self { *self }`

Diff for: src/libsyntax_ext/deriving/cmp/eq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
2323
span: Span,
2424
mitem: &MetaItem,
2525
item: &Annotatable,
26-
push: &mut FnMut(Annotatable)) {
26+
push: &mut dyn FnMut(Annotatable)) {
2727
let inline = cx.meta_word(span, Symbol::intern("inline"));
2828
let hidden = cx.meta_list_item_word(span, Symbol::intern("hidden"));
2929
let doc = cx.meta_list(span, Symbol::intern("doc"), vec![hidden]);

Diff for: src/libsyntax_ext/deriving/cmp/ord.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
2323
span: Span,
2424
mitem: &MetaItem,
2525
item: &Annotatable,
26-
push: &mut FnMut(Annotatable)) {
26+
push: &mut dyn FnMut(Annotatable)) {
2727
let inline = cx.meta_word(span, Symbol::intern("inline"));
2828
let attrs = vec![cx.attribute(span, inline)];
2929
let trait_def = TraitDef {

Diff for: src/libsyntax_ext/deriving/cmp/partial_eq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
2323
span: Span,
2424
mitem: &MetaItem,
2525
item: &Annotatable,
26-
push: &mut FnMut(Annotatable)) {
26+
push: &mut dyn FnMut(Annotatable)) {
2727
// structures are equal if all fields are equal, and non equal, if
2828
// any fields are not equal or if the enum variants are different
2929
fn cs_op(cx: &mut ExtCtxt,

Diff for: src/libsyntax_ext/deriving/cmp/partial_ord.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt,
2525
span: Span,
2626
mitem: &MetaItem,
2727
item: &Annotatable,
28-
push: &mut FnMut(Annotatable)) {
28+
push: &mut dyn FnMut(Annotatable)) {
2929
macro_rules! md {
3030
($name:expr, $op:expr, $equal:expr) => { {
3131
let inline = cx.meta_word(span, Symbol::intern("inline"));

Diff for: src/libsyntax_ext/deriving/debug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt,
2323
span: Span,
2424
mitem: &MetaItem,
2525
item: &Annotatable,
26-
push: &mut FnMut(Annotatable)) {
26+
push: &mut dyn FnMut(Annotatable)) {
2727
// &mut ::std::fmt::Formatter
2828
let fmtr = Ptr(Box::new(Literal(path_std!(cx, fmt::Formatter))),
2929
Borrowed(None, ast::Mutability::Mutable));

0 commit comments

Comments
 (0)