From dbb4ba8738913051565902fbe5734c0a92b6bd57 Mon Sep 17 00:00:00 2001 From: Bodil Stokke Date: Fri, 15 Mar 2019 23:06:20 +0000 Subject: [PATCH] 2018 edition. --- .gitignore | 2 +- examples/rocket/Cargo.toml | 1 + examples/stdweb/Cargo.toml | 1 + macros/Cargo.toml | 1 + macros/src/config.rs | 2 +- macros/src/declare.rs | 32 ++++++++++++++++---------------- macros/src/error.rs | 2 +- macros/src/grammar.lalrpop | 12 ++++++------ macros/src/html.rs | 12 ++++++------ macros/src/lexer.rs | 2 +- typed-html/Cargo.toml | 1 + typed-html/src/dom.rs | 4 ++-- typed-html/src/elements.rs | 6 +++--- typed-html/src/events.rs | 2 +- typed-html/src/lib.rs | 12 ------------ typed-html/src/output/stdweb.rs | 6 +++--- typed-html/src/types/mod.rs | 2 ++ ui/Cargo.toml | 1 + 18 files changed, 48 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index 6936990..4308d82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -/target +target/ **/*.rs.bk Cargo.lock diff --git a/examples/rocket/Cargo.toml b/examples/rocket/Cargo.toml index 55438e3..1e83183 100644 --- a/examples/rocket/Cargo.toml +++ b/examples/rocket/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "typed-html-rocket-test" version = "0.1.0" +edition = "2018" authors = ["Bodil Stokke "] [dependencies] diff --git a/examples/stdweb/Cargo.toml b/examples/stdweb/Cargo.toml index 3a4bf9e..57a9843 100644 --- a/examples/stdweb/Cargo.toml +++ b/examples/stdweb/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "typed-html-stdweb-test" version = "0.1.0" +edition = "2018" authors = ["Bodil Stokke "] [dependencies] diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 18b68a4..e81e109 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "typed-html-macros" version = "0.1.1" +edition = "2018" authors = ["Bodil Stokke "] build = "build.rs" license = "MPL-2.0+" diff --git a/macros/src/config.rs b/macros/src/config.rs index aee38b4..15b8876 100644 --- a/macros/src/config.rs +++ b/macros/src/config.rs @@ -1,6 +1,6 @@ use proc_macro2::{Ident, Span, TokenStream}; -use map::StringyMap; +use crate::map::StringyMap; pub fn required_children(element: &str) -> &[&str] { match element { diff --git a/macros/src/declare.rs b/macros/src/declare.rs index fd3efd9..ab15fb9 100644 --- a/macros/src/declare.rs +++ b/macros/src/declare.rs @@ -1,12 +1,12 @@ use proc_macro2::{Ident, Literal, TokenStream, TokenTree}; use quote::quote; -use config::{global_attrs, SELF_CLOSING}; -use error::ParseError; -use ident; -use lexer::{Lexer, Token}; -use map::StringyMap; -use parser; +use crate::config::{global_attrs, SELF_CLOSING}; +use crate::error::ParseError; +use crate::ident; +use crate::lexer::{Lexer, Token}; +use crate::map::StringyMap; +use crate::parser; // State @@ -103,7 +103,7 @@ impl Declare { } quote!( - pub struct #elem_name where T: ::OutputType { + pub struct #elem_name where T: crate::OutputType { pub attrs: #attr_type_name, pub data_attributes: Vec<(&'static str, String)>, pub events: T::Events, @@ -140,7 +140,7 @@ impl Declare { } quote!( - impl #elem_name where T: ::OutputType { + impl #elem_name where T: crate::OutputType { pub fn new(#args) -> Self { #elem_name { events: T::Events::default(), @@ -184,7 +184,7 @@ impl Declare { #req_children #opt_children - ::dom::VNode::Element(::dom::VElement { + crate::dom::VNode::Element(crate::dom::VElement { name: #elem_name, attributes, events: &mut self.events, @@ -197,8 +197,8 @@ impl Declare { let elem_name = self.elem_name(); let vnode = self.impl_vnode(); quote!( - impl ::dom::Node for #elem_name where T: ::OutputType { - fn vnode(&'_ mut self) -> ::dom::VNode<'_, T> { + impl crate::dom::Node for #elem_name where T: crate::OutputType { + fn vnode(&'_ mut self) -> crate::dom::VNode<'_, T> { #vnode } } @@ -225,7 +225,7 @@ impl Declare { } quote!( - impl ::dom::Element for #elem_name where T: ::OutputType { + impl crate::dom::Element for #elem_name where T: crate::OutputType { fn name() -> &'static str { #name } @@ -256,7 +256,7 @@ impl Declare { for t in &self.traits { let name = t.clone(); body.extend(quote!( - impl #name for #elem_name where T: ::OutputType {} + impl #name for #elem_name where T: crate::OutputType {} )); } body @@ -265,7 +265,7 @@ impl Declare { fn impl_into_iter(&self) -> TokenStream { let elem_name = self.elem_name(); quote!( - impl IntoIterator for #elem_name where T: ::OutputType { + impl IntoIterator for #elem_name where T: crate::OutputType { type Item = #elem_name; type IntoIter = std::vec::IntoIter<#elem_name>; fn into_iter(self) -> Self::IntoIter { @@ -273,7 +273,7 @@ impl Declare { } } - impl IntoIterator for Box<#elem_name> where T: ::OutputType { + impl IntoIterator for Box<#elem_name> where T: crate::OutputType { type Item = Box<#elem_name>; type IntoIter = std::vec::IntoIter>>; fn into_iter(self) -> Self::IntoIter { @@ -346,7 +346,7 @@ impl Declare { quote!( impl std::fmt::Display for #elem_name where - T: ::OutputType, + T: crate::OutputType, { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { write!(f, "<{}", #name)?; diff --git a/macros/src/error.rs b/macros/src/error.rs index 4cf5321..e4a1df5 100644 --- a/macros/src/error.rs +++ b/macros/src/error.rs @@ -1,6 +1,6 @@ use ansi_term::Style; use lalrpop_util::ParseError::*; -use lexer::Token; +use crate::lexer::Token; use proc_macro2::{Ident, TokenStream}; use quote::{quote, quote_spanned}; diff --git a/macros/src/grammar.lalrpop b/macros/src/grammar.lalrpop index 99c5da7..f339325 100644 --- a/macros/src/grammar.lalrpop +++ b/macros/src/grammar.lalrpop @@ -1,11 +1,11 @@ -use lexer::{self, Token, to_stream}; -use error::HtmlParseError; -use html::{Node, Element}; -use declare::Declare; -use map::StringyMap; +use crate::lexer::{self, Token, to_stream}; +use crate::error::HtmlParseError; +use crate::html::{Node, Element}; +use crate::declare::Declare; +use crate::map::StringyMap; use proc_macro2::{Delimiter, Ident, Literal, Group, TokenTree}; use lalrpop_util::ParseError; -use span; +use crate::span; grammar; diff --git a/macros/src/html.rs b/macros/src/html.rs index bb69c81..684116d 100644 --- a/macros/src/html.rs +++ b/macros/src/html.rs @@ -1,12 +1,12 @@ use proc_macro2::{Delimiter, Group, Ident, Literal, Span, TokenStream, TokenTree}; use quote::{quote, quote_spanned}; -use config::required_children; -use error::ParseError; -use ident; -use lexer::{to_stream, Lexer, Token}; -use map::StringyMap; -use parser::grammar; +use crate::config::required_children; +use crate::error::ParseError; +use crate::ident; +use crate::lexer::{to_stream, Lexer, Token}; +use crate::map::StringyMap; +use crate::parser::grammar; use std::iter::FromIterator; diff --git a/macros/src/lexer.rs b/macros/src/lexer.rs index 8df09de..82342c2 100644 --- a/macros/src/lexer.rs +++ b/macros/src/lexer.rs @@ -1,4 +1,4 @@ -use error::HtmlParseError; +use crate::error::HtmlParseError; use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Span, TokenStream, TokenTree}; use std::iter::FromIterator; diff --git a/typed-html/Cargo.toml b/typed-html/Cargo.toml index 2567541..bbecfef 100644 --- a/typed-html/Cargo.toml +++ b/typed-html/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "typed-html" version = "0.1.1" +edition = "2018" authors = ["Bodil Stokke "] license = "MPL-2.0+" description = "Type checked JSX for Rust" diff --git a/typed-html/src/dom.rs b/typed-html/src/dom.rs index b6bf9a4..8ada76f 100644 --- a/typed-html/src/dom.rs +++ b/typed-html/src/dom.rs @@ -3,8 +3,8 @@ use std::fmt::Display; use std::marker::PhantomData; -use super::OutputType; -use elements::{FlowContent, PhrasingContent}; +use crate::OutputType; +use crate::elements::{FlowContent, PhrasingContent}; use htmlescape::encode_minimal; /// A boxed DOM tree, as returned from the `html!` macro. diff --git a/typed-html/src/elements.rs b/typed-html/src/elements.rs index 0807891..e7bc9b9 100644 --- a/typed-html/src/elements.rs +++ b/typed-html/src/elements.rs @@ -4,9 +4,9 @@ use typed_html_macros::declare_elements; -use super::OutputType; -use dom::{Node, TextNode}; -use types::*; +use crate::OutputType; +use crate::dom::{Node, TextNode}; +use crate::types::*; // Marker traits for element content groups diff --git a/typed-html/src/events.rs b/typed-html/src/events.rs index 23daefe..aa1ac4f 100644 --- a/typed-html/src/events.rs +++ b/typed-html/src/events.rs @@ -1,6 +1,6 @@ //! Event handlers. -use super::OutputType; +use crate::OutputType; use htmlescape::encode_attribute; use std::fmt::{Display, Error, Formatter}; diff --git a/typed-html/src/lib.rs b/typed-html/src/lib.rs index a58f498..2f66881 100644 --- a/typed-html/src/lib.rs +++ b/typed-html/src/lib.rs @@ -191,19 +191,7 @@ //! [Into::into]: https://doc.rust-lang.org/std/convert/trait.Into.html#method.into //! [DOMTree]: dom/type.DOMTree.html -#[macro_use] -extern crate strum_macros; - pub extern crate htmlescape; -extern crate language_tags; -extern crate mime; -extern crate proc_macro_hack; -extern crate proc_macro_nested; -extern crate strum; -extern crate typed_html_macros; - -#[cfg(feature = "stdweb")] -extern crate stdweb; use proc_macro_hack::proc_macro_hack; use std::fmt::Display; diff --git a/typed-html/src/output/stdweb.rs b/typed-html/src/output/stdweb.rs index f5a1138..dc37ed8 100644 --- a/typed-html/src/output/stdweb.rs +++ b/typed-html/src/output/stdweb.rs @@ -4,9 +4,9 @@ use std::marker::PhantomData; use stdweb::web::event::*; use stdweb::web::{self, Element, EventListenerHandle, IElement, IEventTarget, INode}; -use super::super::OutputType; -use dom::VNode; -use events::{EventHandler, IntoEventHandler}; +use crate::OutputType; +use crate::dom::VNode; +use crate::events::{EventHandler, IntoEventHandler}; /// DOM output using the stdweb crate pub struct Stdweb; diff --git a/typed-html/src/types/mod.rs b/typed-html/src/types/mod.rs index 0b91ead..a3a29cc 100644 --- a/typed-html/src/types/mod.rs +++ b/typed-html/src/types/mod.rs @@ -1,5 +1,7 @@ //! Types for attribute values. +use strum_macros::*; + mod class; pub use self::class::Class; diff --git a/ui/Cargo.toml b/ui/Cargo.toml index ba2ab2b..fbf4afc 100644 --- a/ui/Cargo.toml +++ b/ui/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "typed-html-tests" version = "0.0.0" +edition = "2018" authors = ["Bodil Stokke "] publish = false