forked from dtolnay/trybuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.rs
427 lines (407 loc) · 18.5 KB
/
tests.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
use crate::directory::Directory;
use crate::run::PathDependency;
use std::path::Path;
macro_rules! test_normalize {
(
$name:ident
$(DIR=$dir:literal)?
$(WORKSPACE=$workspace:literal)?
$(INPUT=$input:literal)?
$(TARGET=$target:literal)?
$original:literal
$expected:literal
) => {
#[test]
fn $name() {
let context = super::Context {
krate: "trybuild000",
input_file: Path::new({ "tests/ui/error.rs" $(; $input)? }),
source_dir: &Directory::new({ "/git/trybuild/test_suite" $(; $dir)? }),
workspace: &Directory::new({ "/git/trybuild" $(; $workspace)? }),
target_dir: &Directory::new({ "/git/trybuild/target" $(; $target)? }),
path_dependencies: &[PathDependency {
name: String::from("diesel"),
normalized_path: Directory::new("/home/user/documents/rust/diesel/diesel"),
}],
};
let original = $original;
let variations = super::diagnostics(original, context);
let preferred = variations.preferred();
let expected = $expected;
if preferred != expected {
panic!("\nACTUAL: \"{}\"\nEXPECTED: \"{}\"", preferred, expected);
}
}
};
}
test_normalize! {test_basic "
error: `self` parameter is only allowed in associated functions
--> /git/trybuild/test_suite/tests/ui/error.rs:11:23
|
11 | async fn bad_endpoint(self) -> Result<HttpResponseOkObject<()>, HttpError> {
| ^^^^ not semantically valid as function parameter
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0401`.
error: could not compile `trybuild-tests`.
To learn more, run the command again with --verbose.
" "
error: `self` parameter is only allowed in associated functions
--> tests/ui/error.rs:11:23
|
11 | async fn bad_endpoint(self) -> Result<HttpResponseOkObject<()>, HttpError> {
| ^^^^ not semantically valid as function parameter
"}
test_normalize! {test_dir_backslash "
error[E0277]: the trait bound `QueryParams: serde::de::Deserialize<'de>` is not satisfied
--> \\git\\trybuild\\test_suite\\tests\\ui\\error.rs:22:61
" "
error[E0277]: the trait bound `QueryParams: serde::de::Deserialize<'de>` is not satisfied
--> tests/ui/error.rs:22:61
"}
test_normalize! {test_rust_lib
INPUT="tests/ui/not-repeatable.rs"
"
error[E0599]: no method named `quote_into_iter` found for struct `std::net::Ipv4Addr` in the current scope
--> /git/trybuild/test_suite/tests/ui/not-repeatable.rs:6:13
|
6 | let _ = quote! { #(#ip)* };
| ^^^^^^^^^^^^^^^^^^ method not found in `std::net::Ipv4Addr`
|
::: /rustlib/src/rust/src/libstd/net/ip.rs:83:1
::: /rustlib/src/rust/library/std/src/net/ip.rs:83:1
|
83 | pub struct Ipv4Addr {
| -------------------
| |
| doesn't satisfy `std::net::Ipv4Addr: quote::to_tokens::ToTokens`
" "
error[E0599]: no method named `quote_into_iter` found for struct `std::net::Ipv4Addr` in the current scope
--> tests/ui/not-repeatable.rs:6:13
|
6 | let _ = quote! { #(#ip)* };
| ^^^^^^^^^^^^^^^^^^ method not found in `std::net::Ipv4Addr`
|
::: $RUST/src/libstd/net/ip.rs
::: $RUST/std/src/net/ip.rs
|
| pub struct Ipv4Addr {
| -------------------
| |
| doesn't satisfy `std::net::Ipv4Addr: quote::to_tokens::ToTokens`
"}
test_normalize! {test_type_dir_backslash
INPUT="tests/ui/compile-fail-3.rs"
"
error[E0277]: `*mut _` cannot be shared between threads safely
--> /git/trybuild/test_suite/tests/ui/compile-fail-3.rs:7:5
|
7 | thread::spawn(|| {
| ^^^^^^^^^^^^^ `*mut _` cannot be shared between threads safely
|
= help: the trait `std::marker::Sync` is not implemented for `*mut _`
= note: required because of the requirements on the impl of `std::marker::Send` for `&*mut _`
= note: required because it appears within the type `[closure@/git/trybuild/test_suite/ui/compile-fail-3.rs:7:19: 9:6 x:&*mut _]`
" "
error[E0277]: `*mut _` cannot be shared between threads safely
--> tests/ui/compile-fail-3.rs:7:5
|
7 | thread::spawn(|| {
| ^^^^^^^^^^^^^ `*mut _` cannot be shared between threads safely
|
= help: the trait `std::marker::Sync` is not implemented for `*mut _`
= note: required because of the requirements on the impl of `std::marker::Send` for `&*mut _`
= note: required because it appears within the type `[closure@$DIR/ui/compile-fail-3.rs:7:19: 9:6 x:&*mut _]`
"}
test_normalize! {test_strip_path_dependencies "
error[E0277]: the trait bound `diesel::query_builder::SelectStatement<users::table, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, diesel::query_builder::where_clause::WhereClause<diesel::expression::grouped::Grouped<diesel::expression::operators::Eq<posts::columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, i32>>>>>: diesel::query_builder::IntoUpdateTarget` is not satisfied
--> $DIR/update_requires_valid_where_clause.rs:21:12
|
21 | update(users::table.filter(posts::id.eq(1)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `diesel::query_builder::IntoUpdateTarget` is not implemented for `diesel::query_builder::SelectStatement<users::table, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, diesel::query_builder::where_clause::WhereClause<diesel::expression::grouped::Grouped<diesel::expression::operators::Eq<posts::columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, i32>>>>>`
|
::: /home/user/documents/rust/diesel/diesel/src/query_builder/functions.rs:78:18
|
78 | pub fn update<T: IntoUpdateTarget>(source: T) -> UpdateStatement<T::Table, T::WhereClause> {
| ---------------- required by this bound in `diesel::update`
|
= help: the following implementations were found:
<diesel::query_builder::SelectStatement<F, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, W> as diesel::query_builder::IntoUpdateTarget>
" "
error[E0277]: the trait bound `diesel::query_builder::SelectStatement<users::table, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, diesel::query_builder::where_clause::WhereClause<diesel::expression::grouped::Grouped<diesel::expression::operators::Eq<posts::columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, i32>>>>>: diesel::query_builder::IntoUpdateTarget` is not satisfied
--> $DIR/update_requires_valid_where_clause.rs:21:12
|
21 | update(users::table.filter(posts::id.eq(1)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `diesel::query_builder::IntoUpdateTarget` is not implemented for `diesel::query_builder::SelectStatement<users::table, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, diesel::query_builder::where_clause::WhereClause<diesel::expression::grouped::Grouped<diesel::expression::operators::Eq<posts::columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, i32>>>>>`
|
::: $DIESEL/src/query_builder/functions.rs
|
| pub fn update<T: IntoUpdateTarget>(source: T) -> UpdateStatement<T::Table, T::WhereClause> {
| ---------------- required by this bound in `diesel::update`
|
= help: the following implementations were found:
<diesel::query_builder::SelectStatement<F, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, W> as diesel::query_builder::IntoUpdateTarget>
"}
test_normalize! {test_cargo_registry "
error[E0277]: the trait bound `Thread: serde::de::Deserialize<'_>` is not satisfied
--> src/main.rs:2:36
|
2 | let _ = serde_json::from_str::<std::thread::Thread>(\"???\");
| ^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `Thread`
|
::: /home/ferris/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.64/src/de.rs:2584:8
|
2584 | T: de::Deserialize<'a>,
| ------------------- required by this bound in `serde_json::from_str`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `testing` due to previous error
" "
error[E0277]: the trait bound `Thread: serde::de::Deserialize<'_>` is not satisfied
--> src/main.rs:2:36
|
2 | let _ = serde_json::from_str::<std::thread::Thread>(\"???\");
| ^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `Thread`
|
::: $CARGO/serde_json-1.0.64/src/de.rs
|
| T: de::Deserialize<'a>,
| ------------------- required by this bound in `serde_json::from_str`
"}
test_normalize! {test_traits_must_be_implemented "
error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied
--> src/main.rs:7:13
|
4 | struct Error;
| -------------
| |
| doesn't satisfy `Error: Into<anyhow::Error>`
| doesn't satisfy `Error: anyhow::private::kind::TraitKind`
| doesn't satisfy `Error: std::fmt::Display`
...
7 | let _ = anyhow!(Error);
| ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`Error: Into<anyhow::Error>`
which is required by `Error: anyhow::private::kind::TraitKind`
`Error: std::fmt::Display`
which is required by `&Error: anyhow::private::kind::AdhocKind`
`&Error: Into<anyhow::Error>`
which is required by `&Error: anyhow::private::kind::TraitKind`
note: the following traits must be implemented
--> /rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:274:1
|
274 | / pub trait Into<T>: Sized {
275 | | /// Performs the conversion.
276 | | #[stable(feature = \"rust1\", since = \"1.0.0\")]
277 | | fn into(self) -> T;
278 | | }
| |_^
|
::: /rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:715:1
|
715 | / pub trait Display {
716 | | /// Formats the value using the given formatter.
717 | | ///
718 | | /// # Examples
... |
738 | | fn fmt(&self, f: &mut Formatter<'_>) -> Result;
739 | | }
| |_^
= note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info)
" "
error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied
--> src/main.rs:7:13
|
4 | struct Error;
| -------------
| |
| doesn't satisfy `Error: Into<anyhow::Error>`
| doesn't satisfy `Error: anyhow::private::kind::TraitKind`
| doesn't satisfy `Error: std::fmt::Display`
...
7 | let _ = anyhow!(Error);
| ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`Error: Into<anyhow::Error>`
which is required by `Error: anyhow::private::kind::TraitKind`
`Error: std::fmt::Display`
which is required by `&Error: anyhow::private::kind::AdhocKind`
`&Error: Into<anyhow::Error>`
which is required by `&Error: anyhow::private::kind::TraitKind`
note: the following traits must be implemented
--> $RUST/core/src/convert/mod.rs
|
| / pub trait Into<T>: Sized {
| | /// Performs the conversion.
| | #[stable(feature = \"rust1\", since = \"1.0.0\")]
| | fn into(self) -> T;
| | }
| |_^
|
::: $RUST/core/src/fmt/mod.rs
|
| / pub trait Display {
| | /// Formats the value using the given formatter.
| | ///
| | /// # Examples
... |
| | fn fmt(&self, f: &mut Formatter<'_>) -> Result;
| | }
| |_^
= note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info)
"}
test_normalize! {test_pyo3_url
DIR="/pyo3"
WORKSPACE="/pyo3"
"
error: `async fn` is not yet supported for Python functions.
Additional crates such as `pyo3-asyncio` can be used to integrate async Rust and Python. For more information, see https://github.com/PyO3/pyo3/issues/1632
--> tests/ui/invalid_pyfunctions.rs:10:1
|
10 | async fn async_function() {}
| ^^^^^
" "
error: `async fn` is not yet supported for Python functions.
Additional crates such as `pyo3-asyncio` can be used to integrate async Rust and Python. For more information, see https://github.com/PyO3/pyo3/issues/1632
--> tests/ui/invalid_pyfunctions.rs:10:1
|
10 | async fn async_function() {}
| ^^^^^
"}
test_normalize! {test_dropshot_required_by
DIR="/git/dropshot/dropshot"
WORKSPACE="/git/dropshot"
INPUT="tests/fail/bad_endpoint4.rs"
"
error[E0277]: the trait bound `QueryParams: schemars::JsonSchema` is not satisfied
--> /git/dropshot/dropshot/tests/fail/bad_endpoint4.rs:24:14
|
24 | _params: Query<QueryParams>,
| ^^^^^^^^^^^^^^^^^^ the trait `schemars::JsonSchema` is not implemented for `QueryParams`
|
note: required by a bound in `dropshot::Query`
--> /git/dropshot/dropshot/src/handler.rs:547:48
|
547 | pub struct Query<QueryType: DeserializeOwned + JsonSchema + Send + Sync> {
| ^^^^^^^^^^ required by this bound in `dropshot::Query`
"
"
error[E0277]: the trait bound `QueryParams: schemars::JsonSchema` is not satisfied
--> tests/fail/bad_endpoint4.rs:24:14
|
24 | _params: Query<QueryParams>,
| ^^^^^^^^^^^^^^^^^^ the trait `schemars::JsonSchema` is not implemented for `QueryParams`
|
note: required by a bound in `dropshot::Query`
--> src/handler.rs
|
| pub struct Query<QueryType: DeserializeOwned + JsonSchema + Send + Sync> {
| ^^^^^^^^^^ required by this bound in `dropshot::Query`
"}
test_normalize! {test_uniffi_out_dir
DIR="/git/uniffi-rs/fixtures/uitests"
WORKSPACE="/git/uniffi-rs"
TARGET="/git/uniffi-rs/target"
"
error[E0277]: the trait bound `Arc<Counter>: FfiConverter` is not satisfied
--> /git/uniffi-rs/target/debug/build/uniffi_uitests-1a51d46aecb559a7/out/counter.uniffi.rs:160:19
|
160 | match <std::sync::Arc<Counter> as uniffi::FfiConverter>::try_lift(ptr) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FfiConverter` is not implemented for `Arc<Counter>`
|
= help: the following implementations were found:
<Arc<T> as FfiConverter>
= note: required by `try_lift`
" "
error[E0277]: the trait bound `Arc<Counter>: FfiConverter` is not satisfied
--> $OUT_DIR[uniffi_uitests]/counter.uniffi.rs
|
| match <std::sync::Arc<Counter> as uniffi::FfiConverter>::try_lift(ptr) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FfiConverter` is not implemented for `Arc<Counter>`
|
= help: the following implementations were found:
<Arc<T> as FfiConverter>
= note: required by `try_lift`
"}
test_normalize! {test_proc_macro_panic
DIR="D:\\repro"
INPUT="tests\\ui\\nonzero_fail.rs"
"
error[E0080]: evaluation of constant value failed
--> D:\\repro\\tests\\ui\\nonzero_fail.rs:7:10
|
7 | #[derive(NonZeroRepr)]
| ^^^^^^^^^^^ the evaluated program panicked at 'expected non-zero discriminant expression', D:\\repro\\tests\\ui\\nonzero_fail.rs:7:10
" "
error[E0080]: evaluation of constant value failed
--> tests/ui/nonzero_fail.rs:7:10
|
7 | #[derive(NonZeroRepr)]
| ^^^^^^^^^^^ the evaluated program panicked at 'expected non-zero discriminant expression', $DIR/tests/ui/nonzero_fail.rs:7:10
"}
test_normalize! {test_and_n_others "
error[E0277]: no implementation for `u8 >> &str`
--> src/main.rs:2:20
|
2 | let _x = 42_u8 >> \"bar\";
| ^^ no implementation for `u8 >> &str`
|
= help: the trait `Shr<&str>` is not implemented for `u8`
= help: the following other types implement trait `Shr<Rhs>`:
<&'a i128 as Shr<i128>>
<&'a i128 as Shr<i16>>
<&'a i128 as Shr<i32>>
<&'a i128 as Shr<i64>>
<&'a i128 as Shr<i8>>
<&'a i128 as Shr<isize>>
<&'a i128 as Shr<u128>>
<&'a i128 as Shr<u16>>
and 568 others
" "
error[E0277]: no implementation for `u8 >> &str`
--> src/main.rs:2:20
|
2 | let _x = 42_u8 >> \"bar\";
| ^^ no implementation for `u8 >> &str`
|
= help: the trait `Shr<&str>` is not implemented for `u8`
= help: the following other types implement trait `Shr<Rhs>`:
<&'a i128 as Shr<i128>>
<&'a i128 as Shr<i16>>
<&'a i128 as Shr<i32>>
<&'a i128 as Shr<i64>>
<&'a i128 as Shr<i8>>
<&'a i128 as Shr<isize>>
<&'a i128 as Shr<u128>>
<&'a i128 as Shr<u16>>
and $N others
"}
test_normalize! {test_long_file_names "
error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<...>>>>>>`
--> src/main.rs:18:11
|
18 | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `test` defined here
--> src/main.rs:16:1
|
16 | fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: the full type name has been written to `/playground/target/debug/deps/playground-c53df771d95c66fb.c7a39e8d0dd9c781.long-type-16688711729771999621.txt`
the full type name has been written to `/playground/target/debug/deps/playground-c53df771d95c66fb.c7a39e8d0dd9c781.long-type-16688711729771999621.txt`
" "
error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<...>>>>>>`
--> src/main.rs:18:11
|
18 | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `test` defined here
--> src/main.rs:16:1
|
16 | fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"
}