Skip to content

ICE when initializing an array in macro expansion #23232

Closed
@gkoz

Description

@gkoz
trait Foo { fn foo(&self); }

macro_rules! foo {
    () => ();
    ($a:expr, $($n:expr,)*) => (
        impl Foo for [(); $a] {
            fn foo(&self) {
                // Okay
                let baz: [i32; $a] = [$($n),*];
                // ICE
                let bar = [$($n),*];
            }
        }
        foo!($($n,)*);
    )
}

foo!(3, 2, 1, 0,);

fn main() {}
<anon>:11:27: 11:36 error: internal compiler error: cat_expr Errd
<anon>:11                 let bar = [$($n),*];
                                    ^~~~~~~~~
rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-09)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions