Use syn instead of literalext ()

This commit is contained in:
Malthe Borch 2019-05-18 03:44:43 +00:00 committed by Chris Wong
parent ee74c3ec49
commit e302ba57e0
2 changed files with 8 additions and 6 deletions
maud_macros

View file

@ -11,7 +11,7 @@ description = "Compile-time HTML templates."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
literalext = { version = "0.1", default-features = false, features = ["proc-macro"] } syn = "0.15.34"
matches = "0.1.6" matches = "0.1.6"
maud_htmlescape = { version = "0.17.0", path = "../maud_htmlescape" } maud_htmlescape = { version = "0.17.0", path = "../maud_htmlescape" }

View file

@ -10,7 +10,7 @@ use proc_macro::{
use std::collections::HashMap; use std::collections::HashMap;
use std::mem; use std::mem;
use literalext::LiteralExt; use syn::{LitStr, parse_str};
use crate::ast; use crate::ast;
use crate::ParseResult; use crate::ParseResult;
@ -191,10 +191,12 @@ impl Parser {
/// Parses and renders a literal string. /// Parses and renders a literal string.
fn literal(&mut self, lit: &Literal) -> ParseResult<ast::Markup> { fn literal(&mut self, lit: &Literal) -> ParseResult<ast::Markup> {
let content = lit.parse_string().unwrap_or_else(|| { let content = parse_str::<LitStr>(&lit.to_string())
lit.span().error("expected string").emit(); .map(|l| l.value())
String::new() // Insert a dummy value .unwrap_or_else(|_| {
}); lit.span().error("expected string").emit();
String::new() // Insert a dummy value
});
Ok(ast::Markup::Literal { Ok(ast::Markup::Literal {
content, content,
span: lit.span(), span: lit.span(),