diff options
-rw-r--r-- | .cargo_vcs_info.json | 7 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 21 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 15 | ||||
-rw-r--r-- | Cargo.toml.orig | 5 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | src/attr.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | tests/test_attr.rs | 15 | ||||
-rw-r--r-- | tests/test_expr.rs | 6 | ||||
-rw-r--r-- | tests/ui/case-warning.stderr | 8 | ||||
-rw-r--r-- | tests/ui/env-empty.stderr | 2 | ||||
-rw-r--r-- | tests/ui/env-non-string.stderr | 2 | ||||
-rw-r--r-- | tests/ui/env-suffix.stderr | 2 | ||||
-rw-r--r-- | tests/ui/env-unexpected.stderr | 2 | ||||
-rw-r--r-- | tests/ui/invalid-ident.stderr | 2 | ||||
-rw-r--r-- | tests/ui/missing-paren-on-env.stderr | 2 | ||||
-rw-r--r-- | tests/ui/no-env-var.stderr | 2 | ||||
-rw-r--r-- | tests/ui/no-ident-after-colon.stderr | 2 | ||||
-rw-r--r-- | tests/ui/unexpected-group.stderr | 2 | ||||
-rw-r--r-- | tests/ui/unexpected-modifier.stderr | 2 | ||||
-rw-r--r-- | tests/ui/unexpected-punct.stderr | 2 | ||||
-rw-r--r-- | tests/ui/unsupported-literal.stderr | 2 | ||||
-rw-r--r-- | tests/ui/unsupported-modifier.stderr | 2 |
24 files changed, 79 insertions, 42 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index bd3aebb..be43e96 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "b38636e38862f1df2c7b167073b022fcc8819a05" - } -} + "sha1": "4ffed377239acf07f5fbe2cfa152b0824790852b" + }, + "path_in_vcs": "" +}
\ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc09e20..a59ee09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,13 +20,21 @@ jobs: toolchain: ${{matrix.rust}} - run: cargo test + mintest: + name: Rust 1.34.0 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: dtolnay/rust-toolchain@1.34.0 + - run: cargo test --test test_item + msrv: name: Rust 1.31.0 runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@1.31.0 - - run: cargo test --test test_item + - run: cargo check minimal: name: Minimal versions @@ -40,7 +48,16 @@ jobs: clippy: name: Clippy runs-on: ubuntu-latest + if: github.event_name != 'pull_request' steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@clippy - - run: cargo clippy -- -Dclippy::all -Dclippy::pedantic + - run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic + + outdated: + name: Outdated + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v2 + - run: cargo outdated --exit-code 1 @@ -41,7 +41,7 @@ rust_proc_macro { name: "libpaste", crate_name: "paste", cargo_env_compat: true, - cargo_pkg_version: "1.0.5", + cargo_pkg_version: "1.0.6", srcs: ["src/lib.rs"], edition: "2018", } @@ -3,17 +3,17 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" +rust-version = "1.31" name = "paste" -version = "1.0.5" +version = "1.0.6" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Macros for all your token pasting needs" readme = "README.md" @@ -32,4 +32,5 @@ version = "0" version = "1.0" [dev-dependencies.trybuild] -version = "1.0" +version = "1.0.49" +features = ["diff"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 782f2f4..88d4d81 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,8 +1,9 @@ [package] name = "paste" -version = "1.0.5" +version = "1.0.6" authors = ["David Tolnay <dtolnay@gmail.com>"] edition = "2018" +rust-version = "1.31" license = "MIT OR Apache-2.0" description = "Macros for all your token pasting needs" repository = "https://github.com/dtolnay/paste" @@ -15,7 +16,7 @@ proc-macro = true [dev-dependencies] paste-test-suite = { version = "0", path = "tests/macros" } rustversion = "1.0" -trybuild = "1.0" +trybuild = { version = "1.0.49", features = ["diff"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/paste/paste-1.0.5.crate" + value: "https://static.crates.io/crates/paste/paste-1.0.6.crate" } - version: "1.0.5" + version: "1.0.6" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 4 + year: 2022 + month: 3 day: 1 } } 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 + } } } @@ -230,7 +230,7 @@ fn expand( flatten_single_interpolation && !is_attribute, )?; if is_attribute { - nested = expand_attr(nested, span, &mut group_contains_paste)? + nested = expand_attr(nested, span, &mut group_contains_paste)?; } let group = if group_contains_paste { let mut group = Group::new(delimiter, nested); 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); +} diff --git a/tests/test_expr.rs b/tests/test_expr.rs index e8386d0..a61bd03 100644 --- a/tests/test_expr.rs +++ b/tests/test_expr.rs @@ -10,8 +10,8 @@ fn test_shared_hygiene() { #[test] fn test_repeat() { - const ROCKET_A: &'static str = "/a"; - const ROCKET_B: &'static str = "/b"; + const ROCKET_A: &str = "/a"; + const ROCKET_B: &str = "/b"; macro_rules! routes { ($($route:ident),*) => {{ @@ -27,7 +27,7 @@ fn test_repeat() { #[test] fn test_integer() { - const CONST0: &'static str = "const0"; + const CONST0: &str = "const0"; let pasted = paste!([<CONST 0>]); assert_eq!(pasted, CONST0); diff --git a/tests/ui/case-warning.stderr b/tests/ui/case-warning.stderr index d140c19..8309912 100644 --- a/tests/ui/case-warning.stderr +++ b/tests/ui/case-warning.stderr @@ -1,16 +1,16 @@ error: function `fooBar` should have a snake case name - --> $DIR/case-warning.rs:8:20 + --> tests/ui/case-warning.rs:8:20 | 8 | pub fn [<foo $i>]() {} | ^^^^^^^^^^ help: convert the identifier to snake case: `foo_bar` ... 13 | m!(Bar); - | -------- in this macro invocation + | ------- in this macro invocation | note: the lint level is defined here - --> $DIR/case-warning.rs:1:9 + --> tests/ui/case-warning.rs:1:9 | 1 | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(non_snake_case)]` implied by `#[deny(warnings)]` - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/env-empty.stderr b/tests/ui/env-empty.stderr index 3e4d4da..a1ef2e2 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:4:10 + --> tests/ui/env-empty.rs:4:10 | 4 | fn [<env!()>]() {} | ^^^^^^ diff --git a/tests/ui/env-non-string.stderr b/tests/ui/env-non-string.stderr index 7988800..05b8deb 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:4:15 + --> tests/ui/env-non-string.rs:4:15 | 4 | fn [<env!(1.31)>]() {} | ^^^^ diff --git a/tests/ui/env-suffix.stderr b/tests/ui/env-suffix.stderr index 82fad8b..d723cbc 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:4:15 + --> tests/ui/env-suffix.rs:4:15 | 4 | fn [<env!("VAR"suffix)>]() {} | ^^^^^^^^^^^ diff --git a/tests/ui/env-unexpected.stderr b/tests/ui/env-unexpected.stderr index 01bf722..25387b1 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:4:21 + --> tests/ui/env-unexpected.rs:4:21 | 4 | fn [<env!("VAR" "VAR")>]() {} | ^^^^^ diff --git a/tests/ui/invalid-ident.stderr b/tests/ui/invalid-ident.stderr index 2c70cc8..8a233cb 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:4:8 + --> tests/ui/invalid-ident.rs:4:8 | 4 | fn [<0 f>]() {} | ^^^^^^^ diff --git a/tests/ui/missing-paren-on-env.stderr b/tests/ui/missing-paren-on-env.stderr index 64f0391..7b4bc46 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:4:15 + --> tests/ui/missing-paren-on-env.rs:4:15 | 4 | fn [<env! huh>]() {} | ^^^ diff --git a/tests/ui/no-env-var.stderr b/tests/ui/no-env-var.stderr index 9255a8f..60de9ed 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:4:17 + --> tests/ui/no-env-var.rs:4:17 | 4 | fn [<a env!("PASTE_UNKNOWN") b>]() {} | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/no-ident-after-colon.stderr b/tests/ui/no-ident-after-colon.stderr index 928316f..9db91eb 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:4:15 + --> tests/ui/no-ident-after-colon.rs:4:15 | 4 | fn [<name:0>]() {} | ^ diff --git a/tests/ui/unexpected-group.stderr b/tests/ui/unexpected-group.stderr index 4d05139..f66f5c1 100644 --- a/tests/ui/unexpected-group.stderr +++ b/tests/ui/unexpected-group.stderr @@ -1,5 +1,5 @@ error: unexpected token - --> $DIR/unexpected-group.rs:4:12 + --> tests/ui/unexpected-group.rs:4:12 | 4 | fn [<a {} b>]() {} | ^^ diff --git a/tests/ui/unexpected-modifier.stderr b/tests/ui/unexpected-modifier.stderr index 513835c..1eaba31 100644 --- a/tests/ui/unexpected-modifier.stderr +++ b/tests/ui/unexpected-modifier.stderr @@ -1,5 +1,5 @@ error: unexpected modifier - --> $DIR/unexpected-modifier.rs:4:10 + --> tests/ui/unexpected-modifier.rs:4:10 | 4 | fn [<:lower x>]() {} | ^^^^^^ diff --git a/tests/ui/unexpected-punct.stderr b/tests/ui/unexpected-punct.stderr index 456d172..1a74a61 100644 --- a/tests/ui/unexpected-punct.stderr +++ b/tests/ui/unexpected-punct.stderr @@ -1,5 +1,5 @@ error: unexpected punct - --> $DIR/unexpected-punct.rs:4:12 + --> tests/ui/unexpected-punct.rs:4:12 | 4 | fn [<a + b>]() {} | ^ diff --git a/tests/ui/unsupported-literal.stderr b/tests/ui/unsupported-literal.stderr index 0167999..842e2f2 100644 --- a/tests/ui/unsupported-literal.stderr +++ b/tests/ui/unsupported-literal.stderr @@ -1,5 +1,5 @@ error: unsupported literal - --> $DIR/unsupported-literal.rs:4:10 + --> tests/ui/unsupported-literal.rs:4:10 | 4 | fn [<1e+100>]() {} | ^^^^^^ diff --git a/tests/ui/unsupported-modifier.stderr b/tests/ui/unsupported-modifier.stderr index bfb9697..3c70435 100644 --- a/tests/ui/unsupported-modifier.stderr +++ b/tests/ui/unsupported-modifier.stderr @@ -1,5 +1,5 @@ error: unsupported modifier - --> $DIR/unsupported-modifier.rs:4:11 + --> tests/ui/unsupported-modifier.rs:4:11 | 4 | fn [<a:pillow>]() {} | ^^^^^^^ |