Skip to content
/ rust Public
forked from rust-lang/rust

Commit 2ab9db5

Browse files
committed
Migrate check-fail tests for proc_macro::quote! from quote crate
1 parent e9063c3 commit 2ab9db5

13 files changed

+163
-0
lines changed

tests/ui/proc-macro/quote/auxiliary/basic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub fn run_tests(_: TokenStream) -> TokenStream {
4747
// - quote_spanned:
4848
// - fn test_quote_spanned_impl
4949
// - fn test_type_inference_for_span
50+
// - wrong-type-span.rs
5051
// - format_ident:
5152
// - fn test_format_ident
5253
// - fn test_format_ident_strip_raw
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// FIXME(quote): `proc_macro::quote!` doesn't support repetition at the moment, so the stderr is
2+
// expected to be incorrect.
3+
//@ known-bug: #54722
4+
5+
#![feature(proc_macro_quote)]
6+
7+
extern crate proc_macro;
8+
9+
use proc_macro::quote;
10+
11+
fn main() {
12+
let nonrep = "";
13+
14+
// Without some protection against repetitions with no iterator somewhere
15+
// inside, this would loop infinitely.
16+
quote!($($nonrep $nonrep)*);
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: proc macro panicked
2+
--> $DIR/does-not-have-iter-interpolated-dup.rs:16:5
3+
|
4+
LL | quote!($($nonrep $nonrep)*);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: message: `$` must be followed by an ident or `$` in `quote!`
8+
9+
error: aborting due to 1 previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// FIXME(quote): `proc_macro::quote!` doesn't support repetition at the moment, so the stderr is
2+
// expected to be incorrect.
3+
//@ known-bug: #54722
4+
5+
#![feature(proc_macro_quote)]
6+
7+
extern crate proc_macro;
8+
9+
use proc_macro::quote;
10+
11+
fn main() {
12+
let nonrep = "";
13+
14+
// Without some protection against repetitions with no iterator somewhere
15+
// inside, this would loop infinitely.
16+
quote!($($nonrep)*);
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: proc macro panicked
2+
--> $DIR/does-not-have-iter-interpolated.rs:16:5
3+
|
4+
LL | quote!($($nonrep)*);
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: message: `$` must be followed by an ident or `$` in `quote!`
8+
9+
error: aborting due to 1 previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// FIXME(quote): `proc_macro::quote!` doesn't support repetition at the moment, so the stderr is
2+
// expected to be incorrect.
3+
//@ known-bug: #54722
4+
5+
#![feature(proc_macro_quote)]
6+
7+
extern crate proc_macro;
8+
9+
use proc_macro::quote;
10+
11+
fn main() {
12+
quote!($(a b),*);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: proc macro panicked
2+
--> $DIR/does-not-have-iter-separated.rs:12:5
3+
|
4+
LL | quote!($(a b),*);
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
= help: message: `$` must be followed by an ident or `$` in `quote!`
8+
9+
error: aborting due to 1 previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// FIXME(quote): `proc_macro::quote!` doesn't support repetition at the moment, so the stderr is
2+
// expected to be incorrect.
3+
//@ known-bug: #54722
4+
5+
#![feature(proc_macro_quote)]
6+
7+
extern crate proc_macro;
8+
9+
use proc_macro::quote;
10+
11+
fn main() {
12+
quote!($(a b)*);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: proc macro panicked
2+
--> $DIR/does-not-have-iter.rs:12:5
3+
|
4+
LL | quote!($(a b)*);
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
= help: message: `$` must be followed by an ident or `$` in `quote!`
8+
9+
error: aborting due to 1 previous error
10+
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(proc_macro_quote)]
2+
3+
extern crate proc_macro;
4+
5+
use std::net::Ipv4Addr;
6+
7+
use proc_macro::quote;
8+
9+
fn main() {
10+
let ip = Ipv4Addr::LOCALHOST;
11+
let _ = quote! { $ip }; //~ ERROR the trait bound `Ipv4Addr: ToTokens` is not satisfied
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0277]: the trait bound `Ipv4Addr: ToTokens` is not satisfied
2+
--> $DIR/not-quotable.rs:11:13
3+
|
4+
LL | let _ = quote! { $ip };
5+
| ^^^^^^^^^^^^^^
6+
| |
7+
| the trait `ToTokens` is not implemented for `Ipv4Addr`
8+
| required by a bound introduced by this call
9+
|
10+
= help: the following other types implement trait `ToTokens`:
11+
&T
12+
&mut T
13+
Box<T>
14+
CString
15+
Cow<'_, T>
16+
Option<T>
17+
Rc<T>
18+
bool
19+
and 24 others
20+
= note: this error originates in the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
21+
22+
error: aborting due to 1 previous error
23+
24+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// FIXME(quote): `proc_macro::quote!` doesn't support repetition at the moment, so the stderr is
2+
// expected to be incorrect.
3+
//@ known-bug: #54722
4+
5+
#![feature(proc_macro_quote)]
6+
7+
extern crate proc_macro;
8+
9+
use proc_macro::quote;
10+
11+
struct Ipv4Addr;
12+
13+
fn main() {
14+
let ip = Ipv4Addr;
15+
let _ = quote! { $($ip)* };
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: proc macro panicked
2+
--> $DIR/not-repeatable.rs:15:13
3+
|
4+
LL | let _ = quote! { $($ip)* };
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: message: `$` must be followed by an ident or `$` in `quote!`
8+
9+
error: aborting due to 1 previous error
10+

0 commit comments

Comments
 (0)