diff --git a/crates/biome_analyze/src/rule.rs b/crates/biome_analyze/src/rule.rs index f7f1f4ea12fb..9983c8211218 100644 --- a/crates/biome_analyze/src/rule.rs +++ b/crates/biome_analyze/src/rule.rs @@ -704,7 +704,7 @@ pub trait Rule: RuleMeta + Sized { ::NAME, Self::METADATA.name ); - let suppression_text = format!("biome-ignore {}", rule_category); + let suppression_text = format!("biome-ignore {rule_category}"); let root = ctx.root(); let token = root.syntax().token_at_offset(text_range.start()); let mut mutation = root.begin(); diff --git a/crates/biome_cli/src/execute/migrate/ignorefile.rs b/crates/biome_cli/src/execute/migrate/ignorefile.rs index 54943a47a21d..8262bb5fa00e 100644 --- a/crates/biome_cli/src/execute/migrate/ignorefile.rs +++ b/crates/biome_cli/src/execute/migrate/ignorefile.rs @@ -60,7 +60,7 @@ pub(crate) fn convert_pattern(line: &str) -> Result { } let result = if let Some(stripped_line) = line.strip_prefix('/') { // Patterns tha tstarts with `/` are relative to the ignore file - format!("./{}", stripped_line) + format!("./{stripped_line}") } else if line.find('/').is_some_and(|index| index < (line.len() - 1)) || line == "**" || line == "**/" diff --git a/crates/biome_cli/tests/snap_test.rs b/crates/biome_cli/tests/snap_test.rs index 198ead5a07e2..7791f075521d 100644 --- a/crates/biome_cli/tests/snap_test.rs +++ b/crates/biome_cli/tests/snap_test.rs @@ -92,7 +92,7 @@ impl CliSnapshot { let redacted_content = redact_snapshot(file_content).unwrap_or(String::new().into()); - let _ = write!(content, "## `{}`\n\n", redacted_name); + let _ = write!(content, "## `{redacted_name}`\n\n"); let _ = write!(content, "```{extension}"); content.push('\n'); content.push_str(&redacted_content); diff --git a/crates/biome_configuration/src/editorconfig.rs b/crates/biome_configuration/src/editorconfig.rs index 68d01bc73e29..ad1cf781cfde 100644 --- a/crates/biome_configuration/src/editorconfig.rs +++ b/crates/biome_configuration/src/editorconfig.rs @@ -217,13 +217,13 @@ fn expand_unknown_glob_patterns(pattern: &str) -> Result, EditorConf let start = start.parse().map_err(|err| { EditorConfigDiagnostic::invalid_glob_pattern( s, - format!("Error parsing the start of the range: {}", err), + format!("Error parsing the start of the range: {err}"), ) })?; let end = end.parse().map_err(|err| { EditorConfigDiagnostic::invalid_glob_pattern( s, - format!("Error parsing the end of the range: {}", err), + format!("Error parsing the end of the range: {err}"), ) })?; self.variants = Some(VariantType::Range((start, end))); diff --git a/crates/biome_css_analyze/tests/spec_tests.rs b/crates/biome_css_analyze/tests/spec_tests.rs index 9abc07724c5f..7c39514b9f30 100644 --- a/crates/biome_css_analyze/tests/spec_tests.rs +++ b/crates/biome_css_analyze/tests/spec_tests.rs @@ -44,7 +44,7 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) { let extension = input_file.extension().unwrap_or_default(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let quantity_diagnostics = if let Some(scripts) = scripts_from_json(extension, &input_code) { for script in scripts { analyze_and_snap( @@ -184,10 +184,7 @@ fn check_code_action( assert_eq!(new_tree.to_string(), output); if has_bogus_nodes_or_empty_slots(&new_tree) { - panic!( - "modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {}", - new_tree - ) + panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}") } // Checks the returned tree contains no missing children node @@ -206,7 +203,7 @@ pub(crate) fn _run_suppression_test(input: &'static str, _: &str, _: &str, _: &s let input_file = Path::new(input); let file_name = input_file.file_name().and_then(OsStr::to_str).unwrap(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let (group, rule) = parse_test_path(input_file); diff --git a/crates/biome_css_formatter/tests/quick_test.rs b/crates/biome_css_formatter/tests/quick_test.rs index 22bdba725852..827714d22da8 100644 --- a/crates/biome_css_formatter/tests/quick_test.rs +++ b/crates/biome_css_formatter/tests/quick_test.rs @@ -20,7 +20,7 @@ fn quick_test() { } "#; let parse = parse_css(src, CssParserOptions::default()); - println!("{:#?}", parse); + println!("{parse:#?}"); let options = CssFormatOptions::default() .with_line_width(LineWidth::try_from(80).unwrap()) diff --git a/crates/biome_css_parser/src/lexer/mod.rs b/crates/biome_css_parser/src/lexer/mod.rs index f17c5c3e15ce..1217828ddb89 100644 --- a/crates/biome_css_parser/src/lexer/mod.rs +++ b/crates/biome_css_parser/src/lexer/mod.rs @@ -1237,7 +1237,7 @@ impl<'src> CssLexer<'src> { let char = self.current_char_unchecked(); let err = ParseDiagnostic::new( - format!("unexpected character `{}`", char), + format!("unexpected character `{char}`"), self.text_position()..self.text_position() + char.text_len(), ); self.diagnostics.push(err); diff --git a/crates/biome_css_parser/src/lexer/tests.rs b/crates/biome_css_parser/src/lexer/tests.rs index 375a4ab93d2b..e47068eee100 100644 --- a/crates/biome_css_parser/src/lexer/tests.rs +++ b/crates/biome_css_parser/src/lexer/tests.rs @@ -90,8 +90,7 @@ fn losslessness(string: String) -> bool { .recv_timeout(Duration::from_secs(2)) .unwrap_or_else(|_| { panic!( - "Lexer is infinitely recursing with this code: ->{}<-", - string + "Lexer is infinitely recursing with this code: ->{string}<-" ) }); diff --git a/crates/biome_css_parser/src/syntax/parse_error.rs b/crates/biome_css_parser/src/syntax/parse_error.rs index 7e4d7264269a..59854d6ac3a6 100644 --- a/crates/biome_css_parser/src/syntax/parse_error.rs +++ b/crates/biome_css_parser/src/syntax/parse_error.rs @@ -31,12 +31,11 @@ pub(crate) fn expected_non_css_wide_keyword_identifier( // two details being added, but since we're adding the hint as well, we // only want to show one code frame. ParseDiagnostic::new( - format!("Expected an identifier but instead found '{}'", text), + format!("Expected an identifier but instead found '{text}'"), range, ) .with_hint(format!( - "'{}' is a CSS-wide keyword that cannot be used here", - text + "'{text}' is a CSS-wide keyword that cannot be used here" )) } else { expected_identifier(p, range) diff --git a/crates/biome_css_parser/tests/spec_test.rs b/crates/biome_css_parser/tests/spec_test.rs index 65c60978beeb..ec225cf0e449 100644 --- a/crates/biome_css_parser/tests/spec_test.rs +++ b/crates/biome_css_parser/tests/spec_test.rs @@ -143,15 +143,12 @@ pub fn run(test_case: &str, _snapshot_name: &str, test_directory: &str, outcome_ .descendants() .any(|node| node.kind().is_bogus()) { - panic!("Parsed tree of a 'OK' test case should not contain any missing required children or bogus nodes: \n {formatted_ast:#?} \n\n {}", formatted_ast); + panic!("Parsed tree of a 'OK' test case should not contain any missing required children or bogus nodes: \n {formatted_ast:#?} \n\n {formatted_ast}"); } let syntax = parsed.syntax(); if has_bogus_nodes_or_empty_slots(&syntax) { - panic!( - "modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {}", - syntax - ) + panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}") } } ExpectedOutcome::Fail => { @@ -188,9 +185,6 @@ pub fn quick_test() { let syntax = root.syntax(); dbg!(&syntax, root.diagnostics(), root.has_errors()); if has_bogus_nodes_or_empty_slots(&syntax) { - panic!( - "modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {}", - syntax - ) + panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}") } } diff --git a/crates/biome_deserialize/src/diagnostics.rs b/crates/biome_deserialize/src/diagnostics.rs index 96c52af15394..32934110fb1c 100644 --- a/crates/biome_deserialize/src/diagnostics.rs +++ b/crates/biome_deserialize/src/diagnostics.rs @@ -38,7 +38,7 @@ impl std::fmt::Display for VisitableType { VisitableType::MAP => "an object", _ => unreachable!("Unhandled deserialization type."), }; - write!(fmt, "{}", expected_type)?; + write!(fmt, "{expected_type}")?; } Ok(()) } diff --git a/crates/biome_diagnostics/src/adapters.rs b/crates/biome_diagnostics/src/adapters.rs index 241671487b5d..4f1dee5899ad 100644 --- a/crates/biome_diagnostics/src/adapters.rs +++ b/crates/biome_diagnostics/src/adapters.rs @@ -96,7 +96,7 @@ impl Diagnostic for BpafError { fn description(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let bpaf::ParseFailure::Stderr(reason) = &self.error { - write!(fmt, "{}", reason)?; + write!(fmt, "{reason}")?; } Ok(()) } diff --git a/crates/biome_diagnostics/src/diagnostic.rs b/crates/biome_diagnostics/src/diagnostic.rs index 6359c2474e0e..f8874999ad13 100644 --- a/crates/biome_diagnostics/src/diagnostic.rs +++ b/crates/biome_diagnostics/src/diagnostic.rs @@ -143,8 +143,7 @@ impl FromStr for Severity { "warn" => Ok(Self::Warning), "error" => Ok(Self::Error), v => Err(format!( - "Found unexpected value ({}), valid values are: info, warn, error.", - v + "Found unexpected value ({v}), valid values are: info, warn, error." )), } } diff --git a/crates/biome_diagnostics/src/display.rs b/crates/biome_diagnostics/src/display.rs index 98b7bcd00b89..1077fc4777c9 100644 --- a/crates/biome_diagnostics/src/display.rs +++ b/crates/biome_diagnostics/src/display.rs @@ -115,7 +115,7 @@ impl fmt::Display for PrintHeader<'_, D> { } else { let path_name = Path::new(name); if path_name.is_absolute() { - let link = format!("file://{}", name); + let link = format!("file://{name}"); fmt.write_markup(markup! { {name} })?; diff --git a/crates/biome_diagnostics/src/display/backtrace.rs b/crates/biome_diagnostics/src/display/backtrace.rs index 26e82dc2020f..fdc5491c5632 100644 --- a/crates/biome_diagnostics/src/display/backtrace.rs +++ b/crates/biome_diagnostics/src/display/backtrace.rs @@ -275,11 +275,11 @@ pub(super) fn print_backtrace( if let Some(lineno) = symbol.lineno() { // SAFETY: Writing a `u32` to a string should not fail - write!(text, ":{}", lineno).unwrap(); + write!(text, ":{lineno}").unwrap(); if let Some(colno) = symbol.colno() { // SAFETY: Writing a `u32` to a string should not fail - write!(text, ":{}", colno).unwrap(); + write!(text, ":{colno}").unwrap(); } } diff --git a/crates/biome_diagnostics/src/panic.rs b/crates/biome_diagnostics/src/panic.rs index 632f07ced482..739fae45a2fb 100644 --- a/crates/biome_diagnostics/src/panic.rs +++ b/crates/biome_diagnostics/src/panic.rs @@ -14,7 +14,7 @@ impl std::fmt::Display for PanicError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let r = f.write_fmt(format_args!("{}\n", self.info)); if let Some(backtrace) = &self.backtrace { - f.write_fmt(format_args!("Backtrace: {}", backtrace)) + f.write_fmt(format_args!("Backtrace: {backtrace}")) } else { r } diff --git a/crates/biome_formatter/src/builders.rs b/crates/biome_formatter/src/builders.rs index f5c632e0bda3..ae5688c29134 100644 --- a/crates/biome_formatter/src/builders.rs +++ b/crates/biome_formatter/src/builders.rs @@ -391,7 +391,7 @@ impl std::fmt::Debug for LocatedTokenText { } fn debug_assert_no_newlines(text: &str) { - debug_assert!(!text.contains('\r'), "The content '{}' contains an unsupported '\\r' line terminator character but text must only use line feeds '\\n' as line separator. Use '\\n' instead of '\\r' and '\\r\\n' to insert a line break in strings.", text); + debug_assert!(!text.contains('\r'), "The content '{text}' contains an unsupported '\\r' line terminator character but text must only use line feeds '\\n' as line separator. Use '\\n' instead of '\\r' and '\\r\\n' to insert a line break in strings."); } /// Pushes some content to the end of the current line diff --git a/crates/biome_formatter/src/diagnostics.rs b/crates/biome_formatter/src/diagnostics.rs index 95c164d8a920..4bb1ea987421 100644 --- a/crates/biome_formatter/src/diagnostics.rs +++ b/crates/biome_formatter/src/diagnostics.rs @@ -235,7 +235,7 @@ impl Diagnostic for PrintError { fn message(&self, fmt: &mut Formatter<'_>) -> std::io::Result<()> { match self { PrintError::InvalidDocument(inner) => { - let inner = format!("{}", inner); + let inner = format!("{inner}"); fmt.write_markup(markup! { "Invalid document: "{{inner}} }) diff --git a/crates/biome_formatter/src/lib.rs b/crates/biome_formatter/src/lib.rs index 73ea11439350..a805ff61ba2f 100644 --- a/crates/biome_formatter/src/lib.rs +++ b/crates/biome_formatter/src/lib.rs @@ -285,7 +285,7 @@ impl biome_console::fmt::Display for IndentWidth { impl Display for IndentWidth { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let value = self.value(); - f.write_str(&std::format!("{}", value)) + f.write_str(&std::format!("{value}")) } } @@ -364,7 +364,7 @@ impl biome_console::fmt::Display for LineWidth { impl Display for LineWidth { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let value = self.value(); - f.write_str(&std::format!("{}", value)) + f.write_str(&std::format!("{value}")) } } diff --git a/crates/biome_formatter_test/src/diff_report.rs b/crates/biome_formatter_test/src/diff_report.rs index a26dbced97e6..b05311c3ccec 100644 --- a/crates/biome_formatter_test/src/diff_report.rs +++ b/crates/biome_formatter_test/src/diff_report.rs @@ -352,7 +352,7 @@ impl DiffReport { } let line = line.strip_suffix('\n').unwrap_or(line); - writeln!(diff, "{}{}", tag, line).unwrap(); + writeln!(diff, "{tag}{line}").unwrap(); } let ratio = matched_lines as f64 / biome_lines.max(prettier_lines) as f64; @@ -402,7 +402,7 @@ impl DiffReport { diff, } in report_metric_data.files.iter() { - writeln!(report, "### {}", filename).unwrap(); + writeln!(report, "### {filename}").unwrap(); if let Some(diff) = diff { writeln!(report, "```diff").unwrap(); diff --git a/crates/biome_formatter_test/src/snapshot_builder.rs b/crates/biome_formatter_test/src/snapshot_builder.rs index 707ef4b88ec6..b8717d4f8576 100644 --- a/crates/biome_formatter_test/src/snapshot_builder.rs +++ b/crates/biome_formatter_test/src/snapshot_builder.rs @@ -94,7 +94,7 @@ impl<'a> SnapshotBuilder<'a> { writeln!(self.snapshot).unwrap(); writeln!(self.snapshot, "-----").unwrap(); - write!(self.snapshot, "{}", options).unwrap(); + write!(self.snapshot, "{options}").unwrap(); writeln!(self.snapshot, "-----").unwrap(); writeln!(self.snapshot).unwrap(); @@ -128,7 +128,7 @@ impl<'a> SnapshotBuilder<'a> { writeln!(self.snapshot).unwrap(); for (range, text) in formatted.verbatim() { - writeln!(self.snapshot, "{:?} => {:?}", text, range).unwrap(); + writeln!(self.snapshot, "{text:?} => {range:?}").unwrap(); } } diff --git a/crates/biome_formatter_test/src/test_prettier_snapshot.rs b/crates/biome_formatter_test/src/test_prettier_snapshot.rs index 373aa50ea9c6..66a04d8d3571 100644 --- a/crates/biome_formatter_test/src/test_prettier_snapshot.rs +++ b/crates/biome_formatter_test/src/test_prettier_snapshot.rs @@ -34,7 +34,7 @@ impl<'a> PrettierTestFile<'a> { ); let mut input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let (_, range_start_index, range_end_index) = strip_prettier_placeholders(&mut input_code); let parse_input = input_code.replace(PRETTIER_IGNORE, BIOME_IGNORE); diff --git a/crates/biome_formatter_test/src/utils.rs b/crates/biome_formatter_test/src/utils.rs index 71826b9f4906..a567d15c9158 100644 --- a/crates/biome_formatter_test/src/utils.rs +++ b/crates/biome_formatter_test/src/utils.rs @@ -113,7 +113,7 @@ pub fn get_prettier_diff( let input_extension = input_file.extension().and_then(OsStr::to_str); let prettier_snapshot_path = input_extension - .map(|ext| input_file.with_extension(format!("{}.prettier-snap", ext))) + .map(|ext| input_file.with_extension(format!("{ext}.prettier-snap"))) .filter(|path| path.exists()); let prettier_snapshot_path = prettier_snapshot_path.expect("failed to find prettier snapshot"); @@ -128,14 +128,14 @@ pub fn get_prettier_diff( // The output matches prettier's output. There's no need for a snapshot that duplicates the output. // Delete the snapshot file if it already exists, otherwise return early to not create a new snapshot. if let Some(input_extension) = input_extension { - let snapshot_file_name = input_file.with_extension(format!("{}.snap", input_extension)); + let snapshot_file_name = input_file.with_extension(format!("{input_extension}.snap")); if snapshot_file_name.exists() && snapshot_file_name.is_file() { remove_file(snapshot_file_name).ok(); // not the end of the world if it fails } let new_snapshot_file_name = - input_file.with_extension(format!("{}.snap.new", input_extension)); + input_file.with_extension(format!("{input_extension}.snap.new")); if new_snapshot_file_name.exists() && new_snapshot_file_name.is_file() { remove_file(new_snapshot_file_name).ok(); // not the end of the world if it fails } diff --git a/crates/biome_fs/src/fs.rs b/crates/biome_fs/src/fs.rs index 18e6e98489fd..bc453844ea43 100644 --- a/crates/biome_fs/src/fs.rs +++ b/crates/biome_fs/src/fs.rs @@ -437,7 +437,7 @@ impl Advices for ErrorKind { match self { ErrorKind::CantReadFile(path) => visitor.record_log( LogCategory::Error, - &format!("Biome can't read the following file, maybe for permissions reasons or it doesn't exist: {}", path) + &format!("Biome can't read the following file, maybe for permissions reasons or it doesn't exist: {path}") ), ErrorKind::UnknownFileType => visitor.record_log( @@ -446,11 +446,11 @@ impl Advices for ErrorKind { ), ErrorKind::DereferencedSymlink(path) => visitor.record_log( LogCategory::Info, - &format!("Biome encountered a file system entry that is a broken symbolic link: {}", path), + &format!("Biome encountered a file system entry that is a broken symbolic link: {path}"), ), ErrorKind::DeeplyNestedSymlinkExpansion(path) => visitor.record_log( LogCategory::Error, - &format!("Biome encountered a file system entry with too many nested symbolic links, possibly forming an infinite cycle: {}", path), + &format!("Biome encountered a file system entry with too many nested symbolic links, possibly forming an infinite cycle: {path}"), ), } } diff --git a/crates/biome_fs/src/fs/os.rs b/crates/biome_fs/src/fs/os.rs index 84830d75173b..f5a20e4bff12 100644 --- a/crates/biome_fs/src/fs/os.rs +++ b/crates/biome_fs/src/fs/os.rs @@ -110,7 +110,7 @@ impl FileSystem for OsFileSystem { // R: renamed // Source: https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203 .arg("--diff-filter=ACMR") - .arg(format!("{}...HEAD", base)) + .arg(format!("{base}...HEAD")) .output()?; Ok(String::from_utf8_lossy(&output.stdout) diff --git a/crates/biome_graphql_analyze/tests/spec_tests.rs b/crates/biome_graphql_analyze/tests/spec_tests.rs index 9bcde490734e..e5f734eb1580 100644 --- a/crates/biome_graphql_analyze/tests/spec_tests.rs +++ b/crates/biome_graphql_analyze/tests/spec_tests.rs @@ -44,7 +44,7 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) { let extension = input_file.extension().unwrap_or_default(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let quantity_diagnostics = if let Some(scripts) = scripts_from_json(extension, &input_code) { for script in scripts { analyze_and_snap( @@ -174,10 +174,7 @@ fn check_code_action( assert_eq!(new_tree.to_string(), output); if has_bogus_nodes_or_empty_slots(&new_tree) { - panic!( - "modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {}", - new_tree - ) + panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}") } // Checks the returned tree contains no missing children node @@ -196,7 +193,7 @@ pub(crate) fn _run_suppression_test(input: &'static str, _: &str, _: &str, _: &s let input_file = Path::new(input); let file_name = input_file.file_name().and_then(OsStr::to_str).unwrap(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let (group, rule) = parse_test_path(input_file); diff --git a/crates/biome_graphql_parser/src/lexer/mod.rs b/crates/biome_graphql_parser/src/lexer/mod.rs index 1c9e782b92a1..d6389e1b19b1 100644 --- a/crates/biome_graphql_parser/src/lexer/mod.rs +++ b/crates/biome_graphql_parser/src/lexer/mod.rs @@ -312,7 +312,7 @@ impl<'src> GraphqlLexer<'src> { let char = self.current_char_unchecked(); let err = ParseDiagnostic::new( - format!("unexpected character `{}`", char), + format!("unexpected character `{char}`"), self.text_position()..self.text_position() + char.text_len(), ); self.diagnostics.push(err); diff --git a/crates/biome_graphql_parser/src/lexer/tests.rs b/crates/biome_graphql_parser/src/lexer/tests.rs index fefd35b09e96..6e05ea9e3f86 100644 --- a/crates/biome_graphql_parser/src/lexer/tests.rs +++ b/crates/biome_graphql_parser/src/lexer/tests.rs @@ -87,8 +87,7 @@ fn losslessness(string: String) -> bool { .recv_timeout(Duration::from_secs(2)) .unwrap_or_else(|_| { panic!( - "Lexer is infinitely recursing with this code: ->{}<-", - string + "Lexer is infinitely recursing with this code: ->{string}<-" ) }); diff --git a/crates/biome_grit_parser/src/lexer/mod.rs b/crates/biome_grit_parser/src/lexer/mod.rs index ee0eac396081..0aad07a61a50 100644 --- a/crates/biome_grit_parser/src/lexer/mod.rs +++ b/crates/biome_grit_parser/src/lexer/mod.rs @@ -316,7 +316,7 @@ impl<'src> GritLexer<'src> { let char = self.current_char_unchecked(); let err = ParseDiagnostic::new( - format!("unexpected character `{}`", char), + format!("unexpected character `{char}`"), self.text_position()..self.text_position() + char.text_len(), ); self.diagnostics.push(err); diff --git a/crates/biome_grit_parser/src/lexer/tests.rs b/crates/biome_grit_parser/src/lexer/tests.rs index 308699719d00..f46dba7c802d 100644 --- a/crates/biome_grit_parser/src/lexer/tests.rs +++ b/crates/biome_grit_parser/src/lexer/tests.rs @@ -101,8 +101,7 @@ fn losslessness(string: String) -> bool { .recv_timeout(Duration::from_secs(2)) .unwrap_or_else(|_| { panic!( - "Lexer is infinitely recursing with this code: ->{}<-", - string + "Lexer is infinitely recursing with this code: ->{string}<-" ) }); diff --git a/crates/biome_grit_patterns/src/grit_resolved_pattern.rs b/crates/biome_grit_patterns/src/grit_resolved_pattern.rs index b2bb67d6dad6..cf382c861aa1 100644 --- a/crates/biome_grit_patterns/src/grit_resolved_pattern.rs +++ b/crates/biome_grit_patterns/src/grit_resolved_pattern.rs @@ -65,7 +65,7 @@ impl<'a> GritResolvedPattern<'a> { let mut snippets = Vec::new(); snippets.push(ResolvedSnippet::Text("{".into())); for (key, value) in map { - snippets.push(ResolvedSnippet::Text(format!("\"{}\": ", key).into())); + snippets.push(ResolvedSnippet::Text(format!("\"{key}\": ").into())); snippets.extend(value.to_snippets()?); snippets.push(ResolvedSnippet::Text(", ".into())); } diff --git a/crates/biome_html_parser/src/lexer/mod.rs b/crates/biome_html_parser/src/lexer/mod.rs index bb8fab236020..6c34edccd508 100644 --- a/crates/biome_html_parser/src/lexer/mod.rs +++ b/crates/biome_html_parser/src/lexer/mod.rs @@ -109,7 +109,7 @@ impl<'src> HtmlLexer<'src> { let char = self.current_char_unchecked(); let err = ParseDiagnostic::new( - format!("Unexpected character `{}`", char), + format!("Unexpected character `{char}`"), self.text_position()..self.text_position() + char.text_len(), ); self.diagnostics.push(err); diff --git a/crates/biome_html_parser/src/lexer/tests.rs b/crates/biome_html_parser/src/lexer/tests.rs index 3df7cf39f4e7..f70fa882ffcb 100644 --- a/crates/biome_html_parser/src/lexer/tests.rs +++ b/crates/biome_html_parser/src/lexer/tests.rs @@ -32,12 +32,7 @@ fn losslessness(string: String) -> bool { }); let token_ranges = receiver .recv_timeout(Duration::from_secs(2)) - .unwrap_or_else(|_| { - panic!( - "Lexer is infinitely recursing with this code: ->{}<-", - string - ) - }); + .unwrap_or_else(|_| panic!("Lexer is infinitely recursing with this code: ->{string}<-")); let mut new_str = String::with_capacity(string.len()); let mut idx = TextSize::from(0); diff --git a/crates/biome_html_parser/tests/spec_test.rs b/crates/biome_html_parser/tests/spec_test.rs index e56948f05628..ee7fe09f074c 100644 --- a/crates/biome_html_parser/tests/spec_test.rs +++ b/crates/biome_html_parser/tests/spec_test.rs @@ -100,15 +100,12 @@ pub fn run(test_case: &str, _snapshot_name: &str, test_directory: &str, outcome_ .descendants() .any(|node| node.kind().is_bogus()) { - panic!("Parsed tree of a 'OK' test case should not contain any missing required children or bogus nodes: \n {formatted_ast:#?} \n\n {}", formatted_ast); + panic!("Parsed tree of a 'OK' test case should not contain any missing required children or bogus nodes: \n {formatted_ast:#?} \n\n {formatted_ast}"); } let syntax = parsed.syntax(); if has_bogus_nodes_or_empty_slots(&syntax) { - panic!( - "modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {}", - syntax - ) + panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}") } } ExpectedOutcome::Fail => { diff --git a/crates/biome_js_analyze/src/lint/a11y/use_aria_props_for_role.rs b/crates/biome_js_analyze/src/lint/a11y/use_aria_props_for_role.rs index ce2b60f88f72..61f9dcbdbaff 100644 --- a/crates/biome_js_analyze/src/lint/a11y/use_aria_props_for_role.rs +++ b/crates/biome_js_analyze/src/lint/a11y/use_aria_props_for_role.rs @@ -60,7 +60,7 @@ impl UseAriaPropsForRoleState { } self.attribute.as_ref().map(|(attribute, role_name)| { let joined_attributes = &self.missing_aria_props.join(", "); - let description = format!("The element with the {role_name} ARIA role does not have the required ARIA attributes: {}.", joined_attributes); + let description = format!("The element with the {role_name} ARIA role does not have the required ARIA attributes: {joined_attributes}."); RuleDiagnostic::new( rule_category!(), attribute.range(), diff --git a/crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs b/crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs index 598d7bfac344..027dbae2fb85 100644 --- a/crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs +++ b/crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs @@ -280,6 +280,6 @@ impl Display for BannedType { Self::Symbol => "Symbol", Self::EmptyObject => "{}", }; - write!(f, "{}", representation) + write!(f, "{representation}") } } diff --git a/crates/biome_js_analyze/src/lint/correctness/no_global_object_calls.rs b/crates/biome_js_analyze/src/lint/correctness/no_global_object_calls.rs index 9ac22ecaa435..78e4e1ae3bc4 100644 --- a/crates/biome_js_analyze/src/lint/correctness/no_global_object_calls.rs +++ b/crates/biome_js_analyze/src/lint/correctness/no_global_object_calls.rs @@ -170,6 +170,6 @@ impl Display for NonCallableGlobals { NonCallableGlobals::Reflect => "Reflect", NonCallableGlobals::Intl => "Intl", }; - write!(f, "{}", repr) + write!(f, "{repr}") } } diff --git a/crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs b/crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs index 36b2123f7ba8..7402346e4231 100644 --- a/crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs +++ b/crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs @@ -425,7 +425,7 @@ impl Rule for NoUnusedVariables { } }; let name_trimmed = name.text_trimmed(); - let new_name = format!("_{}", name_trimmed); + let new_name = format!("_{name_trimmed}"); let model = ctx.model(); mutation.rename_node_declaration(model, binding, &new_name); diff --git a/crates/biome_js_analyze/src/lint/nursery/no_unused_function_parameters.rs b/crates/biome_js_analyze/src/lint/nursery/no_unused_function_parameters.rs index d2d68676fda8..e8abf99a3acb 100644 --- a/crates/biome_js_analyze/src/lint/nursery/no_unused_function_parameters.rs +++ b/crates/biome_js_analyze/src/lint/nursery/no_unused_function_parameters.rs @@ -156,7 +156,7 @@ impl Rule for NoUnusedFunctionParameters { let name = binding.name_token().ok()?; let name_trimmed = name.text_trimmed(); - let new_name = format!("_{}", name_trimmed); + let new_name = format!("_{name_trimmed}"); let model = ctx.model(); mutation.rename_node_declaration(model, binding, &new_name); diff --git a/crates/biome_js_analyze/src/lint/nursery/use_date_now.rs b/crates/biome_js_analyze/src/lint/nursery/use_date_now.rs index 639fe0fcd27c..fd90c30c6825 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_date_now.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_date_now.rs @@ -80,7 +80,7 @@ impl Rule for UseDateNow { fn diagnostic(_: &RuleContext, (node, kind): &Self::State) -> Option { let message = match kind { - UseDateNowIssueKind::ReplaceMethod(method) => format!("new Date().{}", method), + UseDateNowIssueKind::ReplaceMethod(method) => format!("new Date().{method}"), UseDateNowIssueKind::ReplaceConstructor => "new Date()".to_string(), UseDateNowIssueKind::ReplaceNumberConstructor => "Number(new Date())".to_string(), }; diff --git a/crates/biome_js_analyze/src/lint/nursery/use_import_extensions.rs b/crates/biome_js_analyze/src/lint/nursery/use_import_extensions.rs index 02a4344503b5..bd348661d9bc 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_import_extensions.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_import_extensions.rs @@ -210,12 +210,12 @@ fn get_extensionless_import( }); let part = if is_index_file { - format!("index.{}", import_ext) + format!("index.{import_ext}") } else { // fold always adds trailing slash, so we need to remove it. new_path.pop(); - format!(".{}", import_ext) + format!(".{import_ext}") }; new_path.push_str(&part); diff --git a/crates/biome_js_analyze/src/lint/nursery/use_semantic_elements.rs b/crates/biome_js_analyze/src/lint/nursery/use_semantic_elements.rs index 7321c0210a1c..d8aed5538409 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_semantic_elements.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_semantic_elements.rs @@ -111,7 +111,7 @@ impl Rule for UseSemanticElements { value = attribute.1 )); } else { - error_message.push_str(&format!("<{element}>\n", element = element)); + error_message.push_str(&format!("<{element}>\n")); } } diff --git a/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs b/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs index 65bbe218eb2e..1f2130f2492e 100644 --- a/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs +++ b/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs @@ -1124,7 +1124,7 @@ impl DeserializableValidator for Selector { ) -> bool { if let Err(error) = self.check() { diagnostics - .push(DeserializationDiagnostic::new(format_args!("{}", error)).with_range(range)); + .push(DeserializationDiagnostic::new(format_args!("{error}")).with_range(range)); return false; } true @@ -1624,7 +1624,7 @@ impl std::fmt::Display for Kind { Self::Var => "var", Self::Variable => "variable", }; - write!(f, "{}", repr) + write!(f, "{repr}") } } @@ -1751,7 +1751,7 @@ impl From for Modifiers { impl std::fmt::Display for Modifiers { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for value in self.0.iter() { - write!(f, "{} ", value)?; + write!(f, "{value} ")?; } Ok(()) } diff --git a/crates/biome_js_analyze/src/lint/suspicious/no_control_characters_in_regex.rs b/crates/biome_js_analyze/src/lint/suspicious/no_control_characters_in_regex.rs index 85dceb9560fb..0cacfd908417 100644 --- a/crates/biome_js_analyze/src/lint/suspicious/no_control_characters_in_regex.rs +++ b/crates/biome_js_analyze/src/lint/suspicious/no_control_characters_in_regex.rs @@ -102,7 +102,7 @@ fn decode_escaped_code_point_to_code_point(iter: &mut Peekable) -> Option if c == '}' { iter.next(); let code_point = i64::from_str_radix(&digits, 16).ok()?; - return Some((format!("{{{}}}", digits), code_point)); + return Some((format!("{{{digits}}}"), code_point)); } else { digits.push(iter.next()?); } diff --git a/crates/biome_js_analyze/src/lint/suspicious/no_double_equals.rs b/crates/biome_js_analyze/src/lint/suspicious/no_double_equals.rs index 73c1691ef9c7..bdfe88c23206 100644 --- a/crates/biome_js_analyze/src/lint/suspicious/no_double_equals.rs +++ b/crates/biome_js_analyze/src/lint/suspicious/no_double_equals.rs @@ -83,8 +83,7 @@ impl Rule for NoDoubleEquals { let text_trimmed = op.text_trimmed(); let suggestion = if op.kind() == EQ2 { "===" } else { "!==" }; let description = format!( - "Use {} instead of {}.\n{} is only allowed when comparing against `null`", - suggestion, text_trimmed, text_trimmed + "Use {suggestion} instead of {text_trimmed}.\n{text_trimmed} is only allowed when comparing against `null`" ); Some(RuleDiagnostic::new( rule_category!(), diff --git a/crates/biome_js_analyze/src/lint/suspicious/no_duplicate_object_keys.rs b/crates/biome_js_analyze/src/lint/suspicious/no_duplicate_object_keys.rs index c6b823f6b21c..8ea73d6da857 100644 --- a/crates/biome_js_analyze/src/lint/suspicious/no_duplicate_object_keys.rs +++ b/crates/biome_js_analyze/src/lint/suspicious/no_duplicate_object_keys.rs @@ -262,8 +262,7 @@ impl Rule for NoDuplicateObjectKeys { rule_category!(), member_definition.range(), format!( - "This {} is later overwritten by an object member with the same name.", - member_definition + "This {member_definition} is later overwritten by an object member with the same name." ), ); diagnostic = match defined_property { diff --git a/crates/biome_js_analyze/src/lint/suspicious/no_misleading_character_class.rs b/crates/biome_js_analyze/src/lint/suspicious/no_misleading_character_class.rs index 3b4f5084b0b4..f3a1dcc706e0 100644 --- a/crates/biome_js_analyze/src/lint/suspicious/no_misleading_character_class.rs +++ b/crates/biome_js_analyze/src/lint/suspicious/no_misleading_character_class.rs @@ -200,7 +200,7 @@ impl Rule for NoMisleadingCharacterClass { let text = prev_token.text(); let next_token = JsSyntaxToken::new_detached( JsSyntaxKind::JS_REGEX_LITERAL, - &format!("{}u", text), + &format!("{text}u"), [], [], ); @@ -367,7 +367,7 @@ fn make_suggestion( AnyJsExpression::AnyJsLiteralExpression( AnyJsLiteralExpression::JsStringLiteralExpression( make::js_string_literal_expression(make::js_string_literal( - &format!("'{}u'", text), + &format!("'{text}u'"), )), ), ), @@ -567,11 +567,11 @@ fn handle_simple_or_surrogate_escape_sequence( chars_iter.next(); } else { // If the character is not a valid Unicode char, return as simple string. - return Some(format!("\\u{}", high_surrogate_str)); + return Some(format!("\\u{high_surrogate_str}")); } } else { // If not enough characters, return as if it were a simple string. - return Some(format!("\\u{}", high_surrogate_str)); + return Some(format!("\\u{high_surrogate_str}")); } } @@ -588,8 +588,8 @@ fn handle_simple_or_surrogate_escape_sequence( // - high surrogate on its own doesn't make sense // - low surrogate is not a valid unicode codepoint // e.g \uD83D\u333 - invalid_pair.push_str(&format!("\\u{}", high_surrogate_str)); - invalid_pair.push_str(&format!("\\u{}", low_surrogate_str)); + invalid_pair.push_str(&format!("\\u{high_surrogate_str}")); + invalid_pair.push_str(&format!("\\u{low_surrogate_str}")); return Some(invalid_pair); } low_surrogate_str.push(*next_char); @@ -609,7 +609,7 @@ fn handle_simple_or_surrogate_escape_sequence( } else { match char::from_u32(high_surrogate) { Some(c) => return Some(c.to_string()), - None => invalid_pair.push_str(&format!("\\u{}", high_surrogate_str)), + None => invalid_pair.push_str(&format!("\\u{high_surrogate_str}")), } } } diff --git a/crates/biome_js_analyze/src/suppression_action.rs b/crates/biome_js_analyze/src/suppression_action.rs index f40f264933e5..5f2efe6e3a82 100644 --- a/crates/biome_js_analyze/src/suppression_action.rs +++ b/crates/biome_js_analyze/src/suppression_action.rs @@ -160,7 +160,7 @@ impl SuppressionAction for JsSuppressionAction { let jsx_comment = jsx_expression_child( token(T!['{']).with_trailing_trivia([( TriviaPieceKind::SingleLineComment, - format!("/* {}: */", suppression_text).as_str(), + format!("/* {suppression_text}: */").as_str(), )]), token(T!['}']), ) @@ -197,7 +197,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {}: ", suppression_text).as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -205,7 +205,7 @@ impl SuppressionAction for JsSuppressionAction { new_token = new_token.with_leading_trivia([ ( TriviaPieceKind::SingleLineComment, - format!("// {}: ", suppression_text).as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -220,7 +220,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {}: ", suppression_text).as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -229,7 +229,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {}: ", suppression_text).as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -238,12 +238,12 @@ impl SuppressionAction for JsSuppressionAction { new_token = new_token.with_trailing_trivia([ ( TriviaPieceKind::SingleLineComment, - format!("// {}: ", suppression_text).as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) } else { - let comment = format!("// {}: ", suppression_text); + let comment = format!("// {suppression_text}: "); let mut trivia = vec![ (TriviaPieceKind::SingleLineComment, comment.as_str()), (TriviaPieceKind::Newline, "\n"), diff --git a/crates/biome_js_analyze/src/syntax/correctness/no_duplicate_private_class_members.rs b/crates/biome_js_analyze/src/syntax/correctness/no_duplicate_private_class_members.rs index d871045cadfd..bf5b4c866d50 100644 --- a/crates/biome_js_analyze/src/syntax/correctness/no_duplicate_private_class_members.rs +++ b/crates/biome_js_analyze/src/syntax/correctness/no_duplicate_private_class_members.rs @@ -81,7 +81,7 @@ impl Rule for NoDuplicatePrivateClassMembers { let diagnostic = RuleDiagnostic::new( category!("parse/noDuplicatePrivateClassMembers"), range, - format!("Duplicate private class member {:?}", member_name), + format!("Duplicate private class member {member_name:?}"), ); Some(diagnostic) diff --git a/crates/biome_js_analyze/src/utils/rename.rs b/crates/biome_js_analyze/src/utils/rename.rs index f77ce70a6e35..001cda27a3b6 100644 --- a/crates/biome_js_analyze/src/utils/rename.rs +++ b/crates/biome_js_analyze/src/utils/rename.rs @@ -91,8 +91,7 @@ impl std::fmt::Display for RenameError { } => { write!( f, - "encountered an error while renaming the symbol \"{}\" to \"{}\"", - original_name, new_name + "encountered an error while renaming the symbol \"{original_name}\" to \"{new_name}\"" ) } RenameError::CannotFindDeclaration(_) => { diff --git a/crates/biome_js_analyze/src/utils/tests.rs b/crates/biome_js_analyze/src/utils/tests.rs index 89905117c33c..89ccdc61f459 100644 --- a/crates/biome_js_analyze/src/utils/tests.rs +++ b/crates/biome_js_analyze/src/utils/tests.rs @@ -122,10 +122,7 @@ pub fn assert_remove_identifier_a_ok + Debug type_name::() ) }), - _ => panic!( - "Expected exactly one identifier named a, but got {:?}", - identifiers_a - ), + _ => panic!("Expected exactly one identifier named a, but got {identifiers_a:?}"), }; let mut batch = r.tree().begin(); @@ -137,7 +134,7 @@ pub fn assert_remove_identifier_a_ok + Debug } else if let Some(member) = AnyJsObjectMember::cast_ref(node_to_remove.syntax()) { batch.remove_js_object_member(member) } else { - panic!("Don't know how to remove this node: {:?}", node_to_remove); + panic!("Don't know how to remove this node: {node_to_remove:?}"); }; assert!(batch_result); let root = batch.commit(); diff --git a/crates/biome_js_analyze/tests/quick_test.rs b/crates/biome_js_analyze/tests/quick_test.rs index bd9d2ae11630..0df26776f155 100644 --- a/crates/biome_js_analyze/tests/quick_test.rs +++ b/crates/biome_js_analyze/tests/quick_test.rs @@ -40,7 +40,7 @@ fn run_test() { let extension = input_file.extension().unwrap_or_default(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); if let Some(scripts) = scripts_from_json(extension, &input_code) { for script in scripts { analyze( diff --git a/crates/biome_js_analyze/tests/spec_tests.rs b/crates/biome_js_analyze/tests/spec_tests.rs index f3101cb24049..e96f6a1ae77b 100644 --- a/crates/biome_js_analyze/tests/spec_tests.rs +++ b/crates/biome_js_analyze/tests/spec_tests.rs @@ -44,7 +44,7 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) { let extension = input_file.extension().unwrap_or_default(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let quantity_diagnostics = if let Some(scripts) = scripts_from_json(extension, &input_code) { for script in scripts { analyze_and_snap( @@ -204,10 +204,7 @@ fn check_code_action( assert_eq!(new_tree.to_string(), output); if has_bogus_nodes_or_empty_slots(&new_tree) { - panic!( - "modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {}", - new_tree - ) + panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}") } // Checks the returned tree contains no missing children node @@ -236,7 +233,7 @@ pub(crate) fn run_suppression_test(input: &'static str, _: &str, _: &str, _: &st } }; let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let (group, rule) = parse_test_path(input_file); diff --git a/crates/biome_js_formatter/src/utils/string_utils.rs b/crates/biome_js_formatter/src/utils/string_utils.rs index 366a8aecc7e7..0ce8a189b978 100644 --- a/crates/biome_js_formatter/src/utils/string_utils.rs +++ b/crates/biome_js_formatter/src/utils/string_utils.rs @@ -383,7 +383,7 @@ mod tests { #[quickcheck] fn to_ascii_lowercase_cow_returns_owned_when_some_chars_are_not_lowercase(txt: AsciiString) { - let txt = std::format!("{}A", txt); //guarantees at least one uppercase letter + let txt = std::format!("{txt}A"); //guarantees at least one uppercase letter assert!(matches!(txt.to_ascii_lowercase_cow(), Cow::Owned(s) if s == txt.to_lowercase())); } diff --git a/crates/biome_js_parser/src/lexer/mod.rs b/crates/biome_js_parser/src/lexer/mod.rs index d17d1397b5cd..884e4b087763 100644 --- a/crates/biome_js_parser/src/lexer/mod.rs +++ b/crates/biome_js_parser/src/lexer/mod.rs @@ -1416,7 +1416,7 @@ impl<'src> JsLexer<'src> { #[inline] fn flag_err(&self, flag: char) -> ParseDiagnostic { ParseDiagnostic::new( - format!("Duplicate flag `{}`.", flag), + format!("Duplicate flag `{flag}`."), self.position..self.position + 1, ) .with_hint("This flag was already used.") @@ -1915,7 +1915,7 @@ impl<'src> JsLexer<'src> { self.resolve_identifier(chr) } else { let err = ParseDiagnostic::new( - format!("Unexpected token `{}`", chr), + format!("Unexpected token `{chr}`"), start..self.position + 1, ); self.push_diagnostic(err); diff --git a/crates/biome_js_parser/src/lexer/tests.rs b/crates/biome_js_parser/src/lexer/tests.rs index 6ecdbeb26f4c..1f07278c4b8d 100644 --- a/crates/biome_js_parser/src/lexer/tests.rs +++ b/crates/biome_js_parser/src/lexer/tests.rs @@ -88,12 +88,7 @@ fn losslessness(string: String) -> bool { }); let token_ranges = receiver .recv_timeout(Duration::from_secs(2)) - .unwrap_or_else(|_| { - panic!( - "Lexer is infinitely recursing with this code: ->{}<-", - string - ) - }); + .unwrap_or_else(|_| panic!("Lexer is infinitely recursing with this code: ->{string}<-")); let mut new_str = String::with_capacity(string.len()); let mut idx = TextSize::from(0); @@ -1397,8 +1392,7 @@ fn keywords() { let lexed_kind = lexer.current(); assert_eq!( lexed_kind, kind, - "Expected token '{keyword}' to be of kind {:?} but is {:?}.", - kind, lexed_kind + "Expected token '{keyword}' to be of kind {kind:?} but is {lexed_kind:?}." ); let lexed_range = lexer.current_range(); diff --git a/crates/biome_js_parser/src/syntax/assignment.rs b/crates/biome_js_parser/src/syntax/assignment.rs index 3903a98d0d94..f76e453cc290 100644 --- a/crates/biome_js_parser/src/syntax/assignment.rs +++ b/crates/biome_js_parser/src/syntax/assignment.rs @@ -472,7 +472,7 @@ impl RewriteParseEvents for ReparseAssignment { let name = completed.text(p); if matches!(name, "eval" | "arguments") && p.is_strict_mode() { let error = p.err_builder( - format!("Illegal use of `{}` as an identifier in strict mode", name), + format!("Illegal use of `{name}` as an identifier in strict mode"), completed.range(p), ); p.error(error); diff --git a/crates/biome_js_parser/src/syntax/binding.rs b/crates/biome_js_parser/src/syntax/binding.rs index 3098ee89e041..9c788c2d13b5 100644 --- a/crates/biome_js_parser/src/syntax/binding.rs +++ b/crates/biome_js_parser/src/syntax/binding.rs @@ -73,8 +73,7 @@ pub(crate) fn parse_identifier_binding(p: &mut JsParser) -> ParsedSyntax { if StrictMode.is_supported(p) && matches!(identifier_name, "eval" | "arguments") { let err = p.err_builder( format!( - "Illegal use of `{}` as an identifier in strict mode", - identifier_name + "Illegal use of `{identifier_name}` as an identifier in strict mode" ), identifier.range(p), ); @@ -89,8 +88,7 @@ pub(crate) fn parse_identifier_binding(p: &mut JsParser) -> ParsedSyntax { let err = p .err_builder( format!( - "`let` cannot be declared as a variable name inside of a `{}` declaration", - parent, + "`let` cannot be declared as a variable name inside of a `{parent}` declaration", ), identifier.range(p), @@ -106,21 +104,19 @@ pub(crate) fn parse_identifier_binding(p: &mut JsParser) -> ParsedSyntax { let err = p .err_builder( format!( - "Declarations inside of a `{}` declaration may not have duplicates", - parent + "Declarations inside of a `{parent}` declaration may not have duplicates" ), identifier.range(p), ) .with_detail( identifier.range(p), format!( - "a second declaration of `{}` is not allowed", - identifier_name + "a second declaration of `{identifier_name}` is not allowed" ), ) .with_detail( *existing, - format!("`{}` is first declared here", identifier_name), + format!("`{identifier_name}` is first declared here"), ); p.error(err); identifier.change_to_bogus(p); diff --git a/crates/biome_js_parser/src/syntax/class.rs b/crates/biome_js_parser/src/syntax/class.rs index 5c97caa8cdb7..362cce61ee2f 100644 --- a/crates/biome_js_parser/src/syntax/class.rs +++ b/crates/biome_js_parser/src/syntax/class.rs @@ -253,8 +253,7 @@ fn parse_class(p: &mut JsParser, kind: ClassKind, decorator_list: ParsedSyntax) if TypeScript.is_supported(p) && is_reserved_type_name(text) { let err = p .err_builder(format!( - "`{}` cannot be used as a class name because it is already reserved as a type", - text + "`{text}` cannot be used as a class name because it is already reserved as a type" ),id.range(p), ); p.error(err); @@ -2065,7 +2064,7 @@ impl ClassMemberModifiers { /// or by iterating over all modifiers and keeping track of the modifier it has seen). fn get_first_range_unchecked(&self, kind: ModifierKind) -> TextRange { self.get_first_range(kind) - .unwrap_or_else(|| panic!("Expected modifier of kind {:?} to be present", kind)) + .unwrap_or_else(|| panic!("Expected modifier of kind {kind:?} to be present")) } fn is_empty(&self) -> bool { @@ -2106,7 +2105,7 @@ impl ClassMemberModifiers { self.list_marker.undo_completion(p).abandon(p); return false; } - t => panic!("Unknown member kind {:?}", t), + t => panic!("Unknown member kind {t:?}"), }; self.list_marker.change_kind(p, list_kind); diff --git a/crates/biome_js_parser/src/syntax/expr.rs b/crates/biome_js_parser/src/syntax/expr.rs index f7941bc2bd42..4bc251250d68 100644 --- a/crates/biome_js_parser/src/syntax/expr.rs +++ b/crates/biome_js_parser/src/syntax/expr.rs @@ -1558,8 +1558,7 @@ pub(super) fn parse_identifier(p: &mut JsParser, kind: JsSyntaxKind) -> ParsedSy let name = p.cur_text(); Some(p.err_builder( format!( - "Illegal use of reserved keyword `{}` as an identifier in strict mode", - name + "Illegal use of reserved keyword `{name}` as an identifier in strict mode" ), p.cur_range(), )) diff --git a/crates/biome_js_parser/src/syntax/js_parse_error.rs b/crates/biome_js_parser/src/syntax/js_parse_error.rs index a802e098781a..105cbe4c934b 100644 --- a/crates/biome_js_parser/src/syntax/js_parse_error.rs +++ b/crates/biome_js_parser/src/syntax/js_parse_error.rs @@ -161,7 +161,7 @@ pub(crate) fn duplicate_assertion_keys_error( duplicate_range: TextRange, ) -> ParseDiagnostic { p.err_builder("Duplicate assertion keys are not allowed", first_use) - .with_detail(first_use, format!("First use of the key `{}`", key)) + .with_detail(first_use, format!("First use of the key `{key}`")) .with_detail(duplicate_range, "second use here") } diff --git a/crates/biome_js_parser/src/syntax/stmt.rs b/crates/biome_js_parser/src/syntax/stmt.rs index b833e523a143..6d18214e32e7 100644 --- a/crates/biome_js_parser/src/syntax/stmt.rs +++ b/crates/biome_js_parser/src/syntax/stmt.rs @@ -450,11 +450,11 @@ fn parse_labeled_statement(p: &mut JsParser, context: StatementContext) -> Parse .err_builder("Duplicate statement labels are not allowed", identifier_range) .with_detail( identifier_range, - format!("a second use of `{}` here is not allowed", label), + format!("a second use of `{label}` here is not allowed"), ) .with_detail( *label_item.range(), - format!("`{}` is first used as a label here", label), + format!("`{label}` is first used as a label here"), ); p.error(err); @@ -605,7 +605,7 @@ fn parse_break_statement(p: &mut JsParser) -> ParsedSyntax { Some(_) => None, None => Some( p.err_builder( - format!("Use of undefined statement label `{}`", label_name,), + format!("Use of undefined statement label `{label_name}`",), p.cur_range(), ) .with_hint("This label is used, but it is never defined"), @@ -670,8 +670,7 @@ fn parse_continue_statement(p: &mut JsParser) -> ParsedSyntax { None => { Some(p .err_builder(format!( - "Use of undefined statement label `{}`", - label_name + "Use of undefined statement label `{label_name}`" ), p.cur_range()) .with_hint( diff --git a/crates/biome_js_parser/src/syntax/typescript.rs b/crates/biome_js_parser/src/syntax/typescript.rs index 8fe703b1e814..99a2b04703b0 100644 --- a/crates/biome_js_parser/src/syntax/typescript.rs +++ b/crates/biome_js_parser/src/syntax/typescript.rs @@ -51,7 +51,7 @@ fn parse_ts_identifier_binding( let name = p.text(ident.range(p)); let is_reserved_word_this_context = ts_identifier_context.is_reserved_word(name); if is_reserved_word_this_context { - let error = p.err_builder(format!("Type alias cannot be {}", name), ident.range(p)); + let error = p.err_builder(format!("Type alias cannot be {name}"), ident.range(p)); p.error(error); ident.change_to_bogus(p); } @@ -100,7 +100,7 @@ fn expect_ts_type_list(p: &mut JsParser, clause_name: &str) -> CompletedMarker { if parse_ts_reference_type(p, TypeContext::default()).is_absent() { p.error(p.err_builder( - format!("'{}' list cannot be empty.", clause_name), + format!("'{clause_name}' list cannot be empty."), p.cur_range().start()..p.cur_range().start(), )) } diff --git a/crates/biome_js_parser/src/syntax/typescript/statement.rs b/crates/biome_js_parser/src/syntax/typescript/statement.rs index 9417e6c418cf..fcd80801f768 100644 --- a/crates/biome_js_parser/src/syntax/typescript/statement.rs +++ b/crates/biome_js_parser/src/syntax/typescript/statement.rs @@ -119,8 +119,7 @@ fn parse_ts_enum_id(p: &mut JsParser, enum_token_range: TextRange) { if is_reserved_enum_name(text) { let err = p.err_builder( format!( - "`{}` cannot be used as a enum name because it is already reserved", - text + "`{text}` cannot be used as a enum name because it is already reserved" ), id.range(p), ); diff --git a/crates/biome_js_parser/src/syntax/typescript/ts_parse_error.rs b/crates/biome_js_parser/src/syntax/typescript/ts_parse_error.rs index b70b2208fea7..e9483ccffcaa 100644 --- a/crates/biome_js_parser/src/syntax/typescript/ts_parse_error.rs +++ b/crates/biome_js_parser/src/syntax/typescript/ts_parse_error.rs @@ -25,7 +25,7 @@ pub(crate) fn ts_member_cannot_be( member_type_name: &str, modifier_name: &str, ) -> ParseDiagnostic { - let msg = format!("{} members cannot be {}", member_type_name, modifier_name); + let msg = format!("{member_type_name} members cannot be {modifier_name}"); p.err_builder(msg, range) } @@ -87,7 +87,7 @@ pub(crate) fn ts_only_syntax_error( syntax: &str, range: TextRange, ) -> ParseDiagnostic { - p.err_builder(format!("{} are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.", syntax) + p.err_builder(format!("{syntax} are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.") ,range).with_hint( "TypeScript only syntax") } diff --git a/crates/biome_js_parser/src/test_utils.rs b/crates/biome_js_parser/src/test_utils.rs index 8b70d8122f49..4bd56556cb2b 100644 --- a/crates/biome_js_parser/src/test_utils.rs +++ b/crates/biome_js_parser/src/test_utils.rs @@ -39,10 +39,7 @@ where let has_missing_children = debug_tree.contains("missing (required)"); if has_bogus_nodes_or_empty_slots(&syntax) { - panic!( - "modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {}", - syntax - ) + panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}") } if !program.has_errors() && !has_missing_children { diff --git a/crates/biome_js_parser/src/tests.rs b/crates/biome_js_parser/src/tests.rs index 44d1fd912f3b..5df6860aef3b 100644 --- a/crates/biome_js_parser/src/tests.rs +++ b/crates/biome_js_parser/src/tests.rs @@ -70,7 +70,7 @@ fn try_parse(path: &str, text: &str, options: JsParserOptions) -> Parse { let binding = JsIdentifierBinding::cast(node).unwrap(); // These do the same thing, but with different APIs - assert!( - is_exported == model.is_exported(&binding), - "at \"{}\"", - code - ); - assert!( - is_exported == binding.is_exported(&model), - "at \"{}\"", - code - ); + assert!(is_exported == model.is_exported(&binding), "at \"{code}\""); + assert!(is_exported == binding.is_exported(&model), "at \"{code}\""); } JsSyntaxKind::TS_IDENTIFIER_BINDING => { let binding = TsIdentifierBinding::cast(node).unwrap(); // These do the same thing, but with different APIs - assert!( - is_exported == model.is_exported(&binding), - "at \"{}\"", - code - ); - assert!( - is_exported == binding.is_exported(&model), - "at \"{}\"", - code - ); + assert!(is_exported == model.is_exported(&binding), "at \"{code}\""); + assert!(is_exported == binding.is_exported(&model), "at \"{code}\""); } JsSyntaxKind::JS_REFERENCE_IDENTIFIER => { // Do nothing. } x => { - panic!("This node cannot be exported! {:?}", x); + panic!("This node cannot be exported! {x:?}"); } }; } diff --git a/crates/biome_js_semantic/src/tests/assertions.rs b/crates/biome_js_semantic/src/tests/assertions.rs index 131e4a00d910..96d82129f603 100644 --- a/crates/biome_js_semantic/src/tests/assertions.rs +++ b/crates/biome_js_semantic/src/tests/assertions.rs @@ -458,8 +458,8 @@ impl SemanticAssertions { // OK because we are attached to a declaration } _ => { - println!("Assertion: {:?}", assertion); - println!("Events: {:#?}", events_by_pos); + println!("Assertion: {assertion:?}"); + println!("Events: {events_by_pos:#?}"); error_assertion_not_attached_to_a_declaration( code, assertion.range, @@ -468,8 +468,8 @@ impl SemanticAssertions { } } } else { - println!("Assertion: {:?}", assertion); - println!("Events: {:#?}", events_by_pos); + println!("Assertion: {assertion:?}"); + println!("Events: {events_by_pos:#?}"); error_assertion_not_attached_to_a_declaration(code, assertion.range, test_name); } } @@ -526,17 +526,15 @@ impl SemanticAssertions { }); if !at_least_one_match { - println!("Assertion: {:?}", assertion); - println!("Events: {:#?}", events_by_pos); + println!("Assertion: {assertion:?}"); + println!("Events: {events_by_pos:#?}"); if let Some(unused_match) = unused_match { panic!( - "A read event was found, but was discarded because [{}] when checking {:?}", - unused_match, assertion + "A read event was found, but was discarded because [{unused_match}] when checking {assertion:?}" ); } else { panic!( - "No matching read event found at this range when checking {:?}", - assertion + "No matching read event found at this range when checking {assertion:?}" ); } } @@ -561,8 +559,8 @@ impl SemanticAssertions { let events = match events_by_pos.get(&assertion.range.start()) { Some(events) => events, None => { - println!("Assertion: {:?}", assertion); - println!("Events: {:#?}", events_by_pos); + println!("Assertion: {assertion:?}"); + println!("Events: {events_by_pos:#?}"); panic!("No write event found at this range"); } }; @@ -588,8 +586,8 @@ impl SemanticAssertions { }); if !at_least_one_match { - println!("Assertion: {:?}", assertion); - println!("Events: {:#?}", events_by_pos); + println!("Assertion: {assertion:?}"); + println!("Events: {events_by_pos:#?}"); panic!("No matching write event found at this range"); } } diff --git a/crates/biome_js_transform/tests/spec_tests.rs b/crates/biome_js_transform/tests/spec_tests.rs index 95c0d0d5f75e..97faa0c3f200 100644 --- a/crates/biome_js_transform/tests/spec_tests.rs +++ b/crates/biome_js_transform/tests/spec_tests.rs @@ -43,7 +43,7 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) { let extension = input_file.extension().unwrap_or_default(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let quantity_diagnostics = if let Some(scripts) = scripts_from_json(extension, &input_code) { for script in scripts { analyze_and_snap( @@ -158,10 +158,7 @@ fn check_transformation( assert_eq!(new_tree.to_string(), output); if has_bogus_nodes_or_empty_slots(&new_tree) { - panic!( - "modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {}", - new_tree - ) + panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}") } // Checks the returned tree contains no missing children node diff --git a/crates/biome_json_analyze/tests/spec_tests.rs b/crates/biome_json_analyze/tests/spec_tests.rs index 776ce4b08bf6..dcbe0d663ba1 100644 --- a/crates/biome_json_analyze/tests/spec_tests.rs +++ b/crates/biome_json_analyze/tests/spec_tests.rs @@ -43,7 +43,7 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) { let mut snapshot = String::new(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let quantity_diagnostics = analyze_and_snap(&mut snapshot, &input_code, filter, file_name, input_file); @@ -129,10 +129,7 @@ fn check_code_action(path: &Path, source: &str, action: &AnalyzerAction Lexer<'src> { let char = self.current_char_unchecked(); let err = ParseDiagnostic::new( - format!("unexpected character `{}`", char), + format!("unexpected character `{char}`"), self.text_position()..self.text_position() + char.text_len(), ); self.diagnostics.push(err); diff --git a/crates/biome_json_parser/src/lexer/tests.rs b/crates/biome_json_parser/src/lexer/tests.rs index f15df61b5a98..f706559728e7 100644 --- a/crates/biome_json_parser/src/lexer/tests.rs +++ b/crates/biome_json_parser/src/lexer/tests.rs @@ -78,8 +78,7 @@ fn losslessness(string: String) -> bool { .recv_timeout(Duration::from_secs(2)) .unwrap_or_else(|_| { panic!( - "Lexer is infinitely recursing with this code: ->{}<-", - string + "Lexer is infinitely recursing with this code: ->{string}<-" ) }); diff --git a/crates/biome_lsp/src/diagnostics.rs b/crates/biome_lsp/src/diagnostics.rs index 4352f626d299..a2e0f0bce024 100644 --- a/crates/biome_lsp/src/diagnostics.rs +++ b/crates/biome_lsp/src/diagnostics.rs @@ -26,10 +26,10 @@ impl Display for LspError { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { LspError::WorkspaceError(err) => { - write!(f, "{}", err) + write!(f, "{err}") } LspError::Anyhow(err) => { - write!(f, "{}", err) + write!(f, "{err}") } } } @@ -48,13 +48,13 @@ pub(crate) async fn handle_lsp_error( WorkspaceError::FormatWithErrorsDisabled(_) | WorkspaceError::FileIgnored(_) | WorkspaceError::FileTooLarge(_) => { - let message = format!("{}", err); + let message = format!("{err}"); client.log_message(MessageType::WARNING, message).await; Ok(None) } _ => { - let message = format!("{}", err); + let message = format!("{err}"); client.log_message(MessageType::ERROR, message).await; Ok(None) } diff --git a/crates/biome_migrate/tests/spec_tests.rs b/crates/biome_migrate/tests/spec_tests.rs index 4bc3582b18e2..8efce878780f 100644 --- a/crates/biome_migrate/tests/spec_tests.rs +++ b/crates/biome_migrate/tests/spec_tests.rs @@ -32,7 +32,7 @@ fn run_test(input: &'static str, _: &str, _: &str, _: &str) { let mut snapshot = String::new(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let quantity_diagnostics = analyze_and_snap(&mut snapshot, &input_code, file_name, input_file); @@ -116,10 +116,7 @@ fn check_code_action(path: &Path, source: &str, action: &AnalyzerAction Self { let names = format!("{} {}", article_for(name), name); let msg = if p.source().text().text_len() <= range.start() { - format!("Expected {} but instead found the end of the file.", names) + format!("Expected {names} but instead found the end of the file.") } else { format!("Expected {} but instead found '{}'.", names, p.text(range)) }; @@ -133,7 +133,7 @@ impl ParseDiagnostic { message: MessageAndDescription::from(msg), advice: ParserAdvice::default(), } - .with_detail(range, format!("Expected {} here.", names)) + .with_detail(range, format!("Expected {names} here.")) } pub fn new_with_any(names: &[&str], range: TextRange, p: &impl Parser) -> Self { @@ -160,10 +160,7 @@ impl ParseDiagnostic { } let msg = if p.source().text().text_len() <= range.start() { - format!( - "Expected {} but instead found the end of the file.", - joined_names - ) + format!("Expected {joined_names} but instead found the end of the file.") } else { format!( "Expected {} but instead found '{}'.", @@ -177,7 +174,7 @@ impl ParseDiagnostic { message: MessageAndDescription::from(msg), advice: ParserAdvice::default(), } - .with_detail(range, format!("Expected {} here.", joined_names)) + .with_detail(range, format!("Expected {joined_names} here.")) } pub const fn is_error(&self) -> bool { diff --git a/crates/biome_project/tests/manifest_spec_tests.rs b/crates/biome_project/tests/manifest_spec_tests.rs index 09cb497ecc5f..02f39f74f42d 100644 --- a/crates/biome_project/tests/manifest_spec_tests.rs +++ b/crates/biome_project/tests/manifest_spec_tests.rs @@ -12,7 +12,7 @@ fn run_invalid_configurations(input: &'static str, _: &str, _: &str, _: &str) { let file_name = input_file.file_name().and_then(OsStr::to_str).unwrap(); let extension = input_file.extension().and_then(OsStr::to_str).unwrap(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let mut project = NodeJsProject::default(); match extension { @@ -29,8 +29,7 @@ fn run_invalid_configurations(input: &'static str, _: &str, _: &str, _: &str) { assert!( project.has_errors() || !result.diagnostics.is_empty(), - "The file {} should have diagnostics, but it doesn't have any", - input + "The file {input} should have diagnostics, but it doesn't have any" ); let mut diagnostics_string = project diff --git a/crates/biome_rowan/src/ast/batch.rs b/crates/biome_rowan/src/ast/batch.rs index dc8fa052df32..e31304cf3fac 100644 --- a/crates/biome_rowan/src/ast/batch.rs +++ b/crates/biome_rowan/src/ast/batch.rs @@ -628,7 +628,7 @@ pub mod test { let batch = before.begin(); let after = batch.commit(); - assert_eq!(before_debug, format!("{:#?}", after)); + assert_eq!(before_debug, format!("{after:#?}")); } #[test] @@ -643,7 +643,7 @@ pub mod test { batch.replace_node(a, b); let root = batch.commit(); - assert_eq!(expected_debug, format!("{:#?}", root)); + assert_eq!(expected_debug, format!("{root:#?}")); } #[test] @@ -661,6 +661,6 @@ pub mod test { batch.replace_node(b, d); let after = batch.commit(); - assert_eq!(expected_debug, format!("{:#?}", after)); + assert_eq!(expected_debug, format!("{after:#?}")); } } diff --git a/crates/biome_rowan/src/ast/mod.rs b/crates/biome_rowan/src/ast/mod.rs index b0f18e213f59..2ffdf2fe745a 100644 --- a/crates/biome_rowan/src/ast/mod.rs +++ b/crates/biome_rowan/src/ast/mod.rs @@ -683,7 +683,7 @@ impl> Iterator for AstSeparatedListElement let node = match slot { // The node for this element is missing if the next child is a token instead of a node. - SyntaxSlot::Token(token) => panic!("Malformed list, node expected but found token {:?} instead. You must add missing markers for missing elements.", token), + SyntaxSlot::Token(token) => panic!("Malformed list, node expected but found token {token:?} instead. You must add missing markers for missing elements."), // Missing element SyntaxSlot::Empty { .. } => Err(SyntaxError::MissingRequiredChild), SyntaxSlot::Node(node) => Ok(N::unwrap_cast(node)) @@ -696,7 +696,7 @@ impl> Iterator for AstSeparatedListElement Some(SyntaxSlot::Token(token)) => Ok(Some(token)), // End of list, no trailing separator None => Ok(None), - Some(SyntaxSlot::Node(node)) => panic!("Malformed separated list, separator expected but found node {:?} instead. You must add missing markers for missing separators.", node), + Some(SyntaxSlot::Node(node)) => panic!("Malformed separated list, separator expected but found node {node:?} instead. You must add missing markers for missing separators."), }; Some(AstSeparatedElement { @@ -734,7 +734,7 @@ impl> DoubleEndedIterator let node = match self.slots.next_back() { None => panic!("Malformed separated list, expected a node but found none"), Some(SyntaxSlot::Empty{ .. }) => Err(SyntaxError::MissingRequiredChild), - Some(SyntaxSlot::Token(token)) => panic!("Malformed list, node expected but found token {:?} instead. You must add missing markers for missing elements.", token), + Some(SyntaxSlot::Token(token)) => panic!("Malformed list, node expected but found token {token:?} instead. You must add missing markers for missing elements."), Some(SyntaxSlot::Node(node)) => { Ok(N::unwrap_cast(node)) } @@ -804,10 +804,9 @@ pub mod support { match parent.slots().nth(slot_index)? { SyntaxSlot::Empty { .. } => None, SyntaxSlot::Node(node) => Some(N::unwrap_cast(node)), - SyntaxSlot::Token(token) => panic!( - "expected a node in the slot {} but found token {:?}", - slot_index, token - ), + SyntaxSlot::Token(token) => { + panic!("expected a node in the slot {slot_index} but found token {token:?}") + } } } @@ -827,17 +826,16 @@ pub mod support { slot_index: usize, ) -> N { required_node(parent, slot_index) - .unwrap_or_else(|_| panic!("expected a list in slot {} of {:?}", slot_index, parent)) + .unwrap_or_else(|_| panic!("expected a list in slot {slot_index} of {parent:?}")) } pub fn token(parent: &SyntaxNode, slot_index: usize) -> Option> { match parent.slots().nth(slot_index)? { SyntaxSlot::Empty { .. } => None, SyntaxSlot::Token(token) => Some(token), - SyntaxSlot::Node(node) => panic!( - "expected a token in the slot {} but found node {:?}", - slot_index, node - ), + SyntaxSlot::Node(node) => { + panic!("expected a token in the slot {slot_index} but found node {node:?}") + } } } diff --git a/crates/biome_rowan/src/cursor/node.rs b/crates/biome_rowan/src/cursor/node.rs index 443a8f543819..2f97dafe7fa0 100644 --- a/crates/biome_rowan/src/cursor/node.rs +++ b/crates/biome_rowan/src/cursor/node.rs @@ -325,9 +325,7 @@ impl SyntaxNode { let range = self.text_range(); assert!( range.start() <= offset && offset <= range.end(), - "Bad offset: range {:?} offset {:?}", - range, - offset + "Bad offset: range {range:?} offset {offset:?}" ); if range.is_empty() { return TokenAtOffset::None; diff --git a/crates/biome_rowan/src/green/node.rs b/crates/biome_rowan/src/green/node.rs index c0b7aac20c52..244c88d62c89 100644 --- a/crates/biome_rowan/src/green/node.rs +++ b/crates/biome_rowan/src/green/node.rs @@ -142,7 +142,7 @@ impl fmt::Display for GreenNode { impl fmt::Display for GreenNodeData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for child in self.slots() { - write!(f, "{}", child)?; + write!(f, "{child}")?; } Ok(()) } diff --git a/crates/biome_rowan/src/green/token.rs b/crates/biome_rowan/src/green/token.rs index 503a43d9cb91..65f7b2b1ca9f 100644 --- a/crates/biome_rowan/src/green/token.rs +++ b/crates/biome_rowan/src/green/token.rs @@ -218,7 +218,7 @@ mod tests { assert_eq!("let", t.text_trimmed()); - assert_eq!("\n\t let \t\t", format!("{}", t)); + assert_eq!("\n\t let \t\t", format!("{t}")); } #[test] diff --git a/crates/biome_rowan/src/syntax/node.rs b/crates/biome_rowan/src/syntax/node.rs index d5238ebd479a..84be32545503 100644 --- a/crates/biome_rowan/src/syntax/node.rs +++ b/crates/biome_rowan/src/syntax/node.rs @@ -770,7 +770,7 @@ impl fmt::Debug for SyntaxNode { SyntaxToken::::from(token) )?, cursor::SyntaxSlot::Empty { index, .. } => { - writeln!(f, "{}: (empty)", index)? + writeln!(f, "{index}: (empty)")? } } level += 1; diff --git a/crates/biome_rowan/src/syntax/trivia.rs b/crates/biome_rowan/src/syntax/trivia.rs index 5cecd19cd679..0286c0a5c741 100644 --- a/crates/biome_rowan/src/syntax/trivia.rs +++ b/crates/biome_rowan/src/syntax/trivia.rs @@ -649,12 +649,12 @@ impl SyntaxTrivia { fn print_debug_str>(text: S, f: &mut fmt::Formatter<'_>) -> fmt::Result { let text = text.as_ref(); if text.len() < 25 { - write!(f, "{:?}", text) + write!(f, "{text:?}") } else { for idx in 21..25 { if text.is_char_boundary(idx) { let text = format!("{} ...", &text[..idx]); - return write!(f, "{:?}", text); + return write!(f, "{text:?}"); } } write!(f, "") @@ -671,7 +671,7 @@ impl std::fmt::Debug for SyntaxTrivia { write!(f, ", ")?; } first_piece = false; - write!(f, "{:?}", piece)?; + write!(f, "{piece:?}")?; } write!(f, "]") diff --git a/crates/biome_rowan/src/syntax_node_text.rs b/crates/biome_rowan/src/syntax_node_text.rs index 2b3875381215..6b3bfbfe3703 100644 --- a/crates/biome_rowan/src/syntax_node_text.rs +++ b/crates/biome_rowan/src/syntax_node_text.rs @@ -417,13 +417,9 @@ mod tests { let t2 = build_tree(t2).text(); let expected = t1.to_string() == t2.to_string(); let actual = t1 == t2; - assert_eq!( - expected, actual, - "`{}` (SyntaxText) `{}` (SyntaxText)", - t1, t2 - ); + assert_eq!(expected, actual, "`{t1}` (SyntaxText) `{t2}` (SyntaxText)"); let actual = t1 == *t2.to_string(); - assert_eq!(expected, actual, "`{}` (SyntaxText) `{}` (&str)", t1, t2); + assert_eq!(expected, actual, "`{t1}` (SyntaxText) `{t2}` (&str)"); } fn check(t1: &[&str], t2: &[&str]) { do_check(t1, t2); @@ -451,8 +447,7 @@ mod tests { assert_eq!( expected, &actual, - "`{}` (SyntaxText) `{}` (SyntaxText)", - actual, expected + "`{actual}` (SyntaxText) `{expected}` (SyntaxText)" ); } diff --git a/crates/biome_service/src/matcher/pattern.rs b/crates/biome_service/src/matcher/pattern.rs index f7dc9329a62d..afbaae34ddab 100644 --- a/crates/biome_service/src/matcher/pattern.rs +++ b/crates/biome_service/src/matcher/pattern.rs @@ -706,13 +706,13 @@ mod test { fn test_range_pattern() { let pat = Pattern::new("a[0-9]b").unwrap(); for i in 0..10 { - assert!(pat.matches(&format!("a{}b", i))); + assert!(pat.matches(&format!("a{i}b"))); } assert!(!pat.matches("a_b")); let pat = Pattern::new("a[!0-9]b").unwrap(); for i in 0..10 { - assert!(!pat.matches(&format!("a{}b", i))); + assert!(!pat.matches(&format!("a{i}b"))); } assert!(pat.matches("a_b")); diff --git a/crates/biome_service/src/workspace_types.rs b/crates/biome_service/src/workspace_types.rs index 36df09a7d986..3c082c41bc26 100644 --- a/crates/biome_service/src/workspace_types.rs +++ b/crates/biome_service/src/workspace_types.rs @@ -64,7 +64,7 @@ fn instance_type<'a>( let mut property = make::ident(property); if let Some(description) = description { - let comment = format!("/**\n\t* {} \n\t */", description); + let comment = format!("/**\n\t* {description} \n\t */"); let trivia = vec![ (TriviaPieceKind::Newline, "\n"), (TriviaPieceKind::MultiLineComment, comment.as_str()), @@ -341,7 +341,7 @@ pub fn generate_type<'a>( let mut property = make::ident(property); if let Some(description) = description { - let comment = format!("/**\n\t* {} \n\t */", description); + let comment = format!("/**\n\t* {description} \n\t */"); let trivia = vec![ (TriviaPieceKind::Newline, "\n"), (TriviaPieceKind::MultiLineComment, comment.as_str()), diff --git a/crates/biome_service/tests/spec_tests.rs b/crates/biome_service/tests/spec_tests.rs index 9bb10c1cc38a..ce1176709932 100644 --- a/crates/biome_service/tests/spec_tests.rs +++ b/crates/biome_service/tests/spec_tests.rs @@ -14,7 +14,7 @@ fn run_invalid_configurations(input: &'static str, _: &str, _: &str, _: &str) { let file_name = input_file.file_name().and_then(OsStr::to_str).unwrap(); let extension = input_file.extension().and_then(OsStr::to_str).unwrap(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let result = match extension { "json" => deserialize_from_json_str::( @@ -65,7 +65,7 @@ fn run_valid_configurations(input: &'static str, _: &str, _: &str, _: &str) { let file_name = input_file.file_name().and_then(OsStr::to_str).unwrap(); let extension = input_file.extension().and_then(OsStr::to_str).unwrap(); let input_code = read_to_string(input_file) - .unwrap_or_else(|err| panic!("failed to read {:?}: {:?}", input_file, err)); + .unwrap_or_else(|err| panic!("failed to read {input_file:?}: {err:?}")); let result = match extension { "json" => deserialize_from_json_str::( @@ -102,8 +102,7 @@ fn run_valid_configurations(input: &'static str, _: &str, _: &str, _: &str) { .join("\n\n"); if has_errors { panic!( - "This test should not have diagnostics, but some have been emitted.\n {}", - diagnostics + "This test should not have diagnostics, but some have been emitted.\n {diagnostics}" ); } } else { diff --git a/crates/biome_string_case/src/lib.rs b/crates/biome_string_case/src/lib.rs index 19dbf1516692..cef6cb142c8c 100644 --- a/crates/biome_string_case/src/lib.rs +++ b/crates/biome_string_case/src/lib.rs @@ -267,7 +267,7 @@ impl std::fmt::Display for Case { Case::Uni => "unicase", Case::Upper => "UPPERCASE", }; - write!(f, "{}", repr) + write!(f, "{repr}") } } diff --git a/crates/biome_test_utils/src/lib.rs b/crates/biome_test_utils/src/lib.rs index f6a4e97820b5..608b8949f114 100644 --- a/crates/biome_test_utils/src/lib.rs +++ b/crates/biome_test_utils/src/lib.rs @@ -232,7 +232,7 @@ pub fn assert_errors_are_absent( diagnostics: &[ParseDiagnostic], path: &Path, ) { - let debug_tree = format!("{:?}", program); + let debug_tree = format!("{program:?}"); let has_missing_children = debug_tree.contains("missing (required)"); if diagnostics.is_empty() && !has_bogus_nodes_or_empty_slots(program) && !has_missing_children { @@ -269,7 +269,7 @@ pub fn write_analyzer_snapshot( ) { writeln!(snapshot, "# Input").unwrap(); writeln!(snapshot, "```{markdown_language}").unwrap(); - writeln!(snapshot, "{}", input_code).unwrap(); + writeln!(snapshot, "{input_code}").unwrap(); writeln!(snapshot, "```").unwrap(); writeln!(snapshot).unwrap(); @@ -277,7 +277,7 @@ pub fn write_analyzer_snapshot( writeln!(snapshot, "# Diagnostics").unwrap(); for diagnostic in diagnostics { writeln!(snapshot, "```").unwrap(); - writeln!(snapshot, "{}", diagnostic).unwrap(); + writeln!(snapshot, "{diagnostic}").unwrap(); writeln!(snapshot, "```").unwrap(); writeln!(snapshot).unwrap(); } @@ -287,7 +287,7 @@ pub fn write_analyzer_snapshot( writeln!(snapshot, "# Actions").unwrap(); for action in code_fixes { writeln!(snapshot, "```diff").unwrap(); - writeln!(snapshot, "{}", action).unwrap(); + writeln!(snapshot, "{action}").unwrap(); writeln!(snapshot, "```").unwrap(); writeln!(snapshot).unwrap(); } @@ -301,16 +301,16 @@ pub fn write_transformation_snapshot( extension: &str, ) { writeln!(snapshot, "# Input").unwrap(); - writeln!(snapshot, "```{}", extension).unwrap(); - writeln!(snapshot, "{}", input_code).unwrap(); + writeln!(snapshot, "```{extension}").unwrap(); + writeln!(snapshot, "{input_code}").unwrap(); writeln!(snapshot, "```").unwrap(); writeln!(snapshot).unwrap(); if !transformations.is_empty() { writeln!(snapshot, "# Transformations").unwrap(); for transformation in transformations { - writeln!(snapshot, "```{}", extension).unwrap(); - writeln!(snapshot, "{}", transformation).unwrap(); + writeln!(snapshot, "```{extension}").unwrap(); + writeln!(snapshot, "{transformation}").unwrap(); writeln!(snapshot, "```").unwrap(); writeln!(snapshot).unwrap(); } diff --git a/crates/biome_text_size/src/serde_impls.rs b/crates/biome_text_size/src/serde_impls.rs index a94bee9567a2..b6885d674ac2 100644 --- a/crates/biome_text_size/src/serde_impls.rs +++ b/crates/biome_text_size/src/serde_impls.rs @@ -39,8 +39,7 @@ impl<'de> Deserialize<'de> for TextRange { let (start, end) = Deserialize::deserialize(deserializer)?; if !(start <= end) { return Err(de::Error::custom(format!( - "invalid range: {:?}..{:?}", - start, end + "invalid range: {start:?}..{end:?}" ))); } Ok(TextRange::new(start, end)) diff --git a/crates/tests_macros/src/lib.rs b/crates/tests_macros/src/lib.rs index d6522c1daab0..0cda5b34d72f 100644 --- a/crates/tests_macros/src/lib.rs +++ b/crates/tests_macros/src/lib.rs @@ -175,7 +175,7 @@ impl Arguments { "{}{}", file_stem.to_snake(), if let Some(extension) = path.extension().and_then(|ext| ext.to_str()) { - format!("_{}", extension) + format!("_{extension}") } else { String::new() } @@ -190,7 +190,7 @@ impl Arguments { let mut test_expected_file = path.to_path_buf(); test_expected_file.pop(); - test_expected_file.push(format!("{}.expected{}", file_stem, extension)); + test_expected_file.push(format!("{file_stem}.expected{extension}")); let test_expected_fullpath = test_expected_file.display().to_string(); Some(Variables { diff --git a/xtask/bench/benches/css_analyzer.rs b/xtask/bench/benches/css_analyzer.rs index b26b3775b621..dddd0bb3450e 100644 --- a/xtask/bench/benches/css_analyzer.rs +++ b/xtask/bench/benches/css_analyzer.rs @@ -49,7 +49,7 @@ fn bench_analyzer(criterion: &mut Criterion) { }, ); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } diff --git a/xtask/bench/benches/css_formatter.rs b/xtask/bench/benches/css_formatter.rs index b1d8a210c58c..77b8b5209ca0 100644 --- a/xtask/bench/benches/css_formatter.rs +++ b/xtask/bench/benches/css_formatter.rs @@ -30,7 +30,7 @@ fn bench_css_formatter(criterion: &mut Criterion) { Ok(test_case) => { bench_formatter_group(&mut group, test_case); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } group.finish(); diff --git a/xtask/bench/benches/css_parser.rs b/xtask/bench/benches/css_parser.rs index 66f7a2cdb73b..f350066a2f9b 100644 --- a/xtask/bench/benches/css_parser.rs +++ b/xtask/bench/benches/css_parser.rs @@ -30,7 +30,7 @@ fn bench_css_parser(criterion: &mut Criterion) { Ok(test_case) => { bench_parser_group(&mut group, test_case); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } group.finish(); diff --git a/xtask/bench/benches/graphql_parser.rs b/xtask/bench/benches/graphql_parser.rs index 29efad752173..0856e8680739 100644 --- a/xtask/bench/benches/graphql_parser.rs +++ b/xtask/bench/benches/graphql_parser.rs @@ -30,7 +30,7 @@ fn bench_css_parser(criterion: &mut Criterion) { Ok(test_case) => { bench_parser_group(&mut group, test_case); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } group.finish(); diff --git a/xtask/bench/benches/js_analyzer.rs b/xtask/bench/benches/js_analyzer.rs index 52cbb498f43a..a454c6f246b1 100644 --- a/xtask/bench/benches/js_analyzer.rs +++ b/xtask/bench/benches/js_analyzer.rs @@ -50,7 +50,7 @@ fn bench_analyzer(criterion: &mut Criterion) { }, ); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } diff --git a/xtask/bench/benches/js_formatter.rs b/xtask/bench/benches/js_formatter.rs index 73175389012b..f45c2176764a 100644 --- a/xtask/bench/benches/js_formatter.rs +++ b/xtask/bench/benches/js_formatter.rs @@ -32,7 +32,7 @@ fn bench_js_formatter(criterion: &mut Criterion) { Ok(test_case) => { bench_formatter_group(&mut group, test_case); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } group.finish(); diff --git a/xtask/bench/benches/js_parser.rs b/xtask/bench/benches/js_parser.rs index db5fd629c02e..f899d7dbf228 100644 --- a/xtask/bench/benches/js_parser.rs +++ b/xtask/bench/benches/js_parser.rs @@ -31,7 +31,7 @@ fn bench_js_parser(criterion: &mut Criterion) { Ok(test_case) => { bench_parser_group(&mut group, test_case); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } group.finish(); diff --git a/xtask/bench/benches/json_formatter.rs b/xtask/bench/benches/json_formatter.rs index 215995090f31..16e86ef8dd14 100644 --- a/xtask/bench/benches/json_formatter.rs +++ b/xtask/bench/benches/json_formatter.rs @@ -31,7 +31,7 @@ fn bench_json_formatter(criterion: &mut Criterion) { Ok(test_case) => { bench_formatter_group(&mut group, test_case); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } group.finish(); diff --git a/xtask/bench/benches/json_parser.rs b/xtask/bench/benches/json_parser.rs index df4b8e35c325..74b9fe442950 100644 --- a/xtask/bench/benches/json_parser.rs +++ b/xtask/bench/benches/json_parser.rs @@ -30,7 +30,7 @@ fn bench_json_parser(criterion: &mut Criterion) { Ok(test_case) => { bench_parser_group(&mut group, test_case); } - Err(e) => println!("{:?}", e), + Err(e) => println!("{e:?}"), } } group.finish(); diff --git a/xtask/bench/src/lib.rs b/xtask/bench/src/lib.rs index e137ff36aec9..cfb8c4794577 100644 --- a/xtask/bench/src/lib.rs +++ b/xtask/bench/src/lib.rs @@ -23,7 +23,7 @@ pub fn run_format(format_node: &FormatNode) -> Printed { } pub fn err_to_string(e: E) -> String { - format!("{:?}", e) + format!("{e:?}") } pub fn bench_parser_group(group: &mut BenchmarkGroup, test_case: TestCase) { diff --git a/xtask/codegen/src/ast.rs b/xtask/codegen/src/ast.rs index 2a575befc17e..cf40032324fb 100644 --- a/xtask/codegen/src/ast.rs +++ b/xtask/codegen/src/ast.rs @@ -140,16 +140,16 @@ fn check_unions(unions: &[AstEnumSrc]) { union_queue.extend(¤t_union.variants); } else { // We either have a circular dependency or 2 variants referencing the same type - println!("{}", stack_string); + println!("{stack_string}"); panic!("Variant '{variant}' used twice or circular dependency"); } } else { // The variant isn't another enum // stack_string.push_str(&format!()); - write!(stack_string, "\nBASE-VAR CHECK : {}", variant).unwrap(); + write!(stack_string, "\nBASE-VAR CHECK : {variant}").unwrap(); if !union_set.insert(variant) { // The variant already used - println!("{}", stack_string); + println!("{stack_string}"); panic!("Variant '{variant}' used twice"); } } @@ -335,7 +335,7 @@ fn clean_token_name(grammar: &Grammar, token: &Token) -> String { // that can't be recognized by [quote]. // Hence, they need to be decorated with single quotes. if "[]{}()`".contains(&name) { - name = format!("'{}'", name); + name = format!("'{name}'"); } name } @@ -388,7 +388,7 @@ fn handle_rule( } Rule::Rep(_) => { - panic!("Create a list node for *many* children {:?}", label); + panic!("Create a list node for *many* children {label:?}"); } Rule::Opt(rule) => { handle_rule(fields, grammar, rule, label, true, false); @@ -398,8 +398,7 @@ fn handle_rule( // within an Opt, like `(A | B)?`. For those, make a new Rule. if optional { panic!( - "Alternates cannot be nested within an optional Rule. Use a new Node to contain the alternate {:?}", - label + "Alternates cannot be nested within an optional Rule. Use a new Node to contain the alternate {label:?}" ); } for rule in rules { @@ -474,7 +473,7 @@ fn handle_comma_list<'a>(grammar: &'a Grammar, rules: &[Rule]) -> Option &grammar[*token].name, - _ => panic!("The separator in rule {:?} must be a token", rules), + _ => panic!("The separator in rule {rules:?} must be a token"), }; Some(CommaList { diff --git a/xtask/codegen/src/formatter.rs b/xtask/codegen/src/formatter.rs index 46799bd762eb..66b3c1b16671 100644 --- a/xtask/codegen/src/formatter.rs +++ b/xtask/codegen/src/formatter.rs @@ -595,7 +595,7 @@ impl NodeDialect { "Css" => NodeDialect::Css, "Grit" => NodeDialect::Grit, _ => { - eprintln!("missing prefix {}", name); + eprintln!("missing prefix {name}"); NodeDialect::Js } } diff --git a/xtask/codegen/src/generate_crate.rs b/xtask/codegen/src/generate_crate.rs index cdc655c90bf7..b55d14f1743b 100644 --- a/xtask/codegen/src/generate_crate.rs +++ b/xtask/codegen/src/generate_crate.rs @@ -43,13 +43,11 @@ pub fn generate_crate(crate_name: String) -> Result<()> { let end_content = "\n## End of crates. DO NOT CHANGE!"; debug_assert!( knope_contents.contains(start_content), - "The file knope.toml must contains `{}`", - start_content + "The file knope.toml must contains `{start_content}`" ); debug_assert!( knope_contents.contains(end_content), - "The file knope.toml must contains `{}`", - end_content + "The file knope.toml must contains `{end_content}`" ); let file_start_index = knope_contents.find(start_content).unwrap() + start_content.len(); diff --git a/xtask/codegen/src/generate_nodes.rs b/xtask/codegen/src/generate_nodes.rs index b9dfc7fbdc57..9bad2a9a8ede 100644 --- a/xtask/codegen/src/generate_nodes.rs +++ b/xtask/codegen/src/generate_nodes.rs @@ -759,7 +759,7 @@ pub fn generate_nodes(ast: &AstSrc, language_kind: LanguageKind) -> Result Ok(LanguageKind::Html), "yaml" => Ok(LanguageKind::Yaml), _ => Err(format!( - "Language {} not supported, please use: `js`, `css`, `json`, `grit`, `graphql`, `html`, `yaml` or yml", - kind + "Language {kind} not supported, please use: `js`, `css`, `json`, `grit`, `graphql`, `html`, `yaml` or yml" )), } } @@ -170,15 +169,15 @@ impl LanguageKind { } pub fn formatter_crate_name(&self) -> String { - format!("biome_{}_formatter", self) + format!("biome_{self}_formatter") } pub fn syntax_crate_name(&self) -> String { - format!("biome_{}_syntax", self) + format!("biome_{self}_syntax") } pub fn factory_crate_name(&self) -> String { - format!("biome_{}_factory", self) + format!("biome_{self}_factory") } pub fn kinds(&self) -> KindsSrc { diff --git a/xtask/codegen/src/parser_tests.rs b/xtask/codegen/src/parser_tests.rs index 131aebf181aa..50c2ccdbf790 100644 --- a/xtask/codegen/src/parser_tests.rs +++ b/xtask/codegen/src/parser_tests.rs @@ -54,7 +54,7 @@ pub fn generate_parser_tests(mode: Mode) -> Result<()> { let existing = existing_tests(&tests_dir, true)?; if let Some(t) = existing.keys().find(|&t| !tests.contains_key(t)) { - panic!("Test is deleted: '{}'", t); + panic!("Test is deleted: '{t}'"); } let mut some_file_was_updated = false; @@ -172,7 +172,7 @@ fn collect_tests(s: &str) -> Vec { Some(("d.ts", suffix)) => (Language::TypeScriptDefinition, suffix), Some(("tsx", suffix)) => (Language::Tsx, suffix), Some((_, suffix)) => (Language::JavaScript, suffix), - _ => panic!("wrong test configuration: {:?}", suffix), + _ => panic!("wrong test configuration: {suffix:?}"), }; let (name, options) = match suffix.split_once(' ') { @@ -251,7 +251,7 @@ fn existing_tests(dir: &Path, ok: bool) -> Result HashMap { let buffer = fs::read(path) - .unwrap_or_else(|err| panic!("Can't read the file of the {} results: {:?}", name, err)); + .unwrap_or_else(|err| panic!("Can't read the file of the {name} results: {err:?}")); let content = decode_maybe_utf16_string(&buffer) - .unwrap_or_else(|err| panic!("Can't read the file of the {} results: {:?}", name, err)); - - serde_json::from_str(&content).unwrap_or_else(|err| { - panic!( - "Can't parse the JSON file of the {} results: {:?}", - name, err - ) - }) + .unwrap_or_else(|err| panic!("Can't read the file of the {name} results: {err:?}")); + + serde_json::from_str(&content) + .unwrap_or_else(|err| panic!("Can't parse the JSON file of the {name} results: {err:?}")) } diff --git a/xtask/coverage/src/reporters.rs b/xtask/coverage/src/reporters.rs index b239a714aa8b..90eb8385d9c0 100644 --- a/xtask/coverage/src/reporters.rs +++ b/xtask/coverage/src/reporters.rs @@ -201,7 +201,7 @@ impl SummaryReporter { } fn writeln(&mut self, msg: &str) { - writeln!(self.buffer, "{}", msg).unwrap(); + writeln!(self.buffer, "{msg}").unwrap(); } fn summary_table(results: HashMap) -> String { @@ -364,7 +364,7 @@ impl TestReporter for SummaryReporter { .write_all(self.buffer.as_slice()) .unwrap(); - writeln!(self.output_target, "{}", table).unwrap(); + writeln!(self.output_target, "{table}").unwrap(); } } diff --git a/xtask/coverage/src/results.rs b/xtask/coverage/src/results.rs index ca31de467a10..e67d8875775b 100644 --- a/xtask/coverage/src/results.rs +++ b/xtask/coverage/src/results.rs @@ -43,17 +43,17 @@ pub fn emit_compare( match diff.cmp(&0) { std::cmp::Ordering::Less => { if i_am_passed_results { - format!("{}{}", bad, down) + format!("{bad}{down}") } else { - format!("{}{}", good, down) + format!("{good}{down}") } } std::cmp::Ordering::Equal => String::new(), std::cmp::Ordering::Greater => { if i_am_passed_results { - format!("{}{}", good, up) + format!("{good}{up}") } else { - format!("{}{}", bad, up) + format!("{bad}{up}") } } } @@ -71,7 +71,7 @@ pub fn emit_compare( ) } - println!("\n### {}\n", test_suite); + println!("\n### {test_suite}\n"); println!("| Test result | `main` count | This PR count | Difference |"); println!("| :---------: | :----------: | :-----------: | :--------: |"); @@ -137,7 +137,7 @@ pub fn emit_compare( let mut test_cases = tests.iter().map(|test| &test.test_case).collect::>(); test_cases.sort_unstable(); for test_case in test_cases { - println!("{}", test_case); + println!("{test_case}"); } println!("```"); println!(""); @@ -159,7 +159,7 @@ pub fn emit_compare( } else { let mut table = AsciiTable::default(); - println!("{} conformance changes:", test_suite); + println!("{test_suite} conformance changes:"); table .column(0) diff --git a/xtask/coverage/src/runner.rs b/xtask/coverage/src/runner.rs index 79305fa4de8f..1fac5cb7679a 100644 --- a/xtask/coverage/src/runner.rs +++ b/xtask/coverage/src/runner.rs @@ -156,7 +156,7 @@ impl TestCaseFiles { if let Err(err) = Formatter::new(&mut Termcolor(&mut *buffer)).write_markup(markup! { {PrintDiagnostic::verbose(error)} }) { - eprintln!("Failed to print diagnostic: {}", err); + eprintln!("Failed to print diagnostic: {err}"); } } } @@ -246,20 +246,20 @@ pub(crate) fn run_test_suite( let _ = write!(stacktrace, "{}", file.display()); } else if let Some(name) = s.name().and_then(|x| x.as_str()) { - let _ = write!(stacktrace, "{}", name); + let _ = write!(stacktrace, "{name}"); } else { let _ = write!(stacktrace, ""); } match (s.lineno(), s.colno()) { (Some(line), Some(col)) => { - let _ = write!(stacktrace, " @ line {} col {}", line, col); + let _ = write!(stacktrace, " @ line {line} col {col}"); } (Some(line), None) => { - let _ = write!(stacktrace, " @ line {}", line); + let _ = write!(stacktrace, " @ line {line}"); } (None, Some(col)) => { - let _ = write!(stacktrace, " @ col {}", col); + let _ = write!(stacktrace, " @ col {col}"); } _ => {} } @@ -271,7 +271,7 @@ pub(crate) fn run_test_suite( let stacktrace = String::from_utf8(stacktrace).unwrap(); let mut msg = vec![]; - let _ = write!(msg, "{}", info); + let _ = write!(msg, "{info}"); let msg = String::from_utf8(msg).unwrap(); tracing::error!( diff --git a/xtask/coverage/src/symbols/msts.rs b/xtask/coverage/src/symbols/msts.rs index 2e3248b1aaa1..6b768a3e5ae0 100644 --- a/xtask/coverage/src/symbols/msts.rs +++ b/xtask/coverage/src/symbols/msts.rs @@ -139,7 +139,7 @@ impl TestCase for SymbolsMicrosoftTestCase { if let Some(actual) = actual { let name = &code[actual.range()].trim(); - write!(debug_text, "[{}]", name).unwrap(); + write!(debug_text, "[{name}]").unwrap(); } match (expected, actual) { diff --git a/xtask/coverage/src/ts/ts_microsoft.rs b/xtask/coverage/src/ts/ts_microsoft.rs index 4a0af034eb8d..09a3e46bc319 100644 --- a/xtask/coverage/src/ts/ts_microsoft.rs +++ b/xtask/coverage/src/ts/ts_microsoft.rs @@ -144,7 +144,7 @@ fn extract_metadata(code: &str, path: &str) -> TestCaseMetadata { let option_value = option.name("value").unwrap().as_str().trim(); if option_name == "alwaysstrict" { - write!(current_file_content, "\"use strict\";{}", line_ending).unwrap(); + write!(current_file_content, "\"use strict\";{line_ending}").unwrap(); } else if matches!(option_name.as_str(), "module" | "target") && files.is_empty() { run_options.extend( option_value @@ -172,7 +172,7 @@ fn extract_metadata(code: &str, path: &str) -> TestCaseMetadata { // skip leading whitespace continue; } - write!(current_file_content, "{}{}", line, line_ending).unwrap(); + write!(current_file_content, "{line}{line_ending}").unwrap(); } } diff --git a/xtask/libs_bench/benches/contains.rs b/xtask/libs_bench/benches/contains.rs index ed4ab56a912d..f76c373bd351 100644 --- a/xtask/libs_bench/benches/contains.rs +++ b/xtask/libs_bench/benches/contains.rs @@ -13,7 +13,7 @@ pub fn keywords() -> Vec { let v = &["undefined", "NaN", "Infinity", "arguments", "eval"].repeat(repeat); v.iter() .enumerate() - .map(|(i, x)| format!("{}{}", x, i)) + .map(|(i, x)| format!("{x}{i}")) .collect() } diff --git a/xtask/libs_bench/bins/contains_iai.rs b/xtask/libs_bench/bins/contains_iai.rs index 154390ba02d4..72375065909a 100644 --- a/xtask/libs_bench/bins/contains_iai.rs +++ b/xtask/libs_bench/bins/contains_iai.rs @@ -22,7 +22,7 @@ fn main() { for (k, v_setup) in tests.iter() { if let Some(name) = k.strip_suffix("_setup") { let v_all = tests[name]; - println!("{}", name); + println!("{name}"); println!( "\tdiff inst: {} is {} - {}", v_all.0 - v_setup.0, diff --git a/xtask/src/glue.rs b/xtask/src/glue.rs index 4820627bf540..f8cdb782098d 100644 --- a/xtask/src/glue.rs +++ b/xtask/src/glue.rs @@ -112,7 +112,7 @@ pub fn rm_rf(path: impl AsRef) -> Result<()> { #[doc(hidden)] pub fn run_process(cmd: String, echo: bool, stdin: Option<&[u8]>) -> Result { - run_process_inner(&cmd, echo, stdin).with_context(|| format!("process `{}` failed", cmd)) + run_process_inner(&cmd, echo, stdin).with_context(|| format!("process `{cmd}` failed")) } pub fn date_iso() -> Result { @@ -125,7 +125,7 @@ fn run_process_inner(cmd: &str, echo: bool, stdin: Option<&[u8]>) -> Result {}", cmd) + println!("> {cmd}") } let mut command = Command::new(binary); @@ -145,7 +145,7 @@ fn run_process_inner(cmd: &str, echo: bool, stdin: Option<&[u8]>) -> Result Result { pub fn reformat_with_command(text: impl Display, command: impl Display) -> Result { reformat_without_preamble(text).map(|formatted| { - format!("//! This is a generated file. Don't modify it by hand! Run '{}' to re-generate the file.\n\n{}", command, formatted) + format!("//! This is a generated file. Don't modify it by hand! Run '{command}' to re-generate the file.\n\n{formatted}") }) } pub const PREAMBLE: &str = "Generated file, do not edit by hand, see `xtask/codegen`"; pub fn prepend_generated_preamble(content: impl Display) -> String { - format!("//! {}\n\n{}", PREAMBLE, content) + format!("//! {PREAMBLE}\n\n{content}") } pub fn reformat_without_preamble(text: impl Display) -> Result { @@ -62,7 +62,7 @@ pub fn reformat_without_preamble(text: impl Display) -> Result { Result<()> {