Skip to content

Commit

Permalink
Update the cfg recommended by rustc book
Browse files Browse the repository at this point in the history
  • Loading branch information
Spxg committed Jan 7, 2025
1 parent d751944 commit aeac2ee
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ downcast-rs = "1.2.1"
version = "~2.2.0"
path = "../diesel_derives"

[target.'cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))'.dependencies]
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
libsqlite3-sys = { version = ">=0.17.2, <0.31.0", optional = true, features = ["bundled_bindings"] }

[target.'cfg(all(target_family = "wasm", not(target_os = "wasi")))'.dependencies]
[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies]
sqlite-wasm-rs = { version = "0.1.1", optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ pub mod prelude {
// Initializing the database is a one-time operation during
// the life of the program.
#[cfg(feature = "sqlite")]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
pub use sqlite_wasm_rs::init_sqlite;
}

Expand Down
4 changes: 2 additions & 2 deletions diesel/src/sqlite/connection/bind_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::serialize::{IsNull, Output};
use crate::sql_types::HasSqlType;
use crate::sqlite::{Sqlite, SqliteType};
use crate::QueryResult;
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
use libsqlite3_sys as ffi;
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use sqlite_wasm_rs::c as ffi;

#[derive(Debug, Default)]
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/sqlite/connection/functions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
extern crate libsqlite3_sys as ffi;

#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use sqlite_wasm_rs::c as ffi;

use super::raw::RawConnection;
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/sqlite/connection/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
extern crate libsqlite3_sys as ffi;

#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use sqlite_wasm_rs::c as ffi;

mod bind_collector;
Expand Down
10 changes: 5 additions & 5 deletions diesel/src/sqlite/connection/raw.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![allow(unsafe_code)] // ffi calls
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
extern crate libsqlite3_sys as ffi;

#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use sqlite_wasm_rs::c as ffi;

use std::ffi::{CString, NulError};
Expand Down Expand Up @@ -53,17 +53,17 @@ impl RawConnection {
// This support is only available when sqlite is loaded from a
// Worker thread, whether it's loaded in its own dedicated worker
// or in a worker together with client code.
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
let vfs = CString::new("opfs")?;

let connection_status = unsafe {
ffi::sqlite3_open_v2(
database_url.as_ptr(),
&mut conn_pointer,
flags,
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
ptr::null(),
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
vfs.as_ptr(),
)
};
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/sqlite/connection/serialized_database.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![allow(unsafe_code)]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
extern crate libsqlite3_sys as ffi;

#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use sqlite_wasm_rs::c as ffi;

use std::ops::Deref;
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/sqlite/connection/sqlite_value.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![allow(unsafe_code)] // ffi calls
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
extern crate libsqlite3_sys as ffi;

#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use sqlite_wasm_rs::c as ffi;

use std::cell::Ref;
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/sqlite/connection/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::query_builder::{QueryFragment, QueryId};
use crate::result::Error::DatabaseError;
use crate::result::*;
use crate::sqlite::{Sqlite, SqliteType};
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
use libsqlite3_sys as ffi;
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
use sqlite_wasm_rs::c as ffi;
use std::cell::OnceCell;
use std::ffi::{CStr, CString};
Expand Down

0 comments on commit aeac2ee

Please sign in to comment.