Skip to content

Commit c88ed2a

Browse files
authoredSep 30, 2016
Auto merge of #36819 - jseyfried:fix_ast_const_integer_ice, r=nrc
Fix ICE on some macros in const integer positions (e.g. `[u8; m!()]`) Fixes #36816. r? @nrc
2 parents 7660bdf + 4bec961 commit c88ed2a

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
 

‎src/librustc_resolve/macros.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,13 @@ impl<'a> Resolver<'a> {
172172

173173
let mut def_collector = DefCollector::new(&mut self.definitions);
174174
def_collector.visit_macro_invoc = Some(visit_macro_invoc);
175-
def_collector.with_parent(def_index, |def_collector| if !const_integer {
175+
def_collector.with_parent(def_index, |def_collector| {
176+
if const_integer {
177+
if let Expansion::Expr(ref expr) = *expansion {
178+
def_collector.visit_ast_const_integer(expr);
179+
}
180+
}
176181
expansion.visit_with(def_collector)
177-
} else if let Expansion::Expr(ref expr) = *expansion {
178-
def_collector.visit_ast_const_integer(expr);
179182
});
180183
}
181184
}

‎src/test/run-pass/issue-36816.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2016 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 { () => { 1 } }
12+
macro_rules! n { () => { 1 + m!() } }
13+
14+
fn main() {
15+
let _: [u32; n!()] = [0, 0];
16+
}

0 commit comments

Comments
 (0)