From e18d328951b6b9216976d180f3dea2e6600a3982 Mon Sep 17 00:00:00 2001 From: Bodil Stokke <17880+bodil@users.noreply.github.com> Date: Thu, 27 Jan 2022 19:34:04 +0000 Subject: [PATCH] Bump all the deps and appease Clippy, 2022 edition. --- examples/dodrio/todomvc/Cargo.toml | 2 +- examples/dodrio/todomvc/src/lib.rs | 1 + macros/Cargo.toml | 4 +-- macros/src/declare.rs | 4 +-- macros/src/html.rs | 13 ++++----- macros/src/lexer.rs | 5 +--- typed-html/Cargo.toml | 8 +++--- typed-html/src/types/mod.rs | 46 +++++++++++++++--------------- ui/Cargo.toml | 2 +- 9 files changed, 40 insertions(+), 45 deletions(-) diff --git a/examples/dodrio/todomvc/Cargo.toml b/examples/dodrio/todomvc/Cargo.toml index d2b0685..eae203a 100644 --- a/examples/dodrio/todomvc/Cargo.toml +++ b/examples/dodrio/todomvc/Cargo.toml @@ -5,7 +5,7 @@ name = "dodrio-todomvc" version = "0.1.0" [dependencies] -cfg-if = "0.1.7" +cfg-if = "1" dodrio = "0.2.0" futures = "0.3" js-sys = "0.3.15" diff --git a/examples/dodrio/todomvc/src/lib.rs b/examples/dodrio/todomvc/src/lib.rs index 124fa75..13485d4 100755 --- a/examples/dodrio/todomvc/src/lib.rs +++ b/examples/dodrio/todomvc/src/lib.rs @@ -2,6 +2,7 @@ #![recursion_limit = "1024"] #![deny(missing_docs)] +#![allow(unused_braces)] pub mod controller; pub mod keys; diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 91cfd7e..806cb98 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -16,13 +16,13 @@ keywords = ["jsx", "html", "wasm"] proc-macro = true [dependencies] -lalrpop-util = "0.18" +lalrpop-util = "0.19" ansi_term = "0.12.0" proc-macro2 = { version = "1.0.4", features = ["nightly"] } quote = "1.0.2" [build-dependencies] -lalrpop = "0.18" +lalrpop = "0.19" version_check = "0.9.1" [features] diff --git a/macros/src/declare.rs b/macros/src/declare.rs index 9d900f1..819b039 100644 --- a/macros/src/declare.rs +++ b/macros/src/declare.rs @@ -35,7 +35,7 @@ impl Declare { fn attr_type_name(&self) -> TokenTree { Ident::new( - &format!("Attrs_{}", self.name.to_string()), + &format!("Attrs_{}", self.name), self.name.span(), ) .into() @@ -53,7 +53,7 @@ impl Declare { fn req_children(&self) -> impl Iterator + '_ { self.req_children.iter().map(|child| { let child_name: TokenTree = - Ident::new(&format!("child_{}", child.to_string()), child.span()).into(); + Ident::new(&format!("child_{}", child), child.span()).into(); let child_type: TokenTree = Ident::new(&child.to_string(), child.span()).into(); let child_str = Literal::string(&child.to_string()).into(); (child_name, child_type, child_str) diff --git a/macros/src/html.rs b/macros/src/html.rs index 85fd4f9..eefa817 100644 --- a/macros/src/html.rs +++ b/macros/src/html.rs @@ -100,10 +100,9 @@ fn extract_data_attrs(attrs: &mut StringyMap) -> StringyMap = attrs.keys().cloned().collect(); for key in keys { let key_name = key.to_string(); - let prefix = "data_"; - if key_name.starts_with(prefix) { + if let Some(key_name) = key_name.strip_prefix("data_") { let value = attrs.remove(&key).unwrap(); - data.insert(key_name[prefix.len()..].to_string(), value); + data.insert(key_name.to_string(), value); } } data @@ -116,9 +115,7 @@ fn extract_event_handlers( let keys: Vec = attrs.keys().cloned().collect(); for key in keys { let key_name = key.to_string(); - let prefix = "on"; - if key_name.starts_with(prefix) { - let event_name = &key_name[prefix.len()..]; + if let Some(event_name) = key_name.strip_prefix("on") { let value = attrs.remove(&key).unwrap(); events.insert(ident::new_raw(event_name, key.span()), value); } @@ -148,8 +145,8 @@ fn is_string_literal(literal: &Literal) -> bool { #[allow(dead_code)] fn stringify_ident(ident: &Ident) -> String { let s = ident.to_string(); - if s.starts_with("r#") { - s[2..].to_string() + if let Some(raw_s) = s.strip_prefix("r#") { + raw_s.to_string() } else { s } diff --git a/macros/src/lexer.rs b/macros/src/lexer.rs index 82342c2..4a2a412 100644 --- a/macros/src/lexer.rs +++ b/macros/src/lexer.rs @@ -30,10 +30,7 @@ impl Token { } pub fn is_ident(&self) -> bool { - match self { - Token::Ident(_) => true, - _ => false, - } + matches!(self, Token::Ident(_)) } } diff --git a/typed-html/Cargo.toml b/typed-html/Cargo.toml index 22a613f..15ecd06 100644 --- a/typed-html/Cargo.toml +++ b/typed-html/Cargo.toml @@ -19,11 +19,11 @@ maintenance = { status = "looking-for-maintainer" } all-features = true [dependencies] -typed-html-macros = "0.2.2" -strum = "0.18" -strum_macros = "0.18" +typed-html-macros = { path = "../macros" } +strum = "0.23" +strum_macros = "0.23" mime = "0.3.13" -language-tags = "0.2.2" +language-tags = "0.3" htmlescape = "0.3.1" proc-macro-nested = "0.1.3" stdweb = { version = "0.4.14", optional = true } diff --git a/typed-html/src/types/mod.rs b/typed-html/src/types/mod.rs index 6ef069d..0fb5881 100644 --- a/typed-html/src/types/mod.rs +++ b/typed-html/src/types/mod.rs @@ -28,7 +28,7 @@ pub type Integrity = String; pub type Nonce = String; pub type Target = String; -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum AreaShape { #[strum(to_string = "rect")] Rectangle, @@ -40,7 +40,7 @@ pub enum AreaShape { Default, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum BoolOrDefault { #[strum(to_string = "true")] True, @@ -50,7 +50,7 @@ pub enum BoolOrDefault { False, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum ButtonType { #[strum(to_string = "submit")] Submit, @@ -60,7 +60,7 @@ pub enum ButtonType { Button, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum Bool { #[strum(to_string = "true")] True, @@ -78,7 +78,7 @@ impl From for Bool { } } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum CrossOrigin { #[strum(to_string = "anonymous")] Anonymous, @@ -86,7 +86,7 @@ pub enum CrossOrigin { UseCredentials, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum FormEncodingType { #[strum(to_string = "application/x-www-form-urlencoded")] UrlEncoded, @@ -96,7 +96,7 @@ pub enum FormEncodingType { Text, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum FormMethod { #[strum(to_string = "post")] Post, @@ -104,7 +104,7 @@ pub enum FormMethod { Get, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum FormDialogMethod { #[strum(to_string = "post")] Post, @@ -114,7 +114,7 @@ pub enum FormDialogMethod { Dialog, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum HTTPEquiv { #[strum(to_string = "content-security-policy")] ContentSecurityPolicy, @@ -122,7 +122,7 @@ pub enum HTTPEquiv { Refresh, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum ImageDecoding { #[strum(to_string = "sync")] Sync, @@ -132,7 +132,7 @@ pub enum ImageDecoding { Auto, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum InputType { #[strum(to_string = "button")] Button, @@ -180,7 +180,7 @@ pub enum InputType { Week, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum LinkType { #[strum(to_string = "alternate")] Alternate, @@ -228,7 +228,7 @@ pub enum LinkType { Tag, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum Metadata { #[strum(to_string = "application-name")] ApplicationName, @@ -254,7 +254,7 @@ pub enum Metadata { Viewport, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum OnOff { #[strum(to_string = "on")] On, @@ -262,7 +262,7 @@ pub enum OnOff { Off, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum OrderedListType { #[strum(to_string = "a")] LowerCaseLetters, @@ -276,7 +276,7 @@ pub enum OrderedListType { Numbers, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum Preload { #[strum(to_string = "none")] None, @@ -286,7 +286,7 @@ pub enum Preload { Auto, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum ReferrerPolicy { #[strum(to_string = "no-referrer")] NoReferrer, @@ -300,7 +300,7 @@ pub enum ReferrerPolicy { UnsafeUrl, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum Role { #[strum(to_string = "any")] Any, @@ -440,7 +440,7 @@ pub enum Role { TreeGrid, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum Sandbox { #[strum(to_string = "allow-forms")] AllowForms, @@ -466,7 +466,7 @@ pub enum Sandbox { AllowTopNavigationByUserNavigation, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum TableHeaderScope { #[strum(to_string = "row")] Row, @@ -480,7 +480,7 @@ pub enum TableHeaderScope { Auto, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum TextDirection { #[strum(to_string = "ltr")] LeftToRight, @@ -488,7 +488,7 @@ pub enum TextDirection { RightToLeft, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum VideoKind { #[strum(to_string = "subtitles")] Subtitles, @@ -502,7 +502,7 @@ pub enum VideoKind { Metadata, } -#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] pub enum Wrap { #[strum(to_string = "hard")] Hard, diff --git a/ui/Cargo.toml b/ui/Cargo.toml index 886c8e2..84eb5c8 100644 --- a/ui/Cargo.toml +++ b/ui/Cargo.toml @@ -10,7 +10,7 @@ name = "typed-html-tests" path = "main.rs" [dev-dependencies] -compiletest_rs = { version = "0.5", features = ["stable"] } +compiletest_rs = { version = "0.7", features = ["stable"] } typed-html = { path = "../typed-html" } typed-html-macros = { path = "../macros" } version_check = "0.9.1"