Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptt-macro doesn't work #5846
Comments
This comment has been minimized.
This comment has been minimized.
|
Actually, I'm really not sure this should work. I'm nominating this for well-defined. |
This comment has been minimized.
This comment has been minimized.
|
Actually... this definitely shouldn't work in our current system. The basic issue is that a lonely sigil is not a complete "thing". The "tt" macro option is only intended for macros that expand into macro invocations. There are a number of ways around this; at the most basic level, you can insist that the user provide the sigil and the thing it's attached to. This works, but it may be unsatisfying if you want the sigil to be attached to names that are introduced by the macro. In this case, you have a couple of choices.
Anyhow, I would say that as of right now, at least, this is not a bug. I'm going to leave this as nominated mostly because this came up in Vancouver as something that Graydon and I both expected to work. |
This comment has been minimized.
This comment has been minimized.
|
Visiting for triage: still doesn't work, nothing more to add. |
This comment has been minimized.
This comment has been minimized.
|
accepted for well-defined milestone |
This comment has been minimized.
This comment has been minimized.
|
You can work around this by using a dummy macro so that you can pass the #[feature(macro_rules)];
macro_rules! item { ($i: item) => { $i } }
macro_rules! foo (
($x:tt) => { item!(type t = $x int;) }
)
foo!(~)
fn main() {} |
huonw
referenced this issue
Jan 31, 2014
Closed
Add a macro non-terminal for the interior of a block #11928
This comment has been minimized.
This comment has been minimized.
|
reading this workaround makes me feel like our macro system is really broken :(. |
This comment has been minimized.
This comment has been minimized.
|
/cc @kmcallister |
kmcallister
added
A-macros
and removed
A-syntaxext
labels
Feb 23, 2015
This comment has been minimized.
This comment has been minimized.
|
The modernized example macro_rules! foo {
($x:tt) => (type t = $x<int>;)
}
foo!(Box);gives me
which looks like #22819. |
This was referenced Oct 27, 2015
This comment has been minimized.
This comment has been minimized.
|
#16036 notes that another hacky work-around is a nested macro invocation, which avoids needing to define/export dummy macros (although one will want to be careful about giving that internal macro a fairly unique name to avoid trampling on any other macros in scope, unfortunately macro_rules! foo {
($x:tt) => (
macro_rules! internal {
() => { type t = $x<i8>; }
}
internal!();
)
}
foo!(Box); |
sorear
added a commit
to sorear/libuv-rs
that referenced
this issue
Oct 27, 2015
brson
added
P-low
and removed
P-medium
labels
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Updated example: macro_rules! foo {
($x:tt) => (type t = $x<i32>;)
}
foo!(Box);error:
|
brson
added
T-lang
I-nominated
labels
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Triage: This is an ancient P-low bug but per @sanxiyn it actually comes up in the wild a lot - macro writers have to know how to do this workaround. Can this be escalated? Is there a solution somebody could mentor? |
This comment has been minimized.
This comment has been minimized.
|
Discussed at lang meeting, we believe this should remain p-low since we don't know a very easy fix. It should be fixed by converting macro_rules to expand to pure tokens then parsing, rather than mixing the two steps (which we hop would be back-compat). cc @jseyfried |
nrc
removed
the
I-nominated
label
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Fixed in #34908. |
jbclements commentedApr 12, 2013
I haven't finished investigating this, so I'm making an issue just so I don't forget it: