summaryrefslogtreecommitdiff
path: root/src/macro_rules/parse.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-12-28 08:37:09 +0800
committerJohn Hodge <tpg@mutabah.net>2018-12-28 08:37:09 +0800
commit38575976d5835cb8cc9e7ae335969873d01e7d65 (patch)
tree769a861d29ee3470a42fb7cb829944c9255e031d /src/macro_rules/parse.cpp
parenta0bdedaaed4393236877c45bb56692fe05732a56 (diff)
downloadmrust-38575976d5835cb8cc9e7ae335969873d01e7d65.tar.gz
macro_rules - Support for the :vis fragment
Diffstat (limited to 'src/macro_rules/parse.cpp')
-rw-r--r--src/macro_rules/parse.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/macro_rules/parse.cpp b/src/macro_rules/parse.cpp
index 00cf7cf7..e6d9d7ae 100644
--- a/src/macro_rules/parse.cpp
+++ b/src/macro_rules/parse.cpp
@@ -82,6 +82,8 @@ public:
ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_BLOCK) );
else if( type == "item" )
ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_ITEM) );
+ else if( /*TARGETVER_1_29 && */ type == "vis" ) // TODO: Should this be selective?
+ ret.push_back( MacroPatEnt(name, idx, MacroPatEnt::PAT_VIS) );
else
ERROR(lex.point_span(), E0000, "Unknown fragment type '" << type << "'");
break; }
@@ -428,6 +430,19 @@ bool patterns_are_same(const Span& sp, const MacroPatEnt& left, const MacroPatEn
default:
ERROR(sp, E0000, "Incompatible macro fragments " << right << " used with " << left);
}
+ // Matches visibility specifiers
+ case MacroPatEnt::PAT_VIS:
+ switch(left.type)
+ {
+ case MacroPatEnt::PAT_TOKEN:
+ if( is_token_vis(left.tok.type()) )
+ ERROR(sp, E0000, "Incompatible macro fragments");
+ return false;
+ case MacroPatEnt::PAT_VIS:
+ return true;
+ default:
+ ERROR(sp, E0000, "Incompatible macro fragments " << right << " used with " << left);
+ }
}
throw "";
}