From 29aaaba49585696616b9ebd8e6ab9a841303b061 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Fri, 10 Jun 2016 23:34:30 -0700 Subject: [PATCH] Add quasi_codegen::expand and remove the public dependency on syntex This helps to avoid the issue of incompatible syntex types being passed between crates. --- CHANGELOG.md | 8 ++++++++ quasi_codegen/src/lib.rs | 18 +++++++++++++++++- quasi_tests/build.rs | 5 +---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 860b9d86..4a6d8e95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.12.0 + +BACKWARDS INCOMPATIBILITIES / NOTES: + +* Replaced `quasi_codegen::register`'s public dependency on `syntex` with + `quasi_codegen::expand`. +* Update to rustc 1.11.0-nightly (7d2f75a95 2016-06-09). + ## 0.11.0 BACKWARDS INCOMPATIBILITIES / NOTES: diff --git a/quasi_codegen/src/lib.rs b/quasi_codegen/src/lib.rs index 19cb2a5d..748ddcd8 100644 --- a/quasi_codegen/src/lib.rs +++ b/quasi_codegen/src/lib.rs @@ -26,6 +26,12 @@ extern crate syntax; #[cfg(not(feature = "with-syntex"))] extern crate rustc_plugin; +#[cfg(feature = "with-syntex")] +use std::io; + +#[cfg(feature = "with-syntex")] +use std::path::Path; + use syntax::ast; use syntax::codemap::{Span, respan}; use syntax::ext::base::ExtCtxt; @@ -806,7 +812,17 @@ fn expand_parse_call(cx: &ExtCtxt, } #[cfg(feature = "with-syntex")] -pub fn register(reg: &mut syntex::Registry) { +pub fn expand(src: S, dst: D) -> io::Result<()> + where S: AsRef, + D: AsRef, +{ + let mut registry = syntex::Registry::new(); + register(&mut registry); + registry.expand("", src.as_ref(), dst.as_ref()) +} + +#[cfg(feature = "with-syntex")] +fn register(reg: &mut syntex::Registry) { reg.add_macro("quote_tokens", expand_quote_tokens); reg.add_macro("quote_ty", expand_quote_ty); reg.add_macro("quote_expr", expand_quote_expr); diff --git a/quasi_tests/build.rs b/quasi_tests/build.rs index 702fad5d..145dd11d 100644 --- a/quasi_tests/build.rs +++ b/quasi_tests/build.rs @@ -1,4 +1,3 @@ -extern crate syntex; extern crate quasi_codegen; use std::env; @@ -6,11 +5,9 @@ use std::path::Path; pub fn main() { let out_dir = env::var_os("OUT_DIR").unwrap(); - let mut registry = syntex::Registry::new(); - quasi_codegen::register(&mut registry); let src = Path::new("tests/test.rs.in"); let dst = Path::new(&out_dir).join("test.rs"); - registry.expand("", &src, &dst).unwrap(); + quasi_codegen::expand(&src, &dst).unwrap(); }