Skip to content

Commit fb22420

Browse files
committed
libsyntax: Don't ICE on macro invocation in count expr of fixed array type.
1 parent 7dfa3d1 commit fb22420

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,16 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
626626
} => {
627627
// take it apart:
628628
let Local {
629-
ty: _,
629+
ty: ty,
630630
pat: pat,
631631
init: init,
632632
id: id,
633633
span: span,
634634
source: source,
635635
} = **local;
636+
// expand the ty since TyFixedLengthVec contains an Expr
637+
// and thus may have a macro use
638+
let expanded_ty = fld.fold_ty(ty);
636639
// expand the pat (it might contain macro uses):
637640
let expanded_pat = fld.fold_pat(pat);
638641
// find the PatIdents in the pattern:
@@ -656,7 +659,7 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
656659
let new_init_opt = init.map(|e| fld.fold_expr(e));
657660
let rewritten_local =
658661
box(GC) Local {
659-
ty: local.ty,
662+
ty: expanded_ty,
660663
pat: rewritten_pat,
661664
init: new_init_opt,
662665
id: id,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014 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+
#![feature(macro_rules)]
12+
13+
macro_rules! four (
14+
() => (4)
15+
)
16+
fn main() {
17+
let _x: [u16, ..four!()];
18+
}

0 commit comments

Comments
 (0)