Repository: dtolnay/paste (rust)

Issue:
"Expected identifier after `:` error" when `::` is used inside attribute
This simple example:

```rust
macro_rules! a { (#[x = $x:ty]) => {}; }
paste::paste!(a!(#[x = foo::Bar]));
```

Fails with the error message:

```
error: expected identifier after `:`
 --> src/lib.rs:3:27
  |
3 | paste::paste!(a!(#[x = foo::Bar]));
  |                           ^^
```

It seems like `paste!` is treating the attribute as a doc attribute even though it isn't.

Pull request description:
Don't confuse :: with beginning of a case conversion
Fixes #70.

Patch:
diff --git a/src/attr.rs b/src/attr.rs
index 8626d11..d66b843 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -1,6 +1,6 @@
 use crate::error::Result;
 use crate::segment::{self, Segment};
-use proc_macro::{Delimiter, Group, Span, TokenStream, TokenTree};
+use proc_macro::{Delimiter, Group, Spacing, Span, TokenStream, TokenTree};
 use std::iter;
 use std::mem;
 use std::str::FromStr;
@@ -157,6 +157,8 @@ fn is_stringlike(token: &TokenTree) -> bool {
                 None => false,
             }
         }
-        TokenTree::Punct(punct) => punct.as_char() == '\'' || punct.as_char() == ':',
+        TokenTree::Punct(punct) => {
+            punct.as_char() == '\'' || punct.as_char() == ':' && punct.spacing() == Spacing::Alone
+        }
     }
 }


Test patch:
diff --git a/tests/test_attr.rs b/tests/test_attr.rs
index f2a5bf0..c880eac 100644
--- a/tests/test_attr.rs
+++ b/tests/test_attr.rs
@@ -43,3 +43,18 @@ fn test_paste_cfg() {
 
     let _ = new;
 }
+
+#[test]
+fn test_path_in_attr() {
+    macro_rules! m {
+        (#[x = $x:ty]) => {
+            stringify!($x)
+        };
+    }
+
+    let ty = paste! {
+        m!(#[x = foo::Bar])
+    };
+
+    assert_eq!("foo::Bar", ty);
+}