about summary refs log tree commit diff
path: root/compiler/rustc_expand
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_expand')
-rw-r--r--compiler/rustc_expand/src/base.rs2
-rw-r--r--compiler/rustc_expand/src/proc_macro_server.rs22
2 files changed, 19 insertions, 5 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs
index cfeb31fc4c8..09ab26421d6 100644
--- a/compiler/rustc_expand/src/base.rs
+++ b/compiler/rustc_expand/src/base.rs
@@ -1266,7 +1266,7 @@ pub fn expr_to_spanned_string<'a>(
                 );
                 Some((err, true))
             }
-            Ok(ast::LitKind::Err) => None,
+            Ok(ast::LitKind::Err(_)) => None,
             Err(err) => {
                 report_lit_error(&cx.sess.parse_sess, err, token_lit, expr.span);
                 None
diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs
index 3a78bd94505..8f31b5801da 100644
--- a/compiler/rustc_expand/src/proc_macro_server.rs
+++ b/compiler/rustc_expand/src/proc_macro_server.rs
@@ -10,7 +10,7 @@ use rustc_ast::util::literal::escape_byte_str_symbol;
 use rustc_ast_pretty::pprust;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::sync::Lrc;
-use rustc_errors::{MultiSpan, PResult};
+use rustc_errors::{ErrorGuaranteed, MultiSpan, PResult};
 use rustc_parse::lexer::nfc_normalize;
 use rustc_parse::parse_stream_from_source_str;
 use rustc_session::parse::ParseSess;
@@ -63,7 +63,12 @@ impl FromInternal<token::LitKind> for LitKind {
             token::ByteStrRaw(n) => LitKind::ByteStrRaw(n),
             token::CStr => LitKind::CStr,
             token::CStrRaw(n) => LitKind::CStrRaw(n),
-            token::Err => LitKind::Err,
+            token::Err(_guar) => {
+                // This is the only place a `pm::bridge::LitKind::ErrWithGuar`
+                // is constructed. Note that an `ErrorGuaranteed` is available,
+                // as required. See the comment in `to_internal`.
+                LitKind::ErrWithGuar
+            }
             token::Bool => unreachable!(),
         }
     }
@@ -82,7 +87,16 @@ impl ToInternal<token::LitKind> for LitKind {
             LitKind::ByteStrRaw(n) => token::ByteStrRaw(n),
             LitKind::CStr => token::CStr,
             LitKind::CStrRaw(n) => token::CStrRaw(n),
-            LitKind::Err => token::Err,
+            LitKind::ErrWithGuar => {
+                // This is annoying but valid. `LitKind::ErrWithGuar` would
+                // have an `ErrorGuaranteed` except that type isn't available
+                // in that crate. So we have to fake one. And we don't want to
+                // use a delayed bug because there might be lots of these,
+                // which would be expensive.
+                #[allow(deprecated)]
+                let guar = ErrorGuaranteed::unchecked_error_guaranteed();
+                token::Err(guar)
+            }
         }
     }
 }
@@ -477,7 +491,7 @@ impl server::FreeFunctions for Rustc<'_, '_> {
                 | token::LitKind::ByteStrRaw(_)
                 | token::LitKind::CStr
                 | token::LitKind::CStrRaw(_)
-                | token::LitKind::Err => return Err(()),
+                | token::LitKind::Err(_) => return Err(()),
                 token::LitKind::Integer | token::LitKind::Float => {}
             }