mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-20 10:55:14 +00:00
parent
9d5ec04d18
commit
f907d9772c
@ -358,9 +358,8 @@ pub fn expand_quote_item(cx: &mut ExtCtxt,
|
|||||||
sp: Span,
|
sp: Span,
|
||||||
tts: &[ast::TokenTree])
|
tts: &[ast::TokenTree])
|
||||||
-> Box<base::MacResult> {
|
-> Box<base::MacResult> {
|
||||||
let e_attrs = cx.expr_vec_ng(sp);
|
let expanded = expand_parse_call(cx, sp, "parse_item_with_outer_attributes",
|
||||||
let expanded = expand_parse_call(cx, sp, "parse_item",
|
vec!(), tts);
|
||||||
vec!(e_attrs), tts);
|
|
||||||
base::MacExpr::new(expanded)
|
base::MacExpr::new(expanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
|
|||||||
let mut ret = SmallVector::zero();
|
let mut ret = SmallVector::zero();
|
||||||
loop {
|
loop {
|
||||||
let mut parser = self.parser.borrow_mut();
|
let mut parser = self.parser.borrow_mut();
|
||||||
let attrs = parser.parse_outer_attributes();
|
match parser.parse_item_with_outer_attributes() {
|
||||||
match parser.parse_item(attrs) {
|
|
||||||
Some(item) => ret.push(item),
|
Some(item) => ret.push(item),
|
||||||
None => break
|
None => break
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,7 @@ pub fn parse_item_from_source_str(name: String,
|
|||||||
sess: &ParseSess)
|
sess: &ParseSess)
|
||||||
-> Option<Gc<ast::Item>> {
|
-> Option<Gc<ast::Item>> {
|
||||||
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
||||||
let attrs = p.parse_outer_attributes();
|
maybe_aborted(p.parse_item_with_outer_attributes(),p)
|
||||||
maybe_aborted(p.parse_item(attrs),p)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_meta_from_source_str(name: String,
|
pub fn parse_meta_from_source_str(name: String,
|
||||||
|
@ -4965,6 +4965,11 @@ impl<'a> Parser<'a> {
|
|||||||
return IoviNone(attrs);
|
return IoviNone(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parse_item_with_outer_attributes(&mut self) -> Option<Gc<Item>> {
|
||||||
|
let attrs = self.parse_outer_attributes();
|
||||||
|
self.parse_item(attrs)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_item(&mut self, attrs: Vec<Attribute> ) -> Option<Gc<Item>> {
|
pub fn parse_item(&mut self, attrs: Vec<Attribute> ) -> Option<Gc<Item>> {
|
||||||
match self.parse_item_or_view_item(attrs, true) {
|
match self.parse_item_or_view_item(attrs, true) {
|
||||||
IoviNone(_) => None,
|
IoviNone(_) => None,
|
||||||
|
@ -28,6 +28,9 @@ fn syntax_extension(cx: &ExtCtxt) {
|
|||||||
let _f: @syntax::ast::Expr = quote_expr!(cx, ());
|
let _f: @syntax::ast::Expr = quote_expr!(cx, ());
|
||||||
let _g: @syntax::ast::Expr = quote_expr!(cx, true);
|
let _g: @syntax::ast::Expr = quote_expr!(cx, true);
|
||||||
let _h: @syntax::ast::Expr = quote_expr!(cx, 'a');
|
let _h: @syntax::ast::Expr = quote_expr!(cx, 'a');
|
||||||
|
|
||||||
|
let i: Option<@syntax::ast::Item> = quote_item!(cx, #[deriving(Eq)] struct Foo; );
|
||||||
|
assert!(i.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user