From cedfdebaada87efae9605bfb56c950b04bd6d7db Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:43:50 +0100 Subject: [PATCH 01/39] Enable Clippy's pedantic lints --- Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b4edfedb9138..21c43411c45a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,5 +32,4 @@ exclude = [ [workspace.lints.clippy] all = { level = "warn", priority = -1 } -explicit_iter_loop = "warn" -manual_let_else = "warn" +pedantic = { level = "warn", priority = -1 } From b3552c5892a3c834fa04fb290bf2a02a26aa9dec Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Tue, 10 Nov 2026 14:52:56 +0100 Subject: [PATCH 02/39] Fix all results of the Clippy lint `cloned_instead_of_copied` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- shared/yeast/src/query.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/yeast/src/query.rs b/shared/yeast/src/query.rs index 30b78473d25d..37c9ced07e4e 100644 --- a/shared/yeast/src/query.rs +++ b/shared/yeast/src/query.rs @@ -86,7 +86,7 @@ impl QueryNode { }); let empty = Vec::new(); let mut child_iter = - node.fields.get(&field_id).unwrap_or(&empty).iter().cloned(); + node.fields.get(&field_id).unwrap_or(&empty).iter().copied(); if !match_children(field_children.iter(), ast, &mut child_iter, matches) { return false; } From 5ae3fa99156c49c037ba3343e66b6b296a8f2046 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Tue, 10 Nov 2026 14:58:58 +0100 Subject: [PATCH 03/39] Fix all results of the Clippy lint `implicit_clone` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/ast-generator/patches/rust-analyzer.patch | 9 +++++++++ rust/ast-generator/src/main.rs | 6 +++--- rust/extractor/src/config/deserialize.rs | 2 +- rust/extractor/src/crate_graph.rs | 2 +- rust/extractor/src/main.rs | 2 +- shared/tree-sitter-extractor/src/diagnostics.rs | 6 +++--- shared/tree-sitter-extractor/src/extractor/mod.rs | 2 +- shared/tree-sitter-extractor/src/node_types.rs | 10 +++++----- shared/yeast/src/lib.rs | 2 +- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/rust/ast-generator/patches/rust-analyzer.patch b/rust/ast-generator/patches/rust-analyzer.patch index ffe12683b4aa..a9ac0b7c03e5 100644 --- a/rust/ast-generator/patches/rust-analyzer.patch +++ b/rust/ast-generator/patches/rust-analyzer.patch @@ -22,6 +22,15 @@ index 0aad1e2..68f679f 100644 use self::ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc}; pub(crate) fn generate(check: bool) { +@@ -317,7 +321,7 @@ fn generate_nodes(grammar: &AstSrc) -> String { + let trait_name = format_ident!("{}", trait_name); + let kinds: Vec<_> = nodes + .iter() +- .map(|name| format_ident!("{}", to_upper_snake_case(&name.name.to_string()))) ++ .map(|name| format_ident!("{}", to_upper_snake_case(&name.name))) + .collect(); + let nodes = nodes.iter().map(|node| format_ident!("{}", node.name)); + ( @@ -775,7 +779,7 @@ fn pluralize(s: &str) -> String { } diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index f136fd57fc41..444ed0b6502e 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -191,7 +191,7 @@ fn should_predicate_be_extracted(name: &str) -> bool { } fn project_root() -> PathBuf { - let dir = env::var("CARGO_MANIFEST_DIR").unwrap().to_owned(); + let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); PathBuf::from(dir).parent().unwrap().to_owned() } @@ -413,7 +413,7 @@ fn enum_to_extractor_info(node: &AstEnumSrc) -> ExtractorEnumInfo { EnumVariantInfo { name, snake_case_name, - variant_ast_name: v.to_string(), + variant_ast_name: v.clone(), emission, } }) @@ -519,7 +519,7 @@ fn main() -> anyhow::Result<()> { for node in &grammar.enums { for variant in &node.variants { let set = super_types.entry(variant.to_owned()).or_default(); - set.insert(node.name.to_owned()); + set.insert(node.name.clone()); } } // sort things while ensuring super clases are defined before they are used diff --git a/rust/extractor/src/config/deserialize.rs b/rust/extractor/src/config/deserialize.rs index 6e1b9b398b63..17985ff177b5 100644 --- a/rust/extractor/src/config/deserialize.rs +++ b/rust/extractor/src/config/deserialize.rs @@ -62,7 +62,7 @@ impl<'de, S: BuildHasher + Default> Visitor<'de> for MapVisitor { while let Some(el) = seq.next_element::()? { match el.split_once('=') { None => { - ret.insert(el.to_owned(), None); + ret.insert(el, None); } Some((key, value)) => { ret.insert(key.to_owned(), Some(value.to_owned())); diff --git a/rust/extractor/src/crate_graph.rs b/rust/extractor/src/crate_graph.rs index 072bffdc1bf1..c65df621d120 100644 --- a/rust/extractor/src/crate_graph.rs +++ b/rust/extractor/src/crate_graph.rs @@ -76,7 +76,7 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData .display_name .as_ref() .map(|x| x.canonical_name().to_string()), - version: krate_extra.version.to_owned(), + version: krate_extra.version.clone(), cfg_options: krate_id .cfg_options(db) .into_iter() diff --git a/rust/extractor/src/main.rs b/rust/extractor/src/main.rs index 4ede43224d35..1e0a9c082666 100644 --- a/rust/extractor/src/main.rs +++ b/rust/extractor/src/main.rs @@ -282,7 +282,7 @@ fn main() -> anyhow::Result<()> { let files = inputs .iter() .map(|file| { - let file = std::path::absolute(file).unwrap_or(file.to_path_buf()); + let file = std::path::absolute(file).unwrap_or(file.clone()); // On Windows, rust analyzer expects non-`//?/` prefixed paths (see [1]), which is what // `std::fs::canonicalize` returns. So we use `dunce::canonicalize` instead. // [1]: https://github.com/rust-lang/rust-analyzer/issues/18894#issuecomment-2580014730 diff --git a/shared/tree-sitter-extractor/src/diagnostics.rs b/shared/tree-sitter-extractor/src/diagnostics.rs index 412647ee07a5..5516eeb8ecf2 100644 --- a/shared/tree-sitter-extractor/src/diagnostics.rs +++ b/shared/tree-sitter-extractor/src/diagnostics.rs @@ -95,7 +95,7 @@ impl LogWriter { source: Source { id: format!("{}/{}", self.extractor, id), name: name.to_owned(), - extractor_name: Some(self.extractor.to_owned()), + extractor_name: Some(self.extractor.clone()), }, markdown_message: String::new(), plaintext_message: String::new(), @@ -189,7 +189,7 @@ impl DiagnosticLoggers { }; } THREAD_NUM.with(|n| LogWriter { - extractor: self.extractor.to_owned(), + extractor: self.extractor.clone(), inner: None, path: self .root @@ -235,7 +235,7 @@ impl DiagnosticMessage { start_line: Some(line), .. }) => format!("{}:{}: {}", path, line, self.plaintext_message), - _ => self.plaintext_message.to_owned(), + _ => self.plaintext_message.clone(), } } diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index 1bd8677b7414..59d4951d70cc 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -623,7 +623,7 @@ impl<'a> Visitor<'a> { trap::Arg::Label(id), trap::Arg::Int(severity_code), trap::Arg::String("parse_error".to_string()), - trap::Arg::String(mesg.plaintext_message.to_owned()), + trap::Arg::String(mesg.plaintext_message.clone()), trap::Arg::String(full_error_message), trap::Arg::Label(loc), ], diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index 43fc3e11683d..aaef1478f100 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -110,7 +110,7 @@ pub fn read_node_types_str(prefix: &str, node_types_json: &str) -> std::io::Resu fn convert_type(node_type: &NodeType) -> TypeName { TypeName { - kind: node_type.kind.to_string(), + kind: node_type.kind.clone(), named: node_type.named, } } @@ -152,7 +152,7 @@ pub fn convert_nodes(prefix: &str, nodes: &[NodeInfo]) -> NodeTypeMap { add_field( prefix, &type_name, - Some(field_name.to_string()), + Some(field_name.clone()), field_info, &mut fields, &token_kinds, @@ -198,7 +198,7 @@ pub fn convert_nodes(prefix: &str, nodes: &[NodeInfo]) -> NodeTypeMap { add_field( prefix, &type_name, - Some(field_name.to_string()), + Some(field_name.clone()), field_info, &mut fields, &token_kinds, @@ -293,7 +293,7 @@ fn add_field( for (counter, t) in converted_types.into_iter().enumerate() { let dbscheme_variant_name = escape_name(&format!("{}_{}_{}", prefix, parent_flattened_name, t.kind)); - field_token_ints.insert(t.kind.to_owned(), (counter, dbscheme_variant_name)); + field_token_ints.insert(t.kind, (counter, dbscheme_variant_name)); } FieldTypeInfo::ReservedWordInt(field_token_ints) } else if field_info.types.len() == 1 { @@ -327,7 +327,7 @@ fn add_field( }; fields.push(Field { parent: TypeName { - kind: parent_type_name.kind.to_string(), + kind: parent_type_name.kind.clone(), named: parent_type_name.named, }, type_info, diff --git a/shared/yeast/src/lib.rs b/shared/yeast/src/lib.rs index 717ed381aaa1..adb9b07c2a90 100644 --- a/shared/yeast/src/lib.rs +++ b/shared/yeast/src/lib.rs @@ -1083,7 +1083,7 @@ impl Node { match &self.content { NodeContent::Range(_range) => None, NodeContent::String(s) => Some(s.to_string()), - NodeContent::DynamicString(s) => Some(s.to_string()), + NodeContent::DynamicString(s) => Some(s.clone()), } } From e3c310e387d76e0b22a9d2f099e9ff771dd7d835 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Tue, 10 Nov 2026 15:05:24 +0100 Subject: [PATCH 04/39] Fix all results of the Clippy lint `single_match_else` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- .../ast-generator/patches/rust-analyzer.patch | 63 +++++++++++++++++-- shared/yeast/src/bin/node_types_yaml.rs | 25 ++++---- unified/swift-syntax-rs/src/main.rs | 13 ++-- 3 files changed, 77 insertions(+), 24 deletions(-) diff --git a/rust/ast-generator/patches/rust-analyzer.patch b/rust/ast-generator/patches/rust-analyzer.patch index a9ac0b7c03e5..9f70d4f7cd28 100644 --- a/rust/ast-generator/patches/rust-analyzer.patch +++ b/rust/ast-generator/patches/rust-analyzer.patch @@ -31,7 +31,39 @@ index 0aad1e2..68f679f 100644 .collect(); let nodes = nodes.iter().map(|node| format_ident!("{}", node.name)); ( -@@ -775,7 +779,7 @@ fn pluralize(s: &str) -> String { +@@ -521,9 +525,12 @@ + contextual_keywords.iter().map(fmt_kw_as_variant).collect::>(); + let contextual_keywords_tokens = contextual_keywords.iter().map(|it| format_ident!("{it}")); + let contextual_keywords_str_match_arm = grammar.contextual_keywords.iter().map(|kw| { +- match grammar.edition_dependent_keywords.iter().find(|(ed_kw, _)| ed_kw == kw) { +- Some((_, ed)) => quote! { #kw if edition < #ed }, +- None => quote! { #kw }, ++ if let Some((_, ed)) = ++ grammar.edition_dependent_keywords.iter().find(|(ed_kw, _)| ed_kw == kw) ++ { ++ quote! { #kw if edition < #ed } ++ } else { ++ quote! { #kw } + } + }); + let contextual_keywords_variants_match_arm = grammar +@@ -531,9 +538,12 @@ + .iter() + .map(|kw_s| { + let kw = fmt_kw_as_variant(kw_s); +- match grammar.edition_dependent_keywords.iter().find(|(ed_kw, _)| ed_kw == kw_s) { +- Some((_, ed)) => quote! { #kw if edition < #ed }, +- None => quote! { #kw }, ++ if let Some((_, ed)) = ++ grammar.edition_dependent_keywords.iter().find(|(ed_kw, _)| ed_kw == kw_s) ++ { ++ quote! { #kw if edition < #ed } ++ } else { ++ quote! { #kw } + } + }) + .collect::>(); +@@ -775,7 +785,7 @@ fn pluralize(s: &str) -> String { } impl Field { @@ -40,7 +72,7 @@ index 0aad1e2..68f679f 100644 matches!(self, Field::Node { cardinality: Cardinality::Many, .. }) } fn token_kind(&self) -> Option { -@@ -787,7 +791,7 @@ impl Field { +@@ -787,7 +797,7 @@ impl Field { _ => None, } } @@ -49,7 +81,7 @@ index 0aad1e2..68f679f 100644 match self { Field::Token { name, token, .. } => { if let Some(name) = name { -@@ -836,7 +840,7 @@ impl Field { +@@ -836,7 +846,7 @@ impl Field { } } } @@ -58,7 +90,7 @@ index 0aad1e2..68f679f 100644 match self { Field::Token { .. } => format_ident!("SyntaxToken"), Field::Node { ty, .. } => format_ident!("{}", ty), -@@ -849,7 +853,7 @@ fn clean_token_name(name: &str) -> String { +@@ -849,7 +859,7 @@ fn clean_token_name(name: &str) -> String { if cleaned.is_empty() { name.to_owned() } else { cleaned.to_owned() } } @@ -67,6 +99,29 @@ index 0aad1e2..68f679f 100644 let mut res = AstSrc { tokens: "Whitespace Comment String ByteString CString IntNumber FloatNumber Char Byte Ident" +@@ -865,15 +875,12 @@ + let name = grammar[node].name.clone(); + let rule = &grammar[node].rule; + let _g = panic_context::enter(name.clone()); +- match lower_enum(grammar, rule) { +- Some(variants) => { +- let enum_src = AstEnumSrc { doc: Vec::new(), name, traits: Vec::new(), variants }; +- res.enums.push(enum_src); +- } +- None => { +- let mut fields = Vec::new(); +- lower_rule(&mut fields, grammar, None, rule); +- res.nodes.push(AstNodeSrc { doc: Vec::new(), name, traits: Vec::new(), fields }); +- } ++ if let Some(variants) = lower_enum(grammar, rule) { ++ let enum_src = AstEnumSrc { doc: Vec::new(), name, traits: Vec::new(), variants }; ++ res.enums.push(enum_src); ++ } else { ++ let mut fields = Vec::new(); ++ lower_rule(&mut fields, grammar, None, rule); ++ res.nodes.push(AstNodeSrc { doc: Vec::new(), name, traits: Vec::new(), fields }); + } + } diff --git a/xtask/src/codegen/grammar/ast_src.rs b/xtask/src/codegen/grammar/ast_src.rs index 1ae139f..d4d791e 100644 --- a/xtask/src/codegen/grammar/ast_src.rs diff --git a/shared/yeast/src/bin/node_types_yaml.rs b/shared/yeast/src/bin/node_types_yaml.rs index bc392ecb1f66..ea86bdb352cb 100644 --- a/shared/yeast/src/bin/node_types_yaml.rs +++ b/shared/yeast/src/bin/node_types_yaml.rs @@ -18,21 +18,20 @@ struct Cli { fn main() { let args = Cli::parse(); - let input = match &args.input { - Some(path) => std::fs::read_to_string(path).unwrap_or_else(|e| { + let input = if let Some(path) = &args.input { + std::fs::read_to_string(path).unwrap_or_else(|e| { eprintln!("Error reading {path}: {e}"); std::process::exit(1); - }), - None => { - let mut buf = String::new(); - std::io::stdin() - .read_to_string(&mut buf) - .unwrap_or_else(|e| { - eprintln!("Error reading stdin: {e}"); - std::process::exit(1); - }); - buf - } + }) + } else { + let mut buf = String::new(); + std::io::stdin() + .read_to_string(&mut buf) + .unwrap_or_else(|e| { + eprintln!("Error reading stdin: {e}"); + std::process::exit(1); + }); + buf }; let result = if args.from_json { diff --git a/unified/swift-syntax-rs/src/main.rs b/unified/swift-syntax-rs/src/main.rs index d79cd2ffef1f..1df920f69bd9 100644 --- a/unified/swift-syntax-rs/src/main.rs +++ b/unified/swift-syntax-rs/src/main.rs @@ -31,12 +31,11 @@ fn main() -> ExitCode { fn read_source() -> std::io::Result { let mut args = std::env::args().skip(1); - match args.next() { - Some(path) => std::fs::read_to_string(path), - None => { - let mut buf = String::new(); - std::io::stdin().read_to_string(&mut buf)?; - Ok(buf) - } + if let Some(path) = args.next() { + std::fs::read_to_string(path) + } else { + let mut buf = String::new(); + std::io::stdin().read_to_string(&mut buf)?; + Ok(buf) } } From 794119142b441a4e5a5c6e726dd45cf082d4afdc Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Tue, 10 Nov 2026 15:09:00 +0100 Subject: [PATCH 05/39] Fix all results of the Clippy lint `uninlined_format_args` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- cpp/extractor/bmn/src/main.rs | 3 +-- ql/buramu/src/main.rs | 4 ++-- .../tree-sitter-extractor/src/generator/mod.rs | 16 ++++++++-------- shared/tree-sitter-extractor/src/generator/ql.rs | 2 +- shared/tree-sitter-extractor/src/node_types.rs | 10 +++++----- shared/tree-sitter-extractor/src/options.rs | 2 +- shared/tree-sitter-extractor/src/trap.rs | 2 +- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/cpp/extractor/bmn/src/main.rs b/cpp/extractor/bmn/src/main.rs index 54e57d02d6bb..73a0790b2479 100644 --- a/cpp/extractor/bmn/src/main.rs +++ b/cpp/extractor/bmn/src/main.rs @@ -52,8 +52,7 @@ fn get_extractor_executable() -> Result { let extractor = PathBuf::from_iter([&root_dir, "tools", &platform, &binary_name]); if !extractor.exists() { Err(anyhow::anyhow!( - "Extractor executable not found at: {:?}", - extractor + "Extractor executable not found at: {extractor:?}" )) } else { Ok(extractor) diff --git a/ql/buramu/src/main.rs b/ql/buramu/src/main.rs index 11305c34bf57..0fbdacc3d0c2 100644 --- a/ql/buramu/src/main.rs +++ b/ql/buramu/src/main.rs @@ -53,7 +53,7 @@ fn get_blame_dates_for_filedeprecation(file: &str, linenos: &[String]) -> LastMo let mut command = Command::new("git"); command.arg("blame"); for lineno in linenos { - command.arg("-L").arg(format!("{},{}", lineno, lineno)); + command.arg("-L").arg(format!("{lineno},{lineno}")); } command.arg(file); let output = command.output().expect("failed to execute process"); @@ -97,7 +97,7 @@ fn main() { .par_iter() .map(|(file, linenos)| (file, get_blame_dates_for_filedeprecation(file, linenos))); deprecations.for_each(|(file, linenos_and_dates)| { - println!("file: {}", file); + println!("file: {file}"); for (date, linenos) in &linenos_and_dates { println!(" last_modified: {} {}", date, linenos.join(" ")); } diff --git a/shared/tree-sitter-extractor/src/generator/mod.rs b/shared/tree-sitter-extractor/src/generator/mod.rs index 81bf0955cd6e..0d29d67e3ba0 100644 --- a/shared/tree-sitter-extractor/src/generator/mod.rs +++ b/shared/tree-sitter-extractor/src/generator/mod.rs @@ -65,14 +65,14 @@ pub fn generate( for language in languages { let prefix = node_types::to_snake_case(&language.name); - let ast_node_name = format!("{}_ast_node", prefix); - let node_location_table_name = format!("{}_ast_node_location", prefix); - let node_parent_table_name = format!("{}_ast_node_parent", prefix); - let token_name = format!("{}_token", prefix); - let tokeninfo_name = format!("{}_tokeninfo", prefix); - let trivia_token_name = format!("{}_trivia_token", prefix); - let trivia_tokeninfo_name = format!("{}_trivia_tokeninfo", prefix); - let reserved_word_name = format!("{}_reserved_word", prefix); + let ast_node_name = format!("{prefix}_ast_node"); + let node_location_table_name = format!("{prefix}_ast_node_location"); + let node_parent_table_name = format!("{prefix}_ast_node_parent"); + let token_name = format!("{prefix}_token"); + let tokeninfo_name = format!("{prefix}_tokeninfo"); + let trivia_token_name = format!("{prefix}_trivia_token"); + let trivia_tokeninfo_name = format!("{prefix}_trivia_tokeninfo"); + let reserved_word_name = format!("{prefix}_reserved_word"); // When a desugaring is configured, comments and other `extra` nodes are // preserved from the original parse tree as `TriviaToken`s. let has_trivia_tokens = language.desugar.is_some(); diff --git a/shared/tree-sitter-extractor/src/generator/ql.rs b/shared/tree-sitter-extractor/src/generator/ql.rs index c780aec681cd..5c6e12a13a6c 100644 --- a/shared/tree-sitter-extractor/src/generator/ql.rs +++ b/shared/tree-sitter-extractor/src/generator/ql.rs @@ -365,7 +365,7 @@ impl fmt::Display for FormalParameter<'_> { /// Generates a QL library by writing the given `elements` to the `file`. pub fn write(file: &mut dyn std::io::Write, elements: &[TopLevel]) -> std::io::Result<()> { for element in elements { - write!(file, "{}\n\n", element)?; + write!(file, "{element}\n\n")?; } Ok(()) } diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index aaef1478f100..f1d49cb8350f 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -138,7 +138,7 @@ pub fn convert_nodes(prefix: &str, nodes: &[NodeInfo]) -> NodeTypeMap { let flattened_name = &node_type_name(&node.kind, node.named); let dbscheme_name = escape_name(flattened_name); let ql_class_name = dbscheme_name_to_class_name(&dbscheme_name); - let dbscheme_name = format!("{}_{}", prefix, dbscheme_name); + let dbscheme_name = format!("{prefix}_{dbscheme_name}"); let subtypes = &node.subtypes; if !subtypes.is_empty() { // It's a tree-sitter supertype node, for which we create a union @@ -187,8 +187,8 @@ pub fn convert_nodes(prefix: &str, nodes: &[NodeInfo]) -> NodeTypeMap { kind: node.kind.clone(), named: node.named, }; - let table_name = escape_name(&(format!("{}_def", flattened_name))); - let table_name = format!("{}_{}", prefix, table_name); + let table_name = escape_name(&(format!("{flattened_name}_def"))); + let table_name = format!("{prefix}_{table_name}"); let mut fields = Vec::new(); @@ -234,13 +234,13 @@ pub fn convert_nodes(prefix: &str, nodes: &[NodeInfo]) -> NodeTypeMap { counter += 1; let unprefixed_name = node_type_name(&type_name.kind, true); Entry { - dbscheme_name: escape_name(&format!("{}_token_{}", prefix, unprefixed_name)), + dbscheme_name: escape_name(&format!("{prefix}_token_{unprefixed_name}")), ql_class_name: dbscheme_name_to_class_name(&escape_name(&unprefixed_name)), kind: EntryKind::Token { kind_id: counter }, } } else { Entry { - dbscheme_name: format!("{}_reserved_word", prefix), + dbscheme_name: format!("{prefix}_reserved_word"), ql_class_name: "ReservedWord".to_owned(), kind: EntryKind::Token { kind_id: 0 }, } diff --git a/shared/tree-sitter-extractor/src/options.rs b/shared/tree-sitter-extractor/src/options.rs index 4be253104f19..d2fdc5bede0b 100644 --- a/shared/tree-sitter-extractor/src/options.rs +++ b/shared/tree-sitter-extractor/src/options.rs @@ -6,7 +6,7 @@ pub fn num_threads() -> Result { let threads_str = std::env::var("CODEQL_THREADS").unwrap_or_else(|_| "-1".into()); let num_cpus = num_cpus::get(); parse_codeql_threads(&threads_str, num_cpus) - .ok_or_else(|| format!("Unable to parse CODEQL_THREADS value '{}'", threads_str)) + .ok_or_else(|| format!("Unable to parse CODEQL_THREADS value '{threads_str}'")) } /// Parses the given string to determine the number of threads the extractor diff --git a/shared/tree-sitter-extractor/src/trap.rs b/shared/tree-sitter-extractor/src/trap.rs index 492349c6d4ab..d910a2a12c27 100644 --- a/shared/tree-sitter-extractor/src/trap.rs +++ b/shared/tree-sitter-extractor/src/trap.rs @@ -298,7 +298,7 @@ impl Compression { match std::env::var(var_name) { Ok(method) => match Compression::from_string(&method) { Some(c) => Ok(c), - None => Err(format!("Unknown compression method '{}'", method)), + None => Err(format!("Unknown compression method '{method}'")), }, // Default compression method if the env var isn't set: Err(_) => Ok(Compression::Gzip), From 71ef28c417f303eaab3b26ad5e00750e48092c2a Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Tue, 10 Nov 2026 15:13:43 +0100 Subject: [PATCH 06/39] Fix all results of the Clippy lint `map_unwrap_or` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/ast-generator/src/main.rs | 8 +++---- rust/extractor/src/main.rs | 3 +-- .../src/extractor/mod.rs | 22 +++++++++---------- .../tree-sitter-extractor/src/file_paths.rs | 3 +-- shared/yeast/src/captures.rs | 2 +- shared/yeast/src/lib.rs | 7 ++---- unified/extractor/tests/corpus_tests.rs | 3 +-- 7 files changed, 21 insertions(+), 27 deletions(-) diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index 444ed0b6502e..db07a39bb4b0 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -229,10 +229,10 @@ struct Schema { } fn get_bases(name: &str, super_types: &BTreeMap>) -> Vec { - super_types - .get(name) - .map(|tys| tys.iter().map(|t| class_name(t)).collect()) - .unwrap_or_else(|| vec!["AstNode".to_string()]) + super_types.get(name).map_or_else( + || vec!["AstNode".to_string()], + |tys| tys.iter().map(|t| class_name(t)).collect(), + ) } fn enum_src_to_schema_class( diff --git a/rust/extractor/src/main.rs b/rust/extractor/src/main.rs index 1e0a9c082666..e4e6518a080e 100644 --- a/rust/extractor/src/main.rs +++ b/rust/extractor/src/main.rs @@ -258,8 +258,7 @@ fn main() -> anyhow::Result<()> { let (flame_layer, _flush_guard) = if let Some(path) = &config.logging_flamegraph { tracing_flame::FlameLayer::with_file(path) .ok() - .map(|(a, b)| (Some(a), Some(b))) - .unwrap_or((None, None)) + .map_or((None, None), |(a, b)| (Some(a), Some(b))) } else { (None, None) }; diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index 59d4951d70cc..5dc5047440f5 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -135,17 +135,17 @@ pub fn default_subscriber_with_level( .with_filter( tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else( |_| -> tracing_subscriber::EnvFilter { - let verbosity = verbosity - .as_ref() - .map(|v| match v.to_lowercase().as_str() { - "off" | "errors" => "error", - "warnings" => "warn", - "info" | "progress" => "info", - "debug" | "progress+" => "debug", - "trace" | "progress++" | "progress+++" => "trace", - _ => "warn", - }) - .unwrap_or_else(|| "warn"); + let verbosity = + verbosity + .as_ref() + .map_or("warn", |v| match v.to_lowercase().as_str() { + "off" | "errors" => "error", + "warnings" => "warn", + "info" | "progress" => "info", + "debug" | "progress+" => "debug", + "trace" | "progress++" | "progress+++" => "trace", + _ => "warn", + }); tracing_subscriber::EnvFilter::new(format!( "{language}_extractor={verbosity},codeql_extractor={verbosity}" )) diff --git a/shared/tree-sitter-extractor/src/file_paths.rs b/shared/tree-sitter-extractor/src/file_paths.rs index 821a4b2309dd..7b11ab62b88a 100644 --- a/shared/tree-sitter-extractor/src/file_paths.rs +++ b/shared/tree-sitter-extractor/src/file_paths.rs @@ -11,8 +11,7 @@ pub fn relativize_for_diagnostic(path: &Path, source_root: Option<&Path>) -> Str source_root .and_then(|root| path.strip_prefix(root).ok()) .and_then(|rel| rel.to_str()) - .map(|s| s.replace('\\', "/")) - .unwrap_or_else(|| path.display().to_string()) + .map_or_else(|| path.display().to_string(), |s| s.replace('\\', "/")) } /// This represents the minimum supported path transformation that is needed to support extracting diff --git a/shared/yeast/src/captures.rs b/shared/yeast/src/captures.rs index 25f1e2561586..a09acebee4ad 100644 --- a/shared/yeast/src/captures.rs +++ b/shared/yeast/src/captures.rs @@ -92,7 +92,7 @@ impl Captures { .ok_or_else(|| format!("No variable named {fst}"))? .len(); // TODO: better error on missing capture - if id_iter.any(|id| self.captures.get(id).map(Vec::len).unwrap_or(0) != repeats) { + if id_iter.any(|id| self.captures.get(id).map_or(0, Vec::len) != repeats) { return Err("Repeated captures must have the same number of matches".to_string()); } Ok((0..repeats).map(move |iter| { diff --git a/shared/yeast/src/lib.rs b/shared/yeast/src/lib.rs index adb9b07c2a90..1ab821335ee8 100644 --- a/shared/yeast/src/lib.rs +++ b/shared/yeast/src/lib.rs @@ -1090,10 +1090,7 @@ impl Node { /// Read the child ids stored under a given field, or an empty slice if /// no such field is present on this node. pub fn field_children(&self, field_id: FieldId) -> &[Id] { - self.fields - .get(&field_id) - .map(|v| v.as_slice()) - .unwrap_or(&[]) + self.fields.get(&field_id).map_or(&[][..], Vec::as_slice) } } @@ -1344,7 +1341,7 @@ fn apply_rules_inner( )); } - let node_kind = ast.get_node(id).map(|n| n.kind_name()).unwrap_or(""); + let node_kind = ast.get_node(id).map_or("", |n| n.kind_name()); for rule in index.rules_for_kind(node_kind) { let Some(captures) = rule.match_query(ast, id) else { diff --git a/unified/extractor/tests/corpus_tests.rs b/unified/extractor/tests/corpus_tests.rs index 5a45c0f45b17..53f0b7da4838 100644 --- a/unified/extractor/tests/corpus_tests.rs +++ b/unified/extractor/tests/corpus_tests.rs @@ -17,8 +17,7 @@ struct CorpusCase { fn update_mode_enabled() -> bool { std::env::var("UNIFIED_UPDATE_CORPUS") - .map(|v| matches!(v.to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on")) - .unwrap_or(false) + .is_ok_and(|v| matches!(v.to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on")) } /// Parse a corpus `.output` file. The file holds a single test case made of From fd386a1aa5e0c147f6c9b3a39cd1b7b10a7aefb0 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:13:31 +0100 Subject: [PATCH 07/39] Fix all results of the Clippy lint `manual_string_new` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/extractor/src/diagnostics.rs | 2 +- shared/tree-sitter-extractor/src/extractor/mod.rs | 2 +- shared/tree-sitter-extractor/src/file_paths.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/extractor/src/diagnostics.rs b/rust/extractor/src/diagnostics.rs index ab88192c5d3e..8b84f6074351 100644 --- a/rust/extractor/src/diagnostics.rs +++ b/rust/extractor/src/diagnostics.rs @@ -40,7 +40,7 @@ enum Message { impl Default for Message { fn default() -> Self { - Message::TextMessage("".to_string()) + Message::TextMessage(String::new()) } } diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index 5dc5047440f5..28d89fe8754f 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -184,7 +184,7 @@ fn populate_empty_file(writer: &mut trap::Writer) -> trap::Label { "files", vec![ trap::Arg::Label(file_label), - trap::Arg::String("".to_string()), + trap::Arg::String(String::new()), ], ); } diff --git a/shared/tree-sitter-extractor/src/file_paths.rs b/shared/tree-sitter-extractor/src/file_paths.rs index 7b11ab62b88a..109c0799938f 100644 --- a/shared/tree-sitter-extractor/src/file_paths.rs +++ b/shared/tree-sitter-extractor/src/file_paths.rs @@ -114,7 +114,7 @@ fn normalize_path(path: &Path) -> String { if path_components.peek().is_none() { // The path points at a root directory, so we need to add a // trailing slash, e.g. `C:/` instead of `C:`. - components.push("".to_string()); + components.push(String::new()); } } std::path::Component::CurDir => {} From bac4c43aa9764f495da6f0c33c7262769d12bd3f Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:19:15 +0100 Subject: [PATCH 08/39] Fix all results of the Clippy lint `needless_continue` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- shared/tree-sitter-extractor/src/file_paths.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/tree-sitter-extractor/src/file_paths.rs b/shared/tree-sitter-extractor/src/file_paths.rs index 109c0799938f..eceac6ecae2d 100644 --- a/shared/tree-sitter-extractor/src/file_paths.rs +++ b/shared/tree-sitter-extractor/src/file_paths.rs @@ -166,7 +166,7 @@ pub fn path_from_string(path: &str) -> PathBuf { // remove `.` and `..` components for component in components { match component { - std::path::Component::CurDir => continue, + std::path::Component::CurDir => {} std::path::Component::ParentDir => { result.pop(); } From c522fd217ad9520c27eb176c5165f3d46a55d86b Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:31:15 +0100 Subject: [PATCH 09/39] Fix all results of the Clippy lint `match_same_arms` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/ast-generator/src/main.rs | 9 +++------ shared/tree-sitter-extractor/src/extractor/mod.rs | 2 +- shared/tree-sitter-extractor/src/file_paths.rs | 8 ++------ shared/tree-sitter-extractor/src/generator/mod.rs | 4 ++-- shared/tree-sitter-extractor/src/generator/ql_gen.rs | 5 +++-- shared/yeast/src/query.rs | 3 +-- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index db07a39bb4b0..c0537f874757 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -31,8 +31,7 @@ fn class_name(type_name: &str) -> String { fn property_name(type_name: &str, field_name: &str) -> String { let name = match (type_name, field_name) { ("CallExpr", "expr") => "function", - ("LetExpr", "expr") => "scrutinee", - ("MatchExpr", "expr") => "scrutinee", + ("LetExpr" | "MatchExpr", "expr") => "scrutinee", ("Variant", "expr") => "discriminant", ("FieldExpr", "expr") => "container", (_, "name_ref") => "identifier", @@ -128,8 +127,7 @@ fn get_additional_fields(node_name: &str) -> Vec { FieldInfo::optional("self_ty", "Type"), ], "ForExpr" => vec![FieldInfo::optional("iterable", "Expr")], - "WhileExpr" => vec![FieldInfo::optional("condition", "Expr")], - "MatchGuard" => vec![FieldInfo::optional("condition", "Expr")], + "WhileExpr" | "MatchGuard" => vec![FieldInfo::optional("condition", "Expr")], "MacroDef" => vec![ FieldInfo::body("args", "TokenTree"), FieldInfo::body("body", "TokenTree"), @@ -139,8 +137,7 @@ fn get_additional_fields(node_name: &str) -> Vec { "FormatArgsExpr" => vec![FieldInfo::list("args", "FormatArgsArg")], "ArgList" => vec![FieldInfo::list("args", "Expr")], "Fn" => vec![FieldInfo::body("body", "BlockExpr")], - "Const" => vec![FieldInfo::body("body", "Expr")], - "Static" => vec![FieldInfo::body("body", "Expr")], + "Const" | "Static" => vec![FieldInfo::body("body", "Expr")], "Param" => vec![FieldInfo::body("pat", "Pat")], "ClosureExpr" => vec![FieldInfo::optional("body", "Expr")], "ArrayExpr" => vec![FieldInfo::predicate("is_semicolon")], diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index 28d89fe8754f..a15f6c21f6aa 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -140,10 +140,10 @@ pub fn default_subscriber_with_level( .as_ref() .map_or("warn", |v| match v.to_lowercase().as_str() { "off" | "errors" => "error", - "warnings" => "warn", "info" | "progress" => "info", "debug" | "progress+" => "debug", "trace" | "progress++" | "progress+++" => "trace", + // "warnings" or any other string _ => "warn", }); tracing_subscriber::EnvFilter::new(format!( diff --git a/shared/tree-sitter-extractor/src/file_paths.rs b/shared/tree-sitter-extractor/src/file_paths.rs index eceac6ecae2d..c6c118d7b913 100644 --- a/shared/tree-sitter-extractor/src/file_paths.rs +++ b/shared/tree-sitter-extractor/src/file_paths.rs @@ -117,8 +117,7 @@ fn normalize_path(path: &Path) -> String { components.push(String::new()); } } - std::path::Component::CurDir => {} - std::path::Component::ParentDir => {} + std::path::Component::CurDir | std::path::Component::ParentDir => {} } } components.join("/") @@ -205,15 +204,12 @@ pub fn path_for( result.push(share); } }, - std::path::Component::RootDir => { + std::path::Component::RootDir | std::path::Component::CurDir => { // skip } std::path::Component::Normal(_) => { result.push(component); } - std::path::Component::CurDir => { - // skip - } std::path::Component::ParentDir => { result.pop(); } diff --git a/shared/tree-sitter-extractor/src/generator/mod.rs b/shared/tree-sitter-extractor/src/generator/mod.rs index 0d29d67e3ba0..502de6ead1d6 100644 --- a/shared/tree-sitter-extractor/src/generator/mod.rs +++ b/shared/tree-sitter-extractor/src/generator/mod.rs @@ -295,8 +295,8 @@ fn make_field_type<'a>( let case = dbscheme::Entry::Case(dbscheme::Case { name: parent_name, column: match &field.storage { - node_types::Storage::Column { name } => name, - node_types::Storage::Table { name, .. } => name, + node_types::Storage::Column { name } + | node_types::Storage::Table { name, .. } => name, }, branches, }); diff --git a/shared/tree-sitter-extractor/src/generator/ql_gen.rs b/shared/tree-sitter-extractor/src/generator/ql_gen.rs index bd05de8316d8..b18616e617d8 100644 --- a/shared/tree-sitter-extractor/src/generator/ql_gen.rs +++ b/shared/tree-sitter-extractor/src/generator/ql_gen.rs @@ -636,8 +636,9 @@ fn create_field_getters<'a>( // be bound to? let get_value_result_var_name = match &field.type_info { node_types::FieldTypeInfo::ReservedWordInt(_) => "value", - node_types::FieldTypeInfo::Single(_) => "result", - node_types::FieldTypeInfo::Multiple { .. } => "result", + node_types::FieldTypeInfo::Single(_) | node_types::FieldTypeInfo::Multiple { .. } => { + "result" + } }; // Two expressions for getting the value. One that's suitable use in the diff --git a/shared/yeast/src/query.rs b/shared/yeast/src/query.rs index 37c9ced07e4e..2569b776ff88 100644 --- a/shared/yeast/src/query.rs +++ b/shared/yeast/src/query.rs @@ -27,8 +27,7 @@ impl QueryNode { /// Returns None for wildcards (Any) and captures wrapping wildcards. pub fn root_kind(&self) -> Option<&'static str> { match self { - QueryNode::Node { kind, .. } => Some(kind), - QueryNode::UnnamedNode { kind } => Some(kind), + QueryNode::Node { kind, .. } | QueryNode::UnnamedNode { kind } => Some(kind), QueryNode::Capture { node, .. } => node.root_kind(), QueryNode::Any { .. } => None, } From e98c56226e980342537b6c2f5c265d0c5c05bf46 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:34:01 +0100 Subject: [PATCH 10/39] Fix all results of the Clippy lint `unnecessary_literal_bound` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- shared/tree-sitter-extractor/src/extractor/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index a15f6c21f6aa..7fe005a44704 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -478,7 +478,7 @@ struct ExtraNode { } impl AstNode for ExtraNode { - fn kind(&self) -> &str { + fn kind(&self) -> &'static str { "extra" } fn is_named(&self) -> bool { From 17db5e14227e59ae66219f9d117951cde1a23c2b Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:38:03 +0100 Subject: [PATCH 11/39] Fix all results of the Clippy lint `elidable_lifetime_names` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- shared/tree-sitter-extractor/src/extractor/mod.rs | 2 +- shared/yeast/src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index 7fe005a44704..e428e2c83532 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -39,7 +39,7 @@ trait AstNode { } } -impl<'a> AstNode for Node<'a> { +impl AstNode for Node<'_> { fn kind(&self) -> &str { Node::kind(self) } diff --git a/shared/yeast/src/lib.rs b/shared/yeast/src/lib.rs index 1ab821335ee8..614744de5f1d 100644 --- a/shared/yeast/src/lib.rs +++ b/shared/yeast/src/lib.rs @@ -1144,7 +1144,7 @@ impl TranslatorHandle<'_, C> { } } -impl<'a, C: Clone> TranslatorHandle<'a, C> { +impl TranslatorHandle<'_, C> { /// Recursively apply the current phase's rules to `id` and return the /// resulting node ids. pub fn translate( @@ -1570,7 +1570,7 @@ impl<'a, C> Runner<'a, C> { } } -impl<'a, C: Clone> Runner<'a, C> { +impl Runner<'_, C> { /// Parse `tree` against `source` and run the configured translation, threading /// `user_ctx` through every rule transform. The caller owns the /// initial context state. @@ -1664,7 +1664,7 @@ impl<'a, C: Clone> Runner<'a, C> { } } -impl<'a, C: Clone + Default> Runner<'a, C> { +impl Runner<'_, C> { /// Parse `tree` against `source` and run the configured translation, using /// the default context (`C::default()`) as the initial context state. pub fn run_from_tree( From b03995f700e69bf26b382b042c65e7bdfdc3196d Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:55:56 +0100 Subject: [PATCH 12/39] Fix all results of the Clippy lint `doc_markdown` --- clippy.toml | 2 ++ shared/tree-sitter-extractor/src/extractor/mod.rs | 6 +++--- shared/tree-sitter-extractor/src/node_types.rs | 8 ++++---- shared/tree-sitter-extractor/src/options.rs | 2 +- shared/tree-sitter-extractor/src/trap.rs | 4 ++-- shared/yeast-schema/src/node_types_yaml.rs | 4 ++-- shared/yeast/src/dump.rs | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 000000000000..e901773fa799 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,2 @@ +# Names that do not need to be backtick quoted within documentation comments. +doc-valid-idents = ["CodeQL", ".."] diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index e428e2c83532..7803556ff5dc 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -528,9 +528,9 @@ struct Visitor<'a> { file_label: trap::Label, /// The source code as a UTF-8 byte array source: &'a [u8], - /// A diagnostics::LogWriter to write diagnostic messages + /// A `diagnostics::LogWriter` to write diagnostic messages diagnostics_writer: &'a mut diagnostics::LogWriter, - /// A trap::Writer to accumulate trap entries + /// A `trap::Writer` to accumulate trap entries trap_writer: &'a mut trap::Writer, /// Language-specific name of the AST location table ast_node_location_table_name: String, @@ -547,7 +547,7 @@ struct Visitor<'a> { /// All children append their data to the list. When the visitor leaves a /// node the list containing the child data is popped from the stack and /// matched against the dbscheme for the node. If the expectations are met - /// the corresponding row definitions are added to the trap_output. + /// the corresponding row definitions are added to the `trap_output`. stack: Vec<(trap::Label, usize, Vec)>, } diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index f1d49cb8350f..593d7bda28a6 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -5,7 +5,7 @@ use std::path::Path; use std::collections::BTreeSet as Set; use std::fs; -/// A lookup table from TypeName to Entry. +/// A lookup table from `TypeName` to `Entry`. pub type NodeTypeMap = BTreeMap; #[derive(Debug)] @@ -60,7 +60,7 @@ pub struct Field { pub parent: TypeName, pub type_info: FieldTypeInfo, /// The name of the field or None for the anonymous 'children' - /// entry from node_types.json + /// entry from `node_types.json` pub name: Option, /// The name of the predicate to get this field. pub getter_name: String, @@ -457,8 +457,8 @@ pub fn to_snake_case(word: &str) -> String { } result } -/// Given a valid dbscheme name (i.e. in snake case), produces the equivalent QL -/// name (i.e. in CamelCase). For example, "foo_bar_baz" becomes "FooBarBaz". +/// Given a valid dbscheme name (i.e. in `snake case`), produces the equivalent QL +/// name (i.e. in `CamelCase`). For example, `foo_bar_baz` becomes `FooBarBaz`. fn dbscheme_name_to_class_name(dbscheme_name: &str) -> String { fn to_title_case(word: &str) -> String { let mut first = true; diff --git a/shared/tree-sitter-extractor/src/options.rs b/shared/tree-sitter-extractor/src/options.rs index d2fdc5bede0b..52555bb2eac1 100644 --- a/shared/tree-sitter-extractor/src/options.rs +++ b/shared/tree-sitter-extractor/src/options.rs @@ -1,7 +1,7 @@ use num_cpus; /// Gets the number of threads the extractor should use. -/// This is controlled by the CODEQL_THREADS environment variable. +/// This is controlled by the `CODEQL_THREADS` environment variable. pub fn num_threads() -> Result { let threads_str = std::env::var("CODEQL_THREADS").unwrap_or_else(|_| "-1".into()); let num_cpus = num_cpus::get(); diff --git a/shared/tree-sitter-extractor/src/trap.rs b/shared/tree-sitter-extractor/src/trap.rs index d910a2a12c27..8fdb1408c9e9 100644 --- a/shared/tree-sitter-extractor/src/trap.rs +++ b/shared/tree-sitter-extractor/src/trap.rs @@ -55,7 +55,7 @@ impl Writer { /// Note: You probably want to make sure that the key strings that you use are disjoint /// for disjoint column types; the standard way of doing this is to prefix (or append) /// the column type name to the ID. Thus, you might identify methods in Java by the - /// full ID "methods_com.method.package.DeclaringClass.method(argumentList)". + /// full ID `methods_com.method.package.DeclaringClass.method(argumentList)`. pub fn global_id(&mut self, key: &str) -> (Label, bool) { if let Some(label) = self.global_keys.get(key) { return (*label, false); @@ -123,7 +123,7 @@ pub enum Entry { FreshId(Label), /// Maps the label to a key, e.g. `#7=@"foo"`. MapLabelToKey(Label, String), - /// foo_bar(arg*) + /// `foo_bar(arg*)` GenericTuple(String, Vec), Comment(String), } diff --git a/shared/yeast-schema/src/node_types_yaml.rs b/shared/yeast-schema/src/node_types_yaml.rs index 425b57aa2b7f..cc395315512b 100644 --- a/shared/yeast-schema/src/node_types_yaml.rs +++ b/shared/yeast-schema/src/node_types_yaml.rs @@ -128,7 +128,7 @@ fn parse_field_name(raw: &str) -> FieldSpec { } } -/// Resolve a TypeRef to a (type, named) pair, given the sets of known named +/// Resolve a `TypeRef` to a `(type, named)` pair, given the sets of known named /// and unnamed types. fn resolve_type_ref_pair( type_ref: &TypeRef, @@ -151,7 +151,7 @@ fn resolve_type_ref_pair( } } -/// Resolve a TypeRef to a {type, named} JSON record, given the sets of known named +/// Resolve a `TypeRef` to a `{type, named}` JSON record, given the sets of known named /// and unnamed types. fn resolve_type_ref( type_ref: &TypeRef, diff --git a/shared/yeast/src/dump.rs b/shared/yeast/src/dump.rs index 84917fc367af..6e4c3d291667 100644 --- a/shared/yeast/src/dump.rs +++ b/shared/yeast/src/dump.rs @@ -124,7 +124,7 @@ const EMPTY_NODE_TYPES: &[crate::schema::NodeType] = &[]; /// - `schema`: The AST schema to validate against. /// - `node`: The node being checked. /// - `expected`: The set of allowed types for this node, or `None` if type-checking is disabled. -/// - `parent_field`: Optional tuple of (parent_kind, field_name) for context in error messages. +/// - `parent_field`: Optional tuple of `(parent_kind, field_name)` for context in error messages. /// /// # Returns /// `Some(error_message)` if the node violates the schema (e.g., wrong kind, missing field declaration). From 6b00a3772895fcadd62bc71b3fe683b16915f2e9 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 08:59:04 +0100 Subject: [PATCH 13/39] Fix all results of the Clippy lint `unnecessary_join` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- shared/tree-sitter-extractor/src/node_types.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index 593d7bda28a6..1c34838ba762 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -476,8 +476,7 @@ fn dbscheme_name_to_class_name(dbscheme_name: &str) -> String { dbscheme_name .split('_') .map(to_title_case) - .collect::>() - .join("") + .collect::() } #[test] From c2877994cf34b05a52d73e40e6d9ad90c96db979 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:04:00 +0100 Subject: [PATCH 14/39] Fix all results of the Clippy lint `needless_raw_string_hashes` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- .../src/generator/ql_gen.rs | 8 +++---- .../tree-sitter-extractor/src/node_types.rs | 4 ++-- shared/yeast-macros/src/ast.rs | 4 ++-- shared/yeast-schema/src/node_types_yaml.rs | 20 ++++++++-------- shared/yeast/tests/test.rs | 24 +++++++++---------- unified/swift-syntax-rs/src/lib.rs | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/shared/tree-sitter-extractor/src/generator/ql_gen.rs b/shared/tree-sitter-extractor/src/generator/ql_gen.rs index b18616e617d8..2aa4e574d925 100644 --- a/shared/tree-sitter-extractor/src/generator/ql_gen.rs +++ b/shared/tree-sitter-extractor/src/generator/ql_gen.rs @@ -1218,7 +1218,7 @@ mod tests { #[test] fn indexes_predicate_signatures_exposed_by_classes() { - let yaml = r#" + let yaml = r" supertypes: callable: subtypes: [function_like] @@ -1237,7 +1237,7 @@ named: parameter: block: identifier: -"#; +"; let json = yeast::node_types_yaml::convert(yaml).unwrap(); let nodes = node_types::read_node_types_str("test", &json).unwrap(); let signatures = compute_exposed_predicate_signatures(&nodes); @@ -1268,7 +1268,7 @@ named: #[test] fn generates_supertype_getters_and_concrete_overrides() { - let yaml = r#" + let yaml = r" supertypes: callable: subtypes: [function] @@ -1281,7 +1281,7 @@ named: body?: block parameter: block: -"#; +"; let json = yeast::node_types_yaml::convert(yaml).unwrap(); let nodes = node_types::read_node_types_str("test", &json).unwrap(); let generated = convert_nodes(&nodes) diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index 1c34838ba762..944b192bd932 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -494,7 +494,7 @@ fn to_snake_case_test() { #[test] fn supertype_fields_are_preserved() { - let yaml = r#" + let yaml = r" supertypes: callable: subtypes: [function] @@ -505,7 +505,7 @@ named: function: parameter: block: -"#; +"; let json = yeast::node_types_yaml::convert(yaml).unwrap(); let nodes = read_node_types_str("test", &json).unwrap(); let callable = nodes diff --git a/shared/yeast-macros/src/ast.rs b/shared/yeast-macros/src/ast.rs index f534fe4d83a7..0f341fcef29d 100644 --- a/shared/yeast-macros/src/ast.rs +++ b/shared/yeast-macros/src/ast.rs @@ -209,12 +209,12 @@ mod tests { fn output_leaf_kinds() -> BTreeSet { yeast_schema::node_types_yaml::leaf_kinds_from_yaml( - r#" + r" named: assignment: left: identifier identifier: -"#, +", ) .unwrap() } diff --git a/shared/yeast-schema/src/node_types_yaml.rs b/shared/yeast-schema/src/node_types_yaml.rs index cc395315512b..2f54823f5b55 100644 --- a/shared/yeast-schema/src/node_types_yaml.rs +++ b/shared/yeast-schema/src/node_types_yaml.rs @@ -829,13 +829,13 @@ unnamed: #[test] fn test_leaf_kinds_from_yaml() { let leaf_kinds = leaf_kinds_from_yaml( - r#" + r" named: identifier: empty_fields: {} call: callee: identifier -"#, +", ) .unwrap(); @@ -846,14 +846,14 @@ named: #[test] fn test_explicit_unnamed_disambiguation() { - let yaml = r#" + let yaml = r" named: foo: field: [{unnamed: bar}] unnamed: - bar -"#; +"; let json_str = convert(yaml).unwrap(); let result: Vec = serde_json::from_str(&json_str).unwrap(); @@ -863,14 +863,14 @@ unnamed: #[test] fn test_field_suffixes() { - let yaml = r#" + let yaml = r" named: test_node: required_single: foo optional_single?: foo required_multiple+: foo optional_multiple*: foo -"#; +"; let json_str = convert(yaml).unwrap(); let result: Vec = serde_json::from_str(&json_str).unwrap(); @@ -892,7 +892,7 @@ named: #[test] fn test_supertype_fields() { - let yaml = r#" + let yaml = r" supertypes: callable: subtypes: @@ -907,7 +907,7 @@ named: closure: parameter: block: -"#; +"; let json = convert(yaml).unwrap(); let result: Vec = serde_json::from_str(&json).unwrap(); @@ -1007,7 +1007,7 @@ unnamed: #[test] fn test_supertype_fields_round_trip() { - let yaml = r#" + let yaml = r" supertypes: callable: subtypes: [function, closure] @@ -1020,7 +1020,7 @@ named: closure: parameter: block: -"#; +"; let json = convert(yaml).unwrap(); let yaml_output = convert_from_json(&json).unwrap(); diff --git a/shared/yeast/tests/test.rs b/shared/yeast/tests/test.rs index f0e705c0f139..1db2eacb0b46 100644 --- a/shared/yeast/tests/test.rs +++ b/shared/yeast/tests/test.rs @@ -248,7 +248,7 @@ fn test_parse_for_loop() { #[test] fn test_dump_highlights_type_errors_inline() { - let schema_yaml = r#" + let schema_yaml = r" named: program: $children*: assignment @@ -256,7 +256,7 @@ named: left: identifier right: identifier identifier: -"#; +"; let dump = parse_and_dump_typed("x = 1", schema_yaml); assert!(dump.contains("integer \"1\" <-- ERROR:")); @@ -264,7 +264,7 @@ named: #[test] fn test_dump_reports_preserved_unknown_kind_after_transformation() { - let schema_yaml = r#" + let schema_yaml = r" named: program: $children*: assignment @@ -272,7 +272,7 @@ named: left: identifier right: identifier identifier: -"#; +"; // This rewrite runs and preserves the RHS node kind via capture. // With schema above, preserving `integer` should be reported inline. @@ -292,14 +292,14 @@ named: #[test] fn test_dump_reports_undeclared_field_on_node() { - let schema_yaml = r#" + let schema_yaml = r" named: program: $children*: assignment assignment: left: identifier identifier: -"#; +"; let dump = parse_and_dump_typed_with_language("x = y", schema_yaml); assert!(dump.contains("right: identifier \"y\" <-- ERROR:")); @@ -308,7 +308,7 @@ named: #[test] fn test_dump_reports_disallowed_kind_in_field_type() { - let schema_yaml = r#" + let schema_yaml = r" named: program: $children*: assignment @@ -317,7 +317,7 @@ named: right: identifier identifier: integer: -"#; +"; let dump = parse_and_dump_typed_with_language("x = 1", schema_yaml); assert!(dump.contains("right: integer \"1\" <-- ERROR:")); @@ -351,12 +351,12 @@ fn test_query_match() { fn test_run_from_ast_desugars_hand_built_tree() { // Output schema for the desugared tree. Its kind/field names must become // resolvable in the hand-built AST's schema for the rule to build them. - let schema_yaml = r#" + let schema_yaml = r" named: assignment: left: leaf leaf: -"#; +"; // A rule over an *input* kind (`wrapper`) that is not in the output schema, // rewriting to an output `assignment` node. @@ -1062,10 +1062,10 @@ fn test_innermost_choice_catches_first() { assert_dump_eq( &dump_ast(ctx.output, root, input), - r#" + r" assignment left: left_assignment_list - "#, + ", ); } diff --git a/unified/swift-syntax-rs/src/lib.rs b/unified/swift-syntax-rs/src/lib.rs index db494f36a4fb..a0f4b86c0397 100644 --- a/unified/swift-syntax-rs/src/lib.rs +++ b/unified/swift-syntax-rs/src/lib.rs @@ -131,7 +131,7 @@ mod tests { fn parses_source_with_interior_nul() { let json = parse_to_json("let x =\0 1").expect("parsing interior NUL should succeed"); assert!( - json.contains(r#"\u0000"#), + json.contains(r"\u0000"), "interior NUL should be preserved in the JSON tree: {json}" ); } From 52e9f50795a563b6a7b156ceec8a0a800ae9c77a Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:08:11 +0100 Subject: [PATCH 15/39] Fix all results of the Clippy lint `non_std_lazy_statics` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- ql/buramu/src/main.rs | 8 +++----- ruby/extractor/src/extractor.rs | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ql/buramu/src/main.rs b/ql/buramu/src/main.rs index 0fbdacc3d0c2..9efe9e4c7e9d 100644 --- a/ql/buramu/src/main.rs +++ b/ql/buramu/src/main.rs @@ -1,7 +1,7 @@ -use lazy_static::lazy_static; use rayon::prelude::*; use regex::Regex; use std::collections::HashMap; +use std::sync::LazyLock; use std::{io::BufRead, process::Command}; // A map from filenames to lists of line numbers (for just the lines with deprecations) @@ -69,10 +69,8 @@ fn get_blame_dates_for_filedeprecation(file: &str, linenos: &[String]) -> LastMo blame_dates } -lazy_static! { - static ref BLAME_RE: Regex = - Regex::new("(\\d{4}-\\d{2}-\\d{2}).*[+-]\\d{4}\\s+(\\d+)\\)").unwrap(); -} +static BLAME_RE: LazyLock = + LazyLock::new(|| Regex::new("(\\d{4}-\\d{2}-\\d{2}).*[+-]\\d{4}\\s+(\\d+)\\)").unwrap()); fn get_last_modified(line: &str) -> LastModifiedLine { let caps = BLAME_RE.captures(line).unwrap(); diff --git a/ruby/extractor/src/extractor.rs b/ruby/extractor/src/extractor.rs index 91852a5b0057..52c110a27b76 100644 --- a/ruby/extractor/src/extractor.rs +++ b/ruby/extractor/src/extractor.rs @@ -1,12 +1,12 @@ use clap::Args; use codeql_extractor::file_paths::PathTransformer; -use lazy_static::lazy_static; use rayon::prelude::*; use std::borrow::Cow; use std::collections::HashSet; use std::fs; use std::io::BufRead; use std::path::{Path, PathBuf}; +use std::sync::LazyLock; use tree_sitter::{Language, Parser, Range}; use codeql_extractor::{diagnostics, extractor, file_paths, node_types, trap}; @@ -246,9 +246,8 @@ pub fn run(options: Options) -> std::io::Result<()> { res } -lazy_static! { - static ref CP_NUMBER: regex::Regex = regex::Regex::new("cp([0-9]+)").unwrap(); -} +static CP_NUMBER: LazyLock = + LazyLock::new(|| regex::Regex::new("cp([0-9]+)").unwrap()); /// Returns the `encoding::Encoding` corresponding to the given encoding name, if one exists. fn encoding_from_name(encoding_name: &str) -> Option<&(dyn encoding::Encoding + Send + Sync)> { From ae96ca1011f598a872b3fa108ef230fde4d0b595 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:11:44 +0100 Subject: [PATCH 16/39] Fix all results of the Clippy lint `manual_assert` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- .../tree-sitter-extractor/src/generator/ql_gen.rs | 8 +++++--- unified/extractor/tests/corpus_tests.rs | 13 ++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/shared/tree-sitter-extractor/src/generator/ql_gen.rs b/shared/tree-sitter-extractor/src/generator/ql_gen.rs index 2aa4e574d925..78aff197bcb8 100644 --- a/shared/tree-sitter-extractor/src/generator/ql_gen.rs +++ b/shared/tree-sitter-extractor/src/generator/ql_gen.rs @@ -1038,9 +1038,11 @@ pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec> { name: main_table_name, fields, } => { - if fields.is_empty() { - panic!("Encountered node '{}' with no fields", type_name.kind); - } + assert!( + !fields.is_empty(), + "Encountered node '{}' with no fields", + type_name.kind + ); // Count how many columns there will be in the main table. There // will be one for the id, plus one for each field that's stored diff --git a/unified/extractor/tests/corpus_tests.rs b/unified/extractor/tests/corpus_tests.rs index 53f0b7da4838..5a76038b2f54 100644 --- a/unified/extractor/tests/corpus_tests.rs +++ b/unified/extractor/tests/corpus_tests.rs @@ -141,13 +141,12 @@ fn test_corpus() { // The canonical test case lives in the `.swift` file and is the // source of truth. An `.output` file without a `.swift` sibling is // an orphan: there is nothing to drive it from. - if !swift_path.exists() { - panic!( - "Found {} with no corresponding test case; add {} or remove the output file", - output_path.display(), - swift_path.display() - ); - } + assert!( + swift_path.exists(), + "Found {} with no corresponding test case; add {} or remove the output file", + output_path.display(), + swift_path.display() + ); let swift_input = fs::read_to_string(&swift_path) .unwrap_or_else(|e| panic!("Failed to read {}: {e}", swift_path.display())) From 925a3904b143864f7b02907910eb813df16ab56f Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:15:58 +0100 Subject: [PATCH 17/39] Fix all results of the Clippy lint `trivially_copy_pass_by_ref` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/extractor/src/crate_graph.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/extractor/src/crate_graph.rs b/rust/extractor/src/crate_graph.rs index c65df621d120..65a7bd29eaf4 100644 --- a/rust/extractor/src/crate_graph.rs +++ b/rust/extractor/src/crate_graph.rs @@ -33,7 +33,7 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData krate_id .cfg_options(db) .into_iter() - .sorted_by(cmp_flag) + .sorted_by(|&a, &b| cmp_flag(a, b)) .for_each(|x| format!("{x}").hash(&mut hasher)); krate @@ -102,7 +102,7 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData } } -fn cmp_flag(a: &&CfgAtom, b: &&CfgAtom) -> Ordering { +fn cmp_flag(a: &CfgAtom, b: &CfgAtom) -> Ordering { match (a, b) { (CfgAtom::Flag(a), CfgAtom::Flag(b)) => a.as_str().cmp(b.as_str()), (CfgAtom::Flag(a), CfgAtom::KeyValue { key: b, value: _ }) => { From 9e71fdb9451cc901a0668df2f1114d2505e0b170 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:18:31 +0100 Subject: [PATCH 18/39] Fix all results of the Clippy lint `flat_map_option` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/extractor/src/crate_graph.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/extractor/src/crate_graph.rs b/rust/extractor/src/crate_graph.rs index 65a7bd29eaf4..c07d9d28232b 100644 --- a/rust/extractor/src/crate_graph.rs +++ b/rust/extractor/src/crate_graph.rs @@ -39,7 +39,7 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData krate .dependencies .iter() - .flat_map(|d| crate_id_map.get(&d.crate_id)) + .filter_map(|d| crate_id_map.get(&d.crate_id)) .sorted() .for_each(|x| x.hash(&mut hasher)); let hash = hasher.finish(); @@ -61,7 +61,7 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData let crate_dependencies: Vec = krate .dependencies .iter() - .flat_map(|x| crate_id_map.get(&x.crate_id).map(|y| (&x.name, y))) + .filter_map(|x| crate_id_map.get(&x.crate_id).map(|y| (&x.name, y))) .map(|(name, (module, hash))| generated::NamedCrate { id: trap::TrapId::Star, name: name.to_string(), From 5ef41d366510b53baf26c1f36ef8dde8b376594c Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:22:44 +0100 Subject: [PATCH 19/39] Fix all results of the Clippy lint `ref_option` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/extractor/src/configuration.rs | 8 ++++++-- rust/extractor/src/util.rs | 4 ++-- shared/tree-sitter-extractor/src/node_types.rs | 10 +++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/rust/extractor/src/configuration.rs b/rust/extractor/src/configuration.rs index cbf94ee068d3..d1e5726b90a0 100644 --- a/rust/extractor/src/configuration.rs +++ b/rust/extractor/src/configuration.rs @@ -97,8 +97,12 @@ impl Ord for DependencySource<'_> { fn cmp(&self, other: &Self) -> Ordering { // Compare by cfg options first, then by manifest parent directory // (arbitrary but deterministic). - cmp_option_by(&self.cfg_options, &other.cfg_options, compare_cfg_options) - .then_with(|| manifest_parent(self.manifest).cmp(manifest_parent(other.manifest))) + cmp_option_by( + self.cfg_options.as_ref(), + other.cfg_options.as_ref(), + compare_cfg_options, + ) + .then_with(|| manifest_parent(self.manifest).cmp(manifest_parent(other.manifest))) } } diff --git a/rust/extractor/src/util.rs b/rust/extractor/src/util.rs index a12ca6de74a1..5bfa5e3fc8b3 100644 --- a/rust/extractor/src/util.rs +++ b/rust/extractor/src/util.rs @@ -2,8 +2,8 @@ use std::cmp::Ordering; /// Compares options using a custom comparator, with `None` ordered before `Some`. pub(crate) fn cmp_option_by( - left: &Option, - right: &Option, + left: Option<&T>, + right: Option<&T>, compare: impl FnOnce(&T, &T) -> Ordering, ) -> Ordering { match (left, right) { diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index 944b192bd932..1e02d50f32ba 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -70,7 +70,7 @@ pub struct Field { pub storage: Storage, } -fn name_for_field_or_child(name: &Option) -> String { +fn name_for_field_or_child(name: Option<&String>) -> String { match name { Some(name) => name.clone(), None => "child".to_owned(), @@ -259,7 +259,7 @@ fn add_field( token_kinds: &Set, ) { let parent_flattened_name = node_type_name(&parent_type_name.kind, parent_type_name.named); - let column_name = escape_name(&name_for_field_or_child(&field_name)); + let column_name = escape_name(&name_for_field_or_child(field_name.as_ref())); let storage = if !field_info.multiple && field_info.required { // This field must appear exactly once, so we add it as // a column to the main table for the node type. @@ -271,7 +271,7 @@ fn add_field( "{}_{}_{}", prefix, parent_flattened_name, - name_for_field_or_child(&field_name) + name_for_field_or_child(field_name.as_ref()) )); Storage::Table { has_index, @@ -306,14 +306,14 @@ fn add_field( "{}_{}_{}_type", prefix, parent_flattened_name, - name_for_field_or_child(&field_name) + name_for_field_or_child(field_name.as_ref()) ), ql_class: "AstNode".to_owned(), } }; let getter_name = format!( "get{}", - dbscheme_name_to_class_name(&escape_name(&name_for_field_or_child(&field_name))) + dbscheme_name_to_class_name(&escape_name(&name_for_field_or_child(field_name.as_ref()))) ); let getter_suffix = getter_name.strip_prefix("get").unwrap_or(&getter_name); let article = match getter_suffix.chars().next().map(|c| c.to_ascii_lowercase()) { From 31544531ee5e2520d8fa12b6abe7893045e61aad Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:25:59 +0100 Subject: [PATCH 20/39] Fix all results of the Clippy lint `semicolon_if_nothing_returned` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- ruby/extractor/src/extractor.rs | 6 ++--- .../ast-generator/patches/rust-analyzer.patch | 25 +++++++++++++++++++ rust/ast-generator/src/main.rs | 2 +- rust/extractor/src/crate_graph.rs | 2 +- rust/extractor/src/main.rs | 2 +- rust/extractor/src/translate/base.rs | 6 ++--- .../tree-sitter-extractor/src/diagnostics.rs | 2 +- .../src/extractor/mod.rs | 2 +- .../tree-sitter-extractor/src/file_paths.rs | 4 +-- .../src/generator/ql_gen.rs | 2 +- .../tree-sitter-extractor/src/node_types.rs | 4 +-- shared/tree-sitter-extractor/src/trap.rs | 2 +- 12 files changed, 42 insertions(+), 17 deletions(-) diff --git a/ruby/extractor/src/extractor.rs b/ruby/extractor/src/extractor.rs index 52c110a27b76..b3e683dba144 100644 --- a/ruby/extractor/src/extractor.rs +++ b/ruby/extractor/src/extractor.rs @@ -383,9 +383,9 @@ fn scan_coding_comment(content: &[u8]) -> std::option::Option> { { index += 2; while index < content.len() && content[index] as char != '\n' { - index += 1 + index += 1; } - index += 1 + index += 1; } index = skip_space(content, index); @@ -400,7 +400,7 @@ fn scan_coding_comment(content: &[u8]) -> std::option::Option> { if content[index] as char == CODING[word_index] || content[index] as char == CODING[word_index + 1] { - word_index += 2 + word_index += 2; } else { word_index = 0; } diff --git a/rust/ast-generator/patches/rust-analyzer.patch b/rust/ast-generator/patches/rust-analyzer.patch index 9f70d4f7cd28..8ed8210c354a 100644 --- a/rust/ast-generator/patches/rust-analyzer.patch +++ b/rust/ast-generator/patches/rust-analyzer.patch @@ -63,6 +63,22 @@ index 0aad1e2..68f679f 100644 } }) .collect::>(); +@@ -731,6 +741,6 @@ fn to_upper_snake_case(s: &str) -> String { + let mut prev = false; + for c in s.chars() { + if c.is_ascii_uppercase() && prev { +- buf.push('_') ++ buf.push('_'); + } + prev = true; +@@ -745,6 +755,6 @@ fn to_lower_snake_case(s: &str) -> String { + let mut prev = false; + for c in s.chars() { + if c.is_ascii_uppercase() && prev { +- buf.push('_') ++ buf.push('_'); + } + prev = true; @@ -775,7 +785,7 @@ fn pluralize(s: &str) -> String { } @@ -122,6 +138,15 @@ index 0aad1e2..68f679f 100644 + res.nodes.push(AstNodeSrc { doc: Vec::new(), name, traits: Vec::new(), fields }); } } +@@ -979,7 +986,7 @@ fn lower_rule( + } + Rule::Seq(rules) | Rule::Alt(rules) => { + for rule in rules { +- lower_rule(acc, grammar, label, rule) ++ lower_rule(acc, grammar, label, rule); + } + } + Rule::Opt(rule) => lower_rule(acc, grammar, label, rule), diff --git a/xtask/src/codegen/grammar/ast_src.rs b/xtask/src/codegen/grammar/ast_src.rs index 1ae139f..d4d791e 100644 --- a/xtask/src/codegen/grammar/ast_src.rs diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index c0537f874757..b2eaab385644 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -197,7 +197,7 @@ fn to_lower_snake_case(s: &str) -> String { let mut prev = false; for c in s.chars() { if c.is_ascii_uppercase() && prev { - buf.push('_') + buf.push('_'); } prev = true; diff --git a/rust/extractor/src/crate_graph.rs b/rust/extractor/src/crate_graph.rs index c07d9d28232b..49c86f0f81ab 100644 --- a/rust/extractor/src/crate_graph.rs +++ b/rust/extractor/src/crate_graph.rs @@ -96,7 +96,7 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData "Failed to write trap file for crate: {}: {}", root_module_file.display(), err.to_string() - ) + ); }); } } diff --git a/rust/extractor/src/main.rs b/rust/extractor/src/main.rs index e4e6518a080e..738865836f77 100644 --- a/rust/extractor/src/main.rs +++ b/rust/extractor/src/main.rs @@ -101,7 +101,7 @@ impl<'a> Extractor<'a> { "Failed to write trap file for: {}: {}", file.display(), err.to_string() - ) + ); }); self.steps .push(ExtractionStep::extract(before_extract, source_kind, file)); diff --git a/rust/extractor/src/translate/base.rs b/rust/extractor/src/translate/base.rs index 981a600102c4..e44caf75914c 100644 --- a/rust/extractor/src/translate/base.rs +++ b/rust/extractor/src/translate/base.rs @@ -242,7 +242,7 @@ impl<'db> Translator<'db> { { let token_range = clipped_range + parent_range2.start() - parent_range.start(); if let Some((start, end)) = self.location(token_range) { - self.trap.emit_location(self.label, label, start, end) + self.trap.emit_location(self.label, label, start, end); } } } @@ -596,14 +596,14 @@ impl<'db> Translator<'db> { .and_then(ast::Type::cast) .and_then(|t| self.emit_type(&t)) { - generated::PathSegment::emit_type_repr(label, t, &mut self.trap.writer) + generated::PathSegment::emit_type_repr(label, t, &mut self.trap.writer); } if let Some(t) = type_refs .next() .and_then(ast::PathType::cast) .and_then(|t| self.emit_path_type(&t)) { - generated::PathSegment::emit_trait_type_repr(label, t, &mut self.trap.writer) + generated::PathSegment::emit_trait_type_repr(label, t, &mut self.trap.writer); } // moreover as we're skipping emission of TypeAnchor, we need to attach its comments to // this path segment diff --git a/shared/tree-sitter-extractor/src/diagnostics.rs b/shared/tree-sitter-extractor/src/diagnostics.rs index 5516eeb8ecf2..d63566355257 100644 --- a/shared/tree-sitter-extractor/src/diagnostics.rs +++ b/shared/tree-sitter-extractor/src/diagnostics.rs @@ -134,7 +134,7 @@ impl LogWriter { e ); self.path = None; - self.inner = None + self.inner = None; } Ok(file) => self.inner = Some(std::io::BufWriter::new(file)), } diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index 7803556ff5dc..f765d7438a34 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -891,7 +891,7 @@ impl<'a> Visitor<'a> { } let mut args = vec![trap::Arg::Label(parent_id)]; if *has_index { - args.push(trap::Arg::Int(index)) + args.push(trap::Arg::Int(index)); } args.push(child_value.clone()); self.trap_writer.add_tuple(table_name, args); diff --git a/shared/tree-sitter-extractor/src/file_paths.rs b/shared/tree-sitter-extractor/src/file_paths.rs index c6c118d7b913..5854649b00fa 100644 --- a/shared/tree-sitter-extractor/src/file_paths.rs +++ b/shared/tree-sitter-extractor/src/file_paths.rs @@ -133,7 +133,7 @@ pub fn path_from_string(path: &str) -> PathBuf { let mut path = PathBuf::from(path); // make path absolute if path.is_relative() { - path = std::env::current_dir().unwrap().join(path) + path = std::env::current_dir().unwrap().join(path); }; let mut components = path.components(); @@ -192,7 +192,7 @@ pub fn path_for( match component { std::path::Component::Prefix(prefix) => match prefix.kind() { std::path::Prefix::Disk(letter) | std::path::Prefix::VerbatimDisk(letter) => { - result.push(format!("{}_", letter as char)) + result.push(format!("{}_", letter as char)); } std::path::Prefix::Verbatim(x) | std::path::Prefix::DeviceNS(x) => { result.push(x); diff --git a/shared/tree-sitter-extractor/src/generator/ql_gen.rs b/shared/tree-sitter-extractor/src/generator/ql_gen.rs index 78aff197bcb8..e2a24acc7745 100644 --- a/shared/tree-sitter-extractor/src/generator/ql_gen.rs +++ b/shared/tree-sitter-extractor/src/generator/ql_gen.rs @@ -1094,7 +1094,7 @@ pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec> { } main_class.predicates.extend(get_preds); if let Some(get_child_expr) = get_child_expr { - get_child_exprs.push(get_child_expr) + get_child_exprs.push(get_child_expr); } } diff --git a/shared/tree-sitter-extractor/src/node_types.rs b/shared/tree-sitter-extractor/src/node_types.rs index 1e02d50f32ba..315e31cbbf92 100644 --- a/shared/tree-sitter-extractor/src/node_types.rs +++ b/shared/tree-sitter-extractor/src/node_types.rs @@ -424,7 +424,7 @@ fn escape_name(name: &str) -> String { '@' => result.push_str("at"), _ if c.is_uppercase() => { result.push('_'); - result.push_str(&c.to_lowercase().to_string()) + result.push_str(&c.to_lowercase().to_string()); } _ => result.push(c), } @@ -446,7 +446,7 @@ pub fn to_snake_case(word: &str) -> String { for c in word.chars() { if c.is_uppercase() { if !prev_upper { - result.push('_') + result.push('_'); } prev_upper = true; result.push(c.to_ascii_lowercase()); diff --git a/shared/tree-sitter-extractor/src/trap.rs b/shared/tree-sitter-extractor/src/trap.rs index 8fdb1408c9e9..d427dd728e08 100644 --- a/shared/tree-sitter-extractor/src/trap.rs +++ b/shared/tree-sitter-extractor/src/trap.rs @@ -81,7 +81,7 @@ impl Writer { pub fn add_tuple(&mut self, table_name: &str, args: Vec) { self.trap_output - .push(Entry::GenericTuple(table_name.to_owned(), args)) + .push(Entry::GenericTuple(table_name.to_owned(), args)); } pub fn comment(&mut self, text: String) { From 207cc3579467204013242baec847ccb372f6487d Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:27:32 +0100 Subject: [PATCH 21/39] Fix all results of the Clippy lint `unnecessary_semicolon` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/extractor/src/main.rs | 4 ++-- rust/extractor/src/translate/base.rs | 4 ++-- shared/tree-sitter-extractor/src/extractor/mod.rs | 8 ++++---- shared/tree-sitter-extractor/src/file_paths.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rust/extractor/src/main.rs b/rust/extractor/src/main.rs index 738865836f77..38ee82db8961 100644 --- a/rust/extractor/src/main.rs +++ b/rust/extractor/src/main.rs @@ -165,7 +165,7 @@ impl<'a> Extractor<'a> { )); } _ => {} - }; + } self.steps.push(ExtractionStep::load_source(before, file)); Ok(()) } @@ -325,7 +325,7 @@ fn main() -> anyhow::Result<()> { match extractor.load_source(file, &semantics, &vfs) { Ok(()) => extractor.extract_with_semantics(file, &semantics, &vfs, source_mode), Err(e) => extractor.extract_without_semantics(file, source_mode, e), - }; + } } // Fast path when there is no ambiguity in dependency extraction. if dependency_extraction_ambiguity { diff --git a/rust/extractor/src/translate/base.rs b/rust/extractor/src/translate/base.rs index e44caf75914c..d24a65af293c 100644 --- a/rust/extractor/src/translate/base.rs +++ b/rust/extractor/src/translate/base.rs @@ -227,7 +227,7 @@ impl<'db> Translator<'db> { UNKNOWN_LOCATION, ), Some((start, end)) => self.trap.emit_location(self.label, label, start, end), - }; + } } pub fn emit_location_token( &mut self, @@ -390,7 +390,7 @@ impl<'db> Translator<'db> { .text_range() .start(); self.emit_parse_error(node, &SyntaxError::new(error.message, location)); - }; + } } for err in value.value.iter() { self.emit_parse_error(node, err); diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index f765d7438a34..a7f30c55fd5a 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -676,7 +676,7 @@ impl<'a> Visitor<'a> { true, ); return false; - }; + } let id = self.trap_writer.fresh_id(); @@ -722,7 +722,7 @@ impl<'a> Visitor<'a> { trap::Arg::Int(parent_index), ], ); - }; + } self.trap_writer.add_tuple( &self.tokeninfo_table_name, vec![ @@ -750,7 +750,7 @@ impl<'a> Visitor<'a> { trap::Arg::Int(parent_index), ], ); - }; + } let mut all_args = vec![trap::Arg::Label(id)]; all_args.extend(args); self.trap_writer.add_tuple(table_name, all_args); @@ -793,7 +793,7 @@ impl<'a> Visitor<'a> { named: node.is_named(), }, }); - }; + } } } diff --git a/shared/tree-sitter-extractor/src/file_paths.rs b/shared/tree-sitter-extractor/src/file_paths.rs index 5854649b00fa..c87a7f4ffba8 100644 --- a/shared/tree-sitter-extractor/src/file_paths.rs +++ b/shared/tree-sitter-extractor/src/file_paths.rs @@ -134,7 +134,7 @@ pub fn path_from_string(path: &str) -> PathBuf { // make path absolute if path.is_relative() { path = std::env::current_dir().unwrap().join(path); - }; + } let mut components = path.components(); // make Windows paths verbatim (with `\\?\` prefixes) which allow for extended-length paths. From d1f084a87b74f7d9e719c79cf7472f832760e615 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:35:11 +0100 Subject: [PATCH 22/39] Fix all results of the Clippy lint `return_self_not_must_use` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- shared/yeast/src/lib.rs | 3 +++ shared/yeast/src/range.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/shared/yeast/src/lib.rs b/shared/yeast/src/lib.rs index 614744de5f1d..0f83158a609e 100644 --- a/shared/yeast/src/lib.rs +++ b/shared/yeast/src/lib.rs @@ -1439,6 +1439,7 @@ impl DesugaringConfig { /// Add a translation phase with the given name and exhaustive rules. /// /// Runners currently reject configurations containing more than one phase. + #[must_use] pub fn add_phase(mut self, name: impl Into, mut rules: Vec>) -> Self { for rule in &mut rules { rule.set_ignored_location_fields(&self.ignored_location_fields); @@ -1449,6 +1450,7 @@ impl DesugaringConfig { /// Ignore boundary syntax stored under any of these input field names when /// calculating matched locations for rule results. + #[must_use] pub fn with_ignored_location_fields( mut self, fields: impl IntoIterator, @@ -1462,6 +1464,7 @@ impl DesugaringConfig { self } + #[must_use] pub fn with_output_node_types_yaml(mut self, yaml: &'static str) -> Self { self.output_node_types_yaml = Some(yaml); self diff --git a/shared/yeast/src/range.rs b/shared/yeast/src/range.rs index 6b0024596bb5..eaa4b60b1380 100644 --- a/shared/yeast/src/range.rs +++ b/shared/yeast/src/range.rs @@ -33,6 +33,7 @@ pub struct Range { impl Range { /// Return the smallest range containing both ranges. + #[must_use] pub fn union(self, other: Self) -> Self { let (start_byte, start_point) = if self.start_byte <= other.start_byte { (self.start_byte, self.start_point) @@ -53,6 +54,7 @@ impl Range { } /// Return an empty range anchored at this range's start. + #[must_use] pub fn empty_at_start(self) -> Self { Self { end_byte: self.start_byte, @@ -62,6 +64,7 @@ impl Range { } /// Return an empty range anchored at this range's end. + #[must_use] pub fn empty_at_end(self) -> Self { Self { start_byte: self.end_byte, From 43105fbd12b9c6c71046c9d8d3a09ce2701fa459 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 09:39:20 +0100 Subject: [PATCH 23/39] Fix all results of the Clippy lint `match_wildcard_for_single_variants` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- rust/ast-generator/patches/rust-analyzer.patch | 3 ++- shared/tree-sitter-extractor/src/extractor/mod.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rust/ast-generator/patches/rust-analyzer.patch b/rust/ast-generator/patches/rust-analyzer.patch index 8ed8210c354a..cac63dc2b3d8 100644 --- a/rust/ast-generator/patches/rust-analyzer.patch +++ b/rust/ast-generator/patches/rust-analyzer.patch @@ -89,7 +89,8 @@ index 0aad1e2..68f679f 100644 } fn token_kind(&self) -> Option { @@ -787,7 +797,7 @@ impl Field { - _ => None, +- _ => None, ++ Field::Node { .. } => None, } } - fn method_name(&self) -> String { diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index a7f30c55fd5a..abb373c9a0a5 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -756,7 +756,7 @@ impl<'a> Visitor<'a> { self.trap_writer.add_tuple(table_name, all_args); } } - _ => { + EntryKind::Union { .. } => { self.record_parse_error( loc_label, self.diagnostics_writer From a8a155935f3458a2c73936b8b14de28b0279c7dd Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 10:12:41 +0100 Subject: [PATCH 24/39] Fix all results of the Clippy lint `assigning_clones` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- ruby/extractor/src/extractor.rs | 2 +- shared/tree-sitter-extractor/src/diagnostics.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ruby/extractor/src/extractor.rs b/ruby/extractor/src/extractor.rs index b3e683dba144..e1b6f527395c 100644 --- a/ruby/extractor/src/extractor.rs +++ b/ruby/extractor/src/extractor.rs @@ -159,7 +159,7 @@ pub fn run(options: Options) -> std::io::Result<()> { match encoding .decode(&source, encoding::types::DecoderTrap::Replace) { - Ok(str) => source = str.as_bytes().to_owned(), + Ok(str) => str.as_bytes().clone_into(&mut source), Err(msg) => { needs_conversion = false; diagnostics_writer.write( diff --git a/shared/tree-sitter-extractor/src/diagnostics.rs b/shared/tree-sitter-extractor/src/diagnostics.rs index d63566355257..d3c06694803b 100644 --- a/shared/tree-sitter-extractor/src/diagnostics.rs +++ b/shared/tree-sitter-extractor/src/diagnostics.rs @@ -240,7 +240,7 @@ impl DiagnosticMessage { } fn text(&mut self, text: &str) -> &mut Self { - self.plaintext_message = text.to_owned(); + text.clone_into(&mut self.plaintext_message); self } @@ -285,7 +285,7 @@ impl DiagnosticMessage { } pub fn markdown(&mut self, text: &str) -> &mut Self { - self.markdown_message = text.to_owned(); + text.clone_into(&mut self.markdown_message); self } pub fn severity(&mut self, severity: Severity) -> &mut Self { From 187a969b0105a4e8e42d5526ff5b89e62433ca6b Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Wed, 11 Nov 2026 10:15:40 +0100 Subject: [PATCH 25/39] Fix all results of the Clippy lint `needless_pass_by_value` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4429304-eb0c-4b7d-9675-11e1eabfd0b8 --- ruby/extractor/src/extractor.rs | 10 +++++----- ruby/extractor/src/main.rs | 2 +- rust/ast-generator/src/main.rs | 8 ++++---- shared/tree-sitter-extractor/src/generator/mod.rs | 4 ++-- shared/yeast-macros/src/lower.rs | 12 ++++++------ shared/yeast-macros/src/template_parse.rs | 12 ++++++------ shared/yeast/src/lib.rs | 6 +++--- shared/yeast/tests/test.rs | 9 +++------ 8 files changed, 30 insertions(+), 33 deletions(-) diff --git a/ruby/extractor/src/extractor.rs b/ruby/extractor/src/extractor.rs index e1b6f527395c..72403e5d52c5 100644 --- a/ruby/extractor/src/extractor.rs +++ b/ruby/extractor/src/extractor.rs @@ -26,7 +26,7 @@ pub struct Options { file_list: String, } -pub fn run(options: Options) -> std::io::Result<()> { +pub fn run(options: &Options) -> std::io::Result<()> { extractor::set_tracing_level("ruby"); tracing::info!("Extraction started"); let diagnostics = diagnostics::DiagnosticLoggers::new("ruby"); @@ -222,7 +222,7 @@ pub fn run(options: Options) -> std::io::Result<()> { } else { std::fs::copy(&path, &src_archive_file)?; } - write_trap(&trap_dir, path, &trap_writer, trap_compression, path_transformer.as_ref()) + write_trap(&trap_dir, &path, &trap_writer, trap_compression, path_transformer.as_ref()) }) .expect("failed to extract files"); @@ -231,7 +231,7 @@ pub fn run(options: Options) -> std::io::Result<()> { extractor::populate_empty_location(&mut trap_writer); let res = write_trap( &trap_dir, - path, + &path, &trap_writer, trap_compression, path_transformer.as_ref(), @@ -263,14 +263,14 @@ fn encoding_from_name(encoding_name: &str) -> Option<&(dyn encoding::Encoding + fn write_trap( trap_dir: &Path, - path: PathBuf, + path: &Path, trap_writer: &trap::Writer, trap_compression: trap::Compression, path_transformer: Option<&PathTransformer>, ) -> std::io::Result<()> { let trap_file = file_paths::path_for( trap_dir, - &path, + path, trap_compression.extension(), path_transformer, ); diff --git a/ruby/extractor/src/main.rs b/ruby/extractor/src/main.rs index e6721d4e2243..7768a535bc30 100644 --- a/ruby/extractor/src/main.rs +++ b/ruby/extractor/src/main.rs @@ -16,7 +16,7 @@ fn main() -> std::io::Result<()> { let cli = Cli::parse(); match cli { - Cli::Extract(options) => extractor::run(options), + Cli::Extract(options) => extractor::run(&options), Cli::Generate(options) => generator::run(options), Cli::Autobuild(options) => autobuilder::run(options), } diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index b2eaab385644..bd0ce9858578 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -285,7 +285,7 @@ fn fix_blank_lines(s: &str) -> String { fn write_schema( grammar: &AstSrc, - super_types: BTreeMap>, + super_types: &BTreeMap>, mustache_ctx: &mustache::Context, ) -> mustache::Result { let mut schema = Schema::default(); @@ -293,13 +293,13 @@ fn write_schema( grammar .enums .iter() - .map(|node| enum_src_to_schema_class(node, &super_types)), + .map(|node| enum_src_to_schema_class(node, super_types)), ); schema.classes.extend( grammar .nodes .iter() - .map(|node| node_src_to_schema_class(node, &super_types)), + .map(|node| node_src_to_schema_class(node, super_types)), ); let template = mustache_ctx.compile_path("schema")?; let res = template.render_to_string(&schema)?; @@ -530,7 +530,7 @@ fn main() -> anyhow::Result<()> { template_path: root.join("ast-generator").join("templates"), template_extension: "mustache".to_string(), }; - let schema = write_schema(&grammar, super_types, &mustache_ctx)?; + let schema = write_schema(&grammar, &super_types, &mustache_ctx)?; let schema_path = root.join("schema/ast.py"); codegen::ensure_file_contents( crate::flags::CodegenType::Grammar, diff --git a/shared/tree-sitter-extractor/src/generator/mod.rs b/shared/tree-sitter-extractor/src/generator/mod.rs index 502de6ead1d6..d0e766654a84 100644 --- a/shared/tree-sitter-extractor/src/generator/mod.rs +++ b/shared/tree-sitter-extractor/src/generator/mod.rs @@ -97,7 +97,7 @@ pub fn generate( } writeln!(&mut dbscheme_writer, "/*- {} dbscheme -*/", language.name)?; dbscheme::write(&mut dbscheme_writer, &dbscheme_entries)?; - let token_case = create_token_case(&token_name, token_kinds); + let token_case = create_token_case(&token_name, &token_kinds); let mut dbscheme_tail = vec![ dbscheme::Entry::Table(create_tokeninfo(&tokeninfo_name, &token_name)), dbscheme::Entry::Case(token_case), @@ -592,7 +592,7 @@ fn create_tokeninfo<'a>(name: &'a str, type_name: &'a str) -> dbscheme::Table<'a } } -fn create_token_case<'a>(name: &'a str, token_kinds: Map<&'a str, usize>) -> dbscheme::Case<'a> { +fn create_token_case<'a>(name: &'a str, token_kinds: &Map<&'a str, usize>) -> dbscheme::Case<'a> { let branches: Vec<(usize, &str)> = token_kinds .iter() .map(|(&name, kind_id)| (*kind_id, name)) diff --git a/shared/yeast-macros/src/lower.rs b/shared/yeast-macros/src/lower.rs index 6cf8767e2f1b..573983f0a091 100644 --- a/shared/yeast-macros/src/lower.rs +++ b/shared/yeast-macros/src/lower.rs @@ -58,15 +58,15 @@ impl Rule { let captures_ident = Ident::new("__captures", Span::call_site()); let translated_captures_ident = Ident::new("__translated_captures", Span::call_site()); let guard_bindings = - capture_bindings(captures.iter(), quote! { yeast::Id }, &captures_ident); + capture_bindings(captures.iter(), "e! { yeast::Id }, &captures_ident); let raw_bindings = capture_bindings( raw_captures.into_iter(), - quote! { yeast::Id }, + "e! { yeast::Id }, &captures_ident, ); let translated_bindings = capture_bindings( translated_captures.into_iter(), - quote! { yeast::OutputId }, + "e! { yeast::OutputId }, &translated_captures_ident, ); let replacement = self.replacement.lower(); @@ -278,7 +278,7 @@ fn combine_cardinality(parent: Cardinality, child: Cardinality) -> Cardinality { fn capture_bindings<'a>( captures: impl Iterator, - id_type: TokenStream, + id_type: &TokenStream, captures_ident: &Ident, ) -> Vec { captures @@ -367,14 +367,14 @@ impl Template { fn lower_choice(alternatives: &[Alternative]) -> TokenStream { let pick = alternatives.iter().rev().fold( quote! { ::std::option::Option::None }, - |fallback, alternative| alternative.lower_candidate(fallback), + |fallback, alternative| alternative.lower_candidate(&fallback), ); quote! {{ #pick }} } } impl Alternative { - fn lower_candidate(&self, fallback: TokenStream) -> TokenStream { + fn lower_candidate(&self, fallback: &TokenStream) -> TokenStream { let interpolations = RefCell::new(Vec::new()); let context = LoweringContext { choice_alternative_scope: Some(ChoiceAlternativeScope { diff --git a/shared/yeast-macros/src/template_parse.rs b/shared/yeast-macros/src/template_parse.rs index cce42fd0ab19..4b6b2aa8bd7d 100644 --- a/shared/yeast-macros/src/template_parse.rs +++ b/shared/yeast-macros/src/template_parse.rs @@ -38,11 +38,11 @@ fn parse_one(tokens: &mut Tokens) -> Result