diff --git a/maud/src/lib.rs b/maud/src/lib.rs index be2b3b2..f884d71 100644 --- a/maud/src/lib.rs +++ b/maud/src/lib.rs @@ -79,16 +79,6 @@ pub mod rt { Markup { callback: f } } - /// rustc is a butt and doesn't let us quote macro invocations - /// directly. So we factor the `write!` call into a separate - /// function and use that instead. - /// - /// See <https://github.com/rust-lang/rust/issues/16617> - #[inline] - pub fn write_fmt<T: fmt::Display>(w: &mut fmt::Write, value: &T) -> fmt::Result { - write!(w, "{}", *value) - } - pub struct Escaper<'a, 'b: 'a> { pub inner: &'a mut (fmt::Write + 'b), } diff --git a/maud_macros/src/render.rs b/maud_macros/src/render.rs index 7d10eb5..5294ed9 100644 --- a/maud_macros/src/render.rs +++ b/maud_macros/src/render.rs @@ -59,6 +59,7 @@ impl<'cx> Renderer<'cx> { let Renderer { cx, w, stmts, .. } = { self.flush(); self }; quote_expr!(cx, ::maud::rt::make_markup(|$w: &mut ::std::fmt::Write| -> Result<(), ::std::fmt::Error> { + use ::std::fmt::Write; $stmts Ok(()) })) @@ -96,12 +97,13 @@ impl<'cx> Renderer<'cx> { let w = self.w; let expr = match escape { Escape::PassThru => - quote_expr!(self.cx, ::maud::rt::write_fmt($w, &$expr)), + quote_expr!(self.cx, write!($w, "{}", $expr)), Escape::Escape => quote_expr!(self.cx, - ::maud::rt::write_fmt( - &mut ::maud::rt::Escaper { inner: $w }, - &$expr)), + write!( + ::maud::rt::Escaper { inner: $w }, + "{}", + $expr)), }; let stmt = self.cx.stmt_expr(self.cx.expr_try(expr.span, expr)); self.push(stmt); diff --git a/maud_macros/tests/tests.rs b/maud_macros/tests/tests.rs index e501089..3c7b1fa 100644 --- a/maud_macros/tests/tests.rs +++ b/maud_macros/tests/tests.rs @@ -165,16 +165,12 @@ mod splices { assert_eq!(s, "Name: Pinkie Pie. Rating: 1"); } - // FIXME: See <https://github.com/rust-lang/rust/issues/16617> - // for why this is commented out - /* #[test] fn nested_macro_invocation() { let best_pony = "Pinkie Pie"; let s = html! { $(format!("{}", best_pony)) }.to_string(); assert_eq!(s, "Pinkie Pie"); } - */ } #[test]