diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-04-18 22:53:50 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-04-24 20:59:44 +0300 |
| commit | b32d7b592306a2784585e842193db1546a2f9587 (patch) | |
| tree | 4d12769084adfda5aad64a7cb699155f9ee751cc /src/libsyntax/ext | |
| parent | 923001ebb7980ec425e6df561575bccaf5f90240 (diff) | |
| download | rust-b32d7b592306a2784585e842193db1546a2f9587.tar.gz rust-b32d7b592306a2784585e842193db1546a2f9587.zip | |
syntax: Merge keywords and remaining special idents in one list
Simplify the macro used for generation of keywords Make `Keyword::ident` private
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 12 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index c234ea3afeb..b589eacb46d 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -13,9 +13,7 @@ use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind}; use attr; use codemap::{Span, respan, Spanned, DUMMY_SP, Pos}; use ext::base::ExtCtxt; -use parse::token::{keywords, special_idents}; -use parse::token::InternedString; -use parse::token; +use parse::token::{self, keywords, InternedString}; use ptr::P; // Transitional reexports so qquote can find the paths it is looking for @@ -602,7 +600,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_path(self.path_ident(span, id)) } fn expr_self(&self, span: Span) -> P<ast::Expr> { - self.expr_ident(span, keywords::SelfValue.ident) + self.expr_ident(span, keywords::SelfValue.ident()) } fn expr_binary(&self, sp: Span, op: ast::BinOpKind, @@ -1132,7 +1130,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { vis: ast::Visibility, vp: P<ast::ViewPath>) -> P<ast::Item> { P(ast::Item { id: ast::DUMMY_NODE_ID, - ident: special_idents::Invalid, + ident: keywords::Invalid.ident(), attrs: vec![], node: ast::ItemKind::Use(vp), vis: vis, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 3fe4913b5bb..dd6e9a1e4a6 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -25,7 +25,7 @@ use fold; use fold::*; use util::move_map::MoveMap; use parse; -use parse::token::{fresh_mark, fresh_name, intern}; +use parse::token::{fresh_mark, fresh_name, intern, keywords}; use ptr::P; use util::small_vector::SmallVector; use visit; @@ -380,7 +380,7 @@ pub fn expand_item_mac(it: P<ast::Item>, Some(rc) => match *rc { NormalTT(ref expander, tt_span, allow_internal_unstable) => { - if ident.name != parse::token::special_idents::Invalid.name { + if ident.name != keywords::Invalid.name() { fld.cx .span_err(path_span, &format!("macro {}! expects no ident argument, given '{}'", @@ -401,7 +401,7 @@ pub fn expand_item_mac(it: P<ast::Item>, expander.expand(fld.cx, span, &marked_before[..]) } IdentTT(ref expander, tt_span, allow_internal_unstable) => { - if ident.name == parse::token::special_idents::Invalid.name { + if ident.name == keywords::Invalid.name() { fld.cx.span_err(path_span, &format!("macro {}! expects an ident argument", extname)); @@ -420,7 +420,7 @@ pub fn expand_item_mac(it: P<ast::Item>, expander.expand(fld.cx, span, ident, marked_tts) } MacroRulesTT => { - if ident.name == parse::token::special_idents::Invalid.name { + if ident.name == keywords::Invalid.name() { fld.cx.span_err(path_span, "macro_rules! expects an ident argument"); return SmallVector::zero(); } @@ -893,7 +893,7 @@ fn expand_annotatable(a: Annotatable, } ast::ItemKind::Mod(_) | ast::ItemKind::ForeignMod(_) => { let valid_ident = - it.ident.name != parse::token::special_idents::Invalid.name; + it.ident.name != keywords::Invalid.name(); if valid_ident { fld.cx.mod_push(it.ident); @@ -1807,7 +1807,7 @@ mod tests { // run one of the renaming tests fn run_renaming_test(t: &RenamingTest, test_idx: usize) { - let invalid_name = token::special_idents::Invalid.name; + let invalid_name = keywords::Invalid.name(); let (teststr, bound_connections, bound_ident_check) = match *t { (ref str,ref conns, bic) => (str.to_string(), conns.clone(), bic) }; |
