Skip to content

Commit 29a052d

Browse files
committed
Fix ICE with nested macros in certain situations.
1 parent 49c67bd commit 29a052d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/libsyntax/ext/placeholders.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> {
106106
impl<'a, 'b> Folder for PlaceholderExpander<'a, 'b> {
107107
fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> {
108108
match item.node {
109-
ast::ItemKind::Mac(ref mac) if !mac.node.path.segments.is_empty() => {}
110109
ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(),
110+
ast::ItemKind::MacroDef(_) => return SmallVector::one(item),
111111
_ => {}
112112
}
113113

src/test/run-pass/issue-40770.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
macro_rules! m {
12+
($e:expr) => {
13+
macro_rules! n { () => { $e } }
14+
}
15+
}
16+
17+
fn main() {
18+
m!(foo!());
19+
}

0 commit comments

Comments
 (0)