From 4f3bdb9ed8587ed0c22072ee1f579c0c0995654b Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Fri, 27 Nov 2026 15:11:06 +0100 Subject: [PATCH 1/2] Use Rust edition 2024 for all workspace crates Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 23953e7a-978d-432c-afda-c9be5ffedfa6 --- Cargo.toml | 3 +++ cpp/extractor/bmn/Cargo.toml | 2 +- misc/bazel/3rdparty/rust_workspace_deps/crates.bzl | 12 ++++++------ python/extractor/yeast-python/Cargo.toml | 2 +- ql/buramu/Cargo.toml | 2 +- ql/buramu/tree-sitter-blame/Cargo.toml | 2 +- ql/buramu/tree-sitter-blame/bindings/rust/lib.rs | 2 +- ql/extractor/Cargo.toml | 2 +- ruby/extractor/Cargo.toml | 2 +- rust/ast-generator/Cargo.toml | 2 +- rust/autobuild/Cargo.toml | 2 +- rust/extractor/Cargo.toml | 2 +- shared/extractor-common/Cargo.toml | 2 +- shared/tree-sitter-extractor/Cargo.toml | 2 +- shared/yeast-macros/Cargo.toml | 2 +- shared/yeast-schema/Cargo.toml | 2 +- shared/yeast/Cargo.toml | 2 +- unified/extractor-unsupported-os/Cargo.toml | 2 +- unified/extractor/Cargo.toml | 2 +- unified/swift-syntax-rs/Cargo.toml | 2 +- 20 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1b69772450cb..3b91087a7764 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,9 @@ exclude = [ "rust/ql/integration-tests", ] +[workspace.package] +edition = "2024" + [workspace.lints.rust] redundant_imports = "warn" diff --git a/cpp/extractor/bmn/Cargo.toml b/cpp/extractor/bmn/Cargo.toml index 92846ed4272d..c7cbd928253c 100644 --- a/cpp/extractor/bmn/Cargo.toml +++ b/cpp/extractor/bmn/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bmn" version = "0.1.0" -edition = "2024" +edition.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/misc/bazel/3rdparty/rust_workspace_deps/crates.bzl b/misc/bazel/3rdparty/rust_workspace_deps/crates.bzl index 476d5c454881..8216914f89b6 100644 --- a/misc/bazel/3rdparty/rust_workspace_deps/crates.bzl +++ b/misc/bazel/3rdparty/rust_workspace_deps/crates.bzl @@ -316,18 +316,18 @@ def aliases( _CRATE_EDITIONS = { "cpp/extractor/bmn": "2024", "python/extractor/yeast-python": "2024", - "ql/buramu": "2021", - "ql/buramu/tree-sitter-blame": "2021", - "ql/extractor": "2021", + "ql/buramu": "2024", + "ql/buramu/tree-sitter-blame": "2024", + "ql/extractor": "2024", "ruby/extractor": "2024", "rust/ast-generator": "2024", "rust/autobuild": "2024", "rust/extractor": "2024", "shared/extractor-common": "2024", "shared/tree-sitter-extractor": "2024", - "shared/yeast": "2021", - "shared/yeast-macros": "2021", - "shared/yeast-schema": "2021", + "shared/yeast": "2024", + "shared/yeast-macros": "2024", + "shared/yeast-schema": "2024", "unified/extractor": "2024", "unified/extractor-unsupported-os": "2024", "unified/swift-syntax-rs": "2024", diff --git a/python/extractor/yeast-python/Cargo.toml b/python/extractor/yeast-python/Cargo.toml index 58eebfc52ea7..1a047a84b930 100644 --- a/python/extractor/yeast-python/Cargo.toml +++ b/python/extractor/yeast-python/Cargo.toml @@ -2,7 +2,7 @@ name = "yeast-python" version = "0.1.0" authors = ["Taus "] -edition = "2024" +edition.workspace = true [dependencies] anyhow = "1.0" diff --git a/ql/buramu/Cargo.toml b/ql/buramu/Cargo.toml index f004f3e973a2..a2e10fa8c7b3 100644 --- a/ql/buramu/Cargo.toml +++ b/ql/buramu/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "buramu" version = "0.1.0" -edition = "2021" +edition.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/ql/buramu/tree-sitter-blame/Cargo.toml b/ql/buramu/tree-sitter-blame/Cargo.toml index a8a1a4f73e65..c8cb9a7518fc 100644 --- a/ql/buramu/tree-sitter-blame/Cargo.toml +++ b/ql/buramu/tree-sitter-blame/Cargo.toml @@ -5,7 +5,7 @@ version = "0.0.1" keywords = ["incremental", "parsing", "blame"] categories = ["parsing", "text-editors"] repository = "https://github.com/tree-sitter/tree-sitter-blame" -edition = "2021" +edition.workspace = true license = "MIT" build = "bindings/rust/build.rs" diff --git a/ql/buramu/tree-sitter-blame/bindings/rust/lib.rs b/ql/buramu/tree-sitter-blame/bindings/rust/lib.rs index 5be6d041fda3..623e6e256579 100644 --- a/ql/buramu/tree-sitter-blame/bindings/rust/lib.rs +++ b/ql/buramu/tree-sitter-blame/bindings/rust/lib.rs @@ -22,7 +22,7 @@ use tree_sitter_language::LanguageFn; -extern "C" { +unsafe extern "C" { fn tree_sitter_blame() -> *const (); } diff --git a/ql/extractor/Cargo.toml b/ql/extractor/Cargo.toml index 1d1c11218d90..8f68f9331741 100644 --- a/ql/extractor/Cargo.toml +++ b/ql/extractor/Cargo.toml @@ -2,7 +2,7 @@ name = "codeql-extractor-ql" version = "0.1.0" authors = ["GitHub"] -edition = "2021" +edition.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/ruby/extractor/Cargo.toml b/ruby/extractor/Cargo.toml index cb6e3e3041dc..e9b8af450b5c 100644 --- a/ruby/extractor/Cargo.toml +++ b/ruby/extractor/Cargo.toml @@ -3,7 +3,7 @@ name = "codeql-extractor-ruby" description = "CodeQL Ruby extractor" version = "0.1.0" authors = ["GitHub"] -edition = "2024" +edition.workspace = true [lints] workspace = true diff --git a/rust/ast-generator/Cargo.toml b/rust/ast-generator/Cargo.toml index e418ecf9f09b..48391d259149 100644 --- a/rust/ast-generator/Cargo.toml +++ b/rust/ast-generator/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ast-generator" version = "0.1.0" -edition = "2024" +edition.workspace = true license = "MIT" [lints] diff --git a/rust/autobuild/Cargo.toml b/rust/autobuild/Cargo.toml index 6e06d84ce46c..41f0d8710042 100644 --- a/rust/autobuild/Cargo.toml +++ b/rust/autobuild/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "codeql-autobuilder-rust" version = "0.1.0" -edition = "2024" +edition.workspace = true [lints] workspace = true diff --git a/rust/extractor/Cargo.toml b/rust/extractor/Cargo.toml index 0a1a4aaa8505..f013fb07ea76 100644 --- a/rust/extractor/Cargo.toml +++ b/rust/extractor/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "codeql-rust" version = "0.1.0" -edition = "2024" +edition.workspace = true license = "MIT" [lints] diff --git a/shared/extractor-common/Cargo.toml b/shared/extractor-common/Cargo.toml index 56bc5e6cd9a9..437a396936a4 100644 --- a/shared/extractor-common/Cargo.toml +++ b/shared/extractor-common/Cargo.toml @@ -2,7 +2,7 @@ name = "extractor-common" description = "Code shared between the extractors." version = "0.1.0" -edition = "2024" +edition.workspace = true [lints] workspace = true diff --git a/shared/tree-sitter-extractor/Cargo.toml b/shared/tree-sitter-extractor/Cargo.toml index a0424cd9addf..e1a1790cee95 100644 --- a/shared/tree-sitter-extractor/Cargo.toml +++ b/shared/tree-sitter-extractor/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "codeql-extractor" version = "0.2.0" -edition = "2024" +edition.workspace = true authors = ["GitHub"] [lints] diff --git a/shared/yeast-macros/Cargo.toml b/shared/yeast-macros/Cargo.toml index bfc8d57b98f4..f7618dc849fa 100644 --- a/shared/yeast-macros/Cargo.toml +++ b/shared/yeast-macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yeast-macros" version = "0.1.0" -edition = "2021" +edition.workspace = true [lib] proc-macro = true diff --git a/shared/yeast-schema/Cargo.toml b/shared/yeast-schema/Cargo.toml index 02a9c37f056f..5cbe45c70169 100644 --- a/shared/yeast-schema/Cargo.toml +++ b/shared/yeast-schema/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yeast-schema" version = "0.1.0" -edition = "2021" +edition.workspace = true [lints] workspace = true diff --git a/shared/yeast/Cargo.toml b/shared/yeast/Cargo.toml index 7f6138749ad4..a879807c5e76 100644 --- a/shared/yeast/Cargo.toml +++ b/shared/yeast/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yeast" version = "0.1.0" -edition = "2021" +edition.workspace = true [lints] workspace = true diff --git a/unified/extractor-unsupported-os/Cargo.toml b/unified/extractor-unsupported-os/Cargo.toml index c7d4dd17c04b..ae53c0a1193b 100644 --- a/unified/extractor-unsupported-os/Cargo.toml +++ b/unified/extractor-unsupported-os/Cargo.toml @@ -3,7 +3,7 @@ name = "codeql-extractor-unified-unsupported-os" description = "Fallback executable for unsupported CodeQL Unified extractor platforms" version = "0.1.0" authors = ["GitHub"] -edition = "2024" +edition.workspace = true [lints] workspace = true diff --git a/unified/extractor/Cargo.toml b/unified/extractor/Cargo.toml index 1e980161538f..6843d3e6d7bd 100644 --- a/unified/extractor/Cargo.toml +++ b/unified/extractor/Cargo.toml @@ -3,7 +3,7 @@ name = "codeql-extractor-unified" description = "CodeQL Unified extractor" version = "0.1.0" authors = ["GitHub"] -edition = "2024" +edition.workspace = true [lints] workspace = true diff --git a/unified/swift-syntax-rs/Cargo.toml b/unified/swift-syntax-rs/Cargo.toml index 0ec21fb135c6..8530c498a08d 100644 --- a/unified/swift-syntax-rs/Cargo.toml +++ b/unified/swift-syntax-rs/Cargo.toml @@ -3,7 +3,7 @@ name = "swift-syntax-rs" description = "Rust wrapper around the swift-syntax package for parsing Swift source" version = "0.1.0" authors = ["GitHub"] -edition = "2024" +edition.workspace = true links = "SwiftSyntaxFFI" [lints] From 89a7230bee0743a1c9b3affcaf81649114e144e9 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Fri, 27 Nov 2026 15:11:10 +0100 Subject: [PATCH 2/2] Apply clippy and rustfmt fixes for edition 2024 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 23953e7a-978d-432c-afda-c9be5ffedfa6 --- shared/yeast-macros/src/ast.rs | 10 +++-- shared/yeast-macros/src/lower.rs | 2 +- shared/yeast-macros/src/rule_parse.rs | 14 +++---- shared/yeast-macros/src/template_parse.rs | 14 +++---- shared/yeast-schema/src/schema.rs | 2 +- shared/yeast/src/build.rs | 7 ++-- shared/yeast/src/dump.rs | 48 +++++++++++------------ shared/yeast/src/lib.rs | 14 ++----- shared/yeast/src/query.rs | 2 +- shared/yeast/src/visitor.rs | 2 +- shared/yeast/tests/test.rs | 16 ++++---- 11 files changed, 61 insertions(+), 70 deletions(-) diff --git a/shared/yeast-macros/src/ast.rs b/shared/yeast-macros/src/ast.rs index 3ec8948599b4..052e43f8617d 100644 --- a/shared/yeast-macros/src/ast.rs +++ b/shared/yeast-macros/src/ast.rs @@ -294,10 +294,12 @@ named: let [Template::Node(assignment)] = templates.as_slice() else { panic!("expected one output node"); }; - let [Field::Named { - value: Template::Node(structural), - .. - }] = assignment.fields.as_slice() + let [ + Field::Named { + value: Template::Node(structural), + .. + }, + ] = assignment.fields.as_slice() else { panic!("expected one structural child"); }; diff --git a/shared/yeast-macros/src/lower.rs b/shared/yeast-macros/src/lower.rs index b4a27500ec92..7e8efdeb7127 100644 --- a/shared/yeast-macros/src/lower.rs +++ b/shared/yeast-macros/src/lower.rs @@ -1,5 +1,5 @@ use proc_macro2::{Ident, Span, TokenStream, TokenTree}; -use quote::{quote, quote_spanned, ToTokens}; +use quote::{ToTokens, quote, quote_spanned}; use std::cell::RefCell; use std::sync::atomic::{AtomicUsize, Ordering}; use syn::spanned::Spanned; diff --git a/shared/yeast-macros/src/rule_parse.rs b/shared/yeast-macros/src/rule_parse.rs index 4230c61bbe2c..b3d5cfe814fc 100644 --- a/shared/yeast-macros/src/rule_parse.rs +++ b/shared/yeast-macros/src/rule_parse.rs @@ -306,16 +306,16 @@ fn parse_replacement(input: TokenStream) -> Result { return Ok(Replacement::Rust { annotation, body }); } - if let Some(TokenTree::Group(group)) = tokens.peek() { - if group.delimiter() == Delimiter::Brace { - return Err(syn::Error::new( - group.span(), - "bare `{...}` rule bodies are no longer accepted; \ + if let Some(TokenTree::Group(group)) = tokens.peek() + && group.delimiter() == Delimiter::Brace + { + return Err(syn::Error::new( + group.span(), + "bare `{...}` rule bodies are no longer accepted; \ use the annotation form `=> kind [? | *] { ... }` \ (where the kind names the output node's schema kind, \ optionally suffixed with `?` or `*` for cardinality)", - )); - } + )); } let templates = crate::template_parse::parse_templates(tokens.collect())?; diff --git a/shared/yeast-macros/src/template_parse.rs b/shared/yeast-macros/src/template_parse.rs index 4b6b2aa8bd7d..63765c6a13e4 100644 --- a/shared/yeast-macros/src/template_parse.rs +++ b/shared/yeast-macros/src/template_parse.rs @@ -117,13 +117,13 @@ fn parse_node(group: &proc_macro2::Group) -> Result { }; return Err(error); } - if let Some(TokenTree::Punct(punctuation)) = tokens.peek() { - if punctuation.as_char() == '?' { - return Err(syn::Error::new_spanned( - punctuation.clone(), - "`?` is not valid on a `location` field", - )); - } + if let Some(TokenTree::Punct(punctuation)) = tokens.peek() + && punctuation.as_char() == '?' + { + return Err(syn::Error::new_spanned( + punctuation.clone(), + "`?` is not valid on a `location` field", + )); } continue; } diff --git a/shared/yeast-schema/src/schema.rs b/shared/yeast-schema/src/schema.rs index 3ac2779703d9..d69caabb4385 100644 --- a/shared/yeast-schema/src/schema.rs +++ b/shared/yeast-schema/src/schema.rs @@ -1,6 +1,6 @@ use std::collections::{BTreeMap, BTreeSet}; -use crate::{FieldId, KindId, CHILD_FIELD}; +use crate::{CHILD_FIELD, FieldId, KindId}; #[derive(Clone, Debug)] pub struct NodeType { diff --git a/shared/yeast/src/build.rs b/shared/yeast/src/build.rs index c0943a04b09f..e7a9baef2f06 100644 --- a/shared/yeast/src/build.rs +++ b/shared/yeast/src/build.rs @@ -118,11 +118,10 @@ impl<'a, C> BuildCtx<'a, C> { .output .get_node(id) .is_some_and(|node| node.source_range().is_none()) + && let Some(source_range) = self.source_range { - if let Some(source_range) = self.source_range { - self.output - .extend_source_range(id, source_range.empty_at_start()); - } + self.output + .extend_source_range(id, source_range.empty_at_start()); } if !has_explicit_source_range { self.created_nodes_without_source_range.insert(id); diff --git a/shared/yeast/src/dump.rs b/shared/yeast/src/dump.rs index c24de222621c..43f168b352de 100644 --- a/shared/yeast/src/dump.rs +++ b/shared/yeast/src/dump.rs @@ -1,6 +1,6 @@ use std::fmt::Write; -use crate::{schema::Schema, Ast, Node, NodeContent, TreeId, CHILD_FIELD}; +use crate::{Ast, CHILD_FIELD, Node, NodeContent, TreeId, schema::Schema}; #[derive(Clone, Copy)] struct TypeCheckContext<'a> { @@ -249,12 +249,11 @@ fn dump_node( } } - if let Some(context) = type_check { - if let Some(err) = + if let Some(context) = type_check + && let Some(err) = type_error_for_node(context.schema, node, context.expected, context.parent_field) - { - write!(out, " <-- ERROR: {err}").unwrap(); - } + { + write!(out, " <-- ERROR: {err}").unwrap(); } writeln!(out).unwrap(); @@ -392,20 +391,20 @@ fn dump_node( } }); for &child_id in children { - if let Some(child) = ast.get_node(child_id) { - if child.is_named() { - let external = is_external_child(node, child); - dump_node( - ast, - child_id, - source, - options, - indent + 1, - child_type_check, - external, - out, - ); - } + if let Some(child) = ast.get_node(child_id) + && child.is_named() + { + let external = is_external_child(node, child); + dump_node( + ast, + child_id, + source, + options, + indent + 1, + child_type_check, + external, + out, + ); } } } @@ -455,12 +454,11 @@ fn dump_node_inline( } } - if let Some(context) = type_check { - if let Some(err) = + if let Some(context) = type_check + && let Some(err) = type_error_for_node(context.schema, node, context.expected, context.parent_field) - { - write!(out, " <-- ERROR: {err}").unwrap(); - } + { + write!(out, " <-- ERROR: {err}").unwrap(); } writeln!(out).unwrap(); diff --git a/shared/yeast/src/lib.rs b/shared/yeast/src/lib.rs index 04c878f097a1..a16deafed801 100644 --- a/shared/yeast/src/lib.rs +++ b/shared/yeast/src/lib.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; extern crate self as yeast; use serde::Serialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; pub mod build; pub mod captures; @@ -1009,20 +1009,12 @@ impl Ast { pub fn id_for_node_kind(&self, kind: &str) -> Option { let id = self.schema.id_for_node_kind(kind).unwrap_or(0); - if id == 0 { - None - } else { - Some(id) - } + if id == 0 { None } else { Some(id) } } pub fn id_for_unnamed_node_kind(&self, kind: &str) -> Option { let id = self.schema.id_for_unnamed_node_kind(kind).unwrap_or(0); - if id == 0 { - None - } else { - Some(id) - } + if id == 0 { None } else { Some(id) } } } diff --git a/shared/yeast/src/query.rs b/shared/yeast/src/query.rs index 9f438bb647a9..ff567dacd76b 100644 --- a/shared/yeast/src/query.rs +++ b/shared/yeast/src/query.rs @@ -1,4 +1,4 @@ -use crate::{build::BuildCtx, captures::Captures, Ast, TreeId}; +use crate::{Ast, TreeId, build::BuildCtx, captures::Captures}; #[doc(hidden)] pub trait QueryTarget: TreeId { diff --git a/shared/yeast/src/visitor.rs b/shared/yeast/src/visitor.rs index 82fc00c163d8..fa44bbd88279 100644 --- a/shared/yeast/src/visitor.rs +++ b/shared/yeast/src/visitor.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use tree_sitter::{Language, Tree}; -use crate::{Ast, Id, Node, NodeContent, CHILD_FIELD}; +use crate::{Ast, CHILD_FIELD, Id, Node, NodeContent}; #[derive(Debug)] struct VisitorNode { diff --git a/shared/yeast/tests/test.rs b/shared/yeast/tests/test.rs index d62338d177d5..df049e71c78d 100644 --- a/shared/yeast/tests/test.rs +++ b/shared/yeast/tests/test.rs @@ -3142,10 +3142,10 @@ fn test_rule_annotation_repeated() { // top-level `assignment` nodes should appear as siblings. let mut count = 0usize; for id in ast.reachable_node_ids() { - if let Some(n) = ast.get_node(id) { - if n.kind_name() == "assignment" { - count += 1; - } + if let Some(n) = ast.get_node(id) + && n.kind_name() == "assignment" + { + count += 1; } } assert!( @@ -3191,10 +3191,10 @@ fn test_rule_annotation_single() { let ast = run_and_ast("x = 1", vec![r]); let mut has_assignment = false; for id in ast.reachable_node_ids() { - if let Some(n) = ast.get_node(id) { - if n.kind_name() == "assignment" { - has_assignment = true; - } + if let Some(n) = ast.get_node(id) + && n.kind_name() == "assignment" + { + has_assignment = true; } } assert!(has_assignment, "expected an assignment node");