Use absolute paths in generated code

Closes 
This commit is contained in:
Chris Wong 2019-03-28 20:18:12 +13:00
parent eb4ef2f969
commit b86ba7af85
3 changed files with 15 additions and 2 deletions
maud/tests
maud_macros/src

View file

@ -0,0 +1,13 @@
#![feature(proc_macro_hygiene)]
// Make sure `std` is available but the prelude isn't
#![no_std]
extern crate std;
use maud::html;
#[test]
fn issue_170() {
let number = 42;
let _ = html! { (number) };
}

View file

@ -84,7 +84,7 @@ impl Generator {
quote!({ quote!({
// Create a local trait alias so that autoref works // Create a local trait alias so that autoref works
trait Render: maud::Render { trait Render: maud::Render {
fn __maud_render_to(&self, output_ident: &mut String) { fn __maud_render_to(&self, output_ident: &mut ::std::string::String) {
maud::Render::render_to(self, output_ident); maud::Render::render_to(self, output_ident);
} }
} }

View file

@ -46,7 +46,7 @@ fn expand(input: TokenStream) -> TokenStream {
let stmts = generate::generate(markups, output_ident.clone()); let stmts = generate::generate(markups, output_ident.clone());
quote!({ quote!({
extern crate maud; extern crate maud;
let mut $output_ident = String::with_capacity($size_hint); let mut $output_ident = ::std::string::String::with_capacity($size_hint);
$stmts $stmts
maud::PreEscaped($output_ident) maud::PreEscaped($output_ident)
}) })