From 3ef933647ab6adf841d8323a712101f37851eff9 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 7 Dec 2013 13:41:11 +1100 Subject: syntax: print expansion info from #[attribute] macros in the correct format. Previously, any attempt to use this information from inside something like #[deriving(Foo)] would result in it printing like `deriving(Foo)!`. --- src/libsyntax/codemap.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/codemap.rs') diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index f7590e7b4ed..f4cb19bfa24 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -161,8 +161,22 @@ pub struct LocWithOpt { // used to be structural records. Better names, anyone? pub struct FileMapAndLine {fm: @FileMap, line: uint} pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos} + #[deriving(IterBytes)] -pub struct NameAndSpan {name: @str, span: Option} +pub enum MacroFormat { + // e.g. #[deriving(...)] + MacroAttribute, + // e.g. `format!()` + MacroBang +} + +#[deriving(IterBytes)] +pub struct NameAndSpan { + name: @str, + // the format with which the macro was invoked. + format: MacroFormat, + span: Option +} /// Extra information for tracking macro expansion of spans #[deriving(IterBytes)] -- cgit 1.4.1-3-g733a5