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

src/bootstrap/bootstrap.py

Lines changed: 16 additions & 3 deletions
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'

src/bootstrap/builder.rs

Lines changed: 1 addition & 1 deletion
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>>,

src/bootstrap/cache.rs

Lines changed: 1 addition & 1 deletion
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

src/bootstrap/compile.rs

Lines changed: 1 addition & 1 deletion
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;

src/bootstrap/configure.py

Lines changed: 2 additions & 2 deletions
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 + '/')

src/bootstrap/lib.rs

Lines changed: 3 additions & 2 deletions
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();

src/libcore/num/flt2dec/strategy/dragon.rs

Lines changed: 5 additions & 6 deletions
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

src/libcore/num/flt2dec/strategy/grisu.rs

Lines changed: 6 additions & 7 deletions
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};

src/librustc_resolve/lib.rs

Lines changed: 6 additions & 4 deletions
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);

src/libstd/env.rs

Lines changed: 1 addition & 1 deletion
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()

0 commit comments

Comments
 (0)