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