diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-24 12:21:41 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-25 23:46:28 +0200 |
| commit | 96340f67146ff73fb3d308b848d8c7ed62888ca1 (patch) | |
| tree | 0381dc0156c0cd3a17b4a814b90d990296a9ece3 /compiler/rustc_expand/src/base.rs | |
| parent | a955f1cd09a027363729ceed919952d09f76f28e (diff) | |
| download | rust-96340f67146ff73fb3d308b848d8c7ed62888ca1.tar.gz rust-96340f67146ff73fb3d308b848d8c7ed62888ca1.zip | |
Stop compilation if macro expansion failed
Diffstat (limited to 'compiler/rustc_expand/src/base.rs')
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 25ec5401111..44a99aa6ea0 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -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> { @@ -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, } } @@ -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 }); |
