Skip to content

Commit 7b17de6

Browse files
committed
Improve 'sync_db_pools' codegen. Update UI tests.
1 parent a811a18 commit 7b17de6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2257
-1113
lines changed

contrib/db_pools/codegen/tests/ui-fail-stable/database-syntax.stderr

+32-26
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,115 @@
11
error: invalid value: expected string literal
2-
--> $DIR/database-syntax.rs:4:12
2+
--> tests/ui-fail-stable/database-syntax.rs:4:12
33
|
44
4 | #[database(123)]
55
| ^^^
66

77
error: [note] error occurred while deriving `Database`
8-
--> $DIR/database-syntax.rs:3:10
8+
--> tests/ui-fail-stable/database-syntax.rs:3:10
99
|
1010
3 | #[derive(Database)]
1111
| ^^^^^^^^
1212
|
1313
= note: this error originates in the derive macro `Database` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
error: expected key/value `key = value`
16-
--> $DIR/database-syntax.rs:8:25
16+
--> tests/ui-fail-stable/database-syntax.rs:8:25
1717
|
1818
8 | #[database("some-name", "another")]
1919
| ^^^^^^^^^
2020

2121
error: [note] error occurred while deriving `Database`
22-
--> $DIR/database-syntax.rs:7:10
22+
--> tests/ui-fail-stable/database-syntax.rs:7:10
2323
|
2424
7 | #[derive(Database)]
2525
| ^^^^^^^^
2626
|
2727
= note: this error originates in the derive macro `Database` (in Nightly builds, run with -Z macro-backtrace for more info)
2828

2929
error: unexpected attribute parameter: `name`
30-
--> $DIR/database-syntax.rs:12:25
30+
--> tests/ui-fail-stable/database-syntax.rs:12:25
3131
|
3232
12 | #[database("some-name", name = "another")]
33-
| ^^^^
33+
| ^^^^^^^^^^^^^^^^
3434

3535
error: [note] error occurred while deriving `Database`
36-
--> $DIR/database-syntax.rs:11:10
36+
--> tests/ui-fail-stable/database-syntax.rs:11:10
3737
|
3838
11 | #[derive(Database)]
3939
| ^^^^^^^^
4040
|
4141
= note: this error originates in the derive macro `Database` (in Nightly builds, run with -Z macro-backtrace for more info)
4242

4343
error: enums are not supported
44-
--> $DIR/database-syntax.rs:16:1
44+
--> tests/ui-fail-stable/database-syntax.rs:16:1
4545
|
46-
16 | #[database("foo")]
47-
| ^
46+
16 | / #[database("foo")]
47+
17 | | enum D { }
48+
| |___________^
4849

4950
error: [note] error occurred while deriving `Database`
50-
--> $DIR/database-syntax.rs:15:10
51+
--> tests/ui-fail-stable/database-syntax.rs:15:10
5152
|
5253
15 | #[derive(Database)]
5354
| ^^^^^^^^
5455
|
5556
= note: this error originates in the derive macro `Database` (in Nightly builds, run with -Z macro-backtrace for more info)
5657

5758
error: missing `#[database("name")]` attribute
58-
--> $DIR/database-syntax.rs:20:1
59+
--> tests/ui-fail-stable/database-syntax.rs:20:1
5960
|
6061
20 | struct E(deadpool_postgres::Pool);
61-
| ^^^^^^
62+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6263

6364
error: [note] error occurred while deriving `Database`
64-
--> $DIR/database-syntax.rs:19:10
65+
--> tests/ui-fail-stable/database-syntax.rs:19:10
6566
|
6667
19 | #[derive(Database)]
6768
| ^^^^^^^^
6869
|
6970
= note: this error originates in the derive macro `Database` (in Nightly builds, run with -Z macro-backtrace for more info)
7071

7172
error: struct must have exactly one unnamed field
72-
--> $DIR/database-syntax.rs:23:1
73+
--> tests/ui-fail-stable/database-syntax.rs:23:1
7374
|
74-
23 | #[database("foo")]
75-
| ^
75+
23 | / #[database("foo")]
76+
24 | | struct F;
77+
| |_________^
7678

7779
error: [note] error occurred while deriving `Database`
78-
--> $DIR/database-syntax.rs:22:10
80+
--> tests/ui-fail-stable/database-syntax.rs:22:10
7981
|
8082
22 | #[derive(Database)]
8183
| ^^^^^^^^
8284
|
8385
= note: this error originates in the derive macro `Database` (in Nightly builds, run with -Z macro-backtrace for more info)
8486

8587
error: struct must have exactly one unnamed field
86-
--> $DIR/database-syntax.rs:27:1
88+
--> tests/ui-fail-stable/database-syntax.rs:27:1
8789
|
88-
27 | #[database("foo")]
89-
| ^
90+
27 | / #[database("foo")]
91+
28 | | struct G(deadpool_postgres::Pool, deadpool_postgres::Pool);
92+
| |___________________________________________________________^
9093

9194
error: [note] error occurred while deriving `Database`
92-
--> $DIR/database-syntax.rs:26:10
95+
--> tests/ui-fail-stable/database-syntax.rs:26:10
9396
|
9497
26 | #[derive(Database)]
9598
| ^^^^^^^^
9699
|
97100
= note: this error originates in the derive macro `Database` (in Nightly builds, run with -Z macro-backtrace for more info)
98101

99102
error: named structs are not supported
100-
--> $DIR/database-syntax.rs:31:1
103+
--> tests/ui-fail-stable/database-syntax.rs:31:1
101104
|
102-
31 | #[database("foo")]
103-
| ^
105+
31 | / #[database("foo")]
106+
32 | | struct H {
107+
33 | | foo: deadpool_postgres::Pool,
108+
34 | | }
109+
| |_^
104110

105111
error: [note] error occurred while deriving `Database`
106-
--> $DIR/database-syntax.rs:30:10
112+
--> tests/ui-fail-stable/database-syntax.rs:30:10
107113
|
108114
30 | #[derive(Database)]
109115
| ^^^^^^^^

contrib/sync_db_pools/codegen/src/database.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ pub fn database_attr(attr: TokenStream, input: TokenStream) -> Result<TokenStrea
7373
let rocket = quote!(#root::rocket);
7474

7575
let request_guard_type = quote_spanned! { span =>
76-
#(#attrs)* #vis struct #guard_type(#root::Connection<Self, #conn_type>);
76+
#(#attrs)* #vis struct #guard_type(#[allow(dead_code)] #root::Connection<Self, #conn_type>);
7777
};
7878

7979
let pool = quote_spanned!(span => #root::ConnectionPool<Self, #conn_type>);
8080
let conn = quote_spanned!(span => #root::Connection<Self, #conn_type>);
8181

82-
Ok(quote! {
82+
Ok(quote_spanned! { span =>
8383
#request_guard_type
8484

85+
#[allow(dead_code)]
8586
impl #guard_type {
8687
/// Returns a fairing that initializes the database connection pool.
8788
pub fn fairing() -> impl #rocket::fairing::Fairing {

0 commit comments

Comments
 (0)