Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ common --registry=https://bcr.bazel.build

common --@rules_dotnet//dotnet/settings:strict_deps=false

# we only configure a nightly toolchain
common --@rules_rust//rust/toolchain/channel=nightly

# rust does not like the gold linker, while bazel does by default, so let's avoid using it
common:linux --linkopt=-fuse-ld=lld
common:macos --linkopt=-fuse-ld=lld

# Reduce this eventually to empty, once we've fixed all our usages of java, and https://github.com/bazel-contrib/rules_go/issues/4193 is fixed
common --incompatible_autoload_externally="+@rules_java,+@rules_shell"

Expand Down
47 changes: 25 additions & 22 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bazel_dep(name = "rules_kotlin", version = "2.1.3-codeql.1")
bazel_dep(name = "gazelle", version = "0.40.0")
bazel_dep(name = "rules_dotnet", version = "0.17.4")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
bazel_dep(name = "rules_rust", version = "0.58.0")
bazel_dep(name = "rules_rust", version = "0.63.0")
bazel_dep(name = "zstd", version = "1.5.5.bcr.1")

bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
Expand All @@ -38,7 +38,10 @@ bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True
RUST_EDITION = "2024"

# run buildutils-internal/scripts/fill-rust-sha256s.py when updating (internal repo)
RUST_VERSION = "1.86.0"
# a nightly toolchain is required to enable experimental_use_cc_common_link, which we require internally
# we prefer to run the same version as internally, even if experimental_use_cc_common_link is not really
# required in this repo
RUST_VERSION = "nightly/2025-08-01"

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
Expand All @@ -50,26 +53,26 @@ rust.toolchain(
],
# generated by buildutils-internal/scripts/fill-rust-sha256s.py (internal repo)
sha256s = {
"rustc-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "4438b809ce4a083af31ed17aeeedcc8fc60ccffc0625bef1926620751b6989d7",
"rustc-1.86.0-x86_64-apple-darwin.tar.xz": "42b76253626febb7912541a30d3379f463dec89581aad4cb72c6c04fb5a71dc5",
"rustc-1.86.0-aarch64-apple-darwin.tar.xz": "23b8f52102249a47ab5bc859d54c9a3cb588a3259ba3f00f557d50edeca4fde9",
"rustc-1.86.0-x86_64-pc-windows-msvc.tar.xz": "fdde839fea274529a31e51eb85c6df1782cc8479c9d1bc24e2914d66a0de41ab",
"clippy-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "02aaff2c1407d2da8dba19aa4970dd873e311902b120a66cbcdbe51eb8836edf",
"clippy-1.86.0-x86_64-apple-darwin.tar.xz": "bb85efda7bbffaf124867f5ca36d50932b1e8f533c62ee923438afb32ff8fe9a",
"clippy-1.86.0-aarch64-apple-darwin.tar.xz": "239fa3a604b124f0312f2af08537874a1227dba63385484b468cca62e7c4f2f2",
"clippy-1.86.0-x86_64-pc-windows-msvc.tar.xz": "d00498f47d49219f032e2c5eeebdfc3d32317c0dc3d3fd7125327445bc482cb4",
"cargo-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "c5c1590f7e9246ad9f4f97cfe26ffa92707b52a769726596a9ef81565ebd908b",
"cargo-1.86.0-x86_64-apple-darwin.tar.xz": "af163eb02d1a178044d1b4f2375960efd47130f795f6e33d09e345454bb26f4e",
"cargo-1.86.0-aarch64-apple-darwin.tar.xz": "3cb13873d48c3e1e4cc684d42c245226a11fba52af6b047c3346ed654e7a05c0",
"cargo-1.86.0-x86_64-pc-windows-msvc.tar.xz": "e57a9d89619b5604899bac443e68927bdd371e40f2e03e18950b6ceb3eb67966",
"llvm-tools-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "282145ab7a63c98b625856f44b905b4dc726b497246b824632a5790debe95a78",
"llvm-tools-1.86.0-x86_64-apple-darwin.tar.xz": "b55706e92f7da989207c50c13c7add483a9fedd233bc431b106eca2a8f151ec9",
"llvm-tools-1.86.0-aarch64-apple-darwin.tar.xz": "04d3618c686845853585f036e3211eb9e18f2d290f4610a7a78bdc1fcce1ebd9",
"llvm-tools-1.86.0-x86_64-pc-windows-msvc.tar.xz": "721a17cc8dc219177e4277a3592253934ef08daa1e1b12eda669a67d15fad8dd",
"rust-std-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "67be7184ea388d8ce0feaf7fdea46f1775cfc2970930264343b3089898501d37",
"rust-std-1.86.0-x86_64-apple-darwin.tar.xz": "3b1140d54870a080080e84700143f4a342fbd02a410a319b05d9c02e7dcf44cc",
"rust-std-1.86.0-aarch64-apple-darwin.tar.xz": "0fb121fb3b8fa9027d79ff598500a7e5cd086ddbc3557482ed3fdda00832c61b",
"rust-std-1.86.0-x86_64-pc-windows-msvc.tar.xz": "3d5354b7b9cb950b58bff3fce18a652aa374bb30c8f70caebd3bd0b43cb41a33",
"2025-08-01/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz": "9bbeaf5d3fc7247d31463a9083aa251c995cc50662c8219e7a2254d76a72a9a4",
"2025-08-01/rustc-nightly-x86_64-apple-darwin.tar.xz": "c9ea539a8eff0d5d162701f99f9e1aabe14dd0dfb420d62362817a5d09219de7",
"2025-08-01/rustc-nightly-aarch64-apple-darwin.tar.xz": "ae83feebbc39cfd982e4ecc8297731fe79c185173aee138467b334c5404b3773",
"2025-08-01/rustc-nightly-x86_64-pc-windows-msvc.tar.xz": "9f170c30d802a349be60cf52ec46260802093cb1013ad667fc0d528b7b10152f",
"2025-08-01/clippy-nightly-x86_64-unknown-linux-gnu.tar.xz": "9ae5f3cd8f557c4f6df522597c69d14398cf604cfaed2b83e767c4b77a7eaaf6",
"2025-08-01/clippy-nightly-x86_64-apple-darwin.tar.xz": "983cb9ee0b6b968188e04ab2d33743d54764b2681ce565e1b3f2b9135c696a3e",
"2025-08-01/clippy-nightly-aarch64-apple-darwin.tar.xz": "ed2219dbc49d088225e1b7c5c4390fa295066e071fddaa2714018f6bb39ddbf0",
"2025-08-01/clippy-nightly-x86_64-pc-windows-msvc.tar.xz": "911f40ab5cbdd686f40e00965271fe47c4805513a308ed01f30eafb25b448a50",
"2025-08-01/cargo-nightly-x86_64-unknown-linux-gnu.tar.xz": "106463c284e48e4904c717471eeec2be5cc83a9d2cae8d6e948b52438cad2e69",
"2025-08-01/cargo-nightly-x86_64-apple-darwin.tar.xz": "6ad35c40efc41a8c531ea43235058347b6902d98a9693bf0aed7fc16d5590cef",
"2025-08-01/cargo-nightly-aarch64-apple-darwin.tar.xz": "dd28c365e9d298abc3154c797720ad36a0058f131265c9978b4c8e4e37012c8a",
"2025-08-01/cargo-nightly-x86_64-pc-windows-msvc.tar.xz": "7b431286e12d6b3834b038f078389a00cac73f351e8c3152b2504a3c06420b3b",
"2025-08-01/llvm-tools-nightly-x86_64-unknown-linux-gnu.tar.xz": "e342e305d7927cc288d386983b2bc253cfad3776b113386e903d0b302648ef47",
"2025-08-01/llvm-tools-nightly-x86_64-apple-darwin.tar.xz": "e44dd3506524d85c37b3a54bcc91d01378fd2c590b2db5c5974d12f05c1b84d1",
"2025-08-01/llvm-tools-nightly-aarch64-apple-darwin.tar.xz": "0c1b5f46dd81be4a9227b10283a0fcaa39c14fea7e81aea6fd6d9887ff6cdc41",
"2025-08-01/llvm-tools-nightly-x86_64-pc-windows-msvc.tar.xz": "423e5fd11406adccbc31b8456ceb7375ce055cdf45e90d2c3babeb2d7f58383f",
"2025-08-01/rust-std-nightly-x86_64-unknown-linux-gnu.tar.xz": "3c0ceb46a252647a1d4c7116d9ccae684fa5e42aaf3296419febd2c962c3b41d",
"2025-08-01/rust-std-nightly-x86_64-apple-darwin.tar.xz": "3be416003cab10f767390a753d1d16ae4d26c7421c03c98992cf1943e5b0efe8",
"2025-08-01/rust-std-nightly-aarch64-apple-darwin.tar.xz": "4046ac0ef951cb056b5028a399124f60999fa37792eab69d008d8d7965f389b4",
"2025-08-01/rust-std-nightly-x86_64-pc-windows-msvc.tar.xz": "191ed9d8603c3a4fe5a7bbbc2feb72049078dae2df3d3b7d5dedf3abbf823e6e",
},
versions = [RUST_VERSION],
)
Expand Down
10 changes: 6 additions & 4 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# This file specifies the Rust version used to develop and test the
# extractors written in rust. It is set to the lowest version of Rust
# we want to support.
# This file specifies the Rust version used to develop the extractors written
# in rust. Notice that this is just used by using `cargo`-related tools in a
# local dev environment. The actual version used to build the released packs
# is specified in `MODULE.bazel` in the internal repository (typically
# reflected by `MODULE.bazel` in this repository).

[toolchain]
channel = "1.86"
channel = "1.88"
profile = "minimal"
components = [ "clippy", "rustfmt" ]
4 changes: 2 additions & 2 deletions rust/ast-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn class_name(type_name: &str) -> String {
"AsmOptions" => "AsmOptionsList".to_owned(),
"MacroStmts" => "MacroBlockExpr".to_owned(),
_ if type_name.starts_with("Record") => type_name.replacen("Record", "Struct", 1),
_ if type_name.ends_with("Type") => format!("{}Repr", type_name),
_ if type_name.ends_with("Type") => format!("{type_name}Repr"),
_ => type_name.to_owned(),
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ fn get_trait_fields(trait_name: &str) -> Vec<FieldInfo> {
],
"HasArgList" => vec![FieldInfo::optional("arg_list", "ArgList")],
"HasDocComments" => vec![],
_ => panic!("Unknown trait {}", trait_name),
_ => panic!("Unknown trait {trait_name}"),
}
}

Expand Down
6 changes: 3 additions & 3 deletions rust/extractor/src/rust_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'a> RustAnalyzer<'a> {
config: &CargoConfig,
load_config: &LoadCargoConfig,
) -> Option<(RootDatabase, Vfs)> {
let progress = |t| (trace!("progress: {}", t));
let progress = |t| trace!("progress: {t}");
let manifest = project.manifest_path();
match load_workspace_at(manifest.as_ref(), config, load_config, &progress) {
Ok((db, vfs, _macro_server)) => Some((db, vfs)),
Expand All @@ -67,7 +67,7 @@ impl<'a> RustAnalyzer<'a> {
fn get_file_data(
&self,
path: &Path,
) -> Result<(&Semantics<RootDatabase>, EditionedFileId, FileText), &str> {
) -> Result<(&Semantics<'_, RootDatabase>, EditionedFileId, FileText), &str> {
match self {
RustAnalyzer::WithoutSemantics { reason } => Err(reason),
RustAnalyzer::WithSemantics { vfs, semantics } => {
Expand All @@ -82,7 +82,7 @@ impl<'a> RustAnalyzer<'a> {
}
}

pub fn parse(&self, path: &Path) -> ParseResult {
pub fn parse(&self, path: &Path) -> ParseResult<'_> {
match self.get_file_data(path) {
Ok((semantics, file_id, input)) => {
let source_file = semantics.parse(file_id);
Expand Down
8 changes: 3 additions & 5 deletions rust/extractor/src/translate/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,7 @@ impl<'a> Translator<'a> {
.map(|p| format!("[{p}; {size}]"));
}
if let Some(it) = ty.as_slice() {
return self
.canonical_path_from_type(it)
.map(|p| format!("[{}]", p));
return self.canonical_path_from_type(it).map(|p| format!("[{p}]"));
}
if let Some(it) = ty.as_builtin() {
return Some(it.name().as_str().to_owned());
Expand Down Expand Up @@ -651,7 +649,7 @@ impl<'a> Translator<'a> {
// if we have a Hir entity, it means we have semantics
let sema = self.semantics.as_ref().unwrap();
match item.origin(sema.db) {
CrateOrigin::Rustc { name } => format!("rustc:{}", name),
CrateOrigin::Rustc { name } => format!("rustc:{name}"),
CrateOrigin::Local { repo, name } => format!(
"repo:{}:{}",
repo.unwrap_or_default(),
Expand All @@ -660,7 +658,7 @@ impl<'a> Translator<'a> {
CrateOrigin::Library { repo, name } => {
format!("repo:{}:{}", repo.unwrap_or_default(), name)
}
CrateOrigin::Lang(it) => format!("lang:{}", it),
CrateOrigin::Lang(it) => format!("lang:{it}"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust/extractor/src/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait AsTrapKeyPart {

impl AsTrapKeyPart for UntypedLabel {
fn as_key_part(&self) -> String {
format!("{{{}}}", self)
format!("{{{self}}}")
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust/ql/test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ target/

# these are all generated, see `rust/extractor/src/qltest.rs` for details
Cargo.toml
rust-toolchain.toml
/*/**/rust-toolchain.toml
lib.rs
.proc_macro/
.lib/
Expand Down
7 changes: 7 additions & 0 deletions rust/ql/test/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file specifies the Rust version used to test the rust extractor.
# IMPORTANT: this can also have an impact on QL test results

[toolchain]
channel = "1.86"
profile = "minimal"
components = [ "rust-src" ]
8 changes: 0 additions & 8 deletions rust/rust-toolchain.toml

This file was deleted.

10 changes: 5 additions & 5 deletions shared/tree-sitter-extractor/src/autobuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ impl Autobuilder {
let verbosity = env::var("CODEQL_VERBOSITY");

if let Ok(verbosity) = verbosity {
cmd.arg(format!("--verbosity={}", verbosity));
cmd.arg(format!("--verbosity={verbosity}"));
}

for ext in &self.include_extensions {
cmd.arg(format!("--include-extension={}", ext));
cmd.arg(format!("--include-extension={ext}"));
}

for glob in &self.include_globs {
cmd.arg(format!("--include={}", glob));
cmd.arg(format!("--include={glob}"));
}

for glob in &self.exclude_globs {
cmd.arg(format!("--exclude={}", glob));
cmd.arg(format!("--exclude={glob}"));
}

if let Some(limit) = &self.size_limit {
cmd.arg(format!("--size-limit={}", limit));
cmd.arg(format!("--size-limit={limit}"));
}

cmd.arg(format!("--language={}", &self.language));
Expand Down
2 changes: 1 addition & 1 deletion shared/tree-sitter-extractor/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl DiagnosticLoggers {
path: self
.root
.as_ref()
.map(|root| root.to_owned().join(format!("extractor_{}.jsonl", n))),
.map(|root| root.to_owned().join(format!("extractor_{n}.jsonl"))),
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions shared/tree-sitter-extractor/src/extractor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub fn extract(
parser.set_language(language).unwrap();
parser.set_included_ranges(ranges).unwrap();
let tree = parser.parse(source, None).expect("Failed to parse file");
trap_writer.comment(format!("Auto-generated TRAP file for {}", path_str));
trap_writer.comment(format!("Auto-generated TRAP file for {path_str}"));
let file_label = populate_file(trap_writer, path, transformer);
let mut visitor = Visitor::new(
source,
Expand Down Expand Up @@ -298,9 +298,9 @@ impl<'a> Visitor<'a> {
source,
diagnostics_writer,
trap_writer,
ast_node_location_table_name: format!("{}_ast_node_location", language_prefix),
ast_node_parent_table_name: format!("{}_ast_node_parent", language_prefix),
tokeninfo_table_name: format!("{}_tokeninfo", language_prefix),
ast_node_location_table_name: format!("{language_prefix}_ast_node_location"),
ast_node_parent_table_name: format!("{language_prefix}_ast_node_parent"),
tokeninfo_table_name: format!("{language_prefix}_tokeninfo"),
schema,
stack: Vec::new(),
}
Expand Down
2 changes: 1 addition & 1 deletion shared/tree-sitter-extractor/src/extractor/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Extractor {
.iter()
.map(|file_list| {
File::open(file_list)
.unwrap_or_else(|_| panic!("Unable to open file list at {:?}", file_list))
.unwrap_or_else(|_| panic!("Unable to open file list at {file_list:?}"))
})
.collect();

Expand Down
12 changes: 6 additions & 6 deletions shared/tree-sitter-extractor/src/generator/dbscheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl fmt::Display for Case<'_> {
writeln!(f, "case @{}.{} of", &self.name, &self.column)?;
let mut sep = " ";
for (c, tp) in &self.branches {
writeln!(f, "{} {} = @{}", sep, c, tp)?;
writeln!(f, "{sep} {c} = @{tp}")?;
sep = "|";
}
writeln!(f, ";")
Expand All @@ -68,7 +68,7 @@ impl fmt::Display for Table<'_> {
if key_index > 0 {
write!(f, ", ")?;
}
write!(f, "{}", key)?;
write!(f, "{key}")?;
}
writeln!(f, "]")?;
}
Expand Down Expand Up @@ -112,7 +112,7 @@ impl fmt::Display for Union<'_> {
} else {
write!(f, " | ")?;
}
write!(f, "@{}", member)?;
write!(f, "@{member}")?;
}
Ok(())
}
Expand All @@ -122,9 +122,9 @@ impl fmt::Display for Union<'_> {
pub fn write(file: &mut dyn std::io::Write, entries: &[Entry]) -> std::io::Result<()> {
for entry in entries {
match entry {
Entry::Case(case) => write!(file, "{}\n\n", case)?,
Entry::Table(table) => write!(file, "{}\n\n", table)?,
Entry::Union(union) => write!(file, "{}\n\n", union)?,
Entry::Case(case) => write!(file, "{case}\n\n")?,
Entry::Table(table) => write!(file, "{table}\n\n")?,
Entry::Union(union) => write!(file, "{union}\n\n")?,
}
}

Expand Down
4 changes: 2 additions & 2 deletions shared/tree-sitter-extractor/src/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ fn add_field_for_column_storage<'a>(
/// values are their integer representations.
fn convert_nodes(
nodes: &node_types::NodeTypeMap,
) -> (Vec<dbscheme::Entry>, Set<&str>, Map<&str, usize>) {
let mut entries: Vec<dbscheme::Entry> = Vec::new();
) -> (Vec<dbscheme::Entry<'_>>, Set<&str>, Map<&str, usize>) {
let mut entries = Vec::new();
let mut ast_node_members: Set<&str> = Set::new();
let token_kinds: Map<&str, usize> = nodes
.iter()
Expand Down
Loading
Loading