summaryrefslogtreecommitdiffstats
path: root/third_party/rust/quote/tests/ui
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/quote/tests/ui
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/quote/tests/ui')
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.rs9
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr10
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.rs9
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.stderr10
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter-separated.rs5
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter-separated.stderr10
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter.rs5
-rw-r--r--third_party/rust/quote/tests/ui/does-not-have-iter.stderr10
-rw-r--r--third_party/rust/quote/tests/ui/not-quotable.rs7
-rw-r--r--third_party/rust/quote/tests/ui/not-quotable.stderr20
-rw-r--r--third_party/rust/quote/tests/ui/not-repeatable.rs8
-rw-r--r--third_party/rust/quote/tests/ui/not-repeatable.stderr35
-rw-r--r--third_party/rust/quote/tests/ui/wrong-type-span.rs7
-rw-r--r--third_party/rust/quote/tests/ui/wrong-type-span.stderr8
14 files changed, 153 insertions, 0 deletions
diff --git a/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.rs b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.rs
new file mode 100644
index 0000000000..0a39f41507
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.rs
@@ -0,0 +1,9 @@
+use quote::quote;
+
+fn main() {
+ let nonrep = "";
+
+ // Without some protection against repetitions with no iterator somewhere
+ // inside, this would loop infinitely.
+ quote!(#(#nonrep #nonrep)*);
+}
diff --git a/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
new file mode 100644
index 0000000000..8087879af7
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
@@ -0,0 +1,10 @@
+error[E0308]: mismatched types
+ --> tests/ui/does-not-have-iter-interpolated-dup.rs:8:5
+ |
+8 | quote!(#(#nonrep #nonrep)*);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | expected struct `HasIterator`, found struct `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/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.rs b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.rs
new file mode 100644
index 0000000000..2c740cc083
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.rs
@@ -0,0 +1,9 @@
+use quote::quote;
+
+fn main() {
+ let nonrep = "";
+
+ // Without some protection against repetitions with no iterator somewhere
+ // inside, this would loop infinitely.
+ quote!(#(#nonrep)*);
+}
diff --git a/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.stderr b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.stderr
new file mode 100644
index 0000000000..2dcf206dd4
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter-interpolated.stderr
@@ -0,0 +1,10 @@
+error[E0308]: mismatched types
+ --> tests/ui/does-not-have-iter-interpolated.rs:8:5
+ |
+8 | quote!(#(#nonrep)*);
+ | ^^^^^^^^^^^^^^^^^^^
+ | |
+ | expected struct `HasIterator`, found struct `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/third_party/rust/quote/tests/ui/does-not-have-iter-separated.rs b/third_party/rust/quote/tests/ui/does-not-have-iter-separated.rs
new file mode 100644
index 0000000000..c027243dda
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter-separated.rs
@@ -0,0 +1,5 @@
+use quote::quote;
+
+fn main() {
+ quote!(#(a b),*);
+}
diff --git a/third_party/rust/quote/tests/ui/does-not-have-iter-separated.stderr b/third_party/rust/quote/tests/ui/does-not-have-iter-separated.stderr
new file mode 100644
index 0000000000..87a19fe073
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter-separated.stderr
@@ -0,0 +1,10 @@
+error[E0308]: mismatched types
+ --> tests/ui/does-not-have-iter-separated.rs:4:5
+ |
+4 | quote!(#(a b),*);
+ | ^^^^^^^^^^^^^^^^
+ | |
+ | expected struct `HasIterator`, found struct `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/third_party/rust/quote/tests/ui/does-not-have-iter.rs b/third_party/rust/quote/tests/ui/does-not-have-iter.rs
new file mode 100644
index 0000000000..8908353b57
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter.rs
@@ -0,0 +1,5 @@
+use quote::quote;
+
+fn main() {
+ quote!(#(a b)*);
+}
diff --git a/third_party/rust/quote/tests/ui/does-not-have-iter.stderr b/third_party/rust/quote/tests/ui/does-not-have-iter.stderr
new file mode 100644
index 0000000000..32aa62d9bb
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/does-not-have-iter.stderr
@@ -0,0 +1,10 @@
+error[E0308]: mismatched types
+ --> tests/ui/does-not-have-iter.rs:4:5
+ |
+4 | quote!(#(a b)*);
+ | ^^^^^^^^^^^^^^^
+ | |
+ | expected struct `HasIterator`, found struct `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/third_party/rust/quote/tests/ui/not-quotable.rs b/third_party/rust/quote/tests/ui/not-quotable.rs
new file mode 100644
index 0000000000..220542d841
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/not-quotable.rs
@@ -0,0 +1,7 @@
+use quote::quote;
+use std::net::Ipv4Addr;
+
+fn main() {
+ let ip = Ipv4Addr::LOCALHOST;
+ _ = quote! { #ip };
+}
diff --git a/third_party/rust/quote/tests/ui/not-quotable.stderr b/third_party/rust/quote/tests/ui/not-quotable.stderr
new file mode 100644
index 0000000000..c323d99b76
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/not-quotable.stderr
@@ -0,0 +1,20 @@
+error[E0277]: the trait bound `Ipv4Addr: ToTokens` is not satisfied
+ --> tests/ui/not-quotable.rs:6:9
+ |
+6 | _ = 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
+ &'a mut T
+ Box<T>
+ Cow<'a, T>
+ Option<T>
+ Rc<T>
+ RepInterp<T>
+ String
+ and 23 others
+ = note: this error originates in the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/quote/tests/ui/not-repeatable.rs b/third_party/rust/quote/tests/ui/not-repeatable.rs
new file mode 100644
index 0000000000..c1debf5f80
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/not-repeatable.rs
@@ -0,0 +1,8 @@
+use quote::quote;
+
+struct Ipv4Addr;
+
+fn main() {
+ let ip = Ipv4Addr;
+ _ = quote! { #(#ip)* };
+}
diff --git a/third_party/rust/quote/tests/ui/not-repeatable.stderr b/third_party/rust/quote/tests/ui/not-repeatable.stderr
new file mode 100644
index 0000000000..264a89f9e9
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/not-repeatable.stderr
@@ -0,0 +1,35 @@
+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
+ |
+3 | struct Ipv4Addr;
+ | ---------------
+ | |
+ | method `quote_into_iter` not found for this struct
+ | doesn't satisfy `Ipv4Addr: Iterator`
+ | doesn't satisfy `Ipv4Addr: ToTokens`
+ | 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
+ |
+ = note: the following trait bounds were not satisfied:
+ `Ipv4Addr: Iterator`
+ which is required by `Ipv4Addr: ext::RepIteratorExt`
+ `&Ipv4Addr: Iterator`
+ which is required by `&Ipv4Addr: ext::RepIteratorExt`
+ `Ipv4Addr: ToTokens`
+ which is required by `Ipv4Addr: ext::RepToTokensExt`
+ `&mut Ipv4Addr: Iterator`
+ which is required by `&mut Ipv4Addr: ext::RepIteratorExt`
+note: the traits `ToTokens` and `Iterator` must be implemented
+ --> src/to_tokens.rs
+ |
+ | pub trait ToTokens {
+ | ^^^^^^^^^^^^^^^^^^
+ |
+ ::: $RUST/core/src/iter/traits/iterator.rs
+ |
+ | pub trait Iterator {
+ | ^^^^^^^^^^^^^^^^^^
+ = note: this error originates in the macro `$crate::quote_bind_into_iter` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/quote/tests/ui/wrong-type-span.rs b/third_party/rust/quote/tests/ui/wrong-type-span.rs
new file mode 100644
index 0000000000..d5601c8a06
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/wrong-type-span.rs
@@ -0,0 +1,7 @@
+use quote::quote_spanned;
+
+fn main() {
+ let span = "";
+ let x = 0i32;
+ quote_spanned!(span=> #x);
+}
diff --git a/third_party/rust/quote/tests/ui/wrong-type-span.stderr b/third_party/rust/quote/tests/ui/wrong-type-span.stderr
new file mode 100644
index 0000000000..c774a4c3af
--- /dev/null
+++ b/third_party/rust/quote/tests/ui/wrong-type-span.stderr
@@ -0,0 +1,8 @@
+error[E0308]: mismatched types
+ --> tests/ui/wrong-type-span.rs:6:20
+ |
+6 | quote_spanned!(span=> #x);
+ | ---------------^^^^------
+ | | |
+ | | expected struct `Span`, found `&str`
+ | expected due to this