Skip to content

Commit cdfc57c

Browse files
authored
Use Windows 2022 in CI & fix Rust 1.89 clippy (#380)
1 parent 8336549 commit cdfc57c

File tree

14 files changed

+43
-38
lines changed

14 files changed

+43
-38
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
os:
2424
- ubuntu-latest
2525
- macos-13
26-
- windows-2019
26+
- windows-latest
2727
runs-on: ${{ matrix.os }}
2828
defaults:
2929
run:
@@ -41,6 +41,7 @@ jobs:
4141
- name: Setup PostgreSQL on Linux
4242
if: runner.os == 'Linux'
4343
run: |
44+
set -ex
4445
sudo apt-get update
4546
sudo apt-get install -y postgresql
4647
sudo sed -i "s/scram-sha-256/trust/" /etc/postgresql/16/main/pg_hba.conf
@@ -51,6 +52,7 @@ jobs:
5152
- name: Setup PostgreSQL on MacOS
5253
if: runner.os == 'macOS'
5354
run: |
55+
set -ex
5456
brew install postgresql
5557
initdb -D /usr/local/var/postgres
5658
pg_ctl -D /usr/local/var/postgres start
@@ -59,8 +61,8 @@ jobs:
5961
echo BUTANE_PG_CONNSTR="host=localhost user=postgres sslmode=disable port=5432" >> $GITHUB_ENV
6062
- name: Install PostgreSQL on Windows
6163
if: runner.os == 'Windows'
62-
shell: bash
6364
run: |
65+
set -ex
6466
choco install postgresql12 --force --params '/Password:root'
6567
echo "C:\Program Files\PostgreSQL\12\bin" >> $GITHUB_PATH
6668
echo "C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_PATH
@@ -72,7 +74,7 @@ jobs:
7274
run: |
7375
choco install sqlite
7476
cd /D C:\ProgramData\chocolatey\lib\SQLite\tools
75-
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
77+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
7678
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib
7779
echo "C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_PATH
7880
echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_ENV
@@ -116,6 +118,7 @@ jobs:
116118
git diff --cached --exit-code
117119
- name: Run tests in examples
118120
run: |
121+
set -ex
119122
cargo +stable test -p example --all-features
120123
cd examples
121124
for dir in *; do

butane_core/src/custom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub enum SqlValCustom {
3333
}
3434

3535
impl SqlValCustom {
36-
pub fn as_valref(&self) -> SqlValRefCustom {
36+
pub fn as_valref(&self) -> SqlValRefCustom<'_> {
3737
match self {
3838
#[cfg(feature = "pg")]
3939
SqlValCustom::Pg { ty, data } => SqlValRefCustom::PgBytes {

butane_core/src/db/connmethods.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Column {
9191
/// Backend-specific row abstraction. Only implementors of new
9292
/// backends need use this trait directly.
9393
pub trait BackendRow {
94-
fn get(&self, idx: usize, ty: SqlType) -> Result<SqlValRef>;
94+
fn get(&self, idx: usize, ty: SqlType) -> Result<SqlValRef<'_>>;
9595
fn len(&self) -> usize;
9696
// clippy wants this method to exist
9797
fn is_empty(&self) -> bool {
@@ -111,7 +111,7 @@ pub trait BackendRows {
111111
fn mapped<F, B>(self, f: F) -> MapDeref<Self, F>
112112
where
113113
Self: Sized,
114-
F: FnMut(&(dyn BackendRow)) -> Result<B>,
114+
F: FnMut(&dyn BackendRow) -> Result<B>,
115115
{
116116
MapDeref { it: self, f }
117117
}
@@ -126,7 +126,7 @@ pub struct MapDeref<I, F> {
126126
impl<I, F, B> fallible_iterator::FallibleIterator for MapDeref<I, F>
127127
where
128128
I: BackendRows,
129-
F: FnMut(&(dyn BackendRow)) -> Result<B>,
129+
F: FnMut(&dyn BackendRow) -> Result<B>,
130130
{
131131
type Item = B;
132132
type Error = crate::Error;
@@ -171,23 +171,23 @@ impl<T> BackendRows for VecRows<T>
171171
where
172172
T: BackendRow,
173173
{
174-
fn next(&mut self) -> Result<Option<&(dyn BackendRow)>> {
174+
fn next(&mut self) -> Result<Option<&dyn BackendRow>> {
175175
let ret = self.rows.get(self.idx);
176176
self.idx += 1;
177177
Ok(ret.map(|row| row as &dyn BackendRow))
178178
}
179179

180-
fn current(&self) -> Option<&(dyn BackendRow)> {
180+
fn current(&self) -> Option<&dyn BackendRow> {
181181
self.rows.get(self.idx).map(|row| row as &dyn BackendRow)
182182
}
183183
}
184184

185185
impl BackendRows for Box<dyn BackendRows + '_> {
186-
fn next(&mut self) -> Result<Option<&(dyn BackendRow)>> {
186+
fn next(&mut self) -> Result<Option<&dyn BackendRow>> {
187187
BackendRows::next(self.deref_mut())
188188
}
189189

190-
fn current(&self) -> Option<&(dyn BackendRow)> {
190+
fn current(&self) -> Option<&dyn BackendRow> {
191191
self.deref().current()
192192
}
193193
}
@@ -200,7 +200,7 @@ pub(crate) struct VecRow {
200200

201201
#[cfg(feature = "async-adapter")]
202202
impl VecRow {
203-
fn new(original: &(dyn BackendRow), columns: &[Column]) -> Result<Self> {
203+
fn new(original: &dyn BackendRow, columns: &[Column]) -> Result<Self> {
204204
if original.len() != columns.len() {
205205
return Err(crate::Error::BoundsError(
206206
"row length doesn't match columns specifier length".into(),
@@ -220,7 +220,7 @@ impl VecRow {
220220

221221
#[cfg(feature = "async-adapter")]
222222
impl BackendRow for VecRow {
223-
fn get(&self, idx: usize, ty: SqlType) -> Result<SqlValRef> {
223+
fn get(&self, idx: usize, ty: SqlType) -> Result<SqlValRef<'_>> {
224224
self.values
225225
.get(idx)
226226
.ok_or_else(|| crate::Error::BoundsError("idx out of bounds".into()))

butane_core/src/db/helper.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ use crate::query::{BoolExpr::*, Expr, Join, Order, OrderDirection};
1313
use crate::Error;
1414
use crate::{query, Result, SqlType, SqlVal};
1515

16-
pub trait PlaceholderSource {
17-
fn next_placeholder(&mut self) -> Cow<str>;
16+
/// Trait for generating SQL placeholders.
17+
pub(crate) trait PlaceholderSource {
18+
/// Returns the next placeholder for a parameterized query.
19+
fn next_placeholder(&mut self) -> Cow<'_, str>;
1820
}
1921

2022
/// Quotes the `word` if it is a reserved word.
21-
pub fn quote_reserved_word(word: &str) -> Cow<str> {
23+
pub fn quote_reserved_word(word: &str) -> Cow<'_, str> {
2224
if sqlparser::keywords::ALL_KEYWORDS.contains(&word.to_uppercase().as_str()) {
2325
format!("\"{}\"", word).into()
2426
} else {

butane_core/src/db/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub trait BackendConnection: ConnectionMethods + Debug + Send {
117117
)]
118118
#[async_trait]
119119
impl BackendConnection for Box<dyn BackendConnection> {
120-
async fn transaction(&mut self) -> Result<Transaction> {
120+
async fn transaction(&mut self) -> Result<Transaction<'_>> {
121121
self.deref_mut().transaction().await
122122
}
123123
fn backend(&self) -> Box<dyn Backend> {
@@ -299,7 +299,7 @@ impl ConnectionAsync {
299299
)]
300300
#[async_trait]
301301
impl BackendConnection for Connection {
302-
async fn transaction(&mut self) -> Result<Transaction> {
302+
async fn transaction(&mut self) -> Result<Transaction<'_>> {
303303
self.conn.transaction().await
304304
}
305305
fn backend(&self) -> Box<dyn Backend> {
@@ -690,7 +690,7 @@ impl TryFrom<&String> for ConnectionSpec {
690690
}
691691
}
692692

693-
fn conn_complete_if_dir(path: &Path) -> Cow<Path> {
693+
fn conn_complete_if_dir(path: &Path) -> Cow<'_, Path> {
694694
if path.is_dir() {
695695
Cow::from(path.join("connection.json"))
696696
} else {

butane_core/src/db/pg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Debug for PgConnection {
140140
}
141141
}
142142

143-
type DynToSqlPg<'a> = (dyn postgres::types::ToSql + Sync + 'a);
143+
type DynToSqlPg<'a> = dyn postgres::types::ToSql + Sync + 'a;
144144

145145
fn sqlval_for_pg_query(v: &SqlVal) -> &dyn postgres::types::ToSql {
146146
v as &dyn postgres::types::ToSql
@@ -545,7 +545,7 @@ fn check_columns(row: &postgres::Row, cols: &[Column]) -> Result<()> {
545545
}
546546

547547
impl BackendRow for postgres::Row {
548-
fn get(&self, idx: usize, _ty: SqlType) -> Result<SqlValRef> {
548+
fn get(&self, idx: usize, _ty: SqlType) -> Result<SqlValRef<'_>> {
549549
Ok(self.try_get(idx)?)
550550
}
551551
fn len(&self) -> usize {
@@ -695,7 +695,7 @@ fn drop_fkey_constraints(table: &ATable, column: &AColumn) -> Result<String> {
695695
modified_column.remove_reference();
696696
change_column(table, column, &modified_column)
697697
}
698-
fn col_sqltype(col: &AColumn) -> Result<Cow<str>> {
698+
fn col_sqltype(col: &AColumn) -> Result<Cow<'_, str>> {
699699
match col.typeid()? {
700700
TypeIdentifier::Name(name) => Ok(Cow::Owned(name)),
701701
TypeIdentifier::Ty(ty) => {
@@ -930,7 +930,7 @@ impl PgPlaceholderSource {
930930
}
931931
}
932932
impl helper::PlaceholderSource for PgPlaceholderSource {
933-
fn next_placeholder(&mut self) -> Cow<str> {
933+
fn next_placeholder(&mut self) -> Cow<'_, str> {
934934
let ret = Cow::Owned(format!("${}", self.n));
935935
self.n += 1;
936936
ret

butane_core/src/db/sqlite.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ impl<'a> QueryAdapterInner<'a> {
569569
Ok(rows.next()?)
570570
}
571571

572-
fn current(self: Pin<&Self>) -> Option<&rusqlite::Row> {
572+
fn current(self: Pin<&Self>) -> Option<&rusqlite::Row<'_>> {
573573
let this = self.project_ref();
574574
this.rows.as_ref().unwrap().get()
575575
}
@@ -604,7 +604,7 @@ impl BackendRows for QueryAdapter<'_> {
604604
}
605605

606606
impl BackendRow for rusqlite::Row<'_> {
607-
fn get(&self, idx: usize, ty: SqlType) -> Result<SqlValRef> {
607+
fn get(&self, idx: usize, ty: SqlType) -> Result<SqlValRef<'_>> {
608608
sql_valref_from_rusqlite(self.get_ref(idx)?, &ty)
609609
}
610610
fn len(&self) -> usize {
@@ -751,7 +751,7 @@ fn define_constraint(column: &AColumn) -> String {
751751
}
752752
}
753753

754-
fn col_sqltype(col: &AColumn) -> Cow<str> {
754+
fn col_sqltype(col: &AColumn) -> Cow<'_, str> {
755755
match col.typeid() {
756756
Ok(TypeIdentifier::Ty(ty)) => Cow::Borrowed(sqltype(&ty)),
757757
Ok(TypeIdentifier::Name(name)) => Cow::Owned(name),
@@ -911,7 +911,7 @@ impl SQLitePlaceholderSource {
911911
}
912912
}
913913
impl helper::PlaceholderSource for SQLitePlaceholderSource {
914-
fn next_placeholder(&mut self) -> Cow<str> {
914+
fn next_placeholder(&mut self) -> Cow<'_, str> {
915915
// sqlite placeholder is always a question mark.
916916
Cow::Borrowed("?")
917917
}

butane_core/src/fkey.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<T> AsPrimaryKey<T> for ForeignKey<T>
153153
where
154154
T: DataObject,
155155
{
156-
fn as_pk(&self) -> Cow<T::PKType> {
156+
fn as_pk(&self) -> Cow<'_, T::PKType> {
157157
Cow::Owned(self.pk())
158158
}
159159
}

butane_core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub mod internal {
8989

9090
/// Returns the Sql values of all columns except not any auto columns.
9191
/// Used internally. You are unlikely to need to call this directly.
92-
fn non_auto_values(&self, include_pk: bool) -> Vec<SqlValRef>;
92+
fn non_auto_values(&self, include_pk: bool) -> Vec<SqlValRef<'_>>;
9393
}
9494
}
9595

butane_core/src/migrations/fsmigrations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ impl Migration for FsMigration {
311311
Ok(db)
312312
}
313313

314-
fn migration_from(&self) -> Result<Option<Cow<str>>> {
314+
fn migration_from(&self) -> Result<Option<Cow<'_, str>>> {
315315
Ok(self.info()?.from_name.map(Cow::from))
316316
}
317317

318-
fn name(&self) -> Cow<str> {
318+
fn name(&self) -> Cow<'_, str> {
319319
// There should be no way our root has no name portion
320320
self.root.file_name().unwrap().to_string_lossy()
321321
}

0 commit comments

Comments
 (0)