Skip to content

Commit e5e9275

Browse files
committed
Auto merge of rust-lang#41102 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests - Successful merges: rust-lang#40908, rust-lang#41011, rust-lang#41026, rust-lang#41037, rust-lang#41050 - Failed merges:
2 parents 1a9b382 + 89b364d commit e5e9275

Some content is hidden

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

74 files changed

+285
-173
lines changed

src/bootstrap/bootstrap.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -600,16 +600,19 @@ def bootstrap():
600600

601601
def main():
602602
start_time = time()
603+
help_triggered = ('-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
603604
try:
604605
bootstrap()
605-
print("Build completed successfully in %s" % format_build_time(time() - start_time))
606+
if not help_triggered:
607+
print("Build completed successfully in %s" % format_build_time(time() - start_time))
606608
except (SystemExit, KeyboardInterrupt) as e:
607609
if hasattr(e, 'code') and isinstance(e.code, int):
608610
exit_code = e.code
609611
else:
610612
exit_code = 1
611613
print(e)
612-
print("Build completed unsuccessfully in %s" % format_build_time(time() - start_time))
614+
if not help_triggered:
615+
print("Build completed unsuccessfully in %s" % format_build_time(time() - start_time))
613616
sys.exit(exit_code)
614617

615618
if __name__ == '__main__':

src/bootstrap/clean.rs

+22-20
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,38 @@ pub fn clean(build: &Build) {
4444
}
4545

4646
fn rm_rf(path: &Path) {
47-
if !path.exists() {
48-
return
49-
}
50-
if path.is_file() {
51-
return do_op(path, "remove file", |p| fs::remove_file(p));
52-
}
53-
54-
for file in t!(fs::read_dir(path)) {
55-
let file = t!(file).path();
47+
match path.symlink_metadata() {
48+
Err(e) => {
49+
if e.kind() == ErrorKind::NotFound {
50+
return;
51+
}
52+
panic!("failed to get metadata for file {}: {}", path.display(), e);
53+
},
54+
Ok(metadata) => {
55+
if metadata.file_type().is_file() || metadata.file_type().is_symlink() {
56+
do_op(path, "remove file", |p| fs::remove_file(p));
57+
return;
58+
}
5659

57-
if file.is_dir() {
58-
rm_rf(&file);
59-
} else {
60-
// On windows we can't remove a readonly file, and git will
61-
// often clone files as readonly. As a result, we have some
62-
// special logic to remove readonly files on windows.
63-
do_op(&file, "remove file", |p| fs::remove_file(p));
64-
}
65-
}
66-
do_op(path, "remove dir", |p| fs::remove_dir(p));
60+
for file in t!(fs::read_dir(path)) {
61+
rm_rf(&t!(file).path());
62+
}
63+
do_op(path, "remove dir", |p| fs::remove_dir(p));
64+
},
65+
};
6766
}
6867

6968
fn do_op<F>(path: &Path, desc: &str, mut f: F)
7069
where F: FnMut(&Path) -> io::Result<()>
7170
{
7271
match f(path) {
7372
Ok(()) => {}
73+
// On windows we can't remove a readonly file, and git will often clone files as readonly.
74+
// As a result, we have some special logic to remove readonly files on windows.
75+
// This is also the reason that we can't use things like fs::remove_dir_all().
7476
Err(ref e) if cfg!(windows) &&
7577
e.kind() == ErrorKind::PermissionDenied => {
76-
let mut p = t!(path.metadata()).permissions();
78+
let mut p = t!(path.symlink_metadata()).permissions();
7779
p.set_readonly(false);
7880
t!(fs::set_permissions(path, p));
7981
f(path).unwrap_or_else(|e| {

0 commit comments

Comments
 (0)