Skip to content

chore: update format #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use_small_heuristics = "Max"
imports_granularity = "Module"
3 changes: 2 additions & 1 deletion bootstrap/src/clean.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::Args;

use crate::{manifest::Manifest, Run};
use crate::manifest::Manifest;
use crate::Run;

/// Clean the build directory
#[derive(Args, Debug)]
Expand Down
22 changes: 4 additions & 18 deletions bootstrap/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ pub struct FmtCommand {
impl Run for FmtCommand {
fn run(&self, _manifest: &crate::manifest::Manifest) {
self.perform(
Command::new("cargo")
.arg("fmt")
.args(["--manifest-path", "bootstrap/Cargo.toml"]),
Command::new("cargo").arg("fmt").args(["--manifest-path", "bootstrap/Cargo.toml"]),
);
self.perform(
Command::new("cargo")
Expand All @@ -26,18 +24,10 @@ impl Run for FmtCommand {
.arg("--all"),
);
for file in glob("example/**/*.rs").unwrap() {
self.perform(
Command::new("rustfmt")
.args(["--edition", "2021"])
.arg(file.unwrap()),
);
self.perform(Command::new("rustfmt").args(["--edition", "2021"]).arg(file.unwrap()));
}
for file in glob("tests/**/*.rs").unwrap() {
self.perform(
Command::new("rustfmt")
.args(["--edition", "2021"])
.arg(file.unwrap()),
);
self.perform(Command::new("rustfmt").args(["--edition", "2021"]).arg(file.unwrap()));
}
}
}
Expand All @@ -48,10 +38,6 @@ impl FmtCommand {
command.arg("--check");
}
log::debug!("running {:?}", command);
assert!(
command.status().unwrap().success(),
"failed to run {:?}",
command
);
assert!(command.status().unwrap().success(), "failed to run {:?}", command);
}
}
9 changes: 2 additions & 7 deletions bootstrap/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ impl Manifest {
pub fn prepare(&self) {
cprintln!("<b>[BUILD]</b> codegen backend");
let mut command = Command::new("cargo");
command
.arg("build")
.args(["--manifest-path", "crates/Cargo.toml"]);
command.arg("build").args(["--manifest-path", "crates/Cargo.toml"]);
if self.verbose {
command.args(["-F", "debug"]);
}
Expand Down Expand Up @@ -61,10 +59,7 @@ impl Manifest {
command
.args(["--edition", "2021"])
.arg("-Z")
.arg(format!(
"codegen-backend={}",
self.codegen_backend().display()
))
.arg(format!("codegen-backend={}", self.codegen_backend().display()))
.args(["-C", "panic=abort"])
.args(["-C", "lto=false"])
.arg(format!("-Lall={}", self.out_dir.display()))
Expand Down
3 changes: 2 additions & 1 deletion bootstrap/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::path::PathBuf;

use clap::Args;

use crate::{manifest::Manifest, Run};
use crate::manifest::Manifest;
use crate::Run;

/// Invoke rustc
#[derive(Args, Debug)]
Expand Down
22 changes: 5 additions & 17 deletions bootstrap/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use color_print::{cprint, cprintln};
use glob::glob;
use which::which;

use crate::{manifest::Manifest, Run};
use crate::manifest::Manifest;
use crate::Run;

/// Run tests
#[derive(Args, Debug)]
Expand Down Expand Up @@ -55,12 +56,7 @@ impl TestCommand {
}
let name = format!("example/{}", filename.to_string_lossy());
let output = manifest.out_dir.join("example").join(filename);
result.push(TestCase {
name,
source: case,
output,
test: TestType::Compile,
})
result.push(TestCase { name, source: case, output, test: TestType::Compile })
}

// Codegen tests
Expand All @@ -69,12 +65,7 @@ impl TestCommand {
let filename = case.file_stem().unwrap();
let name = format!("codegen/{}", filename.to_string_lossy());
let output = manifest.out_dir.join("tests/codegen").join(filename);
result.push(TestCase {
name,
source: case,
output,
test: TestType::FileCheck,
})
result.push(TestCase { name, source: case, output, test: TestType::FileCheck })
}

result
Expand Down Expand Up @@ -140,10 +131,7 @@ impl FileChecker {
filename.ends_with(".c") && filename.starts_with(case.as_ref())
});

assert!(
generated.is_some(),
"could not find {case}'s generated file"
);
assert!(generated.is_some(), "could not find {case}'s generated file");
let generated = generated.unwrap();

let generated = File::open(generated.path()).unwrap();
Expand Down
21 changes: 4 additions & 17 deletions crates/rustc_codegen_c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,8 @@ impl CodegenBackend for CCodegen {
}
.to_owned();

let ongoing_codegen = codegen_crate(
self.clone(),
tcx,
target_cpu,
metadata,
need_metadata_module,
);
let ongoing_codegen =
codegen_crate(self.clone(), tcx, target_cpu, metadata, need_metadata_module);
Box::new(ongoing_codegen)
}

Expand All @@ -82,10 +77,7 @@ impl CodegenBackend for CCodegen {
sess: &Session,
_outputs: &OutputFilenames,
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
ongoing_codegen
.downcast::<OngoingCodegen<Self>>()
.expect("expected CCodegen")
.join(sess)
ongoing_codegen.downcast::<OngoingCodegen<Self>>().expect("expected CCodegen").join(sess)
}

fn link(
Expand All @@ -94,12 +86,7 @@ impl CodegenBackend for CCodegen {
codegen_results: CodegenResults,
outputs: &OutputFilenames,
) -> Result<(), ErrorGuaranteed> {
link_binary(
sess,
&crate::archive::ArArchiveBuilderBuilder,
&codegen_results,
outputs,
)
link_binary(sess, &crate::archive::ArArchiveBuilderBuilder, &codegen_results, outputs)
}
}

Expand Down