Skip to content

Commit

Permalink
--fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Mar 3, 2023
1 parent 9c54c84 commit ba66a0d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion crates/swc/benches/minify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn files_group(c: &mut Criterion) {

let mut bench_file = |name: &str| {
group.bench_function(name, |b| {
bench_minify(b, &format!("{}.js", name));
bench_minify(b, &format!("{name}.js"));
});
};

Expand Down
10 changes: 5 additions & 5 deletions crates/swc/tests/error_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ fn file(f: impl AsRef<Path>) -> NormalizedOutput {
},
);
if let Err(e) = s {
return Ok(format!("{:?}", e).into());
return Ok(format!("{e:?}").into());
}

panic!("invalid swcrc should abort build, but got {:?}", s);
panic!("invalid swcrc should abort build, but got {s:?}");
})
.unwrap()
}

#[test]
fn swcrc_simple() {
let f = file("tests/swcrc_errors/simple/foo.js");
println!("{}", f);
println!("{f}");
}

#[testing::fixture("tests/errors/**/input.js")]
Expand Down Expand Up @@ -78,7 +78,7 @@ fn fixture(input: PathBuf) {
.expect_err("should fail")
});

let output = NormalizedOutput::from(format!("{}", err));
let output = NormalizedOutput::from(format!("{err}"));

output.compare_to_file(&output_path).unwrap();
output.compare_to_file(output_path).unwrap();
}
15 changes: 6 additions & 9 deletions crates/swc/tests/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn issue_706() {

#[testing::fixture("tests/fixture/**/*.map")]
fn validate_map(map_file: PathBuf) {
let content = fs::read_to_string(&map_file).unwrap();
let content = fs::read_to_string(map_file).unwrap();
if content.is_empty() {
return;
}
Expand Down Expand Up @@ -219,7 +219,7 @@ fn extract_node_stack_trace(output: Output) -> NormalizedOutput {

let stderr = String::from_utf8_lossy(&output.stderr);

eprintln!("\n\n\nStderr: {}\n\n\n", stderr);
eprintln!("\n\n\nStderr: {stderr}\n\n\n");
//
let stacks = stderr
.lines()
Expand Down Expand Up @@ -297,10 +297,7 @@ fn issue_4112() {
if source_count == 1 {
return Ok(());
}
panic!(
"Validation failed, should has 1 source, but {}",
source_count
);
panic!("Validation failed, should has 1 source, but {source_count}");
})
.unwrap()
}
Expand Down Expand Up @@ -370,7 +367,7 @@ fn should_work_with_emit_source_map_columns() {
assert_eq!(token.get_src_col(), 11);
}
Err(err) => {
panic!("Error: {:#?}", err);
panic!("Error: {err:#?}");
}
}

Expand Down Expand Up @@ -404,7 +401,7 @@ fn should_work_with_emit_source_map_columns() {
assert_eq!(token.get_src_col(), 2);
}
Err(err) => {
panic!("Error: {:#?}", err);
panic!("Error: {err:#?}");
}
}

Expand Down Expand Up @@ -499,7 +496,7 @@ export const fixupRiskConfigData = (data: any): types.RiskConfigType => {
assert_eq!(token.get_src(), (6, 2));
}
Err(err) => {
panic!("Error: {:#?}", err);
panic!("Error: {err:#?}");
}
}

Expand Down
5 changes: 1 addition & 4 deletions crates/swc_ecma_codegen/tests/test262.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ fn do_test(entry: &Path, minify: bool) {

let ref_dir = ref_dir;

let msg = format!(
"\n\n========== Running codegen test {}\nSource:\n{}\n",
file_name, input
);
let msg = format!("\n\n========== Running codegen test {file_name}\nSource:\n{input}\n");
let mut wr = Buf(Arc::new(RwLock::new(vec![])));

::testing::run_test(false, |cm, handler| {
Expand Down
20 changes: 10 additions & 10 deletions crates/swc_ecma_minifier/tests/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ fn custom_fixture(input: PathBuf) {

testing::run_test2(false, |cm, handler| {
let mangle = dir.join("mangle.json");
let mangle = read_to_string(&mangle).ok();
let mangle = read_to_string(mangle).ok();
if let Some(mangle) = &mangle {
eprintln!(
"---- {} -----\n{}",
Expand Down Expand Up @@ -336,7 +336,7 @@ fn custom_fixture(input: PathBuf) {
fn projects(input: PathBuf) {
let dir = input.parent().unwrap();
let config = dir.join("config.json");
let config = read_to_string(&config).expect("failed to read config.json");
let config = read_to_string(config).expect("failed to read config.json");
eprintln!("---- {} -----\n{}", Color::Green.paint("Config"), config);

testing::run_test2(false, |cm, handler| {
Expand Down Expand Up @@ -443,12 +443,12 @@ fn fixture(input: PathBuf) {

let dir = input.parent().unwrap();
let config = dir.join("config.json");
let config = read_to_string(&config).expect("failed to read config.json");
let config = read_to_string(config).expect("failed to read config.json");
eprintln!("---- {} -----\n{}", Color::Green.paint("Config"), config);

testing::run_test2(false, |cm, handler| {
let mangle = dir.join("mangle.json");
let mangle = read_to_string(&mangle).ok();
let mangle = read_to_string(mangle).ok();
if let Some(mangle) = &mangle {
eprintln!(
"---- {} -----\n{}",
Expand All @@ -470,7 +470,7 @@ fn fixture(input: PathBuf) {
eprintln!("---- {} -----\n{}", Color::Green.paint("Output"), output);

let expected = {
let expected = read_to_string(&dir.join("output.js")).unwrap();
let expected = read_to_string(dir.join("output.js")).unwrap();
let fm = cm.new_source_file(FileName::Anon, expected);
let lexer = Lexer::new(
Default::default(),
Expand Down Expand Up @@ -512,7 +512,7 @@ fn fixture(input: PathBuf) {
// Check output.teraer.js
let identical = (|| -> Option<()> {
let expected = {
let expected = read_to_string(&dir.join("output.terser.js")).ok()?;
let expected = read_to_string(dir.join("output.terser.js")).ok()?;
let fm = cm.new_source_file(FileName::Anon, expected);
let lexer = Lexer::new(
Default::default(),
Expand Down Expand Up @@ -562,9 +562,9 @@ fn fixture(input: PathBuf) {
})()
.is_some();
if identical {
let s = read_to_string(&dir.join("output.terser.js"))
let s = read_to_string(dir.join("output.terser.js"))
.expect("failed to read output.terser.js");
std::fs::write(&dir.join("output.js"), s.as_bytes())
std::fs::write(dir.join("output.js"), s.as_bytes())
.expect("failed to update output.js");
}
}
Expand Down Expand Up @@ -662,7 +662,7 @@ impl Shower<'_> {
if span.is_dummy() {
let src = print(self.cm.clone(), &[node], false, false);
self.handler
.struct_span_warn(span, &format!("{}: {}", name, src))
.struct_span_warn(span, &format!("{name}: {src}"))
.emit();
} else {
self.handler.struct_span_warn(span, name).emit();
Expand All @@ -677,7 +677,7 @@ impl Shower<'_> {

if span.is_dummy() {
self.handler
.struct_span_warn(span, &format!("{:?}", node))
.struct_span_warn(span, &format!("{node:?}"))
.emit();
} else {
self.handler.struct_span_warn(span, name).emit();
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_node_bundler/src/loaders/swc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl SwcLoader {
FileName::Real(v) => v,
_ => bail!("swc-loader only accepts path. Got `{}`", name),
})
.with_context(|| format!("failed to load file `{}`", name))?;
.with_context(|| format!("failed to load file `{name}`"))?;

if let FileName::Real(path) = name {
if let Some(ext) = path.extension() {
Expand Down

0 comments on commit ba66a0d

Please sign in to comment.