Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Update to rust HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Mar 20, 2015
1 parent c142c8e commit ba6b45a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "quasi"
version = "0.1.6"
version = "0.1.7"
authors = ["Erick Tryzelaar <[email protected]>"]
license = "MIT/Apache-2.0"
description = "A quasi-quoting macro system"
repository = "https://github.com/erickt/rust-quasi"

[dev-dependencies]
quasi_macros = "*"
[dev-dependencies.quasi_macros]
path = "quasi_macros"
version = "0.1.7"
2 changes: 1 addition & 1 deletion quasi_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quasi_macros"
version = "0.1.6"
version = "0.1.7"
authors = ["Erick Tryzelaar <[email protected]>"]
license = "MIT/Apache-2.0"
description = "A quasi-quoting macro system"
Expand Down
24 changes: 3 additions & 21 deletions quasi_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ pub fn expand_quote_stmt(cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree])
-> Box<base::MacResult+'static> {
let builder = aster::AstBuilder::new().span(sp);

let e_attrs = builder.expr().call()
.path().global().ids(&["std", "vec", "Vec", "new"]).build()
.build();

let expanded = expand_parse_call(cx, sp, "parse_stmt",
vec!(e_attrs), tts);

let expanded = expand_parse_call(cx, sp, "parse_stmt", vec!(), tts);
base::MacEager::expr(expanded)
}

Expand Down Expand Up @@ -97,20 +89,11 @@ pub fn expand_quote_block<'cx>(cx: &'cx mut ExtCtxt,
base::MacEager::expr(expanded)
}

pub fn expand_quote_method(cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree])
-> Box<base::MacResult+'static> {
let expanded = expand_parse_call(cx, sp, "parse_method_with_outer_attributes",
vec!(), tts);
base::MacEager::expr(expanded)
}

pub fn expand_quote_item<'cx>(cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree])
-> Box<base::MacResult+'cx> {
let expanded = expand_parse_call(cx, sp, "parse_item_with_outer_attributes",
let expanded = expand_parse_call(cx, sp, "parse_item",
vec!(), tts);
base::MacEager::expr(expanded)
}
Expand All @@ -119,7 +102,7 @@ pub fn expand_quote_impl_item<'cx>(cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree])
-> Box<base::MacResult+'cx> {
let expanded = expand_parse_call(cx, sp, "parse_impl_item_with_outer_attributes",
let expanded = expand_parse_call(cx, sp, "parse_impl_item",
vec!(), tts);
base::MacEager::expr(expanded)
}
Expand Down Expand Up @@ -558,7 +541,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("quote_pat", expand_quote_pat);
reg.register_macro("quote_arm", expand_quote_arm);
reg.register_macro("quote_block", expand_quote_block);
reg.register_macro("quote_method", expand_quote_method);
reg.register_macro("quote_item", expand_quote_item);
reg.register_macro("quote_impl_item", expand_quote_impl_item);
//reg.register_macro("quote_where_clause", expand_quote_where_clause);
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,7 @@ impl<'a> ExtParseUtils for ExtCtxt<'a> {
parse::parse_stmt_from_source_str("<quote expansion>".to_string(),
s,
self.cfg(),
Vec::new(),
self.parse_sess())
self.parse_sess()).expect("parse error")
}

fn parse_expr(&self, s: String) -> P<ast::Expr> {
Expand Down
2 changes: 1 addition & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn test_quote_stmt() {
let sess = parse::new_parse_sess();
let cx = make_ext_ctxt(&sess);

let stmt = quote_stmt!(&cx, let x = 20;);
let stmt = quote_stmt!(&cx, let x = 20;).unwrap();
assert_eq!(pprust::stmt_to_string(&stmt), "let x = 20;");
}

Expand Down

0 comments on commit ba6b45a

Please sign in to comment.