Skip to content

Commit 9faeadc

Browse files
committed
Auto merge of #144516 - matthiaskrgr:rollup-zoaluag, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #144359 (add codegen test for variadics) - #144409 (Stop compilation early if macro expansion failed) - #144422 (library/windows_targets: Fix macro expansion error in 'link' macro) - #144430 (tests: aarch64-outline-atomics: Remove hardcoded target) - #144445 (Fix `./x check bootstrap` (again)) - #144453 (canonicalize build root in `tests/run-make/linker-warning`) - #144454 (move uefi test to run-make) - #144464 (Only run bootstrap tests in `x test` on CI) - #144495 (bump cargo_metadata) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ce5fdd7 + b19b5bd commit 9faeadc

File tree

54 files changed

+569
-513
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+569
-513
lines changed

Cargo.lock

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -441,20 +441,6 @@ dependencies = [
441441
"thiserror 1.0.69",
442442
]
443443

444-
[[package]]
445-
name = "cargo_metadata"
446-
version = "0.19.2"
447-
source = "registry+https://github.com/rust-lang/crates.io-index"
448-
checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba"
449-
dependencies = [
450-
"camino",
451-
"cargo-platform 0.1.9",
452-
"semver",
453-
"serde",
454-
"serde_json",
455-
"thiserror 2.0.12",
456-
]
457-
458444
[[package]]
459445
name = "cargo_metadata"
460446
version = "0.21.0"
@@ -1364,7 +1350,7 @@ version = "0.1.0"
13641350
dependencies = [
13651351
"anyhow",
13661352
"askama",
1367-
"cargo_metadata 0.18.1",
1353+
"cargo_metadata 0.21.0",
13681354
"serde",
13691355
"serde_json",
13701356
"thiserror 1.0.69",
@@ -5370,7 +5356,7 @@ name = "tidy"
53705356
version = "0.1.0"
53715357
dependencies = [
53725358
"build_helper",
5373-
"cargo_metadata 0.19.2",
5359+
"cargo_metadata 0.21.0",
53745360
"fluent-syntax",
53755361
"ignore",
53765362
"miropt-test-tools",

compiler/rustc_expand/src/base.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,7 @@ pub struct ExtCtxt<'a> {
12241224
pub(super) expanded_inert_attrs: MarkedAttrs,
12251225
/// `-Zmacro-stats` data.
12261226
pub macro_stats: FxHashMap<(Symbol, MacroKind), MacroStat>,
1227+
pub nb_macro_errors: usize,
12271228
}
12281229

12291230
impl<'a> ExtCtxt<'a> {
@@ -1254,6 +1255,7 @@ impl<'a> ExtCtxt<'a> {
12541255
expanded_inert_attrs: MarkedAttrs::new(),
12551256
buffered_early_lint: vec![],
12561257
macro_stats: Default::default(),
1258+
nb_macro_errors: 0,
12571259
}
12581260
}
12591261

@@ -1315,6 +1317,12 @@ impl<'a> ExtCtxt<'a> {
13151317
self.current_expansion.id.expansion_cause()
13161318
}
13171319

1320+
/// This method increases the internal macro errors count and then call `trace_macros_diag`.
1321+
pub fn macro_error_and_trace_macros_diag(&mut self) {
1322+
self.nb_macro_errors += 1;
1323+
self.trace_macros_diag();
1324+
}
1325+
13181326
pub fn trace_macros_diag(&mut self) {
13191327
for (span, notes) in self.expansions.iter() {
13201328
let mut db = self.dcx().create_note(errors::TraceMacro { span: *span });

compiler/rustc_expand/src/expand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
693693
crate_name: self.cx.ecfg.crate_name,
694694
});
695695

696-
self.cx.trace_macros_diag();
696+
self.cx.macro_error_and_trace_macros_diag();
697697
guar
698698
}
699699

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

@@ -1048,7 +1048,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
10481048
}
10491049
annotate_err_with_kind(&mut err, kind, span);
10501050
let guar = err.emit();
1051-
self.cx.trace_macros_diag();
1051+
self.cx.macro_error_and_trace_macros_diag();
10521052
kind.dummy(span, guar)
10531053
}
10541054
}

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ enum EofMatcherPositions {
299299
}
300300

301301
/// Represents the possible results of an attempted parse.
302+
#[derive(Debug)]
302303
pub(crate) enum ParseResult<T, F> {
303304
/// Parsed successfully.
304305
Success(T),

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn expand_macro<'cx>(
280280
// Retry and emit a better error.
281281
let (span, guar) =
282282
diagnostics::failed_to_match_macro(cx.psess(), sp, def_span, name, arg, rules);
283-
cx.trace_macros_diag();
283+
cx.macro_error_and_trace_macros_diag();
284284
DummyResult::any(span, guar)
285285
}
286286
}

compiler/rustc_interface/src/passes.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ fn configure_and_expand(
208208
// Expand macros now!
209209
let krate = sess.time("expand_crate", || ecx.monotonic_expander().expand_crate(krate));
210210

211+
if ecx.nb_macro_errors > 0 {
212+
sess.dcx().abort_if_errors();
213+
}
214+
211215
// The rest is error reporting and stats
212216

213217
sess.psess.buffered_lints.with_lock(|buffered_lints: &mut Vec<BufferedEarlyLint>| {

library/windows_targets/src/lib.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,12 @@ pub macro link_dylib {
3434

3535
#[cfg(feature = "windows_raw_dylib")]
3636
pub macro link($($tt:tt)*) {
37-
$crate::link_raw_dylib!($($tt)*)
37+
$crate::link_raw_dylib!($($tt)*);
3838
}
3939

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

5545
#[cfg(not(feature = "windows_raw_dylib"))]

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3132,7 +3132,11 @@ impl Step for Bootstrap {
31323132
}
31333133

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

31383142
fn make_run(run: RunConfig<'_>) {

src/bootstrap/src/utils/shared_helpers.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
//! This module serves two purposes:
2-
//! 1. It is part of the `utils` module and used in other parts of bootstrap.
3-
//! 2. It is embedded inside bootstrap shims to avoid a dependency on the bootstrap library.
4-
//! Therefore, this module should never use any other bootstrap module. This reduces binary
5-
//! size and improves compilation time by minimizing linking time.
2+
//!
3+
//! 1. It is part of the `utils` module and used in other parts of bootstrap.
4+
//! 2. It is embedded inside bootstrap shims to avoid a dependency on the bootstrap library.
5+
//! Therefore, this module should never use any other bootstrap module. This reduces binary size
6+
//! and improves compilation time by minimizing linking time.
7+
8+
// # Note on tests
9+
//
10+
// If we were to declare a tests submodule here, the shim binaries that include this module via
11+
// `#[path]` would fail to find it, which breaks `./x check bootstrap`. So instead the unit tests
12+
// for this module are in `super::tests::shared_helpers_tests`.
613

714
#![allow(dead_code)]
815

9-
#[cfg(test)]
10-
mod tests;
11-
1216
use std::env;
1317
use std::ffi::OsString;
1418
use std::fs::OpenOptions;
1519
use std::io::Write;
1620
use std::process::Command;
1721
use std::str::FromStr;
1822

19-
// If we were to declare a tests submodule here, the shim binaries that include this
20-
// module via `#[path]` would fail to find it, which breaks `./x check bootstrap`.
21-
// So instead the unit tests for this module are in `super::tests::shared_helpers_tests`.
22-
2323
/// Returns the environment variable which the dynamic library lookup path
2424
/// resides in for this platform.
2525
pub fn dylib_path_var() -> &'static str {

src/bootstrap/src/utils/tests/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ use crate::{Build, Config, Flags, t};
1212

1313
pub mod git;
1414

15+
// Note: tests for `shared_helpers` is separate here, as otherwise shim binaries that include the
16+
// `shared_helpers` via `#[path]` would fail to find it, breaking `./x check bootstrap`.
17+
mod shared_helpers_tests;
18+
1519
/// Holds temporary state of a bootstrap test.
1620
/// Right now it is only used to redirect the build directory of the bootstrap
1721
/// invocation, in the future it would be great if we could actually execute

0 commit comments

Comments
 (0)