Skip to content

Cannot use ty followed by >> on macro #25274

Closed
@thelink2012

Description

@thelink2012

Using ty followed by >> doesn't work in a macro but it does works when followed by > > instead. This seems very like one of the old C++03 template issues.

Using >>: http://is.gd/KTICUL

macro_rules! test {
    (
        fn fun() -> Option<Box<$t:ty>>;
    ) => {
        fn fun(x: $t) -> Option<Box<$t>>
        { Some(Box::new(x)) }
    }
}

test! {
    fn fun() -> Option<Box<i32>>;
}

fn main() {
    fun(0).unwrap();
}

Gives

<anon>:4:32: 4:37 error: `$t:ty` is followed by `>>`, which is not allowed for `ty` fragments
<anon>:4         fn fun() -> Option<Box<$t:ty>>;
                                        ^~~~~

Using > > instead of >> fixes it: http://is.gd/gSD3MR

Meta

All the tests were conducted on the playpen using the nightly and beta option (no difference) so I'm not sure about the version but the issue also happens on my local installation rustc 1.0.0-beta.3 (5241bf9c3 2015-04-25) (built 2015-04-25) (yep a bit outdated but cba to update eh).

Metadata

Metadata

Assignees

Labels

A-grammarArea: The grammar of RustA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions