From 0135b521ad38615e9a07aac54d9c22627af57ca4 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sat, 15 Feb 2014 22:10:16 -0800 Subject: [PATCH] syntax: add syntax extension helper to make simple view items --- src/libsyntax/ext/build.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index d311a542ac6..7ac324e5092 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -242,6 +242,9 @@ pub trait AstBuilder { fn view_use(&self, sp: Span, vis: ast::Visibility, vp: ~[@ast::ViewPath]) -> ast::ViewItem; + fn view_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> ast::ViewItem; + fn view_use_simple_(&self, sp: Span, vis: ast::Visibility, + ident: ast::Ident, path: ast::Path) -> ast::ViewItem; fn view_use_list(&self, sp: Span, vis: ast::Visibility, path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::ViewItem; fn view_use_glob(&self, sp: Span, @@ -900,6 +903,20 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } } + fn view_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> ast::ViewItem { + let last = path.segments.last().unwrap().identifier; + self.view_use_simple_(sp, vis, last, path) + } + + fn view_use_simple_(&self, sp: Span, vis: ast::Visibility, + ident: ast::Ident, path: ast::Path) -> ast::ViewItem { + self.view_use(sp, vis, + ~[@respan(sp, + ast::ViewPathSimple(ident, + path, + ast::DUMMY_NODE_ID))]) + } + fn view_use_list(&self, sp: Span, vis: ast::Visibility, path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::ViewItem { let imports = imports.map(|id| {