Skip to content

Commit 0135b52

Browse files
committed
syntax: add syntax extension helper to make simple view items
1 parent bb8721d commit 0135b52

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libsyntax/ext/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ pub trait AstBuilder {
242242

243243
fn view_use(&self, sp: Span,
244244
vis: ast::Visibility, vp: ~[@ast::ViewPath]) -> ast::ViewItem;
245+
fn view_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> ast::ViewItem;
246+
fn view_use_simple_(&self, sp: Span, vis: ast::Visibility,
247+
ident: ast::Ident, path: ast::Path) -> ast::ViewItem;
245248
fn view_use_list(&self, sp: Span, vis: ast::Visibility,
246249
path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::ViewItem;
247250
fn view_use_glob(&self, sp: Span,
@@ -900,6 +903,20 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
900903
}
901904
}
902905

906+
fn view_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> ast::ViewItem {
907+
let last = path.segments.last().unwrap().identifier;
908+
self.view_use_simple_(sp, vis, last, path)
909+
}
910+
911+
fn view_use_simple_(&self, sp: Span, vis: ast::Visibility,
912+
ident: ast::Ident, path: ast::Path) -> ast::ViewItem {
913+
self.view_use(sp, vis,
914+
~[@respan(sp,
915+
ast::ViewPathSimple(ident,
916+
path,
917+
ast::DUMMY_NODE_ID))])
918+
}
919+
903920
fn view_use_list(&self, sp: Span, vis: ast::Visibility,
904921
path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::ViewItem {
905922
let imports = imports.map(|id| {

0 commit comments

Comments
 (0)