Currently Syntex is a public dependency because the argument to serde_codegen::register
is &mut syntex::Registry
:
// build.rs
pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let src = Path::new("src/main.rs.in");
let dst = Path::new(&out_dir).join("main.rs");
let mut registry = syntex::Registry::new();
serde_codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap();
}
Let's see if we can do something more similar to this instead:
// build.rs
pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let src = Path::new("src/main.rs.in");
let dst = Path::new(&out_dir).join("main.rs");
// no more public Syntex dependency
serde_codegen::expand(&src, &dst).unwrap();
}
The downside would be if someone wants to apply more than one compiler plugin, their code is parsed multiple times:
serde_codegen::expand(&src, &tmp1).unwrap();
other_plugin::expand(&tmp1, &tmp2).unwrap();
third_plugin::expand(&tmp2, &dst).unwrap();
This seems like a worthwhile compromise to me. I'm betting that the number of projects that use more than one compiler plugin on stable is pretty small. (My main project actually does, but it's nightly-only, so this wouldn't affect me.)
The new serde_codegen::expand
is in, but I am leaving this open until we either remove serde_codegen::register
in a breaking release or decide to keep it.
As I mentioned in in the other thread, I'm all for getting rid of serde_codegen::register
.
Most helpful comment
As I mentioned in in the other thread, I'm all for getting rid of
serde_codegen::register
.