Repository: dtolnay/paste
Pull request #46 (2020-07-26 20:18:11)

Combine item! and expr! into one macro


Patch:
diff --git a/src/lib.rs b/src/lib.rs
index 2a20043..b56066d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -21,23 +21,20 @@
 //!
 //! # Pasting identifiers
 //!
-//! There are two entry points, `paste::expr!` for macros in expression position and
-//! `paste::item!` for macros in item position.
-//!
-//! Within either one, identifiers inside `[<`...`>]` are pasted together to form a
-//! single identifier.
+//! Within the `paste!` macro, identifiers inside `[<`...`>]` are pasted
+//! together to form a single identifier.
 //!
 //! ```
-//! // Macro in item position: at module scope or inside of an impl block.
-//! paste::item! {
+//! use paste::paste;
+//!
+//! paste! {
 //!     // Defines a const called `QRST`.
 //!     const [<Q R S T>]: &str = "success!";
 //! }
 //!
 //! fn main() {
-//!     // Macro in expression position: inside a function body.
 //!     assert_eq!(
-//!         paste::expr! { [<Q R S T>].len() },
+//!         paste! { [<Q R S T>].len() },
 //!         8,
 //!     );
 //! }
@@ -52,12 +49,14 @@
 //! macro expands to a vector containing `ROUTE_A` and `ROUTE_B`.
 //!
 //! ```
+//! use paste::paste;
+//!
 //! const ROUTE_A: &str = "/a";
 //! const ROUTE_B: &str = "/b";
 //!
 //! macro_rules! routes {
 //!     ($($route:ident),*) => {{
-//!         paste::expr! {
+//!         paste! {
 //!             vec![$( [<ROUTE_ $route>] ),*]
 //!         }
 //!     }}
@@ -73,6 +72,8 @@
 //! fields.
 //!
 //! ```
+//! use paste::paste;
+//!
 //! macro_rules! make_a_struct_and_getters {
 //!     ($name:ident { $($field:ident),* }) => {
 //!         // Define a struct. This expands to:
@@ -95,7 +96,7 @@
 //!         //         pub fn get_b(&self) -> &str { &self.b }
 //!         //         pub fn get_c(&self) -> &str { &self.c }
 //!         //     }
-//!         paste::item! {
+//!         paste! {
 //!             impl $name {
 //!                 $(
 //!                     pub fn [<get_ $field>](&self) -> &str {
@@ -144,26 +145,8 @@ use proc_macro::{
 use std::iter::{self, FromIterator, Peekable};
 use std::panic;
 
-/// Paste identifiers within a macro invocation that expands to one or more
-/// items.
-///
-/// An item is like a struct definition, function, impl block, or anything else
-/// that can appear at the top level of a module scope.
 #[proc_macro]
-pub fn item(input: TokenStream) -> TokenStream {
-    expand_paste(input)
-}
-
-/// Paste identifiers within a macro invocation that expands to an expression.
-#[proc_macro]
-pub fn expr(input: TokenStream) -> TokenStream {
-    TokenStream::from(TokenTree::Group(Group::new(
-        Delimiter::Brace,
-        expand_paste(input),
-    )))
-}
-
-fn expand_paste(input: TokenStream) -> TokenStream {
+pub fn paste(input: TokenStream) -> TokenStream {
     let mut contains_paste = false;
     match expand(input, &mut contains_paste) {
         Ok(expanded) => expanded,


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 1f74b87..41b4e8e 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1,7 +1,11 @@
+use paste::paste;
+
 mod test_basic {
+    use paste::paste;
+
     struct Struct;
 
-    paste::item! {
+    paste! {
         impl Struct {
             fn [<a b c>]() {}
         }
@@ -14,10 +18,12 @@ mod test_basic {
 }
 
 mod test_in_impl {
+    use paste::paste;
+
     struct Struct;
 
     impl Struct {
-        paste::item! {
+        paste! {
             fn [<a b c>]() {}
         }
     }
@@ -30,7 +36,7 @@ mod test_in_impl {
 
 #[test]
 fn test_shared_hygiene() {
-    paste::expr! {
+    paste! {
         let [<a a>] = 1;
         assert_eq!([<a a>], 1);
     }
@@ -43,7 +49,7 @@ fn test_repeat() {
 
     macro_rules! routes {
         ($($route:ident),*) => {{
-            paste::expr! {
+            paste! {
                 vec![$( [<ROCKET_ $route>] ),*]
             }
         }}
@@ -57,13 +63,13 @@ fn test_repeat() {
 fn test_integer() {
     const CONST0: &'static str = "const0";
 
-    let pasted = paste::expr!([<CONST 0>]);
+    let pasted = paste!([<CONST 0>]);
     assert_eq!(pasted, CONST0);
 }
 
 #[test]
 fn test_underscore() {
-    paste::expr! {
+    paste! {
         const A_B: usize = 0;
         assert_eq!([<A _ B>], 0);
     }
@@ -71,7 +77,7 @@ fn test_underscore() {
 
 #[test]
 fn test_lifetime() {
-    paste::expr! {
+    paste! {
         #[allow(dead_code)]
         struct S<[<'d e>]> {
             q: &[<'d e>] str,
@@ -81,7 +87,7 @@ fn test_lifetime() {
 
 #[test]
 fn test_keyword() {
-    paste::expr! {
+    paste! {
         struct [<F move>];
 
         let _ = Fmove;
@@ -90,7 +96,7 @@ fn test_keyword() {
 
 #[test]
 fn test_literal_str() {
-    paste::expr! {
+    paste! {
         #[allow(non_camel_case_types)]
         struct [<Foo "Bar-Baz">];
 
@@ -100,7 +106,7 @@ fn test_literal_str() {
 
 #[test]
 fn test_env_literal() {
-    paste::expr! {
+    paste! {
         struct [<Lib env bar>];
 
         let _ = Libenvbar;
@@ -109,7 +115,7 @@ fn test_env_literal() {
 
 #[test]
 fn test_env_present() {
-    paste::expr! {
+    paste! {
         struct [<Lib env!("CARGO_PKG_NAME")>];
 
         let _ = Libpaste;
@@ -118,7 +124,7 @@ fn test_env_present() {
 
 #[test]
 fn test_raw_identifier() {
-    paste::expr! {
+    paste! {
         struct [<F r#move>];
 
         let _ = Fmove;
@@ -139,7 +145,7 @@ fn test_false_start() {
         }
     }
 
-    paste::expr! {
+    paste! {
         let x = [<S as Trait>::f()];
         assert_eq!(x[0], 0);
     }
@@ -149,23 +155,25 @@ fn test_false_start() {
 fn test_local_variable() {
     let yy = 0;
 
-    paste::expr! {
+    paste! {
         assert_eq!([<y y>], 0);
     }
 }
 
 #[test]
 fn test_empty() {
-    paste::expr! {
+    paste! {
         assert_eq!(stringify!([<y y>]), "yy");
         assert_eq!(stringify!([<>]).replace(' ', ""), "[<>]");
     }
 }
 
 mod test_none_delimited_single_ident {
+    use paste::paste;
+
     macro_rules! m {
         ($id:ident) => {
-            paste::item! {
+            paste! {
                 fn f() -> &'static str {
                     stringify!($id)
                 }
@@ -182,9 +190,11 @@ mod test_none_delimited_single_ident {
 }
 
 mod test_none_delimited_single_lifetime {
+    use paste::paste;
+
     macro_rules! m {
         ($life:lifetime) => {
-            paste::item! {
+            paste! {
                 pub struct S;
                 impl<$life> S {
                     fn f() {}
@@ -202,9 +212,11 @@ mod test_none_delimited_single_lifetime {
 }
 
 mod test_to_lower {
+    use paste::paste;
+
     macro_rules! m {
         ($id:ident) => {
-            paste::item! {
+            paste! {
                 fn [<my_ $id:lower _here>](_arg: u8) -> &'static str {
                     stringify!([<$id:lower>])
                 }
@@ -222,7 +234,7 @@ mod test_to_lower {
 
 #[test]
 fn test_env_to_lower() {
-    paste::expr! {
+    paste! {
         struct [<Lib env!("CARGO_PKG_NAME"):lower>];
 
         let _ = Libpaste;
@@ -230,9 +242,11 @@ fn test_env_to_lower() {
 }
 
 mod test_to_upper {
+    use paste::paste;
+
     macro_rules! m {
         ($id:ident) => {
-            paste::item! {
+            paste! {
                 const [<MY_ $id:upper _HERE>]: &str = stringify!([<$id:upper>]);
             }
         };
@@ -248,7 +262,7 @@ mod test_to_upper {
 
 #[test]
 fn test_env_to_upper() {
-    paste::expr! {
+    paste! {
         const [<LIB env!("CARGO_PKG_NAME"):upper>]: &str = "libpaste";
 
         let _ = LIBPASTE;
@@ -256,9 +270,11 @@ fn test_env_to_upper() {
 }
 
 mod test_to_snake {
+    use paste::paste;
+
     macro_rules! m {
         ($id:ident) => {
-            paste::item! {
+            paste! {
                 const DEFAULT_SNAKE: &str = stringify!([<$id:snake>]);
                 const LOWER_SNAKE: &str = stringify!([<$id:snake:lower>]);
                 const UPPER_SNAKE: &str = stringify!([<$id:snake:upper>]);
@@ -278,7 +294,7 @@ mod test_to_snake {
 
 #[test]
 fn test_env_to_snake() {
-    paste::expr! {
+    paste! {
         const [<LIB env!("CARGO_PKG_NAME"):snake:upper>]: &str = "libpaste";
 
         let _ = LIBPASTE;
@@ -286,9 +302,11 @@ fn test_env_to_snake() {
 }
 
 mod test_to_camel {
+    use paste::paste;
+
     macro_rules! m {
         ($id:ident) => {
-            paste::item! {
+            paste! {
                 const DEFAULT_CAMEL: &str = stringify!([<$id:camel>]);
                 const LOWER_CAMEL: &str = stringify!([<$id:camel:lower>]);
                 const UPPER_CAMEL: &str = stringify!([<$id:camel:upper>]);
@@ -308,7 +326,7 @@ mod test_to_camel {
 
 #[test]
 fn test_env_to_camel() {
-    paste::expr! {
+    paste! {
         #[allow(non_upper_case_globals)]
         const [<LIB env!("CARGO_PKG_NAME"):camel>]: &str = "libpaste";
 
@@ -319,9 +337,11 @@ fn test_env_to_camel() {
 mod test_doc_expr {
     // https://github.com/dtolnay/paste/issues/29
 
+    use paste::paste;
+
     macro_rules! doc_expr {
         ($doc:expr) => {
-            paste::item! {
+            paste! {
                 #[doc = $doc]
                 pub struct S;
             }
@@ -339,6 +359,8 @@ mod test_doc_expr {
 mod test_type_in_path {
     // https://github.com/dtolnay/paste/issues/31
 
+    use paste::paste;
+
     mod keys {
         #[derive(Default)]
         pub struct Mib<T = ()>(std::marker::PhantomData<T>);
@@ -346,7 +368,7 @@ mod test_type_in_path {
 
     macro_rules! types {
         ($mib:ty) => {
-            paste::item! {
+            paste! {
                 #[derive(Default)]
                 pub struct S(pub keys::$mib);
             }
@@ -355,7 +377,7 @@ mod test_type_in_path {
 
     macro_rules! write {
         ($fn:ident, $field:ty) => {
-            paste::item! {
+            paste! {
                 pub fn $fn() -> $field {
                     $field::default()
                 }
@@ -378,11 +400,13 @@ mod test_type_in_path {
 mod test_type_in_fn_arg {
     // https://github.com/dtolnay/paste/issues/38
 
+    use paste::paste;
+
     fn _jit_address(_node: ()) {}
 
     macro_rules! jit_reexport {
         ($fn:ident, $arg:ident : $typ:ty) => {
-            paste::item! {
+            paste! {
                 pub fn $fn($arg: $typ) {
                     [<_jit_ $fn>]($arg);
                 }
@@ -401,9 +425,11 @@ mod test_type_in_fn_arg {
 mod test_pat_in_expr_position {
     // https://github.com/xiph/rav1e/pull/2324/files
 
+    use paste::paste;
+
     macro_rules! rav1e_bad {
         ($e:pat) => {
-            paste::item! {
+            paste! {
                 #[test]
                 fn test() {
                     let _ = $e;
@@ -418,10 +444,12 @@ mod test_pat_in_expr_position {
 mod test_x86_feature_literal {
     // work around https://github.com/rust-lang/rust/issues/72726
 
+    use paste::paste;
+
     #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
     macro_rules! my_is_x86_feature_detected {
         ($feat:literal) => {
-            paste::item! {
+            paste! {
                 #[test]
                 fn test() {
                     let _ = is_x86_feature_detected!($feat);
diff --git a/tests/ui/case-warning.rs b/tests/ui/case-warning.rs
index 4b41ab6..fdea4d6 100644
--- a/tests/ui/case-warning.rs
+++ b/tests/ui/case-warning.rs
@@ -1,8 +1,10 @@
 #![deny(warnings)]
 
+use paste::paste;
+
 macro_rules! m {
     ($i:ident) => {
-        paste::item! {
+        paste! {
             pub fn [<foo $i>]() {}
         }
     };
diff --git a/tests/ui/case-warning.stderr b/tests/ui/case-warning.stderr
index 5bf37a0..d140c19 100644
--- a/tests/ui/case-warning.stderr
+++ b/tests/ui/case-warning.stderr
@@ -1,10 +1,10 @@
 error: function `fooBar` should have a snake case name
-  --> $DIR/case-warning.rs:6:20
+  --> $DIR/case-warning.rs:8:20
    |
-6  |             pub fn [<foo $i>]() {}
+8  |             pub fn [<foo $i>]() {}
    |                    ^^^^^^^^^^ help: convert the identifier to snake case: `foo_bar`
 ...
-11 | m!(Bar);
+13 | m!(Bar);
    | -------- in this macro invocation
    |
 note: the lint level is defined here
diff --git a/tests/ui/env-empty.rs b/tests/ui/env-empty.rs
index d1682f5..1e9f2d0 100644
--- a/tests/ui/env-empty.rs
+++ b/tests/ui/env-empty.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<env!()>]() {}
 }
 
diff --git a/tests/ui/env-empty.stderr b/tests/ui/env-empty.stderr
index ef8f362..3e4d4da 100644
--- a/tests/ui/env-empty.stderr
+++ b/tests/ui/env-empty.stderr
@@ -1,5 +1,5 @@
 error: expected string literal as argument to env! macro
- --> $DIR/env-empty.rs:2:10
+ --> $DIR/env-empty.rs:4:10
   |
-2 |     fn [<env!()>]() {}
+4 |     fn [<env!()>]() {}
   |          ^^^^^^
diff --git a/tests/ui/env-non-string.rs b/tests/ui/env-non-string.rs
index d35a445..55255ef 100644
--- a/tests/ui/env-non-string.rs
+++ b/tests/ui/env-non-string.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<env!(1.31)>]() {}
 }
 
diff --git a/tests/ui/env-non-string.stderr b/tests/ui/env-non-string.stderr
index 007ebcf..7988800 100644
--- a/tests/ui/env-non-string.stderr
+++ b/tests/ui/env-non-string.stderr
@@ -1,5 +1,5 @@
 error: expected string literal
- --> $DIR/env-non-string.rs:2:15
+ --> $DIR/env-non-string.rs:4:15
   |
-2 |     fn [<env!(1.31)>]() {}
+4 |     fn [<env!(1.31)>]() {}
   |               ^^^^
diff --git a/tests/ui/env-suffix.rs b/tests/ui/env-suffix.rs
index cd9e15e..b5c60af 100644
--- a/tests/ui/env-suffix.rs
+++ b/tests/ui/env-suffix.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<env!("VAR"suffix)>]() {}
 }
 
diff --git a/tests/ui/env-suffix.stderr b/tests/ui/env-suffix.stderr
index c696fa1..82fad8b 100644
--- a/tests/ui/env-suffix.stderr
+++ b/tests/ui/env-suffix.stderr
@@ -1,5 +1,5 @@
 error: expected string literal
- --> $DIR/env-suffix.rs:2:15
+ --> $DIR/env-suffix.rs:4:15
   |
-2 |     fn [<env!("VAR"suffix)>]() {}
+4 |     fn [<env!("VAR"suffix)>]() {}
   |               ^^^^^^^^^^^
diff --git a/tests/ui/env-unexpected.rs b/tests/ui/env-unexpected.rs
index 1a34ae8..39cb770 100644
--- a/tests/ui/env-unexpected.rs
+++ b/tests/ui/env-unexpected.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<env!("VAR" "VAR")>]() {}
 }
 
diff --git a/tests/ui/env-unexpected.stderr b/tests/ui/env-unexpected.stderr
index 63095de..01bf722 100644
--- a/tests/ui/env-unexpected.stderr
+++ b/tests/ui/env-unexpected.stderr
@@ -1,5 +1,5 @@
 error: unexpected token in env! macro
- --> $DIR/env-unexpected.rs:2:21
+ --> $DIR/env-unexpected.rs:4:21
   |
-2 |     fn [<env!("VAR" "VAR")>]() {}
+4 |     fn [<env!("VAR" "VAR")>]() {}
   |                     ^^^^^
diff --git a/tests/ui/invalid-ident.rs b/tests/ui/invalid-ident.rs
index 529896d..d566e65 100644
--- a/tests/ui/invalid-ident.rs
+++ b/tests/ui/invalid-ident.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<0 f>]() {}
 }
 
diff --git a/tests/ui/invalid-ident.stderr b/tests/ui/invalid-ident.stderr
index bec43c4..2c70cc8 100644
--- a/tests/ui/invalid-ident.stderr
+++ b/tests/ui/invalid-ident.stderr
@@ -1,5 +1,5 @@
 error: `"0f"` is not a valid identifier
- --> $DIR/invalid-ident.rs:2:8
+ --> $DIR/invalid-ident.rs:4:8
   |
-2 |     fn [<0 f>]() {}
+4 |     fn [<0 f>]() {}
   |        ^^^^^^^
diff --git a/tests/ui/missing-paren-on-env.rs b/tests/ui/missing-paren-on-env.rs
index b8a51b0..44fefbd 100644
--- a/tests/ui/missing-paren-on-env.rs
+++ b/tests/ui/missing-paren-on-env.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<env! huh>]() {}
 }
 
diff --git a/tests/ui/missing-paren-on-env.stderr b/tests/ui/missing-paren-on-env.stderr
index 6e99bea..64f0391 100644
--- a/tests/ui/missing-paren-on-env.stderr
+++ b/tests/ui/missing-paren-on-env.stderr
@@ -1,5 +1,5 @@
 error: expected `(`
- --> $DIR/missing-paren-on-env.rs:2:15
+ --> $DIR/missing-paren-on-env.rs:4:15
   |
-2 |     fn [<env! huh>]() {}
+4 |     fn [<env! huh>]() {}
   |               ^^^
diff --git a/tests/ui/no-env-var.rs b/tests/ui/no-env-var.rs
index 87aad35..c6d8c3d 100644
--- a/tests/ui/no-env-var.rs
+++ b/tests/ui/no-env-var.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<a env!("PASTE_UNKNOWN") b>]() {}
 }
 
diff --git a/tests/ui/no-env-var.stderr b/tests/ui/no-env-var.stderr
index e79d148..9255a8f 100644
--- a/tests/ui/no-env-var.stderr
+++ b/tests/ui/no-env-var.stderr
@@ -1,5 +1,5 @@
 error: no such env var: "PASTE_UNKNOWN"
- --> $DIR/no-env-var.rs:2:17
+ --> $DIR/no-env-var.rs:4:17
   |
-2 |     fn [<a env!("PASTE_UNKNOWN") b>]() {}
+4 |     fn [<a env!("PASTE_UNKNOWN") b>]() {}
   |                 ^^^^^^^^^^^^^^^
diff --git a/tests/ui/no-ident-after-colon.rs b/tests/ui/no-ident-after-colon.rs
index 83a25d3..50b3b0d 100644
--- a/tests/ui/no-ident-after-colon.rs
+++ b/tests/ui/no-ident-after-colon.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<name:0>]() {}
 }
 
diff --git a/tests/ui/no-ident-after-colon.stderr b/tests/ui/no-ident-after-colon.stderr
index 2f36bac..928316f 100644
--- a/tests/ui/no-ident-after-colon.stderr
+++ b/tests/ui/no-ident-after-colon.stderr
@@ -1,5 +1,5 @@
 error: expected identifier after `:`
- --> $DIR/no-ident-after-colon.rs:2:15
+ --> $DIR/no-ident-after-colon.rs:4:15
   |
-2 |     fn [<name:0>]() {}
+4 |     fn [<name:0>]() {}
   |               ^
diff --git a/tests/ui/unexpected-group.rs b/tests/ui/unexpected-group.rs
index 9fed522..63ee516 100644
--- a/tests/ui/unexpected-group.rs
+++ b/tests/ui/unexpected-group.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<a {} b>]() {}
 }
 
diff --git a/tests/ui/unexpected-group.stderr b/tests/ui/unexpected-group.stderr
index c5d4a82..4d05139 100644
--- a/tests/ui/unexpected-group.stderr
+++ b/tests/ui/unexpected-group.stderr
@@ -1,5 +1,5 @@
 error: unexpected token
- --> $DIR/unexpected-group.rs:2:12
+ --> $DIR/unexpected-group.rs:4:12
   |
-2 |     fn [<a {} b>]() {}
+4 |     fn [<a {} b>]() {}
   |            ^^
diff --git a/tests/ui/unexpected-modifier.rs b/tests/ui/unexpected-modifier.rs
index 00a1e99..99fe68f 100644
--- a/tests/ui/unexpected-modifier.rs
+++ b/tests/ui/unexpected-modifier.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<:lower x>]() {}
 }
 
diff --git a/tests/ui/unexpected-modifier.stderr b/tests/ui/unexpected-modifier.stderr
index 4a518b8..513835c 100644
--- a/tests/ui/unexpected-modifier.stderr
+++ b/tests/ui/unexpected-modifier.stderr
@@ -1,5 +1,5 @@
 error: unexpected modifier
- --> $DIR/unexpected-modifier.rs:2:10
+ --> $DIR/unexpected-modifier.rs:4:10
   |
-2 |     fn [<:lower x>]() {}
+4 |     fn [<:lower x>]() {}
   |          ^^^^^^
diff --git a/tests/ui/unexpected-punct.rs b/tests/ui/unexpected-punct.rs
index b2313b5..d0edb92 100644
--- a/tests/ui/unexpected-punct.rs
+++ b/tests/ui/unexpected-punct.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<a + b>]() {}
 }
 
diff --git a/tests/ui/unexpected-punct.stderr b/tests/ui/unexpected-punct.stderr
index 9564310..456d172 100644
--- a/tests/ui/unexpected-punct.stderr
+++ b/tests/ui/unexpected-punct.stderr
@@ -1,5 +1,5 @@
 error: unexpected punct
- --> $DIR/unexpected-punct.rs:2:12
+ --> $DIR/unexpected-punct.rs:4:12
   |
-2 |     fn [<a + b>]() {}
+4 |     fn [<a + b>]() {}
   |            ^
diff --git a/tests/ui/unsupported-literal.rs b/tests/ui/unsupported-literal.rs
index d3768bd..6538971 100644
--- a/tests/ui/unsupported-literal.rs
+++ b/tests/ui/unsupported-literal.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<1e+100>]() {}
 }
 
diff --git a/tests/ui/unsupported-literal.stderr b/tests/ui/unsupported-literal.stderr
index 30fe5b4..0167999 100644
--- a/tests/ui/unsupported-literal.stderr
+++ b/tests/ui/unsupported-literal.stderr
@@ -1,5 +1,5 @@
 error: unsupported literal
- --> $DIR/unsupported-literal.rs:2:10
+ --> $DIR/unsupported-literal.rs:4:10
   |
-2 |     fn [<1e+100>]() {}
+4 |     fn [<1e+100>]() {}
   |          ^^^^^^
diff --git a/tests/ui/unsupported-modifier.rs b/tests/ui/unsupported-modifier.rs
index 5ab049f..a65b36a 100644
--- a/tests/ui/unsupported-modifier.rs
+++ b/tests/ui/unsupported-modifier.rs
@@ -1,4 +1,6 @@
-paste::item! {
+use paste::paste;
+
+paste! {
     fn [<a:pillow>]() {}
 }
 
diff --git a/tests/ui/unsupported-modifier.stderr b/tests/ui/unsupported-modifier.stderr
index ffbc742..bfb9697 100644
--- a/tests/ui/unsupported-modifier.stderr
+++ b/tests/ui/unsupported-modifier.stderr
@@ -1,5 +1,5 @@
 error: unsupported modifier
- --> $DIR/unsupported-modifier.rs:2:11
+ --> $DIR/unsupported-modifier.rs:4:11
   |
-2 |     fn [<a:pillow>]() {}
+4 |     fn [<a:pillow>]() {}
   |           ^^^^^^^