Merge pull request #19828 from github/redsun82/rust-fix-nightly-toolchain

Rust: fix nightly toolchain version for tests using it
This commit is contained in:
Paolo Tranquilli
2025-06-20 14:40:05 +02:00
committed by GitHub
11 changed files with 35 additions and 23 deletions

View File

@@ -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>,

View File

@@ -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")

View File

@@ -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

View File

@@ -1,6 +1,9 @@
Cargo.toml
lib.rs
target/
# these are all generated, see `rust/extractor/src/qltest.rs` for details
Cargo.toml
rust-toolchain.toml
lib.rs
.proc_macro/
.lib/

View File

@@ -1,2 +1,3 @@
qltest_use_nightly: true
qltest_dependencies:
- poem = { version = "3.1.7" }

View File

@@ -1,8 +0,0 @@
# 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.
[toolchain]
channel = "nightly"
profile = "minimal"
components = [ ]

View File

@@ -1,3 +1,3 @@
qltest_cargo_check: true
qltest_use_nightly: true
qltest_dependencies:
- libc = { version = "0.2.11" }

View File

@@ -1,2 +0,0 @@
[toolchain]
channel = "nightly"

View File

@@ -1,13 +1,13 @@
multiplePathResolutions
| deallocation.rs:106:16:106:19 | libc | file://:0:0:0:0 | Crate(libc@0.2.171) |
| deallocation.rs:106:16:106:19 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
| deallocation.rs:106:16:106:19 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
| deallocation.rs:106:16:106:27 | ...::malloc | file://:0:0:0:0 | fn malloc |
| deallocation.rs:106:16:106:27 | ...::malloc | file://:0:0:0:0 | fn malloc |
| deallocation.rs:112:3:112:6 | libc | file://:0:0:0:0 | Crate(libc@0.2.171) |
| deallocation.rs:112:3:112:6 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
| deallocation.rs:112:3:112:6 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
| deallocation.rs:112:3:112:12 | ...::free | file://:0:0:0:0 | fn free |
| deallocation.rs:112:3:112:12 | ...::free | file://:0:0:0:0 | fn free |
| deallocation.rs:112:29:112:32 | libc | file://:0:0:0:0 | Crate(libc@0.2.171) |
| deallocation.rs:112:29:112:32 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
| deallocation.rs:112:29:112:32 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
| deallocation.rs:260:11:260:22 | ...::from | file://:0:0:0:0 | fn from |
| deallocation.rs:260:11:260:22 | ...::from | file://:0:0:0:0 | fn from |

View File

@@ -1,3 +1,3 @@
qltest_cargo_check: true
qltest_use_nightly: true
qltest_dependencies:
- libc = { version = "0.2.11" }

View File

@@ -1,2 +0,0 @@
[toolchain]
channel = "nightly-2025-03-17"