Add support for macro expansion inside trait items
This commit is contained in:
@@ -227,6 +227,11 @@ pub trait MacResult {
|
||||
None
|
||||
}
|
||||
|
||||
/// Create zero or more trait items.
|
||||
fn make_trait_items(self: Box<Self>) -> Option<SmallVector<ast::TraitItem>> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Create a pattern.
|
||||
fn make_pat(self: Box<Self>) -> Option<P<ast::Pat>> {
|
||||
None
|
||||
@@ -274,6 +279,7 @@ make_MacEager! {
|
||||
pat: P<ast::Pat>,
|
||||
items: SmallVector<P<ast::Item>>,
|
||||
impl_items: SmallVector<ast::ImplItem>,
|
||||
trait_items: SmallVector<ast::TraitItem>,
|
||||
stmts: SmallVector<ast::Stmt>,
|
||||
ty: P<ast::Ty>,
|
||||
}
|
||||
@@ -291,6 +297,10 @@ impl MacResult for MacEager {
|
||||
self.impl_items
|
||||
}
|
||||
|
||||
fn make_trait_items(self: Box<Self>) -> Option<SmallVector<ast::TraitItem>> {
|
||||
self.trait_items
|
||||
}
|
||||
|
||||
fn make_stmts(self: Box<Self>) -> Option<SmallVector<ast::Stmt>> {
|
||||
match self.stmts.as_ref().map_or(0, |s| s.len()) {
|
||||
0 => make_stmts_default!(self),
|
||||
@@ -399,6 +409,14 @@ impl MacResult for DummyResult {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_trait_items(self: Box<DummyResult>) -> Option<SmallVector<ast::TraitItem>> {
|
||||
if self.expr_only {
|
||||
None
|
||||
} else {
|
||||
Some(SmallVector::zero())
|
||||
}
|
||||
}
|
||||
|
||||
fn make_stmts(self: Box<DummyResult>) -> Option<SmallVector<ast::Stmt>> {
|
||||
Some(SmallVector::one(
|
||||
codemap::respan(self.span,
|
||||
|
||||
Reference in New Issue
Block a user