mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Merge branch 'main' into aibaars/rust-expand-assoc-items
This commit is contained in:
@@ -62,6 +62,7 @@ pub struct Config {
|
||||
pub qltest: bool,
|
||||
pub qltest_cargo_check: bool,
|
||||
pub qltest_dependencies: Vec<String>,
|
||||
pub qltest_use_nightly: bool,
|
||||
pub sysroot: Option<PathBuf>,
|
||||
pub sysroot_src: Option<PathBuf>,
|
||||
pub rustc_src: Option<PathBuf>,
|
||||
|
||||
@@ -8,6 +8,9 @@ use std::path::Path;
|
||||
use std::process::Command;
|
||||
use tracing::info;
|
||||
|
||||
const EDITION: &str = "2021";
|
||||
const NIGHTLY: &str = "nightly-2025-06-01";
|
||||
|
||||
fn dump_lib() -> anyhow::Result<()> {
|
||||
let path_iterator = glob("*.rs").context("globbing test sources")?;
|
||||
let paths = path_iterator
|
||||
@@ -29,8 +32,11 @@ enum TestCargoManifest<'a> {
|
||||
uses_proc_macro: bool,
|
||||
uses_main: bool,
|
||||
dependencies: &'a [String],
|
||||
edition: &'a str,
|
||||
},
|
||||
Macro {
|
||||
edition: &'a str,
|
||||
},
|
||||
Macro {},
|
||||
}
|
||||
|
||||
impl TestCargoManifest<'_> {
|
||||
@@ -56,16 +62,26 @@ fn dump_cargo_manifest(dependencies: &[String]) -> anyhow::Result<()> {
|
||||
uses_proc_macro,
|
||||
uses_main: fs::exists("main.rs").context("checking existence of main.rs")?,
|
||||
dependencies,
|
||||
edition: EDITION,
|
||||
};
|
||||
if uses_proc_macro {
|
||||
TestCargoManifest::Workspace {}.dump("")?;
|
||||
lib_manifest.dump(".lib")?;
|
||||
TestCargoManifest::Macro {}.dump(".proc_macro")
|
||||
TestCargoManifest::Macro { edition: EDITION }.dump(".proc_macro")
|
||||
} else {
|
||||
lib_manifest.dump("")
|
||||
}
|
||||
}
|
||||
|
||||
fn dump_nightly_toolchain() -> anyhow::Result<()> {
|
||||
fs::write(
|
||||
"rust-toolchain.toml",
|
||||
format!("[toolchain]\nchannel = \"{NIGHTLY}\"\n"),
|
||||
)
|
||||
.context("writing rust-toolchain.toml")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_sources(config: &mut Config) -> anyhow::Result<()> {
|
||||
let path_iterator = glob("**/*.rs").context("globbing test sources")?;
|
||||
config.inputs = path_iterator
|
||||
@@ -79,6 +95,9 @@ pub(crate) fn prepare(config: &mut Config) -> anyhow::Result<()> {
|
||||
dump_lib()?;
|
||||
set_sources(config)?;
|
||||
dump_cargo_manifest(&config.qltest_dependencies)?;
|
||||
if config.qltest_use_nightly {
|
||||
dump_nightly_toolchain()?;
|
||||
}
|
||||
if config.qltest_cargo_check {
|
||||
let status = Command::new("cargo")
|
||||
.env("RUSTFLAGS", "-Awarnings")
|
||||
|
||||
@@ -11,7 +11,7 @@ members = [".lib", ".proc_macro"]
|
||||
[package]
|
||||
name = "test"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
edition = "{{ edition }}"
|
||||
[lib]
|
||||
path = "{{#uses_proc_macro}}../{{/uses_proc_macro}}lib.rs"
|
||||
{{#uses_main}}
|
||||
@@ -32,7 +32,7 @@ proc_macro = { path = "../.proc_macro" }
|
||||
[package]
|
||||
name = "proc_macro"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
edition = "{{ edition }}"
|
||||
[lib]
|
||||
path = "../proc_macro.rs"
|
||||
proc_macro = true
|
||||
|
||||
Reference in New Issue
Block a user