Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
921b6c0
If HOME is empty, use the fallback instead
ChrisDenton May 31, 2025
f75595d
add codegen test for variadics (also replacing some existing does-thi…
RalfJung Jul 23, 2025
732097e
disable cfg.has_reliable_f128 on amdgcn
ZuseZ4 Jul 23, 2025
1de927c
library/windows_targets: Fix macro expansion error in 'link' macro
itf Jul 24, 2025
3d0dedd
Enable outline-atomics for aarch64-unknown-linux-musl
Gelbpunkt Jul 25, 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
57481e7
clif: Don't set the `compiler-builtins-no-f16-f128` feature
tgross35 Jul 25, 2025
2b17897
Revert "coverage: Enlarge empty spans during MIR instrumentation, not…
Zalathar Jul 26, 2025
69ebf70
test using multiple c-variadic ABIs in the same program
folkertdev Jul 23, 2025
85e5100
Rollup merge of #141840 - ChrisDenton:noempty, r=ChrisDenton
jhpratt Jul 27, 2025
e2c2d1a
Rollup merge of #144359 - RalfJung:vararg-codegen, r=compiler-errors
jhpratt Jul 27, 2025
c96c802
Rollup merge of #144379 - folkertdev:c-variadic-same-program-multiple…
jhpratt Jul 27, 2025
2c395c7
Rollup merge of #144383 - ZuseZ4:disable-f128-on-amdgcn, r=oli-obk
jhpratt Jul 27, 2025
c92d61d
Rollup merge of #144409 - GuillaumeGomez:macro-expansion-early-abort,…
jhpratt Jul 27, 2025
d809998
Rollup merge of #144422 - itf:itf-patch-2-1, r=ChrisDenton
jhpratt Jul 27, 2025
aaa37e5
Rollup merge of #144429 - Gelbpunkt:outline-atomics-aarch64-musl, r=A…
jhpratt Jul 27, 2025
ba4a691
Rollup merge of #144430 - Gelbpunkt:aarch64-outline-atomics-target, r…
jhpratt Jul 27, 2025
c5e81ea
Rollup merge of #144445 - jieyouxu:revert-shared_helpers_tests, r=Kobzol
jhpratt Jul 27, 2025
e04daf9
Rollup merge of #144453 - WaffleLapkin:canonical-build-root, r=jieyouxu
jhpratt Jul 27, 2025
2c0a331
Rollup merge of #144464 - Kobzol:x-test-default, r=jieyouxu
jhpratt Jul 27, 2025
d250b5c
Rollup merge of #144470 - tgross35:clif-remove-no-f16-f128, r=bjorn3
jhpratt Jul 27, 2025
8aa3d41
Rollup merge of #144480 - Zalathar:revert-empty-span, r=Zalathar
jhpratt Jul 27, 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
Prev Previous commit
Next Next commit
Stop compilation if macro expansion failed
  • Loading branch information
GuillaumeGomez committed Jul 25, 2025
commit 96340f67146ff73fb3d308b848d8c7ed62888ca1
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