From 8d13b2a046d35e657c7e497cfeda6b2165dc931f Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Thu, 27 Oct 2022 21:39:57 +0200 Subject: [PATCH] Store `ErrorGuaranteed` in `ErrorReported` --- compiler/rustc_expand/src/mbe/macro_parser.rs | 7 ++++--- compiler/rustc_expand/src/mbe/macro_rules.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index c8bdc39311c6..aa7a06f66d72 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -72,6 +72,7 @@ pub(crate) use NamedMatch::*; pub(crate) use ParseResult::*; +use rustc_errors::ErrorGuaranteed; use crate::mbe::{KleeneOp, TokenTree}; @@ -270,7 +271,7 @@ pub(crate) enum ParseResult { Failure(Token, &'static str), /// Fatal error (malformed macro?). Abort compilation. Error(rustc_span::Span, String), - ErrorReported, + ErrorReported(ErrorGuaranteed), } /// A `ParseResult` where the `Success` variant contains a mapping of @@ -612,14 +613,14 @@ impl TtParser { // edition-specific matching behavior for non-terminals. let nt = match parser.to_mut().parse_nonterminal(kind) { Err(mut err) => { - err.span_label( + let guarantee = err.span_label( span, format!( "while parsing argument for this `{kind}` macro fragment" ), ) .emit(); - return ErrorReported; + return ErrorReported(guarantee); } Ok(nt) => nt, }; diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index f6fe38174f7c..3ddea80c8444 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -333,7 +333,7 @@ fn expand_macro<'cx>( cx.struct_span_err(span, &msg).emit(); return DummyResult::any(span); } - ErrorReported => return DummyResult::any(sp), + ErrorReported(_) => return DummyResult::any(sp), } // The matcher was not `Success(..)`ful. @@ -470,7 +470,7 @@ pub fn compile_declarative_macro( .emit(); return dummy_syn_ext(); } - ErrorReported => { + ErrorReported(_) => { return dummy_syn_ext(); } };