mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
syntax: add syntax extension helper to make simple view items
This commit is contained in:
parent
bb8721da69
commit
0135b521ad
@ -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| {
|
||||
|
Loading…
Reference in New Issue
Block a user