From 83f7ae1e164d134fdd0379e30a500b5c6adfdfa0 Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Tue, 13 Dec 2022 09:39:05 +0100 Subject: Upgrade paste to 1.0.10 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/paste For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md Test: TreeHugger Change-Id: I9ad982c3a32bde1bc4328094f2a60c135c7cd0d4 --- tests/compiletest.rs | 1 + tests/test_expr.rs | 48 ++++++++++++++++++++++++++++++++++++- tests/test_item.rs | 4 ++-- tests/ui/invalid-ident.rs | 8 +++++++ tests/ui/invalid-ident.stderr | 24 +++++++++++++++---- tests/ui/unsupported-literal.rs | 16 ++++++++++++- tests/ui/unsupported-literal.stderr | 24 ++++++++++++++++--- 7 files changed, 114 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/compiletest.rs b/tests/compiletest.rs index f9aea23..7974a62 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -1,4 +1,5 @@ #[rustversion::attr(not(nightly), ignore)] +#[cfg_attr(miri, ignore)] #[test] fn ui() { let t = trybuild::TestCases::new(); diff --git a/tests/test_expr.rs b/tests/test_expr.rs index a61bd03..41d84ce 100644 --- a/tests/test_expr.rs +++ b/tests/test_expr.rs @@ -26,11 +26,34 @@ fn test_repeat() { } #[test] -fn test_integer() { +fn test_literal_to_identifier() { const CONST0: &str = "const0"; let pasted = paste!([]); assert_eq!(pasted, CONST0); + + let pasted = paste!([]); + assert_eq!(pasted, CONST0); + + let pasted = paste!([]); + assert_eq!(pasted, CONST0); + + let pasted = paste!([]); + assert_eq!(pasted, CONST0); + + let pasted = paste!([]); + assert_eq!(pasted, CONST0); +} + +#[test] +fn test_literal_suffix() { + macro_rules! literal { + ($bit:tt) => { + paste!([<1_u $bit>]) + }; + } + + assert_eq!(literal!(32), 1); } #[test] @@ -235,3 +258,26 @@ mod test_local_setter { assert_eq!(a.val, 42); } } + +// https://github.com/dtolnay/paste/issues/85 +#[test] +fn test_top_level_none_delimiter() { + macro_rules! clone { + ($val:expr) => { + paste! { + $val.clone() + } + }; + } + + #[derive(Clone)] + struct A; + + impl A { + fn consume_self(self) { + let _ = self; + } + } + + clone!(&A).consume_self(); +} diff --git a/tests/test_item.rs b/tests/test_item.rs index 86c98a9..3821510 100644 --- a/tests/test_item.rs +++ b/tests/test_item.rs @@ -59,8 +59,8 @@ mod test_none_delimited_single_lifetime { macro_rules! m { ($life:lifetime) => { paste! { - pub struct S; - impl<$life> S { + pub struct S<$life>(&$life ()); + impl<$life> S<$life> { fn f() {} } } diff --git a/tests/ui/invalid-ident.rs b/tests/ui/invalid-ident.rs index d566e65..6a8cf3c 100644 --- a/tests/ui/invalid-ident.rs +++ b/tests/ui/invalid-ident.rs @@ -4,4 +4,12 @@ paste! { fn [<0 f>]() {} } +paste! { + fn []() {} +} + +paste! { + fn []() {} +} + fn main() {} diff --git a/tests/ui/invalid-ident.stderr b/tests/ui/invalid-ident.stderr index 8a233cb..28593fb 100644 --- a/tests/ui/invalid-ident.stderr +++ b/tests/ui/invalid-ident.stderr @@ -1,5 +1,21 @@ -error: `"0f"` is not a valid identifier - --> tests/ui/invalid-ident.rs:4:8 +error: expected identifier, found `0f` + --> tests/ui/invalid-ident.rs:3:1 | -4 | fn [<0 f>]() {} - | ^^^^^^^ +3 | / paste! { +4 | | fn [<0 f>]() {} +5 | | } + | |_^ expected identifier + | + = note: this error originates in the macro `paste` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `"f\""` is not a valid identifier + --> tests/ui/invalid-ident.rs:8:8 + | +8 | fn []() {} + | ^^^^^^^^^ + +error: `"f'"` is not a valid identifier + --> tests/ui/invalid-ident.rs:12:8 + | +12 | fn []() {} + | ^^^^^^^^^ diff --git a/tests/ui/unsupported-literal.rs b/tests/ui/unsupported-literal.rs index 6538971..7a9c490 100644 --- a/tests/ui/unsupported-literal.rs +++ b/tests/ui/unsupported-literal.rs @@ -1,7 +1,21 @@ use paste::paste; paste! { - fn [<1e+100>]() {} + fn []() {} +} + +paste! { + // `xyz` is not correct. `xbyz` is certainly not correct. Maybe `x121z` + // would be justifiable but for now don't accept this. + fn []() {} +} + +paste! { + fn []() {} +} + +paste! { + fn []() {} } fn main() {} diff --git a/tests/ui/unsupported-literal.stderr b/tests/ui/unsupported-literal.stderr index 842e2f2..a802b45 100644 --- a/tests/ui/unsupported-literal.stderr +++ b/tests/ui/unsupported-literal.stderr @@ -1,5 +1,23 @@ error: unsupported literal - --> tests/ui/unsupported-literal.rs:4:10 + --> tests/ui/unsupported-literal.rs:4:12 | -4 | fn [<1e+100>]() {} - | ^^^^^^ +4 | fn []() {} + | ^^^^^^ + +error: unsupported literal + --> tests/ui/unsupported-literal.rs:10:12 + | +10 | fn []() {} + | ^^^^ + +error: unsupported literal + --> tests/ui/unsupported-literal.rs:14:12 + | +14 | fn []() {} + | ^^^^ + +error: unsupported literal + --> tests/ui/unsupported-literal.rs:18:12 + | +18 | fn []() {} + | ^^^^^ -- cgit v1.2.3