Skip to content

Commit e932f3e

Browse files
authored
Merge pull request #5 from Wybxc/fmt
chore: update format
2 parents 473e659 + 2e7b5c6 commit e932f3e

File tree

7 files changed

+21
-61
lines changed

7 files changed

+21
-61
lines changed

.rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use_small_heuristics = "Max"
2+
imports_granularity = "Module"

bootstrap/src/clean.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use clap::Args;
22

3-
use crate::{manifest::Manifest, Run};
3+
use crate::manifest::Manifest;
4+
use crate::Run;
45

56
/// Clean the build directory
67
#[derive(Args, Debug)]

bootstrap/src/fmt.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ pub struct FmtCommand {
1515
impl Run for FmtCommand {
1616
fn run(&self, _manifest: &crate::manifest::Manifest) {
1717
self.perform(
18-
Command::new("cargo")
19-
.arg("fmt")
20-
.args(["--manifest-path", "bootstrap/Cargo.toml"]),
18+
Command::new("cargo").arg("fmt").args(["--manifest-path", "bootstrap/Cargo.toml"]),
2119
);
2220
self.perform(
2321
Command::new("cargo")
@@ -26,18 +24,10 @@ impl Run for FmtCommand {
2624
.arg("--all"),
2725
);
2826
for file in glob("example/**/*.rs").unwrap() {
29-
self.perform(
30-
Command::new("rustfmt")
31-
.args(["--edition", "2021"])
32-
.arg(file.unwrap()),
33-
);
27+
self.perform(Command::new("rustfmt").args(["--edition", "2021"]).arg(file.unwrap()));
3428
}
3529
for file in glob("tests/**/*.rs").unwrap() {
36-
self.perform(
37-
Command::new("rustfmt")
38-
.args(["--edition", "2021"])
39-
.arg(file.unwrap()),
40-
);
30+
self.perform(Command::new("rustfmt").args(["--edition", "2021"]).arg(file.unwrap()));
4131
}
4232
}
4333
}
@@ -48,10 +38,6 @@ impl FmtCommand {
4838
command.arg("--check");
4939
}
5040
log::debug!("running {:?}", command);
51-
assert!(
52-
command.status().unwrap().success(),
53-
"failed to run {:?}",
54-
command
55-
);
41+
assert!(command.status().unwrap().success(), "failed to run {:?}", command);
5642
}
5743
}

bootstrap/src/manifest.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ impl Manifest {
1414
pub fn prepare(&self) {
1515
cprintln!("<b>[BUILD]</b> codegen backend");
1616
let mut command = Command::new("cargo");
17-
command
18-
.arg("build")
19-
.args(["--manifest-path", "crates/Cargo.toml"]);
17+
command.arg("build").args(["--manifest-path", "crates/Cargo.toml"]);
2018
if self.verbose {
2119
command.args(["-F", "debug"]);
2220
}
@@ -61,10 +59,7 @@ impl Manifest {
6159
command
6260
.args(["--edition", "2021"])
6361
.arg("-Z")
64-
.arg(format!(
65-
"codegen-backend={}",
66-
self.codegen_backend().display()
67-
))
62+
.arg(format!("codegen-backend={}", self.codegen_backend().display()))
6863
.args(["-C", "panic=abort"])
6964
.args(["-C", "lto=false"])
7065
.arg(format!("-Lall={}", self.out_dir.display()))

bootstrap/src/rustc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use std::path::PathBuf;
22

33
use clap::Args;
44

5-
use crate::{manifest::Manifest, Run};
5+
use crate::manifest::Manifest;
6+
use crate::Run;
67

78
/// Invoke rustc
89
#[derive(Args, Debug)]

bootstrap/src/test.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use color_print::{cprint, cprintln};
77
use glob::glob;
88
use which::which;
99

10-
use crate::{manifest::Manifest, Run};
10+
use crate::manifest::Manifest;
11+
use crate::Run;
1112

1213
/// Run tests
1314
#[derive(Args, Debug)]
@@ -55,12 +56,7 @@ impl TestCommand {
5556
}
5657
let name = format!("example/{}", filename.to_string_lossy());
5758
let output = manifest.out_dir.join("example").join(filename);
58-
result.push(TestCase {
59-
name,
60-
source: case,
61-
output,
62-
test: TestType::Compile,
63-
})
59+
result.push(TestCase { name, source: case, output, test: TestType::Compile })
6460
}
6561

6662
// Codegen tests
@@ -69,12 +65,7 @@ impl TestCommand {
6965
let filename = case.file_stem().unwrap();
7066
let name = format!("codegen/{}", filename.to_string_lossy());
7167
let output = manifest.out_dir.join("tests/codegen").join(filename);
72-
result.push(TestCase {
73-
name,
74-
source: case,
75-
output,
76-
test: TestType::FileCheck,
77-
})
68+
result.push(TestCase { name, source: case, output, test: TestType::FileCheck })
7869
}
7970

8071
result
@@ -140,10 +131,7 @@ impl FileChecker {
140131
filename.ends_with(".c") && filename.starts_with(case.as_ref())
141132
});
142133

143-
assert!(
144-
generated.is_some(),
145-
"could not find {case}'s generated file"
146-
);
134+
assert!(generated.is_some(), "could not find {case}'s generated file");
147135
let generated = generated.unwrap();
148136

149137
let generated = File::open(generated.path()).unwrap();

crates/rustc_codegen_c/src/lib.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,8 @@ impl CodegenBackend for CCodegen {
6666
}
6767
.to_owned();
6868

69-
let ongoing_codegen = codegen_crate(
70-
self.clone(),
71-
tcx,
72-
target_cpu,
73-
metadata,
74-
need_metadata_module,
75-
);
69+
let ongoing_codegen =
70+
codegen_crate(self.clone(), tcx, target_cpu, metadata, need_metadata_module);
7671
Box::new(ongoing_codegen)
7772
}
7873

@@ -82,10 +77,7 @@ impl CodegenBackend for CCodegen {
8277
sess: &Session,
8378
_outputs: &OutputFilenames,
8479
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
85-
ongoing_codegen
86-
.downcast::<OngoingCodegen<Self>>()
87-
.expect("expected CCodegen")
88-
.join(sess)
80+
ongoing_codegen.downcast::<OngoingCodegen<Self>>().expect("expected CCodegen").join(sess)
8981
}
9082

9183
fn link(
@@ -94,12 +86,7 @@ impl CodegenBackend for CCodegen {
9486
codegen_results: CodegenResults,
9587
outputs: &OutputFilenames,
9688
) -> Result<(), ErrorGuaranteed> {
97-
link_binary(
98-
sess,
99-
&crate::archive::ArArchiveBuilderBuilder,
100-
&codegen_results,
101-
outputs,
102-
)
89+
link_binary(sess, &crate::archive::ArArchiveBuilderBuilder, &codegen_results, outputs)
10390
}
10491
}
10592

0 commit comments

Comments
 (0)