summaryrefslogtreecommitdiffstats
path: root/vendor/quote/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/quote/tests
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/quote/tests')
-rw-r--r--vendor/quote/tests/test.rs32
-rw-r--r--vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr2
-rw-r--r--vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr2
-rw-r--r--vendor/quote/tests/ui/does-not-have-iter-separated.stderr2
-rw-r--r--vendor/quote/tests/ui/does-not-have-iter.stderr2
-rw-r--r--vendor/quote/tests/ui/not-quotable.rs2
-rw-r--r--vendor/quote/tests/ui/not-quotable.stderr12
-rw-r--r--vendor/quote/tests/ui/not-repeatable.rs2
-rw-r--r--vendor/quote/tests/ui/not-repeatable.stderr6
-rw-r--r--vendor/quote/tests/ui/wrong-type-span.stderr10
10 files changed, 52 insertions, 20 deletions
diff --git a/vendor/quote/tests/test.rs b/vendor/quote/tests/test.rs
index 52ec7bcfb..eab4f55aa 100644
--- a/vendor/quote/tests/test.rs
+++ b/vendor/quote/tests/test.rs
@@ -1,14 +1,17 @@
#![allow(
clippy::disallowed_names,
+ clippy::let_underscore_untyped,
clippy::shadow_unrelated,
clippy::unseparated_literal_suffix,
clippy::used_underscore_binding
)]
+extern crate proc_macro;
+
use std::borrow::Cow;
use std::collections::BTreeSet;
-use proc_macro2::{Ident, Span, TokenStream};
+use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream};
use quote::{format_ident, quote, quote_spanned, TokenStreamExt};
struct X;
@@ -517,3 +520,30 @@ fn test_quote_raw_id() {
let id = quote!(r#raw_id);
assert_eq!(id.to_string(), "r#raw_id");
}
+
+#[test]
+fn test_type_inference_for_span() {
+ trait CallSite {
+ fn get() -> Self;
+ }
+
+ impl CallSite for Span {
+ fn get() -> Self {
+ Span::call_site()
+ }
+ }
+
+ let span = Span::call_site();
+ let _ = quote_spanned!(span=> ...);
+
+ let delim_span = Group::new(Delimiter::Parenthesis, TokenStream::new()).delim_span();
+ let _ = quote_spanned!(delim_span=> ...);
+
+ let inferred = CallSite::get();
+ let _ = quote_spanned!(inferred=> ...);
+
+ if false {
+ let proc_macro_span = proc_macro::Span::call_site();
+ let _ = quote_spanned!(proc_macro_span.into()=> ...);
+ }
+}
diff --git a/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr b/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
index 8087879af..57d8bf0bd 100644
--- a/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
+++ b/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
8 | quote!(#(#nonrep #nonrep)*);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
- | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition`
+ | expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
| expected due to this
|
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr b/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr
index 2dcf206dd..8ec2d40ef 100644
--- a/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr
+++ b/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
8 | quote!(#(#nonrep)*);
| ^^^^^^^^^^^^^^^^^^^
| |
- | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition`
+ | expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
| expected due to this
|
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/vendor/quote/tests/ui/does-not-have-iter-separated.stderr b/vendor/quote/tests/ui/does-not-have-iter-separated.stderr
index 87a19fe07..7c6e30f2b 100644
--- a/vendor/quote/tests/ui/does-not-have-iter-separated.stderr
+++ b/vendor/quote/tests/ui/does-not-have-iter-separated.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
4 | quote!(#(a b),*);
| ^^^^^^^^^^^^^^^^
| |
- | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition`
+ | expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
| expected due to this
|
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/vendor/quote/tests/ui/does-not-have-iter.stderr b/vendor/quote/tests/ui/does-not-have-iter.stderr
index 32aa62d9b..0b13e5cb7 100644
--- a/vendor/quote/tests/ui/does-not-have-iter.stderr
+++ b/vendor/quote/tests/ui/does-not-have-iter.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
4 | quote!(#(a b)*);
| ^^^^^^^^^^^^^^^
| |
- | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition`
+ | expected `HasIterator`, found `ThereIsNoIteratorInRepetition`
| expected due to this
|
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/vendor/quote/tests/ui/not-quotable.rs b/vendor/quote/tests/ui/not-quotable.rs
index 220542d84..f991c1883 100644
--- a/vendor/quote/tests/ui/not-quotable.rs
+++ b/vendor/quote/tests/ui/not-quotable.rs
@@ -3,5 +3,5 @@ use std::net::Ipv4Addr;
fn main() {
let ip = Ipv4Addr::LOCALHOST;
- _ = quote! { #ip };
+ let _ = quote! { #ip };
}
diff --git a/vendor/quote/tests/ui/not-quotable.stderr b/vendor/quote/tests/ui/not-quotable.stderr
index c323d99b7..79d46548d 100644
--- a/vendor/quote/tests/ui/not-quotable.stderr
+++ b/vendor/quote/tests/ui/not-quotable.stderr
@@ -1,11 +1,11 @@
error[E0277]: the trait bound `Ipv4Addr: ToTokens` is not satisfied
- --> tests/ui/not-quotable.rs:6:9
+ --> tests/ui/not-quotable.rs:6:13
|
-6 | _ = quote! { #ip };
- | ^^^^^^^^^^^^^^
- | |
- | the trait `ToTokens` is not implemented for `Ipv4Addr`
- | required by a bound introduced by this call
+6 | let _ = quote! { #ip };
+ | ^^^^^^^^^^^^^^
+ | |
+ | the trait `ToTokens` is not implemented for `Ipv4Addr`
+ | required by a bound introduced by this call
|
= help: the following other types implement trait `ToTokens`:
&'a T
diff --git a/vendor/quote/tests/ui/not-repeatable.rs b/vendor/quote/tests/ui/not-repeatable.rs
index c1debf5f8..a8f0fe773 100644
--- a/vendor/quote/tests/ui/not-repeatable.rs
+++ b/vendor/quote/tests/ui/not-repeatable.rs
@@ -4,5 +4,5 @@ struct Ipv4Addr;
fn main() {
let ip = Ipv4Addr;
- _ = quote! { #(#ip)* };
+ let _ = quote! { #(#ip)* };
}
diff --git a/vendor/quote/tests/ui/not-repeatable.stderr b/vendor/quote/tests/ui/not-repeatable.stderr
index 264a89f9e..2ed1da043 100644
--- a/vendor/quote/tests/ui/not-repeatable.stderr
+++ b/vendor/quote/tests/ui/not-repeatable.stderr
@@ -1,5 +1,5 @@
error[E0599]: the method `quote_into_iter` exists for struct `Ipv4Addr`, but its trait bounds were not satisfied
- --> tests/ui/not-repeatable.rs:7:9
+ --> tests/ui/not-repeatable.rs:7:13
|
3 | struct Ipv4Addr;
| ---------------
@@ -10,8 +10,8 @@ error[E0599]: the method `quote_into_iter` exists for struct `Ipv4Addr`, but its
| doesn't satisfy `Ipv4Addr: ext::RepIteratorExt`
| doesn't satisfy `Ipv4Addr: ext::RepToTokensExt`
...
-7 | _ = quote! { #(#ip)* };
- | ^^^^^^^^^^^^^^^^^^ method cannot be called on `Ipv4Addr` due to unsatisfied trait bounds
+7 | let _ = quote! { #(#ip)* };
+ | ^^^^^^^^^^^^^^^^^^ method cannot be called on `Ipv4Addr` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`Ipv4Addr: Iterator`
diff --git a/vendor/quote/tests/ui/wrong-type-span.stderr b/vendor/quote/tests/ui/wrong-type-span.stderr
index c774a4c3a..12ad30770 100644
--- a/vendor/quote/tests/ui/wrong-type-span.stderr
+++ b/vendor/quote/tests/ui/wrong-type-span.stderr
@@ -1,8 +1,10 @@
error[E0308]: mismatched types
- --> tests/ui/wrong-type-span.rs:6:20
+ --> tests/ui/wrong-type-span.rs:6:5
|
6 | quote_spanned!(span=> #x);
- | ---------------^^^^------
- | | |
- | | expected struct `Span`, found `&str`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | expected `Span`, found `&str`
| expected due to this
+ |
+ = note: this error originates in the macro `quote_spanned` (in Nightly builds, run with -Z macro-backtrace for more info)