Skip to content

Commit d716b80

Browse files
nyuriktgross35
authored andcommitted
chore: inline format args
(backport <rust-lang#4416>) (cherry picked from commit 444d9df)
1 parent c544ee4 commit d716b80

File tree

4 files changed

+55
-58
lines changed

4 files changed

+55
-58
lines changed

build.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,17 @@ fn main() {
130130
if rustc_minor_ver >= 80 {
131131
for cfg in ALLOWED_CFGS {
132132
if rustc_minor_ver >= 75 {
133-
println!("cargo:rustc-check-cfg=cfg({})", cfg);
133+
println!("cargo:rustc-check-cfg=cfg({cfg})");
134134
} else {
135-
println!("cargo:rustc-check-cfg=values({})", cfg);
135+
println!("cargo:rustc-check-cfg=values({cfg})");
136136
}
137137
}
138138
for &(name, values) in CHECK_CFG_EXTRA {
139139
let values = values.join("\",\"");
140140
if rustc_minor_ver >= 75 {
141-
println!("cargo:rustc-check-cfg=cfg({},values(\"{}\"))", name, values);
141+
println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))");
142142
} else {
143-
println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
143+
println!("cargo:rustc-check-cfg=values({name},\"{values}\")");
144144
}
145145
}
146146
}
@@ -267,7 +267,7 @@ fn emcc_version_code() -> Option<u64> {
267267

268268
fn set_cfg(cfg: &str) {
269269
if !ALLOWED_CFGS.contains(&cfg) {
270-
panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg);
270+
panic!("trying to set cfg {cfg}, but it is not in ALLOWED_CFGS");
271271
}
272-
println!("cargo:rustc-cfg={}", cfg);
272+
println!("cargo:rustc-cfg={cfg}");
273273
}

ci/ios/deploy_and_run_on_ios_simulator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::process::Command;
1616
macro_rules! t {
1717
($e:expr) => (match $e {
1818
Ok(e) => e,
19-
Err(e) => panic!("{} failed with: {}", stringify!($e), e),
19+
Err(e) => panic!("{} failed with: {e}", stringify!($e)),
2020
})
2121
}
2222

@@ -143,7 +143,7 @@ trait CheckStatus {
143143

144144
impl CheckStatus for Command {
145145
fn check_status(&mut self) {
146-
println!("\trunning: {:?}", self);
146+
println!("\trunning: {self:?}");
147147
assert!(t!(self.status()).success());
148148
}
149149
}

ci/runtest-android.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ fn main() {
3737
let stderr = String::from_utf8_lossy(&output.stderr);
3838

3939
println!(
40-
"status: {}\nstdout ---\n{}\nstderr ---\n{}",
41-
output.status, stdout, stderr
40+
"status: {}\nstdout ---\n{stdout}\nstderr ---\n{stderr}",
41+
output.status,
4242
);
4343

4444
if !stderr.lines().any(|l| {

libc-test/build.rs

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn do_ctest() {
6969
t if t.contains("windows") => return test_windows(t),
7070
t if t.contains("vxworks") => return test_vxworks(t),
7171
t if t.contains("nto-qnx") => return test_neutrino(t),
72-
t => panic!("unknown target {}", t),
72+
t => panic!("unknown target {t}"),
7373
}
7474
}
7575

@@ -109,13 +109,13 @@ fn do_semver() {
109109
process_semver_file(&mut output, &mut semver_root, &vendor);
110110
}
111111
process_semver_file(&mut output, &mut semver_root, &os);
112-
let os_arch = format!("{}-{}", os, arch);
112+
let os_arch = format!("{os}-{arch}");
113113
process_semver_file(&mut output, &mut semver_root, &os_arch);
114114
if target_env != "" {
115-
let os_env = format!("{}-{}", os, target_env);
115+
let os_env = format!("{os}-{target_env}");
116116
process_semver_file(&mut output, &mut semver_root, &os_env);
117117

118-
let os_env_arch = format!("{}-{}-{}", os, target_env, arch);
118+
let os_env_arch = format!("{os}-{target_env}-{arch}");
119119
process_semver_file(&mut output, &mut semver_root, &os_env_arch);
120120
}
121121
}
@@ -132,7 +132,7 @@ fn process_semver_file<W: Write, P: AsRef<Path>>(output: &mut W, path: &mut Path
132132
path.pop();
133133
return;
134134
}
135-
Err(err) => panic!("unexpected error opening file: {}", err),
135+
Err(err) => panic!("unexpected error opening file: {err}"),
136136
};
137137
let input = BufReader::new(input_file);
138138

@@ -471,9 +471,9 @@ fn test_apple(target: &str) {
471471
// OSX calls this something else
472472
"sighandler_t" => "sig_t".to_string(),
473473

474-
t if is_union => format!("union {}", t),
474+
t if is_union => format!("union {t}"),
475475
t if t.ends_with("_t") => t.to_string(),
476-
t if is_struct => format!("struct {}", t),
476+
t if is_struct => format!("struct {t}"),
477477
t => t.to_string(),
478478
}
479479
});
@@ -654,9 +654,9 @@ fn test_openbsd(target: &str) {
654654
// OSX calls this something else
655655
"sighandler_t" => "sig_t".to_string(),
656656

657-
t if is_union => format!("union {}", t),
657+
t if is_union => format!("union {t}"),
658658
t if t.ends_with("_t") => t.to_string(),
659-
t if is_struct => format!("struct {}", t),
659+
t if is_struct => format!("struct {t}"),
660660
t => t.to_string(),
661661
}
662662
});
@@ -753,15 +753,15 @@ fn test_cygwin(target: &str) {
753753

754754
"Ioctl" => "int".to_string(),
755755

756-
t if is_union => format!("union {}", t),
756+
t if is_union => format!("union {t}"),
757757

758758
t if t.ends_with("_t") => t.to_string(),
759759

760760
// sigval is a struct in Rust, but a union in C:
761761
"sigval" => format!("union sigval"),
762762

763763
// put `struct` in front of all structs:.
764-
t if is_struct => format!("struct {}", t),
764+
t if is_struct => format!("struct {t}"),
765765

766766
t => t.to_string(),
767767
}
@@ -905,7 +905,7 @@ fn test_windows(target: &str) {
905905
"sighandler_t" if !gnu => "_crt_signal_t".to_string(),
906906
"sighandler_t" if gnu => "__p_sig_fn_t".to_string(),
907907

908-
t if is_union => format!("union {}", t),
908+
t if is_union => format!("union {t}"),
909909
t if t.ends_with("_t") => t.to_string(),
910910

911911
// Windows uppercase structs don't have `struct` in front:
@@ -918,7 +918,7 @@ fn test_windows(target: &str) {
918918
"struct __utimbuf64".to_string()
919919
} else {
920920
// put `struct` in front of all structs:
921-
format!("struct {}", t)
921+
format!("struct {t}")
922922
}
923923
}
924924
t => t.to_string(),
@@ -1164,8 +1164,8 @@ fn test_solarish(target: &str) {
11641164
"FILE" => "__FILE".to_string(),
11651165
"DIR" | "Dl_info" => ty.to_string(),
11661166
t if t.ends_with("_t") => t.to_string(),
1167-
t if is_struct => format!("struct {}", t),
1168-
t if is_union => format!("union {}", t),
1167+
t if is_struct => format!("struct {t}"),
1168+
t if is_union => format!("union {t}"),
11691169
t => t.to_string(),
11701170
});
11711171

@@ -1434,12 +1434,12 @@ fn test_netbsd(target: &str) {
14341434
// OSX calls this something else
14351435
"sighandler_t" => "sig_t".to_string(),
14361436

1437-
t if is_union => format!("union {}", t),
1437+
t if is_union => format!("union {t}"),
14381438

14391439
t if t.ends_with("_t") => t.to_string(),
14401440

14411441
// put `struct` in front of all structs:.
1442-
t if is_struct => format!("struct {}", t),
1442+
t if is_struct => format!("struct {t}"),
14431443

14441444
t => t.to_string(),
14451445
}
@@ -1650,15 +1650,15 @@ fn test_dragonflybsd(target: &str) {
16501650
// FIXME(dragonflybsd): OSX calls this something else
16511651
"sighandler_t" => "sig_t".to_string(),
16521652

1653-
t if is_union => format!("union {}", t),
1653+
t if is_union => format!("union {t}"),
16541654

16551655
t if t.ends_with("_t") => t.to_string(),
16561656

16571657
// sigval is a struct in Rust, but a union in C:
16581658
"sigval" => format!("union sigval"),
16591659

16601660
// put `struct` in front of all structs:.
1661-
t if is_struct => format!("struct {}", t),
1661+
t if is_struct => format!("struct {t}"),
16621662

16631663
t => t.to_string(),
16641664
}
@@ -1828,11 +1828,11 @@ fn test_wasi(target: &str) {
18281828

18291829
cfg.type_name(move |ty, is_struct, is_union| match ty {
18301830
"FILE" | "fd_set" | "DIR" => ty.to_string(),
1831-
t if is_union => format!("union {}", t),
1832-
t if t.starts_with("__wasi") && t.ends_with("_u") => format!("union {}", t),
1833-
t if t.starts_with("__wasi") && is_struct => format!("struct {}", t),
1831+
t if is_union => format!("union {t}"),
1832+
t if t.starts_with("__wasi") && t.ends_with("_u") => format!("union {t}"),
1833+
t if t.starts_with("__wasi") && is_struct => format!("struct {t}"),
18341834
t if t.ends_with("_t") => t.to_string(),
1835-
t if is_struct => format!("struct {}", t),
1835+
t if is_struct => format!("struct {t}"),
18361836
t => t.to_string(),
18371837
});
18381838

@@ -1881,7 +1881,7 @@ fn test_android(target: &str) {
18811881
let target_pointer_width = match target {
18821882
t if t.contains("aarch64") || t.contains("x86_64") => 64,
18831883
t if t.contains("i686") || t.contains("arm") => 32,
1884-
t => panic!("unsupported target: {}", t),
1884+
t => panic!("unsupported target: {t}"),
18851885
};
18861886
let x86 = target.contains("i686") || target.contains("x86_64");
18871887
let aarch64 = target.contains("aarch64");
@@ -2040,15 +2040,15 @@ fn test_android(target: &str) {
20402040
// Just pass all these through, no need for a "struct" prefix
20412041
"FILE" | "fd_set" | "Dl_info" | "Elf32_Phdr" | "Elf64_Phdr" => ty.to_string(),
20422042

2043-
t if is_union => format!("union {}", t),
2043+
t if is_union => format!("union {t}"),
20442044

20452045
t if t.ends_with("_t") => t.to_string(),
20462046

20472047
// sigval is a struct in Rust, but a union in C:
20482048
"sigval" => format!("union sigval"),
20492049

20502050
// put `struct` in front of all structs:.
2051-
t if is_struct => format!("struct {}", t),
2051+
t if is_struct => format!("struct {t}"),
20522052

20532053
t => t.to_string(),
20542054
}
@@ -2553,15 +2553,15 @@ fn test_freebsd(target: &str) {
25532553
// FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273
25542554
"sighandler_t" => "sig_t".to_string(),
25552555

2556-
t if is_union => format!("union {}", t),
2556+
t if is_union => format!("union {t}"),
25572557

25582558
t if t.ends_with("_t") => t.to_string(),
25592559

25602560
// sigval is a struct in Rust, but a union in C:
25612561
"sigval" => format!("union sigval"),
25622562

25632563
// put `struct` in front of all structs:.
2564-
t if is_struct => format!("struct {}", t),
2564+
t if is_struct => format!("struct {t}"),
25652565

25662566
t => t.to_string(),
25672567
}
@@ -3158,10 +3158,10 @@ fn test_emscripten(target: &str) {
31583158
t if t.ends_with("_t") => t.to_string(),
31593159

31603160
// put `struct` in front of all structs:.
3161-
t if is_struct => format!("struct {}", t),
3161+
t if is_struct => format!("struct {t}"),
31623162

31633163
// put `union` in front of all unions:
3164-
t if is_union => format!("union {}", t),
3164+
t if is_union => format!("union {t}"),
31653165

31663166
t => t.to_string(),
31673167
}
@@ -3438,12 +3438,12 @@ fn test_neutrino(target: &str) {
34383438

34393439
"Ioctl" => "int".to_string(),
34403440

3441-
t if is_union => format!("union {}", t),
3441+
t if is_union => format!("union {t}"),
34423442

34433443
t if t.ends_with("_t") => t.to_string(),
34443444

34453445
// put `struct` in front of all structs:.
3446-
t if is_struct => format!("struct {}", t),
3446+
t if is_struct => format!("struct {t}"),
34473447

34483448
t => t.to_string(),
34493449
}
@@ -3664,9 +3664,9 @@ fn test_vxworks(target: &str) {
36643664

36653665
cfg.type_name(move |ty, is_struct, is_union| match ty {
36663666
"DIR" | "FILE" | "Dl_info" | "RTP_DESC" => ty.to_string(),
3667-
t if is_union => format!("union {}", t),
3667+
t if is_union => format!("union {t}"),
36683668
t if t.ends_with("_t") => t.to_string(),
3669-
t if is_struct => format!("struct {}", t),
3669+
t if is_struct => format!("struct {t}"),
36703670
t => t.to_string(),
36713671
});
36723672

@@ -3716,10 +3716,7 @@ fn test_linux(target: &str) {
37163716
(true, false, false) => (),
37173717
(false, true, false) => (),
37183718
(false, false, true) => (),
3719-
(_, _, _) => panic!(
3720-
"linux target lib is gnu: {}, musl: {}, uclibc: {}",
3721-
gnu, musl, uclibc
3722-
),
3719+
(_, _, _) => panic!("linux target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}"),
37233720
}
37243721

37253722
let arm = target.contains("arm");
@@ -3959,9 +3956,9 @@ fn test_linux(target: &str) {
39593956
// typedefs don't need any keywords
39603957
t if t.ends_with("_t") => t.to_string(),
39613958
// put `struct` in front of all structs:.
3962-
t if is_struct => format!("struct {}", t),
3959+
t if is_struct => format!("struct {t}"),
39633960
// put `union` in front of all unions:
3964-
t if is_union => format!("union {}", t),
3961+
t if is_union => format!("union {t}"),
39653962

39663963
t => t.to_string(),
39673964
}
@@ -4990,8 +4987,8 @@ fn test_linux_like_apis(target: &str) {
49904987
_ => true,
49914988
})
49924989
.type_name(move |ty, is_struct, is_union| match ty {
4993-
t if is_struct => format!("struct {}", t),
4994-
t if is_union => format!("union {}", t),
4990+
t if is_struct => format!("struct {t}"),
4991+
t if is_union => format!("union {t}"),
49954992
t => t.to_string(),
49964993
});
49974994

@@ -5016,8 +5013,8 @@ fn test_linux_like_apis(target: &str) {
50165013
.type_name(move |ty, is_struct, is_union| match ty {
50175014
"Ioctl" if gnu => "unsigned long".to_string(),
50185015
"Ioctl" => "int".to_string(),
5019-
t if is_struct => format!("struct {}", t),
5020-
t if is_union => format!("union {}", t),
5016+
t if is_struct => format!("struct {t}"),
5017+
t if is_union => format!("union {t}"),
50215018
t => t.to_string(),
50225019
});
50235020
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_termios.rs");
@@ -5045,8 +5042,8 @@ fn test_linux_like_apis(target: &str) {
50455042
_ => true,
50465043
})
50475044
.type_name(move |ty, is_struct, is_union| match ty {
5048-
t if is_struct => format!("struct {}", t),
5049-
t if is_union => format!("union {}", t),
5045+
t if is_struct => format!("struct {t}"),
5046+
t if is_union => format!("union {t}"),
50505047
t => t.to_string(),
50515048
});
50525049
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_ipv6.rs");
@@ -5433,9 +5430,9 @@ fn test_haiku(target: &str) {
54335430

54345431
// is actually a union
54355432
"sigval" => format!("union sigval"),
5436-
t if is_union => format!("union {}", t),
5433+
t if is_union => format!("union {t}"),
54375434
t if t.ends_with("_t") => t.to_string(),
5438-
t if is_struct => format!("struct {}", t),
5435+
t if is_struct => format!("struct {t}"),
54395436
t => t.to_string(),
54405437
}
54415438
});

0 commit comments

Comments
 (0)