Skip to content

Commit 45c0c46

Browse files
committed
Cargo: align rust toolchain version with internal repository
Also: * remove new warnings raised by the rust toolchain * run new formatting and linting * update the rust toolchain used by `cargo` While we keep `bazel` builds using the same toolchain as internally (now a nightly one), I opted for using a stable toolchain for `cargo`. The nightly toolchain is only required internally for build reasons, we should keep not using any unstable rust features in our sources.
1 parent 6e38087 commit 45c0c46

File tree

10 files changed

+55
-53
lines changed

10 files changed

+55
-53
lines changed

.bazelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ common --registry=https://bcr.bazel.build
3030

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

33+
# we only configure a nightly toolchain
34+
common --@rules_rust//rust/toolchain/channel=nightly
35+
36+
# rust does not like the gold linker, while bazel does by default, so let's avoid using it
37+
common:linux --linkopt=-fuse-ld=lld
38+
common:macos --linkopt=-fuse-ld=lld
39+
3340
# 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
3441
common --incompatible_autoload_externally="+@rules_java,+@rules_shell"
3542

MODULE.bazel

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bazel_dep(name = "rules_kotlin", version = "2.1.3-codeql.1")
2828
bazel_dep(name = "gazelle", version = "0.40.0")
2929
bazel_dep(name = "rules_dotnet", version = "0.17.4")
3030
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
31-
bazel_dep(name = "rules_rust", version = "0.58.0")
31+
bazel_dep(name = "rules_rust", version = "0.63.0")
3232
bazel_dep(name = "zstd", version = "1.5.5.bcr.1")
3333

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

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

4346
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
4447
rust.toolchain(
@@ -50,26 +53,26 @@ rust.toolchain(
5053
],
5154
# generated by buildutils-internal/scripts/fill-rust-sha256s.py (internal repo)
5255
sha256s = {
53-
"rustc-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "4438b809ce4a083af31ed17aeeedcc8fc60ccffc0625bef1926620751b6989d7",
54-
"rustc-1.86.0-x86_64-apple-darwin.tar.xz": "42b76253626febb7912541a30d3379f463dec89581aad4cb72c6c04fb5a71dc5",
55-
"rustc-1.86.0-aarch64-apple-darwin.tar.xz": "23b8f52102249a47ab5bc859d54c9a3cb588a3259ba3f00f557d50edeca4fde9",
56-
"rustc-1.86.0-x86_64-pc-windows-msvc.tar.xz": "fdde839fea274529a31e51eb85c6df1782cc8479c9d1bc24e2914d66a0de41ab",
57-
"clippy-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "02aaff2c1407d2da8dba19aa4970dd873e311902b120a66cbcdbe51eb8836edf",
58-
"clippy-1.86.0-x86_64-apple-darwin.tar.xz": "bb85efda7bbffaf124867f5ca36d50932b1e8f533c62ee923438afb32ff8fe9a",
59-
"clippy-1.86.0-aarch64-apple-darwin.tar.xz": "239fa3a604b124f0312f2af08537874a1227dba63385484b468cca62e7c4f2f2",
60-
"clippy-1.86.0-x86_64-pc-windows-msvc.tar.xz": "d00498f47d49219f032e2c5eeebdfc3d32317c0dc3d3fd7125327445bc482cb4",
61-
"cargo-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "c5c1590f7e9246ad9f4f97cfe26ffa92707b52a769726596a9ef81565ebd908b",
62-
"cargo-1.86.0-x86_64-apple-darwin.tar.xz": "af163eb02d1a178044d1b4f2375960efd47130f795f6e33d09e345454bb26f4e",
63-
"cargo-1.86.0-aarch64-apple-darwin.tar.xz": "3cb13873d48c3e1e4cc684d42c245226a11fba52af6b047c3346ed654e7a05c0",
64-
"cargo-1.86.0-x86_64-pc-windows-msvc.tar.xz": "e57a9d89619b5604899bac443e68927bdd371e40f2e03e18950b6ceb3eb67966",
65-
"llvm-tools-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "282145ab7a63c98b625856f44b905b4dc726b497246b824632a5790debe95a78",
66-
"llvm-tools-1.86.0-x86_64-apple-darwin.tar.xz": "b55706e92f7da989207c50c13c7add483a9fedd233bc431b106eca2a8f151ec9",
67-
"llvm-tools-1.86.0-aarch64-apple-darwin.tar.xz": "04d3618c686845853585f036e3211eb9e18f2d290f4610a7a78bdc1fcce1ebd9",
68-
"llvm-tools-1.86.0-x86_64-pc-windows-msvc.tar.xz": "721a17cc8dc219177e4277a3592253934ef08daa1e1b12eda669a67d15fad8dd",
69-
"rust-std-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "67be7184ea388d8ce0feaf7fdea46f1775cfc2970930264343b3089898501d37",
70-
"rust-std-1.86.0-x86_64-apple-darwin.tar.xz": "3b1140d54870a080080e84700143f4a342fbd02a410a319b05d9c02e7dcf44cc",
71-
"rust-std-1.86.0-aarch64-apple-darwin.tar.xz": "0fb121fb3b8fa9027d79ff598500a7e5cd086ddbc3557482ed3fdda00832c61b",
72-
"rust-std-1.86.0-x86_64-pc-windows-msvc.tar.xz": "3d5354b7b9cb950b58bff3fce18a652aa374bb30c8f70caebd3bd0b43cb41a33",
56+
"2025-08-01/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz": "9bbeaf5d3fc7247d31463a9083aa251c995cc50662c8219e7a2254d76a72a9a4",
57+
"2025-08-01/rustc-nightly-x86_64-apple-darwin.tar.xz": "c9ea539a8eff0d5d162701f99f9e1aabe14dd0dfb420d62362817a5d09219de7",
58+
"2025-08-01/rustc-nightly-aarch64-apple-darwin.tar.xz": "ae83feebbc39cfd982e4ecc8297731fe79c185173aee138467b334c5404b3773",
59+
"2025-08-01/rustc-nightly-x86_64-pc-windows-msvc.tar.xz": "9f170c30d802a349be60cf52ec46260802093cb1013ad667fc0d528b7b10152f",
60+
"2025-08-01/clippy-nightly-x86_64-unknown-linux-gnu.tar.xz": "9ae5f3cd8f557c4f6df522597c69d14398cf604cfaed2b83e767c4b77a7eaaf6",
61+
"2025-08-01/clippy-nightly-x86_64-apple-darwin.tar.xz": "983cb9ee0b6b968188e04ab2d33743d54764b2681ce565e1b3f2b9135c696a3e",
62+
"2025-08-01/clippy-nightly-aarch64-apple-darwin.tar.xz": "ed2219dbc49d088225e1b7c5c4390fa295066e071fddaa2714018f6bb39ddbf0",
63+
"2025-08-01/clippy-nightly-x86_64-pc-windows-msvc.tar.xz": "911f40ab5cbdd686f40e00965271fe47c4805513a308ed01f30eafb25b448a50",
64+
"2025-08-01/cargo-nightly-x86_64-unknown-linux-gnu.tar.xz": "106463c284e48e4904c717471eeec2be5cc83a9d2cae8d6e948b52438cad2e69",
65+
"2025-08-01/cargo-nightly-x86_64-apple-darwin.tar.xz": "6ad35c40efc41a8c531ea43235058347b6902d98a9693bf0aed7fc16d5590cef",
66+
"2025-08-01/cargo-nightly-aarch64-apple-darwin.tar.xz": "dd28c365e9d298abc3154c797720ad36a0058f131265c9978b4c8e4e37012c8a",
67+
"2025-08-01/cargo-nightly-x86_64-pc-windows-msvc.tar.xz": "7b431286e12d6b3834b038f078389a00cac73f351e8c3152b2504a3c06420b3b",
68+
"2025-08-01/llvm-tools-nightly-x86_64-unknown-linux-gnu.tar.xz": "e342e305d7927cc288d386983b2bc253cfad3776b113386e903d0b302648ef47",
69+
"2025-08-01/llvm-tools-nightly-x86_64-apple-darwin.tar.xz": "e44dd3506524d85c37b3a54bcc91d01378fd2c590b2db5c5974d12f05c1b84d1",
70+
"2025-08-01/llvm-tools-nightly-aarch64-apple-darwin.tar.xz": "0c1b5f46dd81be4a9227b10283a0fcaa39c14fea7e81aea6fd6d9887ff6cdc41",
71+
"2025-08-01/llvm-tools-nightly-x86_64-pc-windows-msvc.tar.xz": "423e5fd11406adccbc31b8456ceb7375ce055cdf45e90d2c3babeb2d7f58383f",
72+
"2025-08-01/rust-std-nightly-x86_64-unknown-linux-gnu.tar.xz": "3c0ceb46a252647a1d4c7116d9ccae684fa5e42aaf3296419febd2c962c3b41d",
73+
"2025-08-01/rust-std-nightly-x86_64-apple-darwin.tar.xz": "3be416003cab10f767390a753d1d16ae4d26c7421c03c98992cf1943e5b0efe8",
74+
"2025-08-01/rust-std-nightly-aarch64-apple-darwin.tar.xz": "4046ac0ef951cb056b5028a399124f60999fa37792eab69d008d8d7965f389b4",
75+
"2025-08-01/rust-std-nightly-x86_64-pc-windows-msvc.tar.xz": "191ed9d8603c3a4fe5a7bbbc2feb72049078dae2df3d3b7d5dedf3abbf823e6e",
7376
},
7477
versions = [RUST_VERSION],
7578
)

rust-toolchain.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# This file specifies the Rust version used to develop and test the
2-
# extractors written in rust. It is set to the lowest version of Rust
3-
# we want to support.
1+
# This file specifies the Rust version used to develop the extractors written
2+
# in rust. Notice that this is just used by using `cargo`-related tools in a
3+
# local dev environment. The actual version used to build the released packs
4+
# is specified in `MODULE.bazel` in the internal repository (typically
5+
# reflected by `MODULE.bazel` in this repository).
46

57
[toolchain]
6-
channel = "1.86"
8+
channel = "1.88"
79
profile = "minimal"
810
components = [ "clippy", "rustfmt" ]

rust/ast-generator/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn class_name(type_name: &str) -> String {
2323
"AsmOptions" => "AsmOptionsList".to_owned(),
2424
"MacroStmts" => "MacroBlockExpr".to_owned(),
2525
_ if type_name.starts_with("Record") => type_name.replacen("Record", "Struct", 1),
26-
_ if type_name.ends_with("Type") => format!("{}Repr", type_name),
26+
_ if type_name.ends_with("Type") => format!("{type_name}Repr"),
2727
_ => type_name.to_owned(),
2828
}
2929
}
@@ -171,7 +171,7 @@ fn get_trait_fields(trait_name: &str) -> Vec<FieldInfo> {
171171
],
172172
"HasArgList" => vec![FieldInfo::optional("arg_list", "ArgList")],
173173
"HasDocComments" => vec![],
174-
_ => panic!("Unknown trait {}", trait_name),
174+
_ => panic!("Unknown trait {trait_name}"),
175175
}
176176
}
177177

rust/extractor/src/rust_analyzer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a> RustAnalyzer<'a> {
5151
config: &CargoConfig,
5252
load_config: &LoadCargoConfig,
5353
) -> Option<(RootDatabase, Vfs)> {
54-
let progress = |t| (trace!("progress: {}", t));
54+
let progress = |t| trace!("progress: {t}");
5555
let manifest = project.manifest_path();
5656
match load_workspace_at(manifest.as_ref(), config, load_config, &progress) {
5757
Ok((db, vfs, _macro_server)) => Some((db, vfs)),
@@ -67,7 +67,7 @@ impl<'a> RustAnalyzer<'a> {
6767
fn get_file_data(
6868
&self,
6969
path: &Path,
70-
) -> Result<(&Semantics<RootDatabase>, EditionedFileId, FileText), &str> {
70+
) -> Result<(&Semantics<'_, RootDatabase>, EditionedFileId, FileText), &str> {
7171
match self {
7272
RustAnalyzer::WithoutSemantics { reason } => Err(reason),
7373
RustAnalyzer::WithSemantics { vfs, semantics } => {
@@ -82,7 +82,7 @@ impl<'a> RustAnalyzer<'a> {
8282
}
8383
}
8484

85-
pub fn parse(&self, path: &Path) -> ParseResult {
85+
pub fn parse(&self, path: &Path) -> ParseResult<'_> {
8686
match self.get_file_data(path) {
8787
Ok((semantics, file_id, input)) => {
8888
let source_file = semantics.parse(file_id);

rust/extractor/src/translate/base.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,7 @@ impl<'a> Translator<'a> {
549549
.map(|p| format!("[{p}; {size}]"));
550550
}
551551
if let Some(it) = ty.as_slice() {
552-
return self
553-
.canonical_path_from_type(it)
554-
.map(|p| format!("[{}]", p));
552+
return self.canonical_path_from_type(it).map(|p| format!("[{p}]"));
555553
}
556554
if let Some(it) = ty.as_builtin() {
557555
return Some(it.name().as_str().to_owned());
@@ -651,7 +649,7 @@ impl<'a> Translator<'a> {
651649
// if we have a Hir entity, it means we have semantics
652650
let sema = self.semantics.as_ref().unwrap();
653651
match item.origin(sema.db) {
654-
CrateOrigin::Rustc { name } => format!("rustc:{}", name),
652+
CrateOrigin::Rustc { name } => format!("rustc:{name}"),
655653
CrateOrigin::Local { repo, name } => format!(
656654
"repo:{}:{}",
657655
repo.unwrap_or_default(),
@@ -660,7 +658,7 @@ impl<'a> Translator<'a> {
660658
CrateOrigin::Library { repo, name } => {
661659
format!("repo:{}:{}", repo.unwrap_or_default(), name)
662660
}
663-
CrateOrigin::Lang(it) => format!("lang:{}", it),
661+
CrateOrigin::Lang(it) => format!("lang:{it}"),
664662
}
665663
}
666664

rust/extractor/src/trap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub trait AsTrapKeyPart {
1616

1717
impl AsTrapKeyPart for UntypedLabel {
1818
fn as_key_part(&self) -> String {
19-
format!("{{{}}}", self)
19+
format!("{{{self}}}")
2020
}
2121
}
2222

rust/rust-toolchain.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

shared/tree-sitter-extractor/src/generator/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ fn add_field_for_column_storage<'a>(
259259
/// values are their integer representations.
260260
fn convert_nodes(
261261
nodes: &node_types::NodeTypeMap,
262-
) -> (Vec<dbscheme::Entry>, Set<&str>, Map<&str, usize>) {
263-
let mut entries: Vec<dbscheme::Entry> = Vec::new();
262+
) -> (Vec<dbscheme::Entry<'_>>, Set<&str>, Map<&str, usize>) {
263+
let mut entries = Vec::new();
264264
let mut ast_node_members: Set<&str> = Set::new();
265265
let token_kinds: Map<&str, usize> = nodes
266266
.iter()

shared/tree-sitter-extractor/src/generator/ql_gen.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Cl
200200
}
201201

202202
// Creates the `ReservedWord` class.
203-
pub fn create_reserved_word_class(db_name: &str) -> ql::Class {
203+
pub fn create_reserved_word_class(db_name: &str) -> ql::Class<'_> {
204204
let class_name = "ReservedWord";
205205
let get_a_primary_ql_class = create_get_a_primary_ql_class(class_name, true);
206206
ql::Class {
@@ -237,7 +237,7 @@ fn create_none_predicate<'a>(
237237

238238
/// Creates an overridden `getAPrimaryQlClass` predicate that returns the given
239239
/// name.
240-
fn create_get_a_primary_ql_class(class_name: &str, is_final: bool) -> ql::Predicate {
240+
fn create_get_a_primary_ql_class(class_name: &str, is_final: bool) -> ql::Predicate<'_> {
241241
ql::Predicate {
242242
qldoc: Some(String::from(
243243
"Gets the name of the primary QL class for this element.",
@@ -318,7 +318,7 @@ pub fn create_get_node_file_predicate<'a>(
318318
}
319319
}
320320

321-
pub fn create_discardable_ast_node_predicate(ast_node_name: &str) -> ql::Predicate {
321+
pub fn create_discardable_ast_node_predicate(ast_node_name: &str) -> ql::Predicate<'_> {
322322
ql::Predicate {
323323
name: "discardableAstNode",
324324
qldoc: Some(String::from(
@@ -352,7 +352,7 @@ pub fn create_discardable_ast_node_predicate(ast_node_name: &str) -> ql::Predica
352352
}
353353
}
354354

355-
pub fn create_discard_ast_node_predicate(ast_node_name: &str) -> ql::Predicate {
355+
pub fn create_discard_ast_node_predicate(ast_node_name: &str) -> ql::Predicate<'_> {
356356
ql::Predicate {
357357
name: "discardAstNode",
358358
qldoc: Some(String::from(
@@ -692,8 +692,8 @@ fn create_field_getters<'a>(
692692
}
693693

694694
/// Converts the given node types into CodeQL classes wrapping the dbscheme.
695-
pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec<ql::TopLevel> {
696-
let mut classes: Vec<ql::TopLevel> = Vec::new();
695+
pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec<ql::TopLevel<'_>> {
696+
let mut classes = Vec::new();
697697
let mut token_kinds = BTreeSet::new();
698698
for (type_name, node) in nodes {
699699
if let node_types::EntryKind::Token { .. } = &node.kind {

0 commit comments

Comments
 (0)