From ef1108a7499fbf04adcc659e2db6176a3eca69be Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 22 Mar 2024 01:21:57 +0800 Subject: [PATCH] chore: Rust v1.77.0 (#2781) --- Cargo.toml | 108 +++++++++--------- crates/oxc_cli/Cargo.toml | 2 +- .../oxc_linter/src/config/settings/jsdoc.rs | 10 +- .../rules/eslint/array_callback_return/mod.rs | 4 +- .../src/rules/jest/no_identical_title.rs | 8 +- .../src/rules/jest/no_jasmine_globals.rs | 4 +- crates/oxc_linter/src/rules/react/jsx_key.rs | 14 +-- crates/oxc_parser/Cargo.toml | 2 +- crates/oxc_parser/examples/multi-thread.rs | 3 + crates/oxc_prettier/src/format/assignment.rs | 2 + crates/oxc_semantic/Cargo.toml | 10 +- crates/oxc_semantic/src/jsdoc/finder.rs | 4 +- crates/oxc_semantic/src/jsdoc/parser/utils.rs | 2 +- crates/oxc_transformer/src/typescript/mod.rs | 12 +- justfile | 2 +- rust-toolchain.toml | 2 +- 16 files changed, 90 insertions(+), 99 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 055a5d128..9d32ea52e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,64 +80,64 @@ oxc_syntax = { version = "0.10.0", path = "crates/oxc_syntax" } oxc_transformer = { version = "0.10.0", path = "crates/oxc_transformer" } # publish = false -oxc_macros = { path = "crates/oxc_macros" } -oxc_linter = { path = "crates/oxc_linter" } -oxc_prettier = { path = "crates/oxc_prettier" } -oxc_tasks_common = { path = "tasks/common" } +oxc_macros = { path = "crates/oxc_macros" } +oxc_linter = { path = "crates/oxc_linter" } +oxc_prettier = { path = "crates/oxc_prettier" } +oxc_tasks_common = { path = "tasks/common" } napi = { version = "2" } napi-derive = { version = "2" } -assert-unchecked = { version = "0.1.2" } -bpaf = { version = "0.9.9" } -bitflags = { version = "2.4.2" } -bumpalo = { version = "3.15.4" } -convert_case = { version = "0.6.0" } -dashmap = { version = "5.5.3" } -flate2 = { version = "1.0.28" } -futures = { version = "0.3.30" } -glob = { version = "0.3.1" } -ignore = { version = "0.4.22" } -itertools = { version = "0.12.1" } -jemallocator = { version = "0.5.4" } -lazy_static = { version = "1.4.0" } -miette = { version = "7.2.0", features = ["fancy-no-syscall"] } -mimalloc = { version = "0.1.39" } -num-bigint = { version = "0.4.4" } -num-traits = { version = "0.2.18" } -phf = { version = "0.11" } -pico-args = { version = "0.5.0" } -proc-macro2 = { version = "1.0.79" } -project-root = { version = "0.2.2" } -quote = { version = "1.0.35" } -rayon = { version = "1.9.0" } -regex = { version = "1.10.3" } -rustc-hash = { version = "1.1.0", default-features = false, features = ["std"] } -ryu-js = { version = "1.0.1" } -ropey = { version = "1.6.1" } -seq-macro = { version = "0.3.5" } -serde = { version = "1.0.197" } -serde_json = { version = "1.0.114" } -syn = { version = "=1.0.109" } -tempfile = { version = "3.10.1" } -thiserror = { version = "1.0.58" } -tokio = { version = "1" } -tower-lsp = { version = "0.20.0", features = ["proposed"] } -unicode-id-start = { version = "1.1.2" } -ureq = { version = "2.9.6", default-features = false, features = ["tls", "json"] } -url = { version = "2.5.0" } -walkdir = { version = "2.5.0" } -indexmap = { version = "2.2.5" } -index_vec = { version = "0.1.3" } -static_assertions = { version = "1.1.0" } -tracing-subscriber = { version = "0.3" } -insta = { version = "1.36.1", features = ["glob"] } -mime_guess = { version = "2.0.4" } -language-tags = { version = "0.3.2" } -tsify = { version = "0.4.5" } -wasm-bindgen = { version = "0.2" } -serde-wasm-bindgen = { version = "0.6.5" } -handlebars = { version = "5.1.0" } +assert-unchecked = { version = "0.1.2" } +bpaf = { version = "0.9.9" } +bitflags = { version = "2.4.2" } +bumpalo = { version = "3.15.4" } +convert_case = { version = "0.6.0" } +dashmap = { version = "5.5.3" } +flate2 = { version = "1.0.28" } +futures = { version = "0.3.30" } +glob = { version = "0.3.1" } +ignore = { version = "0.4.22" } +itertools = { version = "0.12.1" } +jemallocator = { version = "0.5.4" } +lazy_static = { version = "1.4.0" } +miette = { version = "7.2.0", features = ["fancy-no-syscall"] } +mimalloc = { version = "0.1.39" } +num-bigint = { version = "0.4.4" } +num-traits = { version = "0.2.18" } +phf = { version = "0.11" } +pico-args = { version = "0.5.0" } +proc-macro2 = { version = "1.0.79" } +project-root = { version = "0.2.2" } +quote = { version = "1.0.35" } +rayon = { version = "1.9.0" } +regex = { version = "1.10.3" } +rustc-hash = { version = "1.1.0", default-features = false, features = ["std"] } +ryu-js = { version = "1.0.1" } +ropey = { version = "1.6.1" } +seq-macro = { version = "0.3.5" } +serde = { version = "1.0.197" } +serde_json = { version = "1.0.114" } +syn = { version = "=1.0.109" } +tempfile = { version = "3.10.1" } +thiserror = { version = "1.0.58" } +tokio = { version = "1" } +tower-lsp = { version = "0.20.0", features = ["proposed"] } +unicode-id-start = { version = "1.1.2" } +ureq = { version = "2.9.6", default-features = false, features = ["tls", "json"] } +url = { version = "2.5.0" } +walkdir = { version = "2.5.0" } +indexmap = { version = "2.2.5" } +index_vec = { version = "0.1.3" } +static_assertions = { version = "1.1.0" } +tracing-subscriber = { version = "0.3" } +insta = { version = "1.36.1", features = ["glob"] } +mime_guess = { version = "2.0.4" } +language-tags = { version = "0.3.2" } +tsify = { version = "0.4.5" } +wasm-bindgen = { version = "0.2" } +serde-wasm-bindgen = { version = "0.6.5" } +handlebars = { version = "5.1.0" } [profile.release.package.oxc_wasm] opt-level = 'z' diff --git a/crates/oxc_cli/Cargo.toml b/crates/oxc_cli/Cargo.toml index 620a17656..cc8d0cdd1 100644 --- a/crates/oxc_cli/Cargo.toml +++ b/crates/oxc_cli/Cargo.toml @@ -43,7 +43,7 @@ oxc_span = { workspace = true } ignore = { workspace = true, features = ["simd-accel"] } miette = { workspace = true } -tempfile = {workspace=true} +tempfile = { workspace = true } rayon = { workspace = true } bpaf = { workspace = true, features = ["derive", "autocomplete", "bright-color"] } tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/crates/oxc_linter/src/config/settings/jsdoc.rs b/crates/oxc_linter/src/config/settings/jsdoc.rs index 52ab2bb1d..b975a35b6 100644 --- a/crates/oxc_linter/src/config/settings/jsdoc.rs +++ b/crates/oxc_linter/src/config/settings/jsdoc.rs @@ -126,8 +126,14 @@ fn default_true() -> bool { #[serde(untagged)] enum TagNamePreference { TagNameOnly(String), - ObjectWithMessageAndReplacement { message: String, replacement: String }, - ObjectWithMessage { message: String }, + ObjectWithMessageAndReplacement { + message: String, + replacement: String, + }, + ObjectWithMessage { + message: String, + }, + #[allow(dead_code)] FalseOnly(bool), // Should care `true`...? } diff --git a/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs b/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs index 3f3113fe7..a341f16d7 100644 --- a/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs +++ b/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs @@ -206,9 +206,7 @@ pub fn get_array_method_name<'a>( } // "methods", - let Some(method) = callee.static_property_name() else { - return None; - }; + let method = callee.static_property_name()?; if let Some(&array_method) = TARGET_METHODS.get_key(method) { // Check that current node is parent's first argument if call.arguments.len() == 1 && is_nth_argument(call, current_node_arg, 0) { diff --git a/crates/oxc_linter/src/rules/jest/no_identical_title.rs b/crates/oxc_linter/src/rules/jest/no_identical_title.rs index 1fa2a6b16..7339df199 100644 --- a/crates/oxc_linter/src/rules/jest/no_identical_title.rs +++ b/crates/oxc_linter/src/rules/jest/no_identical_title.rs @@ -121,9 +121,7 @@ fn filter_and_process_jest_result<'a>( possible_jest_node: &PossibleJestNode<'a, '_>, ctx: &LintContext<'a>, ) -> Option<(Span, &'a Atom<'a>, JestFnKind, AstNodeId)> { - let Some(result) = parse_general_jest_fn_call(call_expr, possible_jest_node, ctx) else { - return None; - }; + let result = parse_general_jest_fn_call(call_expr, possible_jest_node, ctx)?; let kind = result.kind; // we only need check `describe` or `test` block if !matches!(kind, JestFnKind::General(JestGeneralFnKind::Describe | JestGeneralFnKind::Test)) { @@ -134,9 +132,7 @@ fn filter_and_process_jest_result<'a>( return None; } - let Some(parent_id) = get_closest_block(possible_jest_node.node, ctx) else { - return None; - }; + let parent_id = get_closest_block(possible_jest_node.node, ctx)?; match call_expr.arguments.first() { Some(Argument::Expression(Expression::StringLiteral(string_lit))) => { diff --git a/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs b/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs index e0f9591e8..ef7fa7029 100644 --- a/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs +++ b/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs @@ -134,9 +134,7 @@ fn get_jasmine_property_name<'a>(member_expr: &'a MemberExpression<'a>) -> Optio if !is_jasmine_object { return None; } - let Some((span, property_name)) = member_expr.static_property_info() else { - return None; - }; + let (span, property_name) = member_expr.static_property_info()?; Some((span, property_name)) } diff --git a/crates/oxc_linter/src/rules/react/jsx_key.rs b/crates/oxc_linter/src/rules/react/jsx_key.rs index f4d87b4f9..51b441c84 100644 --- a/crates/oxc_linter/src/rules/react/jsx_key.rs +++ b/crates/oxc_linter/src/rules/react/jsx_key.rs @@ -85,9 +85,7 @@ fn is_in_array_or_iter<'a, 'b>( let mut is_explicit_return = false; loop { - let Some(parent) = ctx.nodes().parent_node(node.id()) else { - return None; - }; + let parent = ctx.nodes().parent_node(node.id())?; match parent.kind() { AstKind::ArrowFunctionExpression(arrow_expr) => { @@ -99,9 +97,7 @@ fn is_in_array_or_iter<'a, 'b>( return None; } - let Some(parent) = ctx.nodes().parent_node(parent.id()) else { - return None; - }; + let parent = ctx.nodes().parent_node(parent.id())?; if let AstKind::ObjectProperty(_) = parent.kind() { return None; @@ -112,9 +108,7 @@ fn is_in_array_or_iter<'a, 'b>( is_outside_containing_function = true; } AstKind::Function(_) => { - let Some(parent) = ctx.nodes().parent_node(parent.id()) else { - return None; - }; + let parent = ctx.nodes().parent_node(parent.id())?; if let AstKind::ObjectProperty(_) = parent.kind() { return None; @@ -391,7 +385,7 @@ fn test() { (Component) =>
]; ", - r" + r" MyStory.decorators = [ (Component) => { const store = useMyStore(); diff --git a/crates/oxc_parser/Cargo.toml b/crates/oxc_parser/Cargo.toml index 30dbeffdd..9826ccf74 100644 --- a/crates/oxc_parser/Cargo.toml +++ b/crates/oxc_parser/Cargo.toml @@ -37,7 +37,7 @@ memchr = "2.7.1" oxc_ast = { workspace = true, features = ["serialize"] } miette = { workspace = true } serde_json = { workspace = true } -ouroboros = "0.18.3" # for `multi-thread` example +ouroboros = "0.18.3" # for `multi-thread` example [features] # Expose Lexer for benchmarks diff --git a/crates/oxc_parser/examples/multi-thread.rs b/crates/oxc_parser/examples/multi-thread.rs index bfe761456..ec4dc5af2 100644 --- a/crates/oxc_parser/examples/multi-thread.rs +++ b/crates/oxc_parser/examples/multi-thread.rs @@ -77,6 +77,9 @@ fn main() { let ast = ast_rx.recv().unwrap(); let index = ast.borrow_index(); println!("received ast({index}) in {:?} at {}", thread::current().id(), timestamp()); + ast.with_ast(|bumpalo_program| { + println!("AST span: {:?}", bumpalo_program.0.span); + }); } } diff --git a/crates/oxc_prettier/src/format/assignment.rs b/crates/oxc_prettier/src/format/assignment.rs index 302a6b2be..af9acf34f 100644 --- a/crates/oxc_prettier/src/format/assignment.rs +++ b/crates/oxc_prettier/src/format/assignment.rs @@ -48,7 +48,9 @@ pub(super) fn print_variable_declarator<'a>( pub(super) enum AssignmentLikeNode<'a, 'b> { AssignmentExpression(&'b AssignmentExpression<'a>), VariableDeclarator(&'b VariableDeclarator<'a>), + #[allow(dead_code)] PropertyDefinition(&'b PropertyDefinition<'a>), + #[allow(dead_code)] AccessorProperty(&'b AccessorProperty<'a>), ObjectProperty(&'b ObjectProperty<'a>), } diff --git a/crates/oxc_semantic/Cargo.toml b/crates/oxc_semantic/Cargo.toml index 8d41a1083..4db12a921 100644 --- a/crates/oxc_semantic/Cargo.toml +++ b/crates/oxc_semantic/Cargo.toml @@ -38,11 +38,11 @@ wasm-bindgen = { workspace = true, optional = true } [dev-dependencies] oxc_parser = { workspace = true } -itertools = { workspace = true } -indexmap = { workspace = true } -insta = { workspace = true } -phf = { workspace = true, features = ["macros"] } -rustc-hash = { workspace = true } +itertools = { workspace = true } +indexmap = { workspace = true } +insta = { workspace = true } +phf = { workspace = true, features = ["macros"] } +rustc-hash = { workspace = true } [features] default = [] diff --git a/crates/oxc_semantic/src/jsdoc/finder.rs b/crates/oxc_semantic/src/jsdoc/finder.rs index 75a51c3db..b3902e785 100644 --- a/crates/oxc_semantic/src/jsdoc/finder.rs +++ b/crates/oxc_semantic/src/jsdoc/finder.rs @@ -19,9 +19,7 @@ impl<'a> JSDocFinder<'a> { } pub fn get_one_by_node<'b>(&'b self, node: &AstNode<'a>) -> Option> { - let Some(jsdocs) = self.get_all_by_node(node) else { - return None; - }; + let jsdocs = self.get_all_by_node(node)?; // If flagged, at least 1 JSDoc is attached // If multiple JSDocs are attached, return the last = nearest diff --git a/crates/oxc_semantic/src/jsdoc/parser/utils.rs b/crates/oxc_semantic/src/jsdoc/parser/utils.rs index 893c8f78c..0ed7fc884 100644 --- a/crates/oxc_semantic/src/jsdoc/parser/utils.rs +++ b/crates/oxc_semantic/src/jsdoc/parser/utils.rs @@ -1,6 +1,6 @@ pub fn trim_multiline_comment(s: &str) -> String { s.trim() - .split('\n') + .lines() .map(|line| line.trim().trim_start_matches('*').trim()) .filter(|line| !line.is_empty()) .collect::>() diff --git a/crates/oxc_transformer/src/typescript/mod.rs b/crates/oxc_transformer/src/typescript/mod.rs index bea7a40da..cf37fb3ee 100644 --- a/crates/oxc_transformer/src/typescript/mod.rs +++ b/crates/oxc_transformer/src/typescript/mod.rs @@ -270,14 +270,10 @@ impl<'a> TypeScript<'a> { fn has_value_references(&self, name: &Atom) -> bool { let root_scope_id = self.ctx.scopes().root_scope_id(); - self.ctx - .scopes() - .get_binding(root_scope_id, name) - .map(|symbol_id| { - self.ctx.symbols().get_flag(symbol_id).is_export() - || self.ctx.symbols().get_resolved_references(symbol_id).any(|x| !x.is_type()) - }) - .unwrap_or_default() + self.ctx.scopes().get_binding(root_scope_id, name).is_some_and(|symbol_id| { + self.ctx.symbols().get_flag(symbol_id).is_export() + || self.ctx.symbols().get_resolved_references(symbol_id).any(|x| !x.is_type()) + }) } } diff --git a/justfile b/justfile index c215046ab..c95fc0e21 100755 --- a/justfile +++ b/justfile @@ -17,7 +17,7 @@ init: ready: git diff --exit-code --quiet typos - cargo fmt + just fmt just check just test just lint diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 06c745813..2fe891cfe 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.76.0" +channel = "1.77.0" profile = "default"