Skip to content

Commit

Permalink
Skip formatting some macros, update UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Dec 3, 2024
1 parent 4404638 commit 03bcfe9
Show file tree
Hide file tree
Showing 23 changed files with 1,046 additions and 1,224 deletions.
3 changes: 2 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ format_code_in_doc_comments = true
format_macro_bodies = true
format_macro_matchers = true
format_strings = true
imports_granularity = "Module"
group_imports = "StdExternalCrate"
imports_granularity = "Module"
normalize_doc_attributes = true
skip_macro_invocations = ["date", "time", "offset"]
wrap_comments = true
14 changes: 7 additions & 7 deletions tests/compile-fail/invalid_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ use time::macros::date;

fn main() {
let _ = date!(+1_000_000-01-01);
let _ = date!(10_000 - 01 - 01);
let _ = date!(10_000-01-01);
let _ = date!(2021-W 60-1);
let _ = date!(2021-W 01-0);
let _ = date!(2021-W 01-8);
let _ = date!(2021 - 00 - 01);
let _ = date!(2021 - 13 - 01);
let _ = date!(2021 - 01 - 00);
let _ = date!(2021 - 01 - 32);
let _ = date!(2021 - 000);
let _ = date!(2021 - 366);
let _ = date!(2021-00-01);
let _ = date!(2021-13-01);
let _ = date!(2021-01-00);
let _ = date!(2021-01-32);
let _ = date!(2021-000);
let _ = date!(2021-366);
let _ = date!(0a);
let _ = date!(2021:);
let _ = date!(2021-W 0a);
Expand Down
62 changes: 31 additions & 31 deletions tests/compile-fail/invalid_date.stderr
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
error: invalid component: year was 1000000
--> $DIR/invalid_date.rs:4:19
--> ../tests/compile-fail/invalid_date.rs:4:19
|
4 | let _ = date!(+1_000_000-01-01);
| ^^^^^^^^^^

error: years with more than four digits must have an explicit sign
--> $DIR/invalid_date.rs:5:19
--> ../tests/compile-fail/invalid_date.rs:5:19
|
5 | let _ = date!(10_000 - 01 - 01);
5 | let _ = date!(10_000-01-01);
| ^^^^^^

error: invalid component: week was 60
--> $DIR/invalid_date.rs:6:24
--> ../tests/compile-fail/invalid_date.rs:6:24
|
6 | let _ = date!(2021-W 60-1);
| ^^^^

error: invalid component: day was 0
--> $DIR/invalid_date.rs:7:29
--> ../tests/compile-fail/invalid_date.rs:7:29
|
7 | let _ = date!(2021-W 01-0);
| ^

error: invalid component: day was 8
--> $DIR/invalid_date.rs:8:29
--> ../tests/compile-fail/invalid_date.rs:8:29
|
8 | let _ = date!(2021-W 01-8);
| ^

error: invalid component: month was 0
--> $DIR/invalid_date.rs:9:26
--> ../tests/compile-fail/invalid_date.rs:9:24
|
9 | let _ = date!(2021 - 00 - 01);
| ^^
9 | let _ = date!(2021-00-01);
| ^^

error: invalid component: month was 13
--> $DIR/invalid_date.rs:10:26
--> ../tests/compile-fail/invalid_date.rs:10:24
|
10 | let _ = date!(2021 - 13 - 01);
| ^^
10 | let _ = date!(2021-13-01);
| ^^

error: invalid component: day was 0
--> $DIR/invalid_date.rs:11:31
--> ../tests/compile-fail/invalid_date.rs:11:27
|
11 | let _ = date!(2021 - 01 - 00);
| ^^
11 | let _ = date!(2021-01-00);
| ^^

error: invalid component: day was 32
--> $DIR/invalid_date.rs:12:31
--> ../tests/compile-fail/invalid_date.rs:12:27
|
12 | let _ = date!(2021 - 01 - 32);
| ^^
12 | let _ = date!(2021-01-32);
| ^^

error: invalid component: ordinal was 0
--> $DIR/invalid_date.rs:13:26
--> ../tests/compile-fail/invalid_date.rs:13:24
|
13 | let _ = date!(2021 - 000);
| ^^^
13 | let _ = date!(2021-000);
| ^^^

error: invalid component: ordinal was 366
--> $DIR/invalid_date.rs:14:26
--> ../tests/compile-fail/invalid_date.rs:14:24
|
14 | let _ = date!(2021 - 366);
| ^^^
14 | let _ = date!(2021-366);
| ^^^

error: invalid component: year was 0a
--> $DIR/invalid_date.rs:15:19
--> ../tests/compile-fail/invalid_date.rs:15:19
|
15 | let _ = date!(0a);
| ^^

error: unexpected token: :
--> $DIR/invalid_date.rs:16:23
--> ../tests/compile-fail/invalid_date.rs:16:23
|
16 | let _ = date!(2021:);
| ^

error: invalid component: week was 0a
--> $DIR/invalid_date.rs:17:26
--> ../tests/compile-fail/invalid_date.rs:17:26
|
17 | let _ = date!(2021-W 0a);
| ^^

error: unexpected token: :
--> $DIR/invalid_date.rs:18:28
--> ../tests/compile-fail/invalid_date.rs:18:28
|
18 | let _ = date!(2021-W 01:);
| ^

error: invalid component: day was 0a
--> $DIR/invalid_date.rs:19:29
--> ../tests/compile-fail/invalid_date.rs:19:29
|
19 | let _ = date!(2021-W 01-0a);
| ^^

error: invalid component: month or ordinal was 0a
--> $DIR/invalid_date.rs:20:24
--> ../tests/compile-fail/invalid_date.rs:20:24
|
20 | let _ = date!(2021-0a);
| ^^

error: invalid component: day was 0a
--> $DIR/invalid_date.rs:21:27
--> ../tests/compile-fail/invalid_date.rs:21:27
|
21 | let _ = date!(2021-01-0a);
| ^^
8 changes: 4 additions & 4 deletions tests/compile-fail/invalid_datetime.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use time::macros::datetime;

fn main() {
let _ = datetime!(2021 - 000 0:00);
let _ = datetime!(2021 - 001 24:00);
let _ = datetime!(2021 - 001 0:00 0);
let _ = datetime!(2021 - 001 0:00 UTC x);
let _ = datetime!(2021-000 0:00);
let _ = datetime!(2021-001 24:00);
let _ = datetime!(2021-001 0:00 0);
let _ = datetime!(2021-001 0:00 UTC x);
}
24 changes: 12 additions & 12 deletions tests/compile-fail/invalid_datetime.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: invalid component: ordinal was 0
--> $DIR/invalid_datetime.rs:4:30
--> ../tests/compile-fail/invalid_datetime.rs:4:28
|
4 | let _ = datetime!(2021 - 000 0:00);
| ^^^
4 | let _ = datetime!(2021-000 0:00);
| ^^^

error: invalid component: hour was 24
--> $DIR/invalid_datetime.rs:5:34
--> ../tests/compile-fail/invalid_datetime.rs:5:32
|
5 | let _ = datetime!(2021 - 001 24:00);
| ^^
5 | let _ = datetime!(2021-001 24:00);
| ^^

error: unexpected token: 0
--> $DIR/invalid_datetime.rs:6:39
--> ../tests/compile-fail/invalid_datetime.rs:6:37
|
6 | let _ = datetime!(2021 - 001 0:00 0);
| ^
6 | let _ = datetime!(2021-001 0:00 0);
| ^

error: unexpected token: x
--> $DIR/invalid_datetime.rs:7:43
--> ../tests/compile-fail/invalid_datetime.rs:7:41
|
7 | let _ = datetime!(2021 - 001 0:00 UTC x);
| ^
7 | let _ = datetime!(2021-001 0:00 UTC x);
| ^
2 changes: 1 addition & 1 deletion tests/compile-fail/invalid_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ serde::format_description!(my_format, OffsetDateTime,); // missing string format
serde::format_description!(my_format, OffsetDateTime "[year] [month]"); // missing comma
serde::format_description!(my_format, OffsetDateTime : "[year] [month]"); // not a comma
serde::format_description!(my_format, OffsetDateTime, "[bad]"); // bad component name
serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
serde::format_description!(my_format, OffsetDateTime, not_string); // not in scope

fn main() {}
42 changes: 4 additions & 38 deletions tests/compile-fail/invalid_serializer.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -72,42 +72,8 @@ error: invalid component
13 | serde::format_description!(my_format, OffsetDateTime, "[bad]"); // bad component name
| ^^^^^^^

error[E0432]: unresolved import `not_string`
--> ../tests/compile-fail/invalid_serializer.rs:14:1
error[E0425]: cannot find value `not_string` in this scope
--> ../tests/compile-fail/invalid_serializer.rs:14:55
|
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no external crate `not_string`
|
= note: this error originates in the macro `serde::format_description` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0391]: cycle detected when computing type of opaque `my_format::description::{opaque#0}`
--> ../tests/compile-fail/invalid_serializer.rs:14:1
|
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires borrow-checking `my_format::description`...
--> ../tests/compile-fail/invalid_serializer.rs:14:1
|
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires promoting constants in MIR for `my_format::description`...
--> ../tests/compile-fail/invalid_serializer.rs:14:1
|
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `my_format::description`...
--> ../tests/compile-fail/invalid_serializer.rs:14:1
|
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing whether `my_format::description::{opaque#0}` is freeze...
= note: ...which requires evaluating trait selection obligation `my_format::description::{opaque#0}: core::marker::Freeze`...
= note: ...which again requires computing type of opaque `my_format::description::{opaque#0}`, completing the cycle
note: cycle used when computing type of `my_format::description::{opaque#0}`
--> ../tests/compile-fail/invalid_serializer.rs:14:1
|
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
= note: this error originates in the macro `serde::format_description` (in Nightly builds, run with -Z macro-backtrace for more info)
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // not in scope
| ^^^^^^^^^^ not found in this scope
26 changes: 13 additions & 13 deletions tests/compile-fail/invalid_time.stderr
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
error: invalid component: hour was 24
--> $DIR/invalid_time.rs:4:19
--> ../tests/compile-fail/invalid_time.rs:4:19
|
4 | let _ = time!(24:00);
| ^^

error: invalid component: minute was 60
--> $DIR/invalid_time.rs:5:21
--> ../tests/compile-fail/invalid_time.rs:5:21
|
5 | let _ = time!(0:60);
| ^^

error: invalid component: second was 60
--> $DIR/invalid_time.rs:6:24
--> ../tests/compile-fail/invalid_time.rs:6:24
|
6 | let _ = time!(0:00:60);
| ^^

error: unexpected token: x
--> $DIR/invalid_time.rs:7:19
--> ../tests/compile-fail/invalid_time.rs:7:19
|
7 | let _ = time!(x);
| ^

error: unexpected token: x
--> $DIR/invalid_time.rs:8:27
--> ../tests/compile-fail/invalid_time.rs:8:27
|
8 | let _ = time!(0:00:00 x);
| ^

error: invalid component: hour was ""
--> $DIR/invalid_time.rs:9:19
--> ../tests/compile-fail/invalid_time.rs:9:19
|
9 | let _ = time!("");
| ^^

error: unexpected end of input
--> $DIR/invalid_time.rs:10:13
--> ../tests/compile-fail/invalid_time.rs:10:13
|
10 | let _ = time!(0:);
| ^^^^^^^^^
|
= note: this error originates in the macro `time` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unexpected token: ,
--> $DIR/invalid_time.rs:11:20
--> ../tests/compile-fail/invalid_time.rs:11:20
|
11 | let _ = time!(0,);
| ^

error: invalid component: second was 0a
--> $DIR/invalid_time.rs:12:24
--> ../tests/compile-fail/invalid_time.rs:12:24
|
12 | let _ = time!(0:00:0a);
| ^^

error: invalid component: hour was 0
--> $DIR/invalid_time.rs:13:19
--> ../tests/compile-fail/invalid_time.rs:13:19
|
13 | let _ = time!(0:00 pm);
| ^^^^^^^

error: unexpected end of input
--> $DIR/invalid_time.rs:14:13
--> ../tests/compile-fail/invalid_time.rs:14:13
|
14 | let _ = time!(0);
| ^^^^^^^^
|
= note: this error originates in the macro `time` (in Nightly builds, run with -Z macro-backtrace for more info)

error: invalid component: hour was 0
--> $DIR/invalid_time.rs:15:19
--> ../tests/compile-fail/invalid_time.rs:15:19
|
15 | let _ = time!(0 pm);
| ^^^^

error: unexpected token: :
--> $DIR/invalid_time.rs:16:24
--> ../tests/compile-fail/invalid_time.rs:16:24
|
16 | let _ = time!(1 am :);
| ^
Loading

0 comments on commit 03bcfe9

Please sign in to comment.