Fix cargo clippy lints
This commit is contained in:
parent
7d16af9a06
commit
7b06af4369
3 changed files with 15 additions and 19 deletions
maud_macros/src
|
@ -48,10 +48,10 @@ impl Generator {
|
|||
}
|
||||
},
|
||||
Markup::Literal { content, .. } => build.push_escaped(&content),
|
||||
Markup::Symbol { symbol } => self.name(symbol.into(), build),
|
||||
Markup::Splice { expr, .. } => build.push_tokens(self.splice(expr.into())),
|
||||
Markup::Element { name, attrs, body } => self.element(name.into(), attrs, body, build),
|
||||
Markup::Let { tokens, .. } => build.push_tokens(tokens.into()),
|
||||
Markup::Symbol { symbol } => self.name(symbol, build),
|
||||
Markup::Splice { expr, .. } => build.push_tokens(self.splice(expr)),
|
||||
Markup::Element { name, attrs, body } => self.element(name, attrs, body, build),
|
||||
Markup::Let { tokens, .. } => build.push_tokens(tokens),
|
||||
Markup::Special { segments } => {
|
||||
for segment in segments {
|
||||
build.push_tokens(self.special(segment));
|
||||
|
@ -65,7 +65,6 @@ impl Generator {
|
|||
.collect();
|
||||
let mut body = TokenTree::Group(Group::new(Delimiter::Brace, body));
|
||||
body.set_span(arms_span.collapse());
|
||||
let head: TokenStream = head.into();
|
||||
quote!(#head #body)
|
||||
});
|
||||
},
|
||||
|
@ -123,21 +122,21 @@ impl Generator {
|
|||
match attr_type {
|
||||
AttrType::Normal { value } => {
|
||||
build.push_str(" ");
|
||||
self.name(name.into(), build);
|
||||
self.name(name, build);
|
||||
build.push_str("=\"");
|
||||
self.markup(value, build);
|
||||
build.push_str("\"");
|
||||
},
|
||||
AttrType::Empty { toggler: None } => {
|
||||
build.push_str(" ");
|
||||
self.name(name.into(), build);
|
||||
self.name(name, build);
|
||||
},
|
||||
AttrType::Empty { toggler: Some(toggler) } => {
|
||||
let head = desugar_toggler(toggler);
|
||||
build.push_tokens({
|
||||
let mut build = self.builder();
|
||||
build.push_str(" ");
|
||||
self.name(name.into(), &mut build);
|
||||
self.name(name, &mut build);
|
||||
let body = build.finish();
|
||||
quote!(#head { #body })
|
||||
})
|
||||
|
@ -148,13 +147,11 @@ impl Generator {
|
|||
|
||||
fn special(&self, Special { head, body, .. }: Special) -> TokenStream {
|
||||
let body = self.block(body);
|
||||
let head: TokenStream = head.into();
|
||||
quote!(#head #body)
|
||||
}
|
||||
|
||||
fn match_arm(&self, MatchArm { head, body }: MatchArm) -> TokenStream {
|
||||
let body = self.block(body);
|
||||
let head: TokenStream = head.into();
|
||||
quote!(#head #body)
|
||||
}
|
||||
}
|
||||
|
@ -204,11 +201,11 @@ fn desugar_classes_or_ids(
|
|||
};
|
||||
let head = desugar_toggler(toggler);
|
||||
markups.push(Markup::Special {
|
||||
segments: vec![Special { at_span: SpanRange::call_site(), head: head.into(), body }],
|
||||
segments: vec![Special { at_span: SpanRange::call_site(), head, body }],
|
||||
});
|
||||
}
|
||||
Some(Attribute {
|
||||
name: TokenStream::from(TokenTree::Ident(Ident::new(attr_name, Span::call_site()))).into(),
|
||||
name: TokenStream::from(TokenTree::Ident(Ident::new(attr_name, Span::call_site()))),
|
||||
attr_type: AttrType::Normal {
|
||||
value: Markup::Block(Block {
|
||||
markups,
|
||||
|
@ -231,8 +228,7 @@ fn prepend_leading_space(name: Markup, leading_space: &mut bool) -> Vec<Markup>
|
|||
markups
|
||||
}
|
||||
|
||||
fn desugar_toggler(Toggler { cond, cond_span }: Toggler) -> TokenStream {
|
||||
let mut cond = TokenStream::from(cond);
|
||||
fn desugar_toggler(Toggler { mut cond, cond_span }: Toggler) -> TokenStream {
|
||||
// If the expression contains an opening brace `{`,
|
||||
// wrap it in parentheses to avoid parse errors
|
||||
if cond.clone().into_iter().any(is_braced_block) {
|
||||
|
|
|
@ -36,7 +36,7 @@ fn expand(input: TokenStream) -> TokenStream {
|
|||
// Heuristic: the size of the resulting markup tends to correlate with the
|
||||
// code size of the template itself
|
||||
let size_hint = input.to_string().len();
|
||||
let markups = parse::parse(input.into());
|
||||
let markups = parse::parse(input);
|
||||
let stmts = generate::generate(markups, output_ident.clone());
|
||||
quote!({
|
||||
extern crate maud;
|
||||
|
|
|
@ -86,7 +86,7 @@ impl Parser {
|
|||
Some((
|
||||
TokenTree::Punct(ref punct),
|
||||
Some(TokenTree::Ident(ref ident)),
|
||||
)) if punct.as_char() == '@' && ident.to_string() == "let" => {
|
||||
)) if punct.as_char() == '@' && *ident == "let" => {
|
||||
self.advance2();
|
||||
let keyword = TokenTree::Ident(ident.clone());
|
||||
result.push(self.let_expr(punct.span(), keyword));
|
||||
|
@ -234,13 +234,13 @@ impl Parser {
|
|||
Some((
|
||||
TokenTree::Punct(ref punct),
|
||||
Some(TokenTree::Ident(ref else_keyword)),
|
||||
)) if punct.as_char() == '@' && else_keyword.to_string() == "else" => {
|
||||
)) if punct.as_char() == '@' && *else_keyword == "else" => {
|
||||
self.advance2();
|
||||
let at_span = punct.span();
|
||||
let else_keyword = TokenTree::Ident(else_keyword.clone());
|
||||
match self.peek() {
|
||||
// `@else if`
|
||||
Some(TokenTree::Ident(ref if_keyword)) if if_keyword.to_string() == "if" => {
|
||||
Some(TokenTree::Ident(ref if_keyword)) if *if_keyword == "if" => {
|
||||
self.advance();
|
||||
let if_keyword = TokenTree::Ident(if_keyword.clone());
|
||||
self.if_expr(at_span, vec![else_keyword, if_keyword], segments)
|
||||
|
@ -300,7 +300,7 @@ impl Parser {
|
|||
let mut head = vec![keyword];
|
||||
loop {
|
||||
match self.next() {
|
||||
Some(TokenTree::Ident(ref in_keyword)) if in_keyword.to_string() == "in" => {
|
||||
Some(TokenTree::Ident(ref in_keyword)) if *in_keyword == "in" => {
|
||||
head.push(TokenTree::Ident(in_keyword.clone()));
|
||||
break;
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue