mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-19 01:50:32 +00:00
Inline all format arguments where possible
This makes code more readale and concise, moving all format arguments like `format!("{}", foo)` into the more compact `format!("{foo}")` form. The change was automatically created with, so there are far less change of an accidental typo. ``` cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args ```
This commit is contained in:
parent
1927c2e1d8
commit
e16c76e3c3
180 changed files with 487 additions and 501 deletions
|
@ -83,7 +83,7 @@ impl Round {
|
|||
|
||||
let a = mean_y - b * mean_x;
|
||||
|
||||
self.plot = format!("y_pred = {:.3} + {:.3} * x\n\nx y y_pred\n", a, b);
|
||||
self.plot = format!("y_pred = {a:.3} + {b:.3} * x\n\nx y y_pred\n");
|
||||
|
||||
let mut se = 0.0;
|
||||
let mut max_error = 0.0f64;
|
||||
|
|
|
@ -153,7 +153,7 @@ impl Fixture {
|
|||
&& !line.contains('.')
|
||||
&& line.chars().all(|it| !it.is_uppercase())
|
||||
{
|
||||
panic!("looks like invalid metadata line: {:?}", line);
|
||||
panic!("looks like invalid metadata line: {line:?}");
|
||||
}
|
||||
|
||||
if let Some(entry) = res.last_mut() {
|
||||
|
@ -172,7 +172,7 @@ impl Fixture {
|
|||
let components = meta.split_ascii_whitespace().collect::<Vec<_>>();
|
||||
|
||||
let path = components[0].to_string();
|
||||
assert!(path.starts_with('/'), "fixture path does not start with `/`: {:?}", path);
|
||||
assert!(path.starts_with('/'), "fixture path does not start with `/`: {path:?}");
|
||||
|
||||
let mut krate = None;
|
||||
let mut deps = Vec::new();
|
||||
|
@ -184,9 +184,8 @@ impl Fixture {
|
|||
let mut introduce_new_source_root = None;
|
||||
let mut target_data_layout = None;
|
||||
for component in components[1..].iter() {
|
||||
let (key, value) = component
|
||||
.split_once(':')
|
||||
.unwrap_or_else(|| panic!("invalid meta line: {:?}", meta));
|
||||
let (key, value) =
|
||||
component.split_once(':').unwrap_or_else(|| panic!("invalid meta line: {meta:?}"));
|
||||
match key {
|
||||
"crate" => krate = Some(value.to_string()),
|
||||
"deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
|
||||
|
@ -216,7 +215,7 @@ impl Fixture {
|
|||
}
|
||||
"new_source_root" => introduce_new_source_root = Some(value.to_string()),
|
||||
"target_data_layout" => target_data_layout = Some(value.to_string()),
|
||||
_ => panic!("bad component: {:?}", component),
|
||||
_ => panic!("bad component: {component:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +252,7 @@ impl MiniCore {
|
|||
#[track_caller]
|
||||
fn assert_valid_flag(&self, flag: &str) {
|
||||
if !self.valid_flags.iter().any(|it| it == flag) {
|
||||
panic!("invalid flag: {:?}, valid flags: {:?}", flag, self.valid_flags);
|
||||
panic!("invalid flag: {flag:?}, valid flags: {:?}", self.valid_flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +262,7 @@ impl MiniCore {
|
|||
let line = line.strip_prefix("//- minicore:").unwrap().trim();
|
||||
for entry in line.split(", ") {
|
||||
if res.has_flag(entry) {
|
||||
panic!("duplicate minicore flag: {:?}", entry);
|
||||
panic!("duplicate minicore flag: {entry:?}");
|
||||
}
|
||||
res.activated_flags.push(entry.to_owned());
|
||||
}
|
||||
|
@ -369,7 +368,7 @@ impl MiniCore {
|
|||
|
||||
for flag in &self.valid_flags {
|
||||
if !seen_regions.iter().any(|it| it == flag) {
|
||||
panic!("unused minicore flag: {:?}", flag);
|
||||
panic!("unused minicore flag: {flag:?}");
|
||||
}
|
||||
}
|
||||
buf
|
||||
|
|
|
@ -146,8 +146,8 @@ pub fn extract_range_or_offset(text: &str) -> (RangeOrOffset, String) {
|
|||
|
||||
/// Extracts ranges, marked with `<tag> </tag>` pairs from the `text`
|
||||
pub fn extract_tags(mut text: &str, tag: &str) -> (Vec<(TextRange, Option<String>)>, String) {
|
||||
let open = format!("<{}", tag);
|
||||
let close = format!("</{}>", tag);
|
||||
let open = format!("<{tag}");
|
||||
let close = format!("</{tag}>");
|
||||
let mut ranges = Vec::new();
|
||||
let mut res = String::new();
|
||||
let mut stack = Vec::new();
|
||||
|
@ -169,8 +169,7 @@ pub fn extract_tags(mut text: &str, tag: &str) -> (Vec<(TextRange, Option<String
|
|||
stack.push((from, attr));
|
||||
} else if text.starts_with(&close) {
|
||||
text = &text[close.len()..];
|
||||
let (from, attr) =
|
||||
stack.pop().unwrap_or_else(|| panic!("unmatched </{}>", tag));
|
||||
let (from, attr) = stack.pop().unwrap_or_else(|| panic!("unmatched </{tag}>"));
|
||||
let to = TextSize::of(&res);
|
||||
ranges.push((TextRange::new(from, to), attr));
|
||||
} else {
|
||||
|
@ -180,7 +179,7 @@ pub fn extract_tags(mut text: &str, tag: &str) -> (Vec<(TextRange, Option<String
|
|||
}
|
||||
}
|
||||
}
|
||||
assert!(stack.is_empty(), "unmatched <{}>", tag);
|
||||
assert!(stack.is_empty(), "unmatched <{tag}>");
|
||||
ranges.sort_by_key(|r| (r.0.start(), r.0.end()));
|
||||
(ranges, res)
|
||||
}
|
||||
|
@ -413,8 +412,8 @@ pub fn format_diff(chunks: Vec<dissimilar::Chunk<'_>>) -> String {
|
|||
for chunk in chunks {
|
||||
let formatted = match chunk {
|
||||
dissimilar::Chunk::Equal(text) => text.into(),
|
||||
dissimilar::Chunk::Delete(text) => format!("\x1b[41m{}\x1b[0m", text),
|
||||
dissimilar::Chunk::Insert(text) => format!("\x1b[42m{}\x1b[0m", text),
|
||||
dissimilar::Chunk::Delete(text) => format!("\x1b[41m{text}\x1b[0m"),
|
||||
dissimilar::Chunk::Insert(text) => format!("\x1b[42m{text}\x1b[0m"),
|
||||
};
|
||||
buf.push_str(&formatted);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue