Skip to content

Commit a8a0579

Browse files
authored
Treat warnings as errors on CI builds (#2651)
1 parent a824e84 commit a8a0579

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

.github/workflows/examples.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
--release
3434
--no-default-features
3535
--features mysql,postgres,sqlite
36+
env:
37+
RUSTFLAGS: -D warnings
3638

3739
- uses: actions/upload-artifact@v3
3840
with:
@@ -157,10 +159,9 @@ jobs:
157159
# so we only check that it compiles.
158160
- name: Chat (Check)
159161
uses: actions-rs/cargo@v1
160-
env:
161162
with:
162163
command: check
163-
args: -p sqlx-example-postgres-check
164+
args: -p sqlx-example-postgres-chat
164165

165166
- name: Files (Setup)
166167
working-directory: examples/postgres/files

.github/workflows/sqlx.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@ jobs:
5555
--manifest-path sqlx-core/Cargo.toml
5656
--no-default-features
5757
--features json,offline,migrate,_rt-${{ matrix.runtime }},_tls-${{ matrix.tls }}
58+
env:
59+
RUSTFLAGS: -D warnings
5860

5961
- uses: actions-rs/cargo@v1
6062
with:
6163
command: check
6264
args: >
6365
--no-default-features
6466
--features all-databases,_unstable-all-types,runtime-${{ matrix.runtime }},tls-${{ matrix.tls }},macros
67+
env:
68+
RUSTFLAGS: -D warnings
6569

6670
test:
6771
name: Unit Test
@@ -211,7 +215,7 @@ jobs:
211215
env:
212216
SQLX_OFFLINE: true
213217
SQLX_OFFLINE_DIR: .sqlx
214-
RUSTFLAGS: --cfg sqlite_ipaddr
218+
RUSTFLAGS: -D warnings --cfg sqlite_ipaddr
215219
LD_LIBRARY_PATH: /tmp/sqlite3-lib
216220

217221
# Test macros in offline mode (still needs DATABASE_URL to run)
@@ -255,7 +259,7 @@ jobs:
255259
env:
256260
# FIXME: needed to disable `ltree` tests in Postgres 9.6
257261
# but `PgLTree` should just fall back to text format
258-
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
262+
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
259263
with:
260264
command: build
261265
args: >
@@ -311,7 +315,7 @@ jobs:
311315
SQLX_OFFLINE_DIR: .sqlx
312316
# FIXME: needed to disable `ltree` tests in Postgres 9.6
313317
# but `PgLTree` should just fall back to text format
314-
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
318+
RUSTFLAGS: -D warnings --cfg postgres_${{ matrix.postgres }}
315319

316320
# Test macros in offline mode (still needs DATABASE_URL to run)
317321
- uses: actions-rs/cargo@v1
@@ -421,7 +425,7 @@ jobs:
421425
env:
422426
SQLX_OFFLINE: true
423427
SQLX_OFFLINE_DIR: .sqlx
424-
RUSTFLAGS: --cfg mysql_${{ matrix.mysql }}
428+
RUSTFLAGS: -D warnings --cfg mysql_${{ matrix.mysql }}
425429

426430
# Test macros in offline mode (still needs DATABASE_URL to run)
427431
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
@@ -517,7 +521,7 @@ jobs:
517521
env:
518522
SQLX_OFFLINE: true
519523
SQLX_OFFLINE_DIR: .sqlx
520-
RUSTFLAGS: --cfg mariadb_${{ matrix.mariadb }}
524+
RUSTFLAGS: -D warnings --cfg mariadb_${{ matrix.mariadb }}
521525

522526
# Test macros in offline mode (still needs DATABASE_URL to run)
523527
- uses: actions-rs/cargo@v1

sqlx-macros-core/src/database/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ pub trait DatabaseExt: Database {
3939
fn describe_blocking(query: &str, database_url: &str) -> sqlx_core::Result<Describe<Self>>;
4040
}
4141

42+
#[allow(dead_code)]
4243
pub struct CachingDescribeBlocking<DB: DatabaseExt> {
4344
connections: Lazy<Mutex<HashMap<String, DB::Connection>>>,
4445
}
4546

47+
#[allow(dead_code)]
4648
impl<DB: DatabaseExt> CachingDescribeBlocking<DB> {
4749
pub const fn new() -> Self {
4850
CachingDescribeBlocking {

sqlx-macros-core/src/test_attr.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
use proc_macro2::{Span, TokenStream};
1+
use proc_macro2::TokenStream;
22
use quote::quote;
3-
use syn::LitStr;
43

4+
#[cfg(feature = "migrate")]
55
struct Args {
6-
fixtures: Vec<LitStr>,
6+
fixtures: Vec<syn::LitStr>,
77
migrations: MigrationsOpt,
88
}
99

10+
#[cfg(feature = "migrate")]
1011
enum MigrationsOpt {
1112
InferredPath,
12-
ExplicitPath(LitStr),
13+
ExplicitPath(syn::LitStr),
1314
ExplicitMigrator(syn::Path),
1415
Disabled,
1516
}
@@ -89,7 +90,8 @@ fn expand_advanced(args: syn::AttributeArgs, input: syn::ItemFn) -> crate::Resul
8990
quote! { args.migrator(&#migrator); }
9091
}
9192
MigrationsOpt::InferredPath if !inputs.is_empty() => {
92-
let migrations_path = crate::common::resolve_path("./migrations", Span::call_site())?;
93+
let migrations_path =
94+
crate::common::resolve_path("./migrations", proc_macro2::Span::call_site())?;
9395

9496
if migrations_path.is_dir() {
9597
let migrator = crate::migrate::expand_migrator(&migrations_path)?;

0 commit comments

Comments
 (0)