| msrv = "1.31.0" |
| { | ||
| "git": { | ||
| "sha1": "3eb762421182b53411e58ff93765b5604ed89c8b" | ||
| "sha1": "b38636e38862f1df2c7b167073b022fcc8819a05" | ||
| } | ||
| } |
@@ -46,2 +46,2 @@ name: CI | ||
| - uses: dtolnay/rust-toolchain@clippy | ||
| - run: cargo clippy -- -Dclippy::all | ||
| - run: cargo clippy -- -Dclippy::all -Dclippy::pedantic |
+1
-1
@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| name = "paste" | ||
| version = "1.0.4" | ||
| version = "1.0.5" | ||
| authors = ["David Tolnay <dtolnay@gmail.com>"] | ||
@@ -19,0 +19,0 @@ description = "Macros for all your token pasting needs" |
+2
-0
@@ -137,2 +137,4 @@ Macros for all your token pasting needs | ||
| pub struct Paste {} | ||
| method_new!(Paste); // expands to #[doc = "Create a new `Paste` object"] | ||
@@ -139,0 +141,0 @@ ``` |
+1
-1
@@ -66,3 +66,3 @@ use crate::error::Result; | ||
| let mut nested_attr = TokenStream::new(); | ||
| for tt in group.stream().into_iter() { | ||
| for tt in group.stream() { | ||
| match &tt { | ||
@@ -69,0 +69,0 @@ TokenTree::Punct(punct) if punct.as_char() == ',' => { |
+28
-10
@@ -135,7 +135,13 @@ //! [![github]](https://github.com/dtolnay/paste) [![crates-io]](https://crates.io/crates/paste) [![docs-rs]](https://docs.rs/paste) | ||
| //! | ||
| //! # struct Paste; | ||
| //! pub struct Paste {} | ||
| //! | ||
| //! method_new!(Paste); // expands to #[doc = "Create a new `Paste` object"] | ||
| //! ``` | ||
| #![allow(clippy::needless_doctest_main)] | ||
| #![allow( | ||
| clippy::doc_markdown, | ||
| clippy::module_name_repetitions, | ||
| clippy::needless_doctest_main, | ||
| clippy::too_many_lines | ||
| )] | ||
@@ -158,3 +164,4 @@ extern crate proc_macro; | ||
| let mut contains_paste = false; | ||
| match expand(input, &mut contains_paste) { | ||
| let flatten_single_interpolation = true; | ||
| match expand(input, &mut contains_paste, flatten_single_interpolation) { | ||
| Ok(expanded) => expanded, | ||
@@ -177,3 +184,7 @@ Err(err) => err.to_compile_error(), | ||
| fn expand(input: TokenStream, contains_paste: &mut bool) -> Result<TokenStream> { | ||
| fn expand( | ||
| input: TokenStream, | ||
| contains_paste: &mut bool, | ||
| flatten_single_interpolation: bool, | ||
| ) -> Result<TokenStream> { | ||
| let mut expanded = TokenStream::new(); | ||
@@ -209,3 +220,6 @@ let mut lookbehind = Lookbehind::Other; | ||
| *contains_paste = true; | ||
| } else if delimiter == Delimiter::None && is_flat_group(&content) { | ||
| } else if flatten_single_interpolation | ||
| && delimiter == Delimiter::None | ||
| && is_single_interpolation_group(&content) | ||
| { | ||
| expanded.extend(content); | ||
@@ -215,6 +229,10 @@ *contains_paste = true; | ||
| let mut group_contains_paste = false; | ||
| let mut nested = expand(content, &mut group_contains_paste)?; | ||
| if delimiter == Delimiter::Bracket | ||
| && (lookbehind == Lookbehind::Pound || lookbehind == Lookbehind::PoundBang) | ||
| { | ||
| let is_attribute = delimiter == Delimiter::Bracket | ||
| && (lookbehind == Lookbehind::Pound || lookbehind == Lookbehind::PoundBang); | ||
| let mut nested = expand( | ||
| content, | ||
| &mut group_contains_paste, | ||
| flatten_single_interpolation && !is_attribute, | ||
| )?; | ||
| if is_attribute { | ||
| nested = expand_attr(nested, span, &mut group_contains_paste)? | ||
@@ -270,3 +288,3 @@ } | ||
| // https://github.com/dtolnay/paste/issues/26 | ||
| fn is_flat_group(input: &TokenStream) -> bool { | ||
| fn is_single_interpolation_group(input: &TokenStream) -> bool { | ||
| #[derive(PartialEq)] | ||
@@ -273,0 +291,0 @@ enum State { |
+23
-0
@@ -55,1 +55,24 @@ use paste::paste; | ||
| } | ||
| // https://github.com/dtolnay/paste/issues/63 | ||
| #[test] | ||
| fn test_stringify() { | ||
| macro_rules! create { | ||
| ($doc:expr) => { | ||
| paste! { | ||
| #[doc = $doc] | ||
| pub struct Struct; | ||
| } | ||
| }; | ||
| } | ||
| macro_rules! forward { | ||
| ($name:ident) => { | ||
| create!(stringify!($name)); | ||
| }; | ||
| } | ||
| forward!(documentation); | ||
| let _ = Struct; | ||
| } |
Sorry, the diff of this file is not supported yet