Skip to content

Rollup of 9 pull requests #144516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f75595d
add codegen test for variadics (also replacing some existing does-thi…
RalfJung Jul 23, 2025
1de927c
library/windows_targets: Fix macro expansion error in 'link' macro
itf Jul 24, 2025
546885c
tests: aarch64-outline-atomics: Remove hardcoded target
Gelbpunkt Jul 25, 2025
73e534b
Revert "Move `shared_helpers` test to a dedicated module"
jieyouxu Jul 25, 2025
430f4f5
Check `./x check bootstrap` in `pr-check-1`
jieyouxu Jul 25, 2025
25036f5
canonicalize build root in `tests/run-make/linker-warning`
WaffleLapkin Jul 25, 2025
3dac888
Only run bootstrap tests in `x test` on CI
Kobzol Jul 25, 2025
96340f6
Stop compilation if macro expansion failed
GuillaumeGomez Jul 24, 2025
5dddba5
Add missing `NOTE` annotations in `tests/ui/macros/trace-macro.rs`
GuillaumeGomez Jul 24, 2025
2725138
Update ui tests with new macro early erroring
GuillaumeGomez Jul 24, 2025
11b3f16
bump cargo_metadata
klensy Jul 26, 2025
bd7b023
move uefi test to run-make
folkertdev Jul 25, 2025
3cf03ec
Rollup merge of #144359 - RalfJung:vararg-codegen, r=compiler-errors
matthiaskrgr Jul 26, 2025
6cbddf4
Rollup merge of #144409 - GuillaumeGomez:macro-expansion-early-abort,…
matthiaskrgr Jul 26, 2025
471f604
Rollup merge of #144422 - itf:itf-patch-2-1, r=ChrisDenton
matthiaskrgr Jul 26, 2025
166dfcb
Rollup merge of #144430 - Gelbpunkt:aarch64-outline-atomics-target, r…
matthiaskrgr Jul 26, 2025
d3fd616
Rollup merge of #144445 - jieyouxu:revert-shared_helpers_tests, r=Kobzol
matthiaskrgr Jul 26, 2025
ca79026
Rollup merge of #144453 - WaffleLapkin:canonical-build-root, r=jieyouxu
matthiaskrgr Jul 26, 2025
debedb3
Rollup merge of #144454 - folkertdev:uefi-tests, r=jieyouxu
matthiaskrgr Jul 26, 2025
5b8aa67
Rollup merge of #144464 - Kobzol:x-test-default, r=jieyouxu
matthiaskrgr Jul 26, 2025
b19b5bd
Rollup merge of #144495 - klensy:cargo_metadata, r=lqd
matthiaskrgr Jul 26, 2025
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
18 changes: 2 additions & 16 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -441,20 +441,6 @@ dependencies = [
"thiserror 1.0.69",
]

[[package]]
name = "cargo_metadata"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba"
dependencies = [
"camino",
"cargo-platform 0.1.9",
"semver",
"serde",
"serde_json",
"thiserror 2.0.12",
]

[[package]]
name = "cargo_metadata"
version = "0.21.0"
Expand Down Expand Up @@ -1364,7 +1350,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"askama",
"cargo_metadata 0.18.1",
"cargo_metadata 0.21.0",
"serde",
"serde_json",
"thiserror 1.0.69",
Expand Down Expand Up @@ -5370,7 +5356,7 @@ name = "tidy"
version = "0.1.0"
dependencies = [
"build_helper",
"cargo_metadata 0.19.2",
"cargo_metadata 0.21.0",
"fluent-syntax",
"ignore",
"miropt-test-tools",
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@ pub struct ExtCtxt<'a> {
pub(super) expanded_inert_attrs: MarkedAttrs,
/// `-Zmacro-stats` data.
pub macro_stats: FxHashMap<(Symbol, MacroKind), MacroStat>,
pub nb_macro_errors: usize,
}

impl<'a> ExtCtxt<'a> {
Expand Down Expand Up @@ -1254,6 +1255,7 @@ impl<'a> ExtCtxt<'a> {
expanded_inert_attrs: MarkedAttrs::new(),
buffered_early_lint: vec![],
macro_stats: Default::default(),
nb_macro_errors: 0,
}
}

Expand Down Expand Up @@ -1315,6 +1317,12 @@ impl<'a> ExtCtxt<'a> {
self.current_expansion.id.expansion_cause()
}

/// This method increases the internal macro errors count and then call `trace_macros_diag`.
pub fn macro_error_and_trace_macros_diag(&mut self) {
self.nb_macro_errors += 1;
self.trace_macros_diag();
}

pub fn trace_macros_diag(&mut self) {
for (span, notes) in self.expansions.iter() {
let mut db = self.dcx().create_note(errors::TraceMacro { span: *span });
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
crate_name: self.cx.ecfg.crate_name,
});

self.cx.trace_macros_diag();
self.cx.macro_error_and_trace_macros_diag();
guar
}

Expand All @@ -707,7 +707,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
) -> ErrorGuaranteed {
let guar =
self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name: &mac.path });
self.cx.trace_macros_diag();
self.cx.macro_error_and_trace_macros_diag();
guar
}

Expand Down Expand Up @@ -1048,7 +1048,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
}
annotate_err_with_kind(&mut err, kind, span);
let guar = err.emit();
self.cx.trace_macros_diag();
self.cx.macro_error_and_trace_macros_diag();
kind.dummy(span, guar)
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ enum EofMatcherPositions {
}

/// Represents the possible results of an attempted parse.
#[derive(Debug)]
pub(crate) enum ParseResult<T, F> {
/// Parsed successfully.
Success(T),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ fn expand_macro<'cx>(
// Retry and emit a better error.
let (span, guar) =
diagnostics::failed_to_match_macro(cx.psess(), sp, def_span, name, arg, rules);
cx.trace_macros_diag();
cx.macro_error_and_trace_macros_diag();
DummyResult::any(span, guar)
}
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ fn configure_and_expand(
// Expand macros now!
let krate = sess.time("expand_crate", || ecx.monotonic_expander().expand_crate(krate));

if ecx.nb_macro_errors > 0 {
sess.dcx().abort_if_errors();
}

// The rest is error reporting and stats

sess.psess.buffered_lints.with_lock(|buffered_lints: &mut Vec<BufferedEarlyLint>| {
Expand Down
16 changes: 3 additions & 13 deletions library/windows_targets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,12 @@ pub macro link_dylib {

#[cfg(feature = "windows_raw_dylib")]
pub macro link($($tt:tt)*) {
$crate::link_raw_dylib!($($tt)*)
$crate::link_raw_dylib!($($tt)*);
}

#[cfg(not(feature = "windows_raw_dylib"))]
pub macro link {
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
// Note: the windows-targets crate uses a pre-built Windows.lib import library which we don't
// have in this repo. So instead we always link kernel32.lib and add the rest of the import
// libraries below by using an empty extern block. This works because extern blocks are not
// connected to the library given in the #[link] attribute.
#[link(name = "kernel32")]
unsafe extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
)
pub macro link($($tt:tt)*) {
$crate::link_dylib!($($tt)*);
}

#[cfg(not(feature = "windows_raw_dylib"))]
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3132,7 +3132,11 @@ impl Step for Bootstrap {
}

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/bootstrap")
// Bootstrap tests might not be perfectly self-contained and can depend on the external
// environment, submodules that are checked out, etc.
// Therefore we only run them by default on CI.
let runs_on_ci = run.builder.config.is_running_on_ci;
run.path("src/bootstrap").default_condition(runs_on_ci)
}

fn make_run(run: RunConfig<'_>) {
Expand Down
22 changes: 11 additions & 11 deletions src/bootstrap/src/utils/shared_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//! This module serves two purposes:
//! 1. It is part of the `utils` module and used in other parts of bootstrap.
//! 2. It is embedded inside bootstrap shims to avoid a dependency on the bootstrap library.
//! Therefore, this module should never use any other bootstrap module. This reduces binary
//! size and improves compilation time by minimizing linking time.
//!
//! 1. It is part of the `utils` module and used in other parts of bootstrap.
//! 2. It is embedded inside bootstrap shims to avoid a dependency on the bootstrap library.
//! Therefore, this module should never use any other bootstrap module. This reduces binary size
//! and improves compilation time by minimizing linking time.

// # Note on tests
//
// If we were to declare a tests submodule here, the shim binaries that include this module via
// `#[path]` would fail to find it, which breaks `./x check bootstrap`. So instead the unit tests
// for this module are in `super::tests::shared_helpers_tests`.

#![allow(dead_code)]

#[cfg(test)]
mod tests;

use std::env;
use std::ffi::OsString;
use std::fs::OpenOptions;
use std::io::Write;
use std::process::Command;
use std::str::FromStr;

// If we were to declare a tests submodule here, the shim binaries that include this
// module via `#[path]` would fail to find it, which breaks `./x check bootstrap`.
// So instead the unit tests for this module are in `super::tests::shared_helpers_tests`.

/// Returns the environment variable which the dynamic library lookup path
/// resides in for this platform.
pub fn dylib_path_var() -> &'static str {
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/utils/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use crate::{Build, Config, Flags, t};

pub mod git;

// Note: tests for `shared_helpers` is separate here, as otherwise shim binaries that include the
// `shared_helpers` via `#[path]` would fail to find it, breaking `./x check bootstrap`.
mod shared_helpers_tests;

/// Holds temporary state of a bootstrap test.
/// Right now it is only used to redirect the build directory of the bootstrap
/// invocation, in the future it would be great if we could actually execute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! The `shared_helpers` module can't have its own tests submodule, because that would cause
//! problems for the shim binaries that include it via `#[path]`, so instead those unit tests live
//! here.
//!
//! To prevent tidy from complaining about this file not being named `tests.rs`, it lives inside a
//! submodule directory named `tests`.

use crate::utils::shared_helpers::parse_value_from_args;

#[test]
Expand Down
1 change: 1 addition & 0 deletions src/ci/docker/host-x86_64/pr-check-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ COPY host-x86_64/pr-check-1/validate-toolstate.sh /scripts/
# We disable optimized compiler built-ins because that requires a C toolchain for the target.
# We also skip the x86_64-unknown-linux-gnu target as it is well-tested by other jobs.
ENV SCRIPT \
python3 ../x.py check bootstrap && \
/scripts/check-default-config-profiles.sh && \
python3 ../x.py build src/tools/build-manifest && \
python3 ../x.py test --stage 0 src/tools/compiletest && \
Expand Down
5 changes: 3 additions & 2 deletions src/ci/docker/host-x86_64/test-various/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ ENV MUSL_TARGETS=x86_64-unknown-linux-musl \
CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++
ENV MUSL_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $MUSL_TARGETS

COPY host-x86_64/test-various/uefi_qemu_test /uefi_qemu_test
ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \
CC_aarch64_unknown_uefi=clang-11 \
CXX_aarch64_unknown_uefi=clang++-11 \
Expand All @@ -88,6 +87,8 @@ ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \
CC_x86_64_unknown_uefi=clang-11 \
CXX_x86_64_unknown_uefi=clang++-11
ENV UEFI_SCRIPT python3 /checkout/x.py --stage 2 build --host='' --target $UEFI_TARGETS && \
python3 -u /uefi_qemu_test/run.py
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target aarch64-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target i686-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target x86_64-unknown-uefi

ENV SCRIPT $WASM_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT
140 changes: 0 additions & 140 deletions src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py

This file was deleted.

1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-stable",
"only-thumb",
"only-tvos",
"only-uefi",
"only-unix",
"only-visionos",
"only-wasm32",
Expand Down
Loading
Loading