From c1b751a40d328b96d4be86e48cd5620ad17e52b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Sun, 24 Jan 2021 09:00:31 +0300 Subject: [PATCH] rustc_expand: Avoid ICE when creating AST with invalid Id if the error was already reported Fixes #81321 --- compiler/rustc_expand/src/proc_macro_server.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index b6195d3bbc4a6..022ae370b7872 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -333,7 +333,8 @@ impl Ident { panic!("`{:?}` is not a valid identifier", string) } if is_raw && !sym.can_be_raw() { - panic!("`{}` cannot be a raw identifier", string); + sess.span_diagnostic + .delay_span_bug(span, &format!("`{}` cannot be a raw identifier", string)); } sess.symbol_gallery.insert(sym, span); Ident { sym, is_raw, span }