mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #20207 from github/redsun82/rust-toolchain
Cargo: align rust toolchain version with internal repository
This commit is contained in:
7
.bazelrc
7
.bazelrc
@@ -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"
|
||||
|
||||
|
||||
47
MODULE.bazel
47
MODULE.bazel
@@ -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)
|
||||
@@ -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(
|
||||
@@ -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],
|
||||
)
|
||||
|
||||
@@ -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" ]
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
@@ -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}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)),
|
||||
@@ -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 } => {
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
@@ -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(),
|
||||
@@ -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}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ pub trait AsTrapKeyPart {
|
||||
|
||||
impl AsTrapKeyPart for UntypedLabel {
|
||||
fn as_key_part(&self) -> String {
|
||||
format!("{{{}}}", self)
|
||||
format!("{{{self}}}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
rust/ql/test/.gitignore
vendored
2
rust/ql/test/.gitignore
vendored
@@ -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/
|
||||
|
||||
7
rust/ql/test/rust-toolchain.toml
Normal file
7
rust/ql/test/rust-toolchain.toml
Normal file
@@ -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" ]
|
||||
@@ -1,8 +0,0 @@
|
||||
# This file specifies the Rust version used to develop and test the rust
|
||||
# extractor. It is set to the lowest version of Rust we want to support.
|
||||
# IMPORTANT: this can also have an impact on QL test results
|
||||
|
||||
[toolchain]
|
||||
channel = "1.86"
|
||||
profile = "minimal"
|
||||
components = [ "clippy", "rustfmt", "rust-src" ]
|
||||
@@ -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));
|
||||
|
||||
@@ -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"))),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
@@ -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(),
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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, ";")
|
||||
@@ -68,7 +68,7 @@ impl fmt::Display for Table<'_> {
|
||||
if key_index > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", key)?;
|
||||
write!(f, "{key}")?;
|
||||
}
|
||||
writeln!(f, "]")?;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ impl fmt::Display for Union<'_> {
|
||||
} else {
|
||||
write!(f, " | ")?;
|
||||
}
|
||||
write!(f, "@{}", member)?;
|
||||
write!(f, "@{member}")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -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")?,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -12,10 +12,10 @@ pub enum TopLevel<'a> {
|
||||
impl fmt::Display for TopLevel<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
TopLevel::Import(imp) => write!(f, "{}", imp),
|
||||
TopLevel::Class(cls) => write!(f, "{}", cls),
|
||||
TopLevel::Module(m) => write!(f, "{}", m),
|
||||
TopLevel::Predicate(pred) => write!(f, "{}", pred),
|
||||
TopLevel::Import(imp) => write!(f, "{imp}"),
|
||||
TopLevel::Class(cls) => write!(f, "{cls}"),
|
||||
TopLevel::Module(m) => write!(f, "{m}"),
|
||||
TopLevel::Predicate(pred) => write!(f, "{pred}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ impl fmt::Display for Import<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "import {}", &self.module)?;
|
||||
if let Some(name) = &self.alias {
|
||||
write!(f, " as {}", name)?;
|
||||
write!(f, " as {name}")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -48,7 +48,7 @@ pub struct Class<'a> {
|
||||
impl fmt::Display for Class<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(qldoc) = &self.qldoc {
|
||||
write!(f, "/** {} */", qldoc)?;
|
||||
write!(f, "/** {qldoc} */")?;
|
||||
}
|
||||
if self.is_abstract {
|
||||
write!(f, "abstract ")?;
|
||||
@@ -58,7 +58,7 @@ impl fmt::Display for Class<'_> {
|
||||
if index > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", supertype)?;
|
||||
write!(f, "{supertype}")?;
|
||||
}
|
||||
writeln!(f, " {{ ")?;
|
||||
|
||||
@@ -81,7 +81,7 @@ impl fmt::Display for Class<'_> {
|
||||
}
|
||||
|
||||
for predicate in &self.predicates {
|
||||
writeln!(f, " {}", predicate)?;
|
||||
writeln!(f, " {predicate}")?;
|
||||
}
|
||||
|
||||
write!(f, "}}")?;
|
||||
@@ -101,7 +101,7 @@ pub struct Module<'a> {
|
||||
impl fmt::Display for Module<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(qldoc) = &self.qldoc {
|
||||
write!(f, "/** {} */", qldoc)?;
|
||||
write!(f, "/** {qldoc} */")?;
|
||||
}
|
||||
if let Some(overlay_annotation) = &self.overlay {
|
||||
write!(f, "overlay[")?;
|
||||
@@ -113,7 +113,7 @@ impl fmt::Display for Module<'_> {
|
||||
}
|
||||
writeln!(f, "module {} {{ ", self.name)?;
|
||||
for decl in &self.body {
|
||||
writeln!(f, " {}", decl)?;
|
||||
writeln!(f, " {decl}")?;
|
||||
}
|
||||
write!(f, "}}")?;
|
||||
Ok(())
|
||||
@@ -140,8 +140,8 @@ impl fmt::Display for Type<'_> {
|
||||
match self {
|
||||
Type::Int => write!(f, "int"),
|
||||
Type::String => write!(f, "string"),
|
||||
Type::Normal(name) => write!(f, "{}", name),
|
||||
Type::At(name) => write!(f, "@{}", name),
|
||||
Type::Normal(name) => write!(f, "{name}"),
|
||||
Type::At(name) => write!(f, "@{name}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,16 +169,16 @@ pub enum Expression<'a> {
|
||||
impl fmt::Display for Expression<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Expression::Var(x) => write!(f, "{}", x),
|
||||
Expression::String(s) => write!(f, "\"{}\"", s),
|
||||
Expression::Integer(n) => write!(f, "{}", n),
|
||||
Expression::Var(x) => write!(f, "{x}"),
|
||||
Expression::String(s) => write!(f, "\"{s}\""),
|
||||
Expression::Integer(n) => write!(f, "{n}"),
|
||||
Expression::Pred(n, args) => {
|
||||
write!(f, "{}(", n)?;
|
||||
write!(f, "{n}(")?;
|
||||
for (index, arg) in args.iter().enumerate() {
|
||||
if index > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", arg)?;
|
||||
write!(f, "{arg}")?;
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
@@ -190,7 +190,7 @@ impl fmt::Display for Expression<'_> {
|
||||
if index > 0 {
|
||||
write!(f, " and ")?;
|
||||
}
|
||||
write!(f, "({})", conjunct)?;
|
||||
write!(f, "({conjunct})")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -203,19 +203,19 @@ impl fmt::Display for Expression<'_> {
|
||||
if index > 0 {
|
||||
write!(f, " or ")?;
|
||||
}
|
||||
write!(f, "({})", disjunct)?;
|
||||
write!(f, "({disjunct})")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Expression::Equals(a, b) => write!(f, "{} = {}", a, b),
|
||||
Expression::Equals(a, b) => write!(f, "{a} = {b}"),
|
||||
Expression::Dot(x, member_pred, args) => {
|
||||
write!(f, "{}.{}(", x, member_pred)?;
|
||||
write!(f, "{x}.{member_pred}(")?;
|
||||
for (index, arg) in args.iter().enumerate() {
|
||||
if index > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", arg)?;
|
||||
write!(f, "{arg}")?;
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
@@ -226,26 +226,26 @@ impl fmt::Display for Expression<'_> {
|
||||
expr,
|
||||
second_expr,
|
||||
} => {
|
||||
write!(f, "{}(", name)?;
|
||||
write!(f, "{name}(")?;
|
||||
if !vars.is_empty() {
|
||||
for (index, var) in vars.iter().enumerate() {
|
||||
if index > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", var)?;
|
||||
write!(f, "{var}")?;
|
||||
}
|
||||
write!(f, " | ")?;
|
||||
}
|
||||
if let Some(range) = range {
|
||||
write!(f, "{} | ", range)?;
|
||||
write!(f, "{range} | ")?;
|
||||
}
|
||||
write!(f, "{}", expr)?;
|
||||
write!(f, "{expr}")?;
|
||||
if let Some(second_expr) = second_expr {
|
||||
write!(f, ", {}", second_expr)?;
|
||||
write!(f, ", {second_expr}")?;
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
Expression::Negation(e) => write!(f, "not ({})", e),
|
||||
Expression::Negation(e) => write!(f, "not ({e})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ pub struct Predicate<'a> {
|
||||
impl fmt::Display for Predicate<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(qldoc) = &self.qldoc {
|
||||
write!(f, "/** {} */", qldoc)?;
|
||||
write!(f, "/** {qldoc} */")?;
|
||||
}
|
||||
if let Some(overlay_annotation) = &self.overlay {
|
||||
write!(f, "overlay[")?;
|
||||
@@ -293,14 +293,14 @@ impl fmt::Display for Predicate<'_> {
|
||||
}
|
||||
match &self.return_type {
|
||||
None => write!(f, "predicate ")?,
|
||||
Some(return_type) => write!(f, "{} ", return_type)?,
|
||||
Some(return_type) => write!(f, "{return_type} ")?,
|
||||
}
|
||||
write!(f, "{}(", self.name)?;
|
||||
for (index, param) in self.formal_parameters.iter().enumerate() {
|
||||
if index > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", param)?;
|
||||
write!(f, "{param}")?;
|
||||
}
|
||||
write!(f, ") {{ {} }}", self.body)?;
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Cl
|
||||
}
|
||||
|
||||
// Creates the `ReservedWord` class.
|
||||
pub fn create_reserved_word_class(db_name: &str) -> ql::Class {
|
||||
pub fn create_reserved_word_class(db_name: &str) -> ql::Class<'_> {
|
||||
let class_name = "ReservedWord";
|
||||
let get_a_primary_ql_class = create_get_a_primary_ql_class(class_name, true);
|
||||
ql::Class {
|
||||
@@ -237,7 +237,7 @@ fn create_none_predicate<'a>(
|
||||
|
||||
/// Creates an overridden `getAPrimaryQlClass` predicate that returns the given
|
||||
/// name.
|
||||
fn create_get_a_primary_ql_class(class_name: &str, is_final: bool) -> ql::Predicate {
|
||||
fn create_get_a_primary_ql_class(class_name: &str, is_final: bool) -> ql::Predicate<'_> {
|
||||
ql::Predicate {
|
||||
qldoc: Some(String::from(
|
||||
"Gets the name of the primary QL class for this element.",
|
||||
@@ -318,7 +318,7 @@ pub fn create_get_node_file_predicate<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_discardable_ast_node_predicate(ast_node_name: &str) -> ql::Predicate {
|
||||
pub fn create_discardable_ast_node_predicate(ast_node_name: &str) -> ql::Predicate<'_> {
|
||||
ql::Predicate {
|
||||
name: "discardableAstNode",
|
||||
qldoc: Some(String::from(
|
||||
@@ -352,7 +352,7 @@ pub fn create_discardable_ast_node_predicate(ast_node_name: &str) -> ql::Predica
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_discard_ast_node_predicate(ast_node_name: &str) -> ql::Predicate {
|
||||
pub fn create_discard_ast_node_predicate(ast_node_name: &str) -> ql::Predicate<'_> {
|
||||
ql::Predicate {
|
||||
name: "discardAstNode",
|
||||
qldoc: Some(String::from(
|
||||
@@ -666,7 +666,7 @@ fn create_field_getters<'a>(
|
||||
}
|
||||
};
|
||||
let qldoc = match &field.name {
|
||||
Some(name) => format!("Gets the node corresponding to the field `{}`.", name),
|
||||
Some(name) => format!("Gets the node corresponding to the field `{name}`."),
|
||||
None => {
|
||||
if formal_parameters.is_empty() {
|
||||
"Gets the child of this node.".to_owned()
|
||||
@@ -692,8 +692,8 @@ fn create_field_getters<'a>(
|
||||
}
|
||||
|
||||
/// Converts the given node types into CodeQL classes wrapping the dbscheme.
|
||||
pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec<ql::TopLevel> {
|
||||
let mut classes: Vec<ql::TopLevel> = Vec::new();
|
||||
pub fn convert_nodes(nodes: &node_types::NodeTypeMap) -> Vec<ql::TopLevel<'_>> {
|
||||
let mut classes = Vec::new();
|
||||
let mut token_kinds = BTreeSet::new();
|
||||
for (type_name, node) in nodes {
|
||||
if let node_types::EntryKind::Token { .. } = &node.kind {
|
||||
|
||||
@@ -326,7 +326,7 @@ fn node_type_name(kind: &str, named: bool) -> String {
|
||||
if named {
|
||||
kind.to_string()
|
||||
} else {
|
||||
format!("{}_unnamed", kind)
|
||||
format!("{kind}_unnamed")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ impl Writer {
|
||||
|
||||
fn write_trap_entries<W: Write>(&self, file: &mut W) -> std::io::Result<()> {
|
||||
for trap_entry in &self.trap_output {
|
||||
writeln!(file, "{}", trap_entry)?;
|
||||
writeln!(file, "{trap_entry}")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -131,21 +131,21 @@ pub enum Entry {
|
||||
impl fmt::Display for Entry {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Entry::FreshId(label) => write!(f, "{}=*", label),
|
||||
Entry::FreshId(label) => write!(f, "{label}=*"),
|
||||
Entry::MapLabelToKey(label, key) => {
|
||||
write!(f, "{}=@\"{}\"", label, key.replace('"', "\"\""))
|
||||
}
|
||||
Entry::GenericTuple(name, args) => {
|
||||
write!(f, "{}(", name)?;
|
||||
write!(f, "{name}(")?;
|
||||
for (index, arg) in args.iter().enumerate() {
|
||||
if index > 0 {
|
||||
write!(f, ",")?;
|
||||
}
|
||||
write!(f, "{}", arg)?;
|
||||
write!(f, "{arg}")?;
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
Entry::Comment(line) => write!(f, "// {}", line),
|
||||
Entry::Comment(line) => write!(f, "// {line}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,8 +179,8 @@ const MAX_STRLEN: usize = 1048576;
|
||||
impl fmt::Display for Arg {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Arg::Label(x) => write!(f, "{}", x),
|
||||
Arg::Int(x) => write!(f, "{}", x),
|
||||
Arg::Label(x) => write!(f, "{x}"),
|
||||
Arg::Int(x) => write!(f, "{x}"),
|
||||
Arg::String(x) => write!(
|
||||
f,
|
||||
"\"{}\"",
|
||||
@@ -220,9 +220,9 @@ impl fmt::Display for Program {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut text = String::new();
|
||||
for trap_entry in &self.0 {
|
||||
text.push_str(&format!("{}\n", trap_entry));
|
||||
text.push_str(&format!("{trap_entry}\n"));
|
||||
}
|
||||
write!(f, "{}", text)
|
||||
write!(f, "{text}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user