From 693ac892f2db5db1ce7cf86db7bf6207b3515c42 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Jul 2020 16:16:53 +0200 Subject: Don't copy-paste `impl_froms` into every crate --- crates/ra_tt/Cargo.toml | 1 + crates/ra_tt/src/lib.rs | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) (limited to 'crates/ra_tt') diff --git a/crates/ra_tt/Cargo.toml b/crates/ra_tt/Cargo.toml index f7230a9ca..b5b12e3af 100644 --- a/crates/ra_tt/Cargo.toml +++ b/crates/ra_tt/Cargo.toml @@ -8,6 +8,7 @@ authors = ["rust-analyzer developers"] doctest = false [dependencies] +stdx = { path = "../stdx" } # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here # to reduce number of compilations smol_str = { version = "0.1.15", features = ["serde"] } diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 342ddbe32..8faf1cc67 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs @@ -1,24 +1,13 @@ //! `tt` crate defines a `TokenTree` data structure: this is the interface (both //! input and output) of macros. It closely mirrors `proc_macro` crate's //! `TokenTree`. - -macro_rules! impl_froms { - ($e:ident: $($v:ident), *) => { - $( - impl From<$v> for $e { - fn from(it: $v) -> $e { - $e::$v(it) - } - } - )* - } -} - use std::{ fmt::{self, Debug}, panic::RefUnwindSafe, }; +use stdx::impl_from; + pub use smol_str::SmolStr; /// Represents identity of the token. @@ -41,7 +30,7 @@ pub enum TokenTree { Leaf(Leaf), Subtree(Subtree), } -impl_froms!(TokenTree: Leaf, Subtree); +impl_from!(Leaf, Subtree for TokenTree); impl TokenTree { pub fn empty() -> Self { @@ -55,7 +44,7 @@ pub enum Leaf { Punct(Punct), Ident(Ident), } -impl_froms!(Leaf: Literal, Punct, Ident); +impl_from!(Literal, Punct, Ident for Leaf); #[derive(Clone, PartialEq, Eq, Hash, Default)] pub struct Subtree { -- cgit v1.2.3 From 6f423466d181130848c229e2684c6dd18f8a5e9d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 14 Jul 2020 10:57:26 +0900 Subject: Add a license field to all the crates --- crates/ra_tt/Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ra_tt') diff --git a/crates/ra_tt/Cargo.toml b/crates/ra_tt/Cargo.toml index b5b12e3af..3c45248c3 100644 --- a/crates/ra_tt/Cargo.toml +++ b/crates/ra_tt/Cargo.toml @@ -3,6 +3,7 @@ edition = "2018" name = "ra_tt" version = "0.1.0" authors = ["rust-analyzer developers"] +license = "MIT OR Apache-2.0" [lib] doctest = false -- cgit v1.2.3