Skip to content

Commit e31bedc

Browse files
authored
Rollup merge of #100924 - est31:closure_to_fn_ptr, r=Mark-Simulacrum
Smaller improvements of tidy and the unicode generator
2 parents 7214f0c + 754b3e7 commit e31bedc

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

Diff for: src/tools/tidy/src/error_codes_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
217217
println!("Checking which error codes lack tests...");
218218

219219
for path in paths {
220-
super::walk(path, &mut |path| super::filter_dirs(path), &mut |entry, contents| {
220+
super::walk(path, &mut super::filter_dirs, &mut |entry, contents| {
221221
let file_name = entry.file_name();
222222
let entry_path = entry.path();
223223

Diff for: src/tools/unicode-table-generator/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn main() {
221221
let write_location = std::env::args().nth(1).unwrap_or_else(|| {
222222
eprintln!("Must provide path to write unicode tables to");
223223
eprintln!(
224-
"e.g. {} library/core/unicode/unicode_data.rs",
224+
"e.g. {} library/core/src/unicode/unicode_data.rs",
225225
std::env::args().next().unwrap_or_default()
226226
);
227227
std::process::exit(1);
+15-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::UNICODE_DIRECTORY;
22
use std::path::Path;
3-
use std::process::Command;
3+
use std::process::{Command, Output};
44

55
static URL_PREFIX: &str = "https://www.unicode.org/Public/UCD/latest/ucd/";
66

@@ -9,6 +9,18 @@ static README: &str = "ReadMe.txt";
99
static RESOURCES: &[&str] =
1010
&["DerivedCoreProperties.txt", "PropList.txt", "UnicodeData.txt", "SpecialCasing.txt"];
1111

12+
#[track_caller]
13+
fn fetch(url: &str) -> Output {
14+
let output = Command::new("curl").arg(URL_PREFIX.to_owned() + url).output().unwrap();
15+
if !output.status.success() {
16+
panic!(
17+
"Failed to run curl to fetch {url}: stderr: {}",
18+
String::from_utf8_lossy(&output.stderr)
19+
);
20+
}
21+
output
22+
}
23+
1224
pub fn fetch_latest() {
1325
let directory = Path::new(UNICODE_DIRECTORY);
1426
if directory.exists() {
@@ -20,27 +32,14 @@ pub fn fetch_latest() {
2032
if let Err(e) = std::fs::create_dir_all(directory) {
2133
panic!("Failed to create {UNICODE_DIRECTORY:?}: {e}");
2234
}
23-
let output = Command::new("curl").arg(URL_PREFIX.to_owned() + README).output().unwrap();
24-
if !output.status.success() {
25-
panic!(
26-
"Failed to run curl to fetch readme: stderr: {}",
27-
String::from_utf8_lossy(&output.stderr)
28-
);
29-
}
35+
let output = fetch(README);
3036
let current = std::fs::read_to_string(directory.join(README)).unwrap_or_default();
3137
if current.as_bytes() != &output.stdout[..] {
3238
std::fs::write(directory.join(README), output.stdout).unwrap();
3339
}
3440

3541
for resource in RESOURCES {
36-
let output = Command::new("curl").arg(URL_PREFIX.to_owned() + resource).output().unwrap();
37-
if !output.status.success() {
38-
panic!(
39-
"Failed to run curl to fetch {}: stderr: {}",
40-
resource,
41-
String::from_utf8_lossy(&output.stderr)
42-
);
43-
}
42+
let output = fetch(resource);
4443
std::fs::write(directory.join(resource), output.stdout).unwrap();
4544
}
4645
}

0 commit comments

Comments
 (0)