Skip to content

Commit f7c56c0

Browse files
committed
codewide: enable additional type-related lints
This commit enables two additional lints in the Scylla Rust wrapper, which have successfully caught some issues in the codebase: - `unnameable_types`, - `unreachable_pub`. Both have already been used in the Rust Driver. As some problems: - either were not possible to be fixed, because they are caused by the bindgen-generated code, - or would require a lot of changes in the codebase and are not worth it right now (e.g., `CassSession` and `CassRetryPolicy`), this commit adds `#[expect(unnameable_types)]` and `#[expect(unreachable_pub)]` attributes to the affected structs.
1 parent ab081ad commit f7c56c0

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

scylla-rust-wrapper/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ strip = "none"
6060

6161
[lints.rust]
6262
unsafe-op-in-unsafe-fn = "warn"
63+
unnameable_types = "warn"
64+
unreachable_pub = "warn"
6365
unexpected_cfgs = { level = "warn", check-cfg = [
6466
'cfg(cpp_integration_testing)',
6567
] }

scylla-rust-wrapper/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub mod types {
5959
// for `cass_false` and `cass_true` globals.
6060
#![allow(non_upper_case_globals)]
6161
#![allow(unused)]
62+
#![allow(unreachable_pub, unnameable_types)]
6263

6364
// Definition for size_t (and possibly other types in the future)
6465
include_bindgen_generated!("basic_types.rs");
@@ -67,43 +68,56 @@ pub mod types {
6768
/// CassError, CassErrorSource, CassWriteType
6869
pub(crate) mod cass_error_types {
6970
#![allow(unused)]
71+
#![allow(unreachable_pub, unnameable_types)]
72+
7073
include_bindgen_generated!("cppdriver_error_types.rs");
7174
}
7275

7376
/// CassValueType
7477
pub(crate) mod cass_data_types {
7578
#![allow(unused)]
79+
#![allow(unreachable_pub, unnameable_types)]
80+
7681
include_bindgen_generated!("cppdriver_data_types.rs");
7782
}
7883

7984
/// CassConsistency
8085
pub(crate) mod cass_consistency_types {
8186
#![allow(unused)]
87+
#![allow(unreachable_pub, unnameable_types)]
88+
8289
include_bindgen_generated!("cppdriver_consistency_types.rs");
8390
}
8491

8592
/// CassBatchType
8693
pub(crate) mod cass_batch_types {
8794
#![allow(unused)]
95+
#![allow(unreachable_pub, unnameable_types)]
96+
8897
include_bindgen_generated!("cppdriver_batch_types.rs");
8998
}
9099

91100
/// CassCompressionType
92101
pub(crate) mod cass_compression_types {
93102
#![allow(unused)]
103+
#![allow(unreachable_pub, unnameable_types)]
104+
94105
include_bindgen_generated!("cppdriver_compression_types.rs");
95106
}
96107

97108
/// CassCollectionType
98109
pub(crate) mod cass_collection_types {
99110
#![allow(unused)]
111+
#![allow(unreachable_pub, unnameable_types)]
112+
100113
include_bindgen_generated!("cppdriver_collection_types.rs");
101114
}
102115

103116
/// CassInet
104117
pub(crate) mod cass_inet_types {
105118
#![allow(unused)]
106119
#![allow(non_camel_case_types, non_snake_case)]
120+
#![allow(unreachable_pub, unnameable_types)]
107121

108122
include_bindgen_generated!("cppdriver_inet_types.rs");
109123
}
@@ -112,13 +126,15 @@ pub(crate) mod cass_inet_types {
112126
pub(crate) mod cass_log_types {
113127
#![allow(unused)]
114128
#![allow(non_camel_case_types, non_snake_case)]
129+
#![allow(unreachable_pub, unnameable_types)]
115130

116131
include_bindgen_generated!("cppdriver_log_types.rs");
117132
}
118133

119134
/// CassColumnType
120135
pub(crate) mod cass_column_types {
121136
#![allow(unused)]
137+
#![allow(unreachable_pub, unnameable_types)]
122138

123139
include_bindgen_generated!("cppdriver_column_type.rs");
124140
}
@@ -127,13 +143,15 @@ pub(crate) mod cass_column_types {
127143
pub(crate) mod cass_uuid_types {
128144
#![allow(unused)]
129145
#![allow(non_camel_case_types, non_snake_case)]
146+
#![allow(unreachable_pub, unnameable_types)]
130147

131148
include_bindgen_generated!("cppdriver_uuid_types.rs");
132149
}
133150

134151
/// CassIteratorType
135152
pub(crate) mod cass_iterator_types {
136153
#![allow(unused)]
154+
#![allow(unreachable_pub, unnameable_types)]
137155

138156
include_bindgen_generated!("cppdriver_iterator_types.rs");
139157
}
@@ -142,6 +160,7 @@ pub(crate) mod cass_iterator_types {
142160
pub(crate) mod cass_metrics_types {
143161
#![allow(unused)]
144162
#![allow(non_camel_case_types, non_snake_case)]
163+
#![allow(unreachable_pub, unnameable_types)]
145164

146165
include_bindgen_generated!("cppdriver_metrics_types.rs");
147166
}

scylla-rust-wrapper/src/retry_policy.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ use std::sync::Arc;
66

77
use crate::argconv::{ArcFFI, CMut, CassBorrowedSharedPtr, CassOwnedSharedPtr, FFI, FromArc};
88

9+
// Technically, we should not allow this struct to be public,
10+
// but this would require a lot of changes in the codebase:
11+
// CassRetryPolicy would need to be a newtype wrapper around
12+
// an additional inner enum.
13+
#[expect(unnameable_types)]
914
#[derive(Debug)]
10-
pub(crate) struct CassLoggingRetryPolicy {
15+
pub struct CassLoggingRetryPolicy {
1116
child_policy: Arc<CassRetryPolicy>,
1217
}
1318

scylla-rust-wrapper/src/session.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ use std::sync::Arc;
3232
use std::time::Duration;
3333
use tokio::sync::RwLock;
3434

35+
// Technically, we should not allow this struct to be public,
36+
// but this would require a lot of changes in the codebase:
37+
// CassSession would need to be a newtype wrapper around this struct
38+
// instead of a type alias.
39+
#[expect(unnameable_types)]
3540
pub struct CassSessionInner {
3641
session: Session,
3742
exec_profile_map: HashMap<ExecProfileName, ExecutionProfileHandle>,

0 commit comments

Comments
 (0)