Skip to content

confusing error message with concat_idents!() use in type position #33709

Closed
@heycam

Description

@heycam

I tried to use concat_idents! to construct the name of a type in a macro. I discovered this wasn't possible, but the error message for it doesn't seem right.

cam@zoo /tmp $ cat m.rs
#![feature(concat_idents)]
#![feature(type_macros)]
pub enum YZ { }
macro_rules! test {
    ($x:ident, $y:ident) => (
        pub struct $x {
            pub ptr: *mut concat_idents!($y, Z),
        }
    )
}
test!(X, Y);
cam@zoo /tmp $ multirust run nightly rustc m.rs
m.rs:7:27: 7:40 error: non-expression macro in expression position: concat_idents
m.rs:7             pub ptr: *mut concat_idents!($y, Z),
                                 ^~~~~~~~~~~~~
error: aborting due to previous error
cam@zoo /tmp $ multirust run nightly rustc --version
rustc 1.10.0-nightly (cd6a40017 2016-05-16)

Maybe the "non-expression" and "expression" need to be swapped around?

CC @nrc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions