diff options
| author | Luqman Aden <me@luqman.ca> | 2014-07-19 00:06:43 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-07-29 15:43:12 -0700 |
| commit | 445340771d8ead72709bbbaffc0b576389985264 (patch) | |
| tree | 1a4aa403c073f0df59e955fbac82452a4a49ec8b | |
| parent | 779d100541e06bf7ffb9021728f8e4790d838213 (diff) | |
| download | rust-445340771d8ead72709bbbaffc0b576389985264.tar.gz rust-445340771d8ead72709bbbaffc0b576389985264.zip | |
libsyntax: Don't ICE on macro invocation in count expr of fixed array type.
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs | 18 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index f82796b480a..a51a79b6d58 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -536,13 +536,16 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander) } => { // take it apart: let Local { - ty: _, + ty: ty, pat: pat, init: init, id: id, span: span, source: source, } = **local; + // expand the ty since TyFixedLengthVec contains an Expr + // and thus may have a macro use + let expanded_ty = fld.fold_ty(ty); // expand the pat (it might contain macro uses): let expanded_pat = fld.fold_pat(pat); // find the PatIdents in the pattern: @@ -566,7 +569,7 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander) let new_init_opt = init.map(|e| fld.fold_expr(e)); let rewritten_local = box(GC) Local { - ty: local.ty, + ty: expanded_ty, pat: rewritten_pat, init: new_init_opt, id: id, diff --git a/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs b/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs new file mode 100644 index 00000000000..847024d42ba --- /dev/null +++ b/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(macro_rules)] + +macro_rules! four ( + () => (4) +) +fn main() { + let _x: [u16, ..four!()]; +} |
