aboutsummaryrefslogtreecommitdiff
path: root/quote/tests/ui
diff options
context:
space:
mode:
Diffstat (limited to 'quote/tests/ui')
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated-dup.rs9
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated-dup.stderr11
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated.rs9
-rw-r--r--quote/tests/ui/does-not-have-iter-interpolated.stderr11
-rw-r--r--quote/tests/ui/does-not-have-iter-separated.rs5
-rw-r--r--quote/tests/ui/does-not-have-iter-separated.stderr11
-rw-r--r--quote/tests/ui/does-not-have-iter.rs5
-rw-r--r--quote/tests/ui/does-not-have-iter.stderr11
-rw-r--r--quote/tests/ui/not-quotable.rs7
-rw-r--r--quote/tests/ui/not-quotable.stderr10
-rw-r--r--quote/tests/ui/not-repeatable.rs7
-rw-r--r--quote/tests/ui/not-repeatable.stderr14
-rw-r--r--quote/tests/ui/wrong-type-span.rs7
-rw-r--r--quote/tests/ui/wrong-type-span.stderr10
14 files changed, 127 insertions, 0 deletions
diff --git a/quote/tests/ui/does-not-have-iter-interpolated-dup.rs b/quote/tests/ui/does-not-have-iter-interpolated-dup.rs
new file mode 100644
index 0000000..0a39f41
--- /dev/null
+++ b/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/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr b/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
new file mode 100644
index 0000000..6ee6fdf
--- /dev/null
+++ b/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/does-not-have-iter-interpolated-dup.rs:8:5
+ |
+8 | quote!(#(#nonrep #nonrep)*);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
+ |
+ = note: expected type `quote::__rt::HasIterator`
+ found type `quote::__rt::ThereIsNoIteratorInRepetition`
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/does-not-have-iter-interpolated.rs b/quote/tests/ui/does-not-have-iter-interpolated.rs
new file mode 100644
index 0000000..2c740cc
--- /dev/null
+++ b/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/quote/tests/ui/does-not-have-iter-interpolated.stderr b/quote/tests/ui/does-not-have-iter-interpolated.stderr
new file mode 100644
index 0000000..8d6c990
--- /dev/null
+++ b/quote/tests/ui/does-not-have-iter-interpolated.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/does-not-have-iter-interpolated.rs:8:5
+ |
+8 | quote!(#(#nonrep)*);
+ | ^^^^^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
+ |
+ = note: expected type `quote::__rt::HasIterator`
+ found type `quote::__rt::ThereIsNoIteratorInRepetition`
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/does-not-have-iter-separated.rs b/quote/tests/ui/does-not-have-iter-separated.rs
new file mode 100644
index 0000000..c027243
--- /dev/null
+++ b/quote/tests/ui/does-not-have-iter-separated.rs
@@ -0,0 +1,5 @@
+use quote::quote;
+
+fn main() {
+ quote!(#(a b),*);
+}
diff --git a/quote/tests/ui/does-not-have-iter-separated.stderr b/quote/tests/ui/does-not-have-iter-separated.stderr
new file mode 100644
index 0000000..c1fd0ad
--- /dev/null
+++ b/quote/tests/ui/does-not-have-iter-separated.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/does-not-have-iter-separated.rs:4:5
+ |
+4 | quote!(#(a b),*);
+ | ^^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
+ |
+ = note: expected type `quote::__rt::HasIterator`
+ found type `quote::__rt::ThereIsNoIteratorInRepetition`
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/does-not-have-iter.rs b/quote/tests/ui/does-not-have-iter.rs
new file mode 100644
index 0000000..8908353
--- /dev/null
+++ b/quote/tests/ui/does-not-have-iter.rs
@@ -0,0 +1,5 @@
+use quote::quote;
+
+fn main() {
+ quote!(#(a b)*);
+}
diff --git a/quote/tests/ui/does-not-have-iter.stderr b/quote/tests/ui/does-not-have-iter.stderr
new file mode 100644
index 0000000..3b87705
--- /dev/null
+++ b/quote/tests/ui/does-not-have-iter.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/does-not-have-iter.rs:4:5
+ |
+4 | quote!(#(a b)*);
+ | ^^^^^^^^^^^^^^^^ expected struct `quote::__rt::HasIterator`, found struct `quote::__rt::ThereIsNoIteratorInRepetition`
+ |
+ = note: expected type `quote::__rt::HasIterator`
+ found type `quote::__rt::ThereIsNoIteratorInRepetition`
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/quote/tests/ui/not-quotable.rs b/quote/tests/ui/not-quotable.rs
new file mode 100644
index 0000000..f991c18
--- /dev/null
+++ b/quote/tests/ui/not-quotable.rs
@@ -0,0 +1,7 @@
+use quote::quote;
+use std::net::Ipv4Addr;
+
+fn main() {
+ let ip = Ipv4Addr::LOCALHOST;
+ let _ = quote! { #ip };
+}
diff --git a/quote/tests/ui/not-quotable.stderr b/quote/tests/ui/not-quotable.stderr
new file mode 100644
index 0000000..f51f85f
--- /dev/null
+++ b/quote/tests/ui/not-quotable.stderr
@@ -0,0 +1,10 @@
+error[E0277]: the trait bound `std::net::Ipv4Addr: quote::to_tokens::ToTokens` is not satisfied
+ --> $DIR/not-quotable.rs:6:13
+ |
+6 | let _ = quote! { #ip };
+ | ^^^^^^^^^^^^^^ the trait `quote::to_tokens::ToTokens` is not implemented for `std::net::Ipv4Addr`
+ |
+ = note: required by `quote::to_tokens::ToTokens::to_tokens`
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/quote/tests/ui/not-repeatable.rs b/quote/tests/ui/not-repeatable.rs
new file mode 100644
index 0000000..ff18060
--- /dev/null
+++ b/quote/tests/ui/not-repeatable.rs
@@ -0,0 +1,7 @@
+use quote::quote;
+use std::net::Ipv4Addr;
+
+fn main() {
+ let ip = Ipv4Addr::LOCALHOST;
+ let _ = quote! { #(#ip)* };
+}
diff --git a/quote/tests/ui/not-repeatable.stderr b/quote/tests/ui/not-repeatable.stderr
new file mode 100644
index 0000000..ddcac05
--- /dev/null
+++ b/quote/tests/ui/not-repeatable.stderr
@@ -0,0 +1,14 @@
+error[E0599]: no method named `quote_into_iter` found for type `std::net::Ipv4Addr` in the current scope
+ --> $DIR/not-repeatable.rs:6:13
+ |
+6 | let _ = quote! { #(#ip)* };
+ | ^^^^^^^^^^^^^^^^^^
+ |
+ = note: the method `quote_into_iter` exists but the following trait bounds were not satisfied:
+ `&mut std::net::Ipv4Addr : quote::__rt::ext::RepIteratorExt`
+ `&std::net::Ipv4Addr : quote::__rt::ext::RepIteratorExt`
+ `std::net::Ipv4Addr : quote::__rt::ext::RepIteratorExt`
+ `std::net::Ipv4Addr : quote::__rt::ext::RepToTokensExt`
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/quote/tests/ui/wrong-type-span.rs b/quote/tests/ui/wrong-type-span.rs
new file mode 100644
index 0000000..1ce391c
--- /dev/null
+++ b/quote/tests/ui/wrong-type-span.rs
@@ -0,0 +1,7 @@
+use quote::quote_spanned;
+
+fn main() {
+ let span = "";
+ let x = 0;
+ quote_spanned!(span=> #x);
+}
diff --git a/quote/tests/ui/wrong-type-span.stderr b/quote/tests/ui/wrong-type-span.stderr
new file mode 100644
index 0000000..a6ae8ef
--- /dev/null
+++ b/quote/tests/ui/wrong-type-span.stderr
@@ -0,0 +1,10 @@
+error[E0308]: mismatched types
+ --> $DIR/wrong-type-span.rs:6:20
+ |
+6 | quote_spanned!(span=> #x);
+ | ^^^^ expected struct `proc_macro2::Span`, found &str
+ |
+ = note: expected type `proc_macro2::Span`
+ found type `&str`
+
+For more information about this error, try `rustc --explain E0308`.