Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #912

Merged
merged 1 commit into from
Feb 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/macro/src/html_tree/html_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub struct HtmlBlock {
}

enum BlockContent {
Node(HtmlNode),
Iterable(HtmlIterable),
Node(Box<HtmlNode>),
Iterable(Box<HtmlIterable>),
}

impl PeekValue<()> for HtmlBlock {
Expand All @@ -29,9 +29,9 @@ impl Parse for HtmlBlock {
let content;
let brace = braced!(content in input);
let content = if HtmlIterable::peek(content.cursor()).is_some() {
BlockContent::Iterable(content.parse()?)
BlockContent::Iterable(Box::new(content.parse()?))
} else {
BlockContent::Node(content.parse()?)
BlockContent::Node(Box::new(content.parse()?))
};

Ok(HtmlBlock { brace, content })
Expand Down
25 changes: 14 additions & 11 deletions crates/macro/src/html_tree/html_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ impl ToTokens for HtmlComponent {
children,
} = self;

let validate_props = if let Props::List(ListProps { props, .. }) = props {
let check_props = props.iter().map(|HtmlProp { label, .. }| {
let validate_props = if let Props::List(list_props) = props {
let check_props = list_props.props.iter().map(|HtmlProp { label, .. }| {
quote! { props.#label; }
});

Expand Down Expand Up @@ -121,8 +121,8 @@ impl ToTokens for HtmlComponent {
};

let init_props = match props {
Props::List(ListProps { props, .. }) => {
let set_props = props.iter().map(|HtmlProp { label, value }| {
Props::List(list_props) => {
let set_props = list_props.props.iter().map(|HtmlProp { label, value }| {
quote_spanned! { value.span()=> .#label(
<::yew::virtual_dom::vcomp::VComp as ::yew::virtual_dom::Transformer<_, _>>::transform(
#value
Expand All @@ -137,7 +137,10 @@ impl ToTokens for HtmlComponent {
.build()
}
}
Props::With(WithProps { props, .. }) => quote! { #props },
Props::With(with_props) => {
let props = &with_props.props;
quote! { #props }
}
Props::None => quote! {
<<#ty as ::yew::html::Component>::Properties as ::yew::html::Properties>::builder()
#set_children
Expand Down Expand Up @@ -343,16 +346,16 @@ enum PropType {
}

enum Props {
List(ListProps),
With(WithProps),
List(Box<ListProps>),
With(Box<WithProps>),
None,
}

impl Props {
fn node_ref(&self) -> Option<&Expr> {
match self {
Props::List(ListProps { node_ref, .. }) => node_ref.as_ref(),
Props::With(WithProps { node_ref, .. }) => node_ref.as_ref(),
Props::List(list_props) => list_props.node_ref.as_ref(),
Props::With(with_props) => with_props.node_ref.as_ref(),
Props::None => None,
}
}
Expand All @@ -374,8 +377,8 @@ impl PeekValue<PropType> for Props {
impl Parse for Props {
fn parse(input: ParseStream) -> ParseResult<Self> {
match Props::peek(input.cursor()) {
Some(PropType::List) => input.parse().map(Props::List),
Some(PropType::With) => input.parse().map(Props::With),
Some(PropType::List) => input.parse().map(|l| Props::List(Box::new(l))),
Some(PropType::With) => input.parse().map(|w| Props::With(Box::new(w))),
None => Ok(Props::None),
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/macro/src/html_tree/html_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ impl Parse for HtmlNode {
Lit::Str(_) | Lit::Char(_) | Lit::Int(_) | Lit::Float(_) | Lit::Bool(_) => {}
_ => return Err(syn::Error::new(lit.span(), "unsupported type")),
}
Node::Literal(lit)
Node::Literal(Box::new(lit))
} else {
Node::Expression(input.parse()?)
Node::Expression(Box::new(input.parse()?))
};

Ok(HtmlNode(node))
Expand Down Expand Up @@ -56,6 +56,6 @@ impl ToTokens for Node {
}

enum Node {
Literal(Lit),
Expression(Expr),
Literal(Box<Lit>),
Expression(Box<Expr>),
}
4 changes: 2 additions & 2 deletions crates/macro/src/html_tree/html_tag/tag_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct TagAttributes {

pub enum ClassesForm {
Tuple(Vec<Expr>),
Single(Expr),
Single(Box<Expr>),
}

lazy_static! {
Expand Down Expand Up @@ -146,7 +146,7 @@ impl TagAttributes {
fn map_classes(class_expr: Expr) -> ClassesForm {
match class_expr {
Expr::Tuple(ExprTuple { elems, .. }) => ClassesForm::Tuple(elems.into_iter().collect()),
expr => ClassesForm::Single(expr),
expr => ClassesForm::Single(Box::new(expr)),
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions crates/macro/src/html_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ pub enum HtmlType {
}

pub enum HtmlTree {
Block(HtmlBlock),
Component(HtmlComponent),
Iterable(HtmlIterable),
List(HtmlList),
Tag(HtmlTag),
Node(HtmlNode),
Block(Box<HtmlBlock>),
Component(Box<HtmlComponent>),
Iterable(Box<HtmlIterable>),
List(Box<HtmlList>),
Tag(Box<HtmlTag>),
Node(Box<HtmlNode>),
Empty,
}

Expand All @@ -46,9 +46,9 @@ impl Parse for HtmlRoot {
let html_root = if HtmlTree::peek(input.cursor()).is_some() {
HtmlRoot(input.parse()?)
} else if HtmlIterable::peek(input.cursor()).is_some() {
HtmlRoot(HtmlTree::Iterable(input.parse()?))
HtmlRoot(HtmlTree::Iterable(Box::new(input.parse()?)))
} else {
HtmlRoot(HtmlTree::Node(input.parse()?))
HtmlRoot(HtmlTree::Node(Box::new(input.parse()?)))
};

if !input.is_empty() {
Expand Down Expand Up @@ -76,10 +76,10 @@ impl Parse for HtmlTree {
.ok_or_else(|| input.error("expected valid html element"))?;
let html_tree = match html_type {
HtmlType::Empty => HtmlTree::Empty,
HtmlType::Component => HtmlTree::Component(input.parse()?),
HtmlType::Tag => HtmlTree::Tag(input.parse()?),
HtmlType::Block => HtmlTree::Block(input.parse()?),
HtmlType::List => HtmlTree::List(input.parse()?),
HtmlType::Component => HtmlTree::Component(Box::new(input.parse()?)),
HtmlType::Tag => HtmlTree::Tag(Box::new(input.parse()?)),
HtmlType::Block => HtmlTree::Block(Box::new(input.parse()?)),
HtmlType::List => HtmlTree::List(Box::new(input.parse()?)),
};
Ok(html_tree)
}
Expand Down
1 change: 0 additions & 1 deletion examples/dashboard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use serde_derive::{Deserialize, Serialize};
use yew::format::{Json, Nothing, Toml};
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask};
use yew::services::Task;
use yew::{html, Component, ComponentLink, Html, ShouldRender};

type AsBinary = bool;
Expand Down