diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2014-02-14 07:07:09 +0200 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2014-02-14 08:43:29 +0200 |
| commit | a02b10a0621adfe36eb3cc2e46f45fc7ccdb7ea2 (patch) | |
| tree | 86fe8ac57360a232b07c4303547194646129561a /src/librustc/front | |
| parent | 22c34f3c4cddea33b916eb92f8d7286b02b865a7 (diff) | |
Refactored ast_map and friends, mainly to have Paths without storing them.
Diffstat (limited to 'src/librustc/front')
| -rw-r--r-- | src/librustc/front/assign_node_ids_and_map.rs | 2 | ||||
| -rw-r--r-- | src/librustc/front/feature_gate.rs | 15 | ||||
| -rw-r--r-- | src/librustc/front/std_inject.rs | 10 | ||||
| -rw-r--r-- | src/librustc/front/test.rs | 7 |
4 files changed, 15 insertions, 19 deletions
diff --git a/src/librustc/front/assign_node_ids_and_map.rs b/src/librustc/front/assign_node_ids_and_map.rs index a6871e513a9..750d09c2d17 100644 --- a/src/librustc/front/assign_node_ids_and_map.rs +++ b/src/librustc/front/assign_node_ids_and_map.rs @@ -25,5 +25,5 @@ impl ast_map::FoldOps for NodeIdAssigner { } pub fn assign_node_ids_and_map(sess: Session, krate: ast::Crate) -> (ast::Crate, ast_map::Map) { - ast_map::map_crate(sess.diagnostic(), krate, NodeIdAssigner { sess: sess }) + ast_map::map_crate(krate, NodeIdAssigner { sess: sess }) } diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index e023003ff9f..52553af53c7 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -99,10 +99,7 @@ impl Context { impl Visitor<()> for Context { fn visit_ident(&mut self, sp: Span, id: ast::Ident, _: ()) { - let string = token::get_ident(id.name); - let s = string.get(); - - if !s.is_ascii() { + if !token::get_ident(id).get().is_ascii() { self.gate_feature("non_ascii_idents", sp, "non-ascii idents are not fully supported."); } @@ -196,29 +193,29 @@ impl Visitor<()> for Context { let msg = " is not stable enough for use and are subject to change"; - if id == self.sess.ident_of("macro_rules") { + if id == token::str_to_ident("macro_rules") { self.gate_feature("macro_rules", path.span, "macro definitions are \ not stable enough for use and are subject to change"); } - else if id == self.sess.ident_of("asm") { + else if id == token::str_to_ident("asm") { self.gate_feature("asm", path.span, "inline assembly is not \ stable enough for use and is subject to change"); } - else if id == self.sess.ident_of("log_syntax") { + else if id == token::str_to_ident("log_syntax") { self.gate_feature("log_syntax", path.span, "`log_syntax!` is not \ stable enough for use and is subject to change"); } - else if id == self.sess.ident_of("trace_macros") { + else if id == token::str_to_ident("trace_macros") { self.gate_feature("trace_macros", path.span, "`trace_macros` is not \ stable enough for use and is subject to change"); } else { for "e in quotes.iter() { - if id == self.sess.ident_of(quote) { + if id == token::str_to_ident(quote) { self.gate_feature("quote", path.span, quote + msg); } } diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index 8171e78151e..f4bc1c19063 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -73,7 +73,7 @@ pub fn with_version(krate: &str) -> Option<(InternedString, ast::StrStyle)> { impl fold::Folder for StandardLibraryInjector { fn fold_crate(&mut self, krate: ast::Crate) -> ast::Crate { let mut vis = ~[ast::ViewItem { - node: ast::ViewItemExternMod(self.sess.ident_of("std"), + node: ast::ViewItemExternMod(token::str_to_ident("std"), with_version("std"), ast::DUMMY_NODE_ID), attrs: ~[ @@ -90,7 +90,7 @@ impl fold::Folder for StandardLibraryInjector { if use_uv(&krate) && !self.sess.building_library.get() { vis.push(ast::ViewItem { - node: ast::ViewItemExternMod(self.sess.ident_of("green"), + node: ast::ViewItemExternMod(token::str_to_ident("green"), with_version("green"), ast::DUMMY_NODE_ID), attrs: ~[], @@ -98,7 +98,7 @@ impl fold::Folder for StandardLibraryInjector { span: DUMMY_SP }); vis.push(ast::ViewItem { - node: ast::ViewItemExternMod(self.sess.ident_of("rustuv"), + node: ast::ViewItemExternMod(token::str_to_ident("rustuv"), with_version("rustuv"), ast::DUMMY_NODE_ID), attrs: ~[], @@ -163,12 +163,12 @@ impl fold::Folder for PreludeInjector { global: false, segments: ~[ ast::PathSegment { - identifier: self.sess.ident_of("std"), + identifier: token::str_to_ident("std"), lifetimes: opt_vec::Empty, types: opt_vec::Empty, }, ast::PathSegment { - identifier: self.sess.ident_of("prelude"), + identifier: token::str_to_ident("prelude"), lifetimes: opt_vec::Empty, types: opt_vec::Empty, }, diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index c28fec12323..819f96a391b 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -289,7 +289,7 @@ mod __test { */ fn mk_std(cx: &TestCtxt) -> ast::ViewItem { - let id_extra = cx.sess.ident_of("extra"); + let id_extra = token::str_to_ident("extra"); let vi = if cx.is_extra { ast::ViewItemUse( ~[@nospan(ast::ViewPathSimple(id_extra, @@ -337,7 +337,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item { attr::mk_attr(attr::mk_word_item(resolve_unexported_str)); let item = ast::Item { - ident: cx.sess.ident_of("__test"), + ident: token::str_to_ident("__test"), attrs: ~[resolve_unexported_attr], id: ast::DUMMY_NODE_ID, node: item_, @@ -345,8 +345,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item { span: DUMMY_SP, }; - debug!("Synthetic test module:\n{}\n", - pprust::item_to_str(&item, cx.sess.intr())); + debug!("Synthetic test module:\n{}\n", pprust::item_to_str(&item)); return @item; } |
