about summary refs log tree commit diff
path: root/compiler/rustc_expand/src/expand.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-04-03 18:46:25 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-04-03 19:42:09 +0300
commitcd22425990462d55dbd01a432dfd2aa517d5ca9c (patch)
tree46f2fa75fef5f91ca8c43fc96baad37879f9be34 /compiler/rustc_expand/src/expand.rs
parent97717a561844eccbb6d6cc114adb94a8fa4e0172 (diff)
downloadrust-cd22425990462d55dbd01a432dfd2aa517d5ca9c.tar.gz
rust-cd22425990462d55dbd01a432dfd2aa517d5ca9c.zip
expand: Do not ICE when a legacy AST-based macro attribute produces and empty expression
Diffstat (limited to 'compiler/rustc_expand/src/expand.rs')
-rw-r--r--compiler/rustc_expand/src/expand.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs
index 470788a972a..42332adcbab 100644
--- a/compiler/rustc_expand/src/expand.rs
+++ b/compiler/rustc_expand/src/expand.rs
@@ -735,7 +735,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
                                     });
                                 }
                             };
-                            fragment_kind.expect_from_annotatables(items)
+                            if fragment_kind == AstFragmentKind::Expr && items.is_empty() {
+                                let msg =
+                                    "removing an expression is not supported in this position";
+                                self.cx.span_err(span, msg);
+                                fragment_kind.dummy(span)
+                            } else {
+                                fragment_kind.expect_from_annotatables(items)
+                            }
                         }
                         Err(mut err) => {
                             err.emit();