chore: upgrade toolchain to latest stable version 1.62.0
MODIFY
crates/rome_js_formatter/src/utils/format_conditional.rs
crates/rome_js_formatter/src/utils/format_conditional.rs
@@ -78,7 +78,7 @@ impl Conditional {
let format_alternate = format_with(|f| self.format_with_alternate(f, alternate.as_ref()));
- let _body = if left_or_right_is_conditional || parent_is_conditional {
+ if left_or_right_is_conditional || parent_is_conditional {
write!(
f,
[indent(&format_args![

MODIFY
crates/rome_js_formatter/tests/spec_test.rs
crates/rome_js_formatter/tests/spec_test.rs
@@ -9,6 +9,7 @@ use rome_service::workspace::{FeatureName, SupportsFeatureParams};
use rome_service::App;
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
+use std::fmt::Write;
use std::fs;
use std::path::{Path, PathBuf};
@@ -99,7 +100,7 @@ impl SnapshotContent {
output.push_str("## Unimplemented nodes/tokens");
output.push_str("\n\n");
for (range, text) in formatted.verbatim() {
- output.push_str(&format!("{:?} => {:?}\n", text, range));
+ writeln!(output, "{:?} => {:?}", text, range).unwrap();
}
}
@@ -111,13 +112,15 @@ impl SnapshotContent {
.peekable();
if exceeding_lines.peek().is_some() {
- output.push_str(&format!(
+ write!(
+ output,
"\n\n## Lines exceeding width of {line_width_limit} characters\n\n"
- ));
+ )
+ .unwrap();
for (line_index, text) in exceeding_lines {
let line_number = line_index + 1;
- output.push_str(&format!("{line_number:>5}: {text}\n"));
+ writeln!(output, "{line_number:>5}: {text}").unwrap();
}
}
@@ -139,9 +142,9 @@ impl SnapshotContent {
let iter = self.output.iter();
for (index, (content, options)) in iter.enumerate() {
let formal_index = index + 1;
- output.push_str(format!("## Output {formal_index}\n").as_str());
+ writeln!(output, "## Output {formal_index}").unwrap();
output.push_str("-----\n");
- output.push_str(format!("{}", options).as_str());
+ write!(output, "{}", options).unwrap();
output.push_str("-----\n");
output.push_str(content.as_str());
}

MODIFY
crates/rome_js_parser/src/syntax/expr.rs
crates/rome_js_parser/src/syntax/expr.rs
@@ -206,7 +206,11 @@ pub(crate) fn parse_number_literal_expression(p: &mut Parser) -> ParsedSyntax {
// Forbid legacy octal number in strict mode
if p.state.strict().is_some()
&& cur_src.starts_with('0')
- && cur_src.chars().nth(1).filter(|c| c.is_digit(10)).is_some()
+ && cur_src
+ .chars()
+ .nth(1)
+ .filter(|c| c.is_ascii_digit())
+ .is_some()
{
let err_msg = if cur_src.contains(['8', '9']) {
"Decimals with leading zeros are not allowed in strict mode."

MODIFY
crates/rome_js_parser/src/tests.rs
crates/rome_js_parser/src/tests.rs
@@ -6,7 +6,7 @@ use rome_diagnostics::{file::SimpleFiles, Emitter};
use rome_js_syntax::{JsAnyRoot, JsLanguage, JsSyntaxKind, SourceType};
use rome_js_syntax::{JsCallArguments, JsLogicalExpression, JsSyntaxNode, JsSyntaxToken};
use rome_rowan::{AstNode, Direction, SyntaxKind, TextSize};
-use std::fmt::Debug;
+use std::fmt::{Debug, Write};
use std::panic::catch_unwind;
use std::path::{Path, PathBuf};
@@ -127,12 +127,14 @@ fn run_and_expect_errors(path: &str, _: &str, _: &str, _: &str) {
emitter
.emit_with_writer(diag, &mut write)
.expect("failed to emit diagnostic");
- actual.push_str(&format!(
+ write!(
+ actual,
"--\n{}",
std::str::from_utf8(write.as_slice()).expect("non utf8 in error buffer")
- ));
+ )
+ .unwrap();
}
- actual.push_str(&format!("--\n{}", text));
+ write!(actual, "--\n{}", text).unwrap();
let path = path.with_extension("rast");
expect_file![path].assert_eq(&actual)

MODIFY
crates/rome_js_semantic/src/tests/mod.rs
crates/rome_js_semantic/src/tests/mod.rs
@@ -9,7 +9,7 @@ macro_rules! assert_semantics {
$(
#[test]
pub fn $name() {
- crate::tests::assertions::assert($code, stringify!($name));
+ $crate::tests::assertions::assert($code, stringify!($name));
}
)*
};

MODIFY
crates/rome_rowan/src/syntax/node.rs
crates/rome_rowan/src/syntax/node.rs
@@ -763,9 +763,9 @@ impl<L: Language> Iterator for SyntaxSlots<L> {
}
}
-impl<'a, L: Language> FusedIterator for SyntaxSlots<L> {}
+impl<L: Language> FusedIterator for SyntaxSlots<L> {}
-impl<'a, L: Language> ExactSizeIterator for SyntaxSlots<L> {
+impl<L: Language> ExactSizeIterator for SyntaxSlots<L> {
fn len(&self) -> usize {
self.raw.len()
}

MODIFY
rust-toolchain.toml
rust-toolchain.toml
# The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy.
# https://rust-lang.github.io/rustup/concepts/profiles.html
profile = "default"
-channel = "1.61.0"
+channel = "1.62.0"

MODIFY
xtask/codegen/src/ast.rs
xtask/codegen/src/ast.rs
@@ -24,9 +24,9 @@ use crate::{
kinds_src::{AstEnumSrc, AstNodeSrc, JS_KINDS_SRC},
update, LanguageKind,
};
+use std::fmt::Write;
use ungrammar::{Grammar, Rule, Token};
use xtask::{project_root, Result};
-
// these node won't generate any code
pub const SYNTAX_ELEMENT_TYPE: &str = "SyntaxElement";
@@ -144,10 +144,12 @@ fn check_unions(unions: &[AstEnumSrc]) {
// The variant is a compound variant
// Get the struct from the map
let current_union = union_map[variant];
- stack_string.push_str(&format!(
+ write!(
+ stack_string,
"\nSUB-ENUM CHECK : {}, variants : {:?}",
current_union.name, current_union.variants
- ));
+ )
+ .unwrap();
// Try to insert the current variant into the set
if union_set.insert(&current_union.name) {
// Add all variants into the BFS queue
@@ -159,7 +161,8 @@ fn check_unions(unions: &[AstEnumSrc]) {
}
} else {
// The variant isn't another enum
- stack_string.push_str(&format!("\nBASE-VAR CHECK : {}", variant));
+ // stack_string.push_str(&format!());
+ write!(stack_string, "\nBASE-VAR CHECK : {}", variant).unwrap();
if !union_set.insert(variant) {
// The variant already used
println!("{}", stack_string);

MODIFY
xtask/coverage/src/symbols/msts.rs
xtask/coverage/src/symbols/msts.rs
use rome_js_semantic::SemanticEvent;
use rome_js_syntax::SourceType;
+use super::utils::{parse_separated_list, parse_str, parse_until_chr, parse_whitespace0};
use crate::check_file_encoding;
use crate::runner::{TestCase, TestCaseFiles, TestRunOutcome, TestSuite};
+use std::fmt::Write;
use std::path::{Path, PathBuf};
use std::str::FromStr;
-use super::utils::{parse_separated_list, parse_str, parse_until_chr, parse_whitespace0};
-
const CASES_PATH: &str = "xtask/coverage/Typescript/tests/baselines/reference";
const BASE_PATH: &str = "xtask/coverage/Typescript";
@@ -107,14 +107,14 @@ impl TestCase for SymbolsMicrosoftTestCase {
debug_text.push_str("expected: ");
if let Some(symbol) = expected {
- debug_text.push_str(&format!("[{}]", &symbol.name));
+ write!(debug_text, "[{}]", &symbol.name).unwrap();
}
debug_text.push_str(" - actual: ");
if let Some(actual) = actual {
let name = actual.str(&code).trim();
- debug_text.push_str(&format!("[{}]", name));
+ write!(debug_text, "[{}]", name).unwrap();
}
match (expected, actual) {

MODIFY
xtask/coverage/src/ts/ts_microsoft.rs
xtask/coverage/src/ts/ts_microsoft.rs
@@ -6,6 +6,7 @@ use regex::Regex;
use rome_js_syntax::{ModuleKind, SourceType};
use rome_rowan::{AstNode, SyntaxKind};
use std::convert::TryFrom;
+use std::fmt::Write;
use std::path::Path;
const CASES_PATH: &str = "xtask/coverage/Typescript/tests/cases";
@@ -121,7 +122,7 @@ fn extract_metadata(code: &str, path: &str) -> TestCaseMetadata {
let option_value = option.name("value").unwrap().as_str().trim();
if option_name == "alwaysstrict" {
- current_file_content.push_str(&format!("\"use strict\";{}", line_ending))
+ 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
@@ -150,8 +151,7 @@ fn extract_metadata(code: &str, path: &str) -> TestCaseMetadata {
// skip leading whitespace
continue;
}
-
- current_file_content.push_str(&format!("{}{}", line, line_ending));
+ write!(current_file_content, "{}{}", line, line_ending).unwrap();
}
}

chore: upgrade toolchain to latest stable version 1.62.0 (#2802)