Skip to content

Commit bc84a17

Browse files
bicarlsenctron
authored andcommitted
Clean up lint errors.
1 parent 4db9b6d commit bc84a17

File tree

10 files changed

+33
-37
lines changed

10 files changed

+33
-37
lines changed

src/cmd/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Config {
2828
match self.command {
2929
Command::Show => {
3030
let (cfg, _working_directory) = config::load(config).await?;
31-
println!("{:#?}", cfg);
31+
println!("{cfg:#?}");
3232
}
3333
Command::GenerateSchema { output } => {
3434
let schema = schemars::schema_for!(Configuration);

src/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub fn check_target_not_found_err(err: anyhow::Error, target: &str) -> anyhow::E
207207
None => return err,
208208
};
209209
match io_err.kind() {
210-
std::io::ErrorKind::NotFound => err.context(format!("'{}' not found", target)),
210+
std::io::ErrorKind::NotFound => err.context(format!("'{target}' not found")),
211211
_ => err,
212212
}
213213
}

src/hooks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ pub fn spawn_hooks(cfg: Arc<RtcBuild>, stage: PipelineStage) -> HookHandles {
3535
tokio::spawn(async move {
3636
let status = command
3737
.spawn()
38-
.with_context(|| format!("error spawning hook call for {}", command_name))?
38+
.with_context(|| format!("error spawning hook call for {command_name}"))?
3939
.wait()
4040
.await
41-
.with_context(|| format!("error calling hook to {}", command_name))?;
41+
.with_context(|| format!("error calling hook to {command_name}"))?;
4242
if !status.success() {
43-
bail!("hook call to {} returned a bad status", command_name);
43+
bail!("hook call to {command_name} returned a bad status");
4444
}
45-
tracing::info!("finished hook {}", command_name);
45+
tracing::info!("finished hook {command_name}");
4646
Ok(())
4747
})
4848
})

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn init_color(cli: &Trunk) -> bool {
7878
#[cfg(windows)]
7979
if colored {
8080
if let Err(err) = nu_ansi_term::enable_ansi_support() {
81-
eprintln!("error enabling ANSI support: {:?}", err);
81+
eprintln!("error enabling ANSI support: {err:?}");
8282
}
8383
}
8484

src/pipelines/html.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,11 @@ impl HtmlPipeline {
250250
/// Prepare the document for final output.
251251
fn finalize_html(&self, target_html: &mut Document) -> Result<()> {
252252
// Write public_url to base element.
253-
target_html.select_mut(
254-
&format!("html head base[{}]", PUBLIC_URL_MARKER_ATTR),
255-
|el| {
256-
el.remove_attribute(PUBLIC_URL_MARKER_ATTR);
257-
el.set_attribute("href", &self.cfg.public_url)?;
258-
Ok(())
259-
},
260-
)?;
253+
target_html.select_mut(&format!("html head base[{PUBLIC_URL_MARKER_ATTR}]"), |el| {
254+
el.remove_attribute(PUBLIC_URL_MARKER_ATTR);
255+
el.set_attribute("href", &self.cfg.public_url)?;
256+
Ok(())
257+
})?;
261258

262259
// Inject the WebSocket autoloader.
263260
if self.cfg.inject_autoloader {

src/pipelines/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,12 @@ pub enum PipelineStage {
371371

372372
/// Create the CSS selector for selecting a trunk link by ID.
373373
fn trunk_id_selector(id: usize) -> String {
374-
format!(r#"link[{}="{}"]"#, TRUNK_ID, id)
374+
format!(r#"link[{TRUNK_ID}="{id}"]"#)
375375
}
376376

377377
/// Create the CSS selector for selecting a trunk script by ID.
378378
fn trunk_script_id_selector(id: usize) -> String {
379-
format!(r#"script[{}="{}"]"#, TRUNK_ID, id)
379+
format!(r#"script[{TRUNK_ID}="{id}"]"#)
380380
}
381381

382382
/// A Display impl that writes out a hashmap of attributes into an html tag.
@@ -448,7 +448,7 @@ impl fmt::Display for AttrWriter<'_> {
448448
if !attr.is_empty() {
449449
if attr.need_escape {
450450
let encoded = htmlescape::encode_attribute(attr);
451-
write!(f, "=\"{}\"", encoded)?;
451+
write!(f, "=\"{encoded}\"")?;
452452
} else {
453453
write!(f, "=\"{}\"", attr.value)?;
454454
}

src/pipelines/rust/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl RustApp {
216216
Some(cargo_profile) => {
217217
let cargo_profile = &cargo_profile.value;
218218
if let Some(config_cargo_profile) = &cfg.cargo_profile {
219-
log::warn!("Cargo profile from configuration ({config_cargo_profile}) will be overridden with HTML file's more specific setting ({})", cargo_profile);
219+
log::warn!("Cargo profile from configuration ({config_cargo_profile}) will be overridden with HTML file's more specific setting ({cargo_profile})");
220220
}
221221
Some(cargo_profile.clone())
222222
}
@@ -563,7 +563,7 @@ impl RustApp {
563563
.context("error creating wasm-bindgen output dir")?;
564564

565565
// Build up args for calling wasm-bindgen.
566-
let arg_out_path = format!("--out-dir={}", bindgen_out);
566+
let arg_out_path = format!("--out-dir={bindgen_out}");
567567
let arg_out_name = format!("--out-name={}", &self.name);
568568
let target_wasm = wasm_path.to_string_lossy().to_string();
569569
let target_type = format!("--target={}", self.wasm_bindgen_target);
@@ -607,21 +607,20 @@ impl RustApp {
607607
apply_data_target_path(format!("{hashed_name}_bg.wasm"), &self.target_path);
608608

609609
let js_name = format!("{}.js", self.name);
610-
let hashed_js_name =
611-
apply_data_target_path(format!("{}.js", hashed_name), &self.target_path);
610+
let hashed_js_name = apply_data_target_path(format!("{hashed_name}.js"), &self.target_path);
612611
let ts_name = format!("{}.d.ts", self.name);
613612
let hashed_ts_name =
614-
apply_data_target_path(format!("{}.d.ts", hashed_name), &self.target_path);
613+
apply_data_target_path(format!("{hashed_name}.d.ts"), &self.target_path);
615614

616615
let js_loader_path = bindgen_out.join(&js_name);
617616
let js_loader_path_dist = self.cfg.staging_dist.join(&hashed_js_name);
618617
let wasm_name = format!("{}_bg.wasm", self.name);
619618
let wasm_path = bindgen_out.join(&wasm_name);
620619
let wasm_path_dist = self.cfg.staging_dist.join(&hashed_wasm_name);
621620

622-
let hashed_loader_name = self.loader_shim.then(|| {
623-
apply_data_target_path(format!("{}_loader.js", hashed_name), &self.target_path)
624-
});
621+
let hashed_loader_name = self
622+
.loader_shim
623+
.then(|| apply_data_target_path(format!("{hashed_name}_loader.js"), &self.target_path));
625624
let loader_shim_path = hashed_loader_name
626625
.as_ref()
627626
.map(|m| self.cfg.staging_dist.join(m));

src/proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ mod tests {
569569
have_outbound_req
570570
.headers()
571571
.get(key.clone())
572-
.unwrap_or_else(|| panic!("Expected header value for {}", key)),
572+
.unwrap_or_else(|| panic!("Expected header value for {key}")),
573573
&HeaderValue::from_static("localhost")
574574
);
575575
continue;

src/serve/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ fn router(state: Arc<State>, cfg: Arc<RtcServe>) -> Result<Router> {
396396
};
397397
for (key, value) in &state.headers {
398398
let name = HeaderName::from_bytes(key.as_bytes())
399-
.with_context(|| format!("invalid header {:?}", key))?;
399+
.with_context(|| format!("invalid header {key:?}"))?;
400400
let value: HeaderValue = value
401401
.parse()
402-
.with_context(|| format!("invalid header value {:?} for header {}", value, name))?;
402+
.with_context(|| format!("invalid header value {value:?} for header {name}"))?;
403403
serve_dir = serve_dir.layer(SetResponseHeaderLayer::overriding(name, value))
404404
}
405405

@@ -446,10 +446,10 @@ fn router(state: Arc<State>, cfg: Arc<RtcServe>) -> Result<Router> {
446446
let mut request_headers = HeaderMap::new();
447447
for (key, value) in &proxy.request_headers {
448448
let name = HeaderName::from_bytes(key.as_bytes())
449-
.with_context(|| format!("invalid header {:?}", key))?;
449+
.with_context(|| format!("invalid header {key:?}"))?;
450450
let value: HeaderValue = value
451451
.parse()
452-
.with_context(|| format!("invalid header value {:?} for header {}", value, name))?;
452+
.with_context(|| format!("invalid header value {value:?} for header {name}"))?;
453453
request_headers.insert(name, value);
454454
}
455455

@@ -524,7 +524,7 @@ async fn html_address_middleware(
524524

525525
// turn into a string literal, or replace with "current host" on the client side
526526
let host = host
527-
.and_then(|uri| uri.to_str().map(|s| format!("'{}'", s)).ok())
527+
.and_then(|uri| uri.to_str().map(|s| format!("'{s}'")).ok())
528528
.unwrap_or_else(|| "window.location.host".into());
529529

530530
let mut data_str = data_str

src/tools.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,26 +191,26 @@ impl Application {
191191
Application::Sass => text
192192
.split_whitespace()
193193
.next()
194-
.with_context(|| format!("missing or malformed version output: {}", text))?
194+
.with_context(|| format!("missing or malformed version output: {text}"))?
195195
.to_owned(),
196196
Application::TailwindCss | Application::TailwindCssExtra => {
197197
let caps = regex_tailwind
198198
.captures(text)
199-
.with_context(|| format!("missing or malformed version output: {}", text))?;
199+
.with_context(|| format!("missing or malformed version output: {text}"))?;
200200
caps.get(1)
201201
.map(|m| m.as_str().to_owned())
202-
.with_context(|| format!("missing capture group in version output: {}", text))?
202+
.with_context(|| format!("missing capture group in version output: {text}"))?
203203
}
204204
Application::WasmBindgen => text
205205
.split(' ')
206206
.nth(1)
207-
.with_context(|| format!("missing or malformed version output: {}", text))?
207+
.with_context(|| format!("missing or malformed version output: {text}"))?
208208
.to_owned(),
209209
Application::WasmOpt => format!(
210210
"version_{}",
211211
text.split(' ')
212212
.nth(2)
213-
.with_context(|| format!("missing or malformed version output: {}", text))?
213+
.with_context(|| format!("missing or malformed version output: {text}"))?
214214
),
215215
};
216216
Ok(formatted_version)

0 commit comments

Comments
 (0)