Skip to content

Commit 03bcfe9

Browse files
committed
Skip formatting some macros, update UI tests
1 parent 4404638 commit 03bcfe9

23 files changed

+1046
-1224
lines changed

rustfmt.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ format_code_in_doc_comments = true
1010
format_macro_bodies = true
1111
format_macro_matchers = true
1212
format_strings = true
13-
imports_granularity = "Module"
1413
group_imports = "StdExternalCrate"
14+
imports_granularity = "Module"
1515
normalize_doc_attributes = true
16+
skip_macro_invocations = ["date", "time", "offset"]
1617
wrap_comments = true

tests/compile-fail/invalid_date.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ use time::macros::date;
22

33
fn main() {
44
let _ = date!(+1_000_000-01-01);
5-
let _ = date!(10_000 - 01 - 01);
5+
let _ = date!(10_000-01-01);
66
let _ = date!(2021-W 60-1);
77
let _ = date!(2021-W 01-0);
88
let _ = date!(2021-W 01-8);
9-
let _ = date!(2021 - 00 - 01);
10-
let _ = date!(2021 - 13 - 01);
11-
let _ = date!(2021 - 01 - 00);
12-
let _ = date!(2021 - 01 - 32);
13-
let _ = date!(2021 - 000);
14-
let _ = date!(2021 - 366);
9+
let _ = date!(2021-00-01);
10+
let _ = date!(2021-13-01);
11+
let _ = date!(2021-01-00);
12+
let _ = date!(2021-01-32);
13+
let _ = date!(2021-000);
14+
let _ = date!(2021-366);
1515
let _ = date!(0a);
1616
let _ = date!(2021:);
1717
let _ = date!(2021-W 0a);
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,107 @@
11
error: invalid component: year was 1000000
2-
--> $DIR/invalid_date.rs:4:19
2+
--> ../tests/compile-fail/invalid_date.rs:4:19
33
|
44
4 | let _ = date!(+1_000_000-01-01);
55
| ^^^^^^^^^^
66

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

103103
error: invalid component: day was 0a
104-
--> $DIR/invalid_date.rs:21:27
104+
--> ../tests/compile-fail/invalid_date.rs:21:27
105105
|
106106
21 | let _ = date!(2021-01-0a);
107107
| ^^
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use time::macros::datetime;
22

33
fn main() {
4-
let _ = datetime!(2021 - 000 0:00);
5-
let _ = datetime!(2021 - 001 24:00);
6-
let _ = datetime!(2021 - 001 0:00 0);
7-
let _ = datetime!(2021 - 001 0:00 UTC x);
4+
let _ = datetime!(2021-000 0:00);
5+
let _ = datetime!(2021-001 24:00);
6+
let _ = datetime!(2021-001 0:00 0);
7+
let _ = datetime!(2021-001 0:00 UTC x);
88
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: invalid component: ordinal was 0
2-
--> $DIR/invalid_datetime.rs:4:30
2+
--> ../tests/compile-fail/invalid_datetime.rs:4:28
33
|
4-
4 | let _ = datetime!(2021 - 000 0:00);
5-
| ^^^
4+
4 | let _ = datetime!(2021-000 0:00);
5+
| ^^^
66

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

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

1919
error: unexpected token: x
20-
--> $DIR/invalid_datetime.rs:7:43
20+
--> ../tests/compile-fail/invalid_datetime.rs:7:41
2121
|
22-
7 | let _ = datetime!(2021 - 001 0:00 UTC x);
23-
| ^
22+
7 | let _ = datetime!(2021-001 0:00 UTC x);
23+
| ^

tests/compile-fail/invalid_serializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ serde::format_description!(my_format, OffsetDateTime,); // missing string format
1111
serde::format_description!(my_format, OffsetDateTime "[year] [month]"); // missing comma
1212
serde::format_description!(my_format, OffsetDateTime : "[year] [month]"); // not a comma
1313
serde::format_description!(my_format, OffsetDateTime, "[bad]"); // bad component name
14-
serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
14+
serde::format_description!(my_format, OffsetDateTime, not_string); // not in scope
1515

1616
fn main() {}

tests/compile-fail/invalid_serializer.stderr

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,42 +72,8 @@ error: invalid component
7272
13 | serde::format_description!(my_format, OffsetDateTime, "[bad]"); // bad component name
7373
| ^^^^^^^
7474

75-
error[E0432]: unresolved import `not_string`
76-
--> ../tests/compile-fail/invalid_serializer.rs:14:1
75+
error[E0425]: cannot find value `not_string` in this scope
76+
--> ../tests/compile-fail/invalid_serializer.rs:14:55
7777
|
78-
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
79-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no external crate `not_string`
80-
|
81-
= note: this error originates in the macro `serde::format_description` (in Nightly builds, run with -Z macro-backtrace for more info)
82-
83-
error[E0391]: cycle detected when computing type of opaque `my_format::description::{opaque#0}`
84-
--> ../tests/compile-fail/invalid_serializer.rs:14:1
85-
|
86-
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
87-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88-
|
89-
note: ...which requires borrow-checking `my_format::description`...
90-
--> ../tests/compile-fail/invalid_serializer.rs:14:1
91-
|
92-
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
93-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94-
note: ...which requires promoting constants in MIR for `my_format::description`...
95-
--> ../tests/compile-fail/invalid_serializer.rs:14:1
96-
|
97-
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
98-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99-
note: ...which requires const checking `my_format::description`...
100-
--> ../tests/compile-fail/invalid_serializer.rs:14:1
101-
|
102-
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
103-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104-
= note: ...which requires computing whether `my_format::description::{opaque#0}` is freeze...
105-
= note: ...which requires evaluating trait selection obligation `my_format::description::{opaque#0}: core::marker::Freeze`...
106-
= note: ...which again requires computing type of opaque `my_format::description::{opaque#0}`, completing the cycle
107-
note: cycle used when computing type of `my_format::description::{opaque#0}`
108-
--> ../tests/compile-fail/invalid_serializer.rs:14:1
109-
|
110-
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
111-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112-
= 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
113-
= note: this error originates in the macro `serde::format_description` (in Nightly builds, run with -Z macro-backtrace for more info)
78+
14 | serde::format_description!(my_format, OffsetDateTime, not_string); // not in scope
79+
| ^^^^^^^^^^ not found in this scope
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
11
error: invalid component: hour was 24
2-
--> $DIR/invalid_time.rs:4:19
2+
--> ../tests/compile-fail/invalid_time.rs:4:19
33
|
44
4 | let _ = time!(24:00);
55
| ^^
66

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

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)