Skip to content

Commit 245ae7d

Browse files
authored
Merge pull request #958 from Lorak-mmk/remove-unreachable-pubs
Remove unreachable pubs
2 parents 7b3e73e + ce0e9f7 commit 245ae7d

File tree

19 files changed

+116
-102
lines changed

19 files changed

+116
-102
lines changed

scylla-cql/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ num-bigint-03 = ["dep:num-bigint-03"]
4444
num-bigint-04 = ["dep:num-bigint-04"]
4545
bigdecimal-04 = ["dep:bigdecimal-04"]
4646
full-serialization = ["chrono", "time", "secret", "num-bigint-03", "num-bigint-04", "bigdecimal-04"]
47+
48+
[lints.rust]
49+
unreachable_pub = "warn"

scylla-macros/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ proc-macro = true
1515
darling = "0.20.0"
1616
syn = "2.0"
1717
quote = "1.0"
18-
proc-macro2 = "1.0"
18+
proc-macro2 = "1.0"
19+
20+
[lints.rust]
21+
unreachable_pub = "warn"

scylla-macros/src/from_row.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use quote::{quote, quote_spanned};
33
use syn::{spanned::Spanned, DeriveInput};
44

55
/// #[derive(FromRow)] derives FromRow for struct
6-
pub fn from_row_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
6+
pub(crate) fn from_row_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
77
let item = syn::parse::<DeriveInput>(tokens_input)?;
88
let path = crate::parser::get_path(&item)?;
99
let struct_fields = crate::parser::parse_named_fields(&item, "FromRow")?;

scylla-macros/src/from_user_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use quote::{quote, quote_spanned};
33
use syn::{spanned::Spanned, DeriveInput};
44

55
/// #[derive(FromUserType)] allows to parse a struct as User Defined Type
6-
pub fn from_user_type_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
6+
pub(crate) fn from_user_type_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
77
let item = syn::parse::<DeriveInput>(tokens_input)?;
88
let path = crate::parser::get_path(&item)?;
99
let struct_fields = crate::parser::parse_named_fields(&item, "FromUserType")?;

scylla-macros/src/into_user_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use quote::{quote, quote_spanned};
33
use syn::{spanned::Spanned, DeriveInput};
44

55
/// #[derive(IntoUserType)] allows to parse a struct as User Defined Type
6-
pub fn into_user_type_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
6+
pub(crate) fn into_user_type_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
77
let item = syn::parse::<DeriveInput>(tokens_input)?;
88
let path = crate::parser::get_path(&item)?;
99
let struct_fields = crate::parser::parse_named_fields(&item, "IntoUserType")?;

scylla-macros/src/serialize/cql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct Context {
6161
fields: Vec<Field>,
6262
}
6363

64-
pub fn derive_serialize_cql(tokens_input: TokenStream) -> Result<syn::ItemImpl, syn::Error> {
64+
pub(crate) fn derive_serialize_cql(tokens_input: TokenStream) -> Result<syn::ItemImpl, syn::Error> {
6565
let input: syn::DeriveInput = syn::parse(tokens_input)?;
6666
let struct_name = input.ident.clone();
6767
let named_fields = crate::parser::parse_named_fields(&input, "SerializeCql")?;

scylla-macros/src/serialize/row.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct Context {
5858
fields: Vec<Field>,
5959
}
6060

61-
pub fn derive_serialize_row(tokens_input: TokenStream) -> Result<syn::ItemImpl, syn::Error> {
61+
pub(crate) fn derive_serialize_row(tokens_input: TokenStream) -> Result<syn::ItemImpl, syn::Error> {
6262
let input: syn::DeriveInput = syn::parse(tokens_input)?;
6363
let struct_name = input.ident.clone();
6464
let named_fields = crate::parser::parse_named_fields(&input, "SerializeRow")?;

scylla-macros/src/value_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use syn::DeriveInput;
44

55
/// #[derive(ValueList)] allows to parse a struct as a list of values,
66
/// which can be fed to the query directly.
7-
pub fn value_list_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
7+
pub(crate) fn value_list_derive(tokens_input: TokenStream) -> Result<TokenStream, syn::Error> {
88
let item = syn::parse::<DeriveInput>(tokens_input)?;
99
let path = crate::parser::get_path(&item)?;
1010
let struct_fields = crate::parser::parse_named_fields(&item, "ValueList")?;

scylla-proxy/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ ntest = "0.9.0"
3232
tracing-subscriber = { version = "0.3.14", features = ["env-filter"] }
3333
tokio = { version = "1.12", features = ["signal"] }
3434

35+
[lints.rust]
36+
unreachable_pub = "warn"

scylla-proxy/src/actions.rs

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ use crate::{
88
frame::{FrameOpcode, FrameParams, RequestFrame, RequestOpcode, ResponseFrame, ResponseOpcode},
99
TargetShard,
1010
};
11-
use scylla_cql::{
12-
errors::{DbError, WriteType},
13-
Consistency,
14-
};
11+
use scylla_cql::errors::DbError;
1512

1613
/// Specifies when an associated [Reaction] will be performed.
1714
/// Conditions are subject to logic, with `not()`, `and()` and `or()`
@@ -407,8 +404,13 @@ impl RequestReaction {
407404
}
408405
}
409406

410-
struct ExampleDbErrors;
411-
impl ExampleDbErrors {
407+
pub mod example_db_errors {
408+
use bytes::Bytes;
409+
use scylla_cql::{
410+
errors::{DbError, WriteType},
411+
Consistency,
412+
};
413+
412414
pub fn syntax_error() -> DbError {
413415
DbError::SyntaxError
414416
}
@@ -507,84 +509,84 @@ pub struct ResponseForger;
507509

508510
impl ResponseForger {
509511
pub fn syntax_error(&self) -> RequestReaction {
510-
RequestReaction::forge_with_error(ExampleDbErrors::syntax_error())
512+
RequestReaction::forge_with_error(example_db_errors::syntax_error())
511513
}
512514
pub fn invalid(&self) -> RequestReaction {
513-
RequestReaction::forge_with_error(ExampleDbErrors::invalid())
515+
RequestReaction::forge_with_error(example_db_errors::invalid())
514516
}
515517
pub fn already_exists(&self) -> RequestReaction {
516-
RequestReaction::forge_with_error(ExampleDbErrors::already_exists())
518+
RequestReaction::forge_with_error(example_db_errors::already_exists())
517519
}
518520
pub fn function_failure(&self) -> RequestReaction {
519-
RequestReaction::forge_with_error(ExampleDbErrors::function_failure())
521+
RequestReaction::forge_with_error(example_db_errors::function_failure())
520522
}
521523
pub fn authentication_error(&self) -> RequestReaction {
522-
RequestReaction::forge_with_error(ExampleDbErrors::authentication_error())
524+
RequestReaction::forge_with_error(example_db_errors::authentication_error())
523525
}
524526
pub fn unauthorized(&self) -> RequestReaction {
525-
RequestReaction::forge_with_error(ExampleDbErrors::unauthorized())
527+
RequestReaction::forge_with_error(example_db_errors::unauthorized())
526528
}
527529
pub fn config_error(&self) -> RequestReaction {
528-
RequestReaction::forge_with_error(ExampleDbErrors::config_error())
530+
RequestReaction::forge_with_error(example_db_errors::config_error())
529531
}
530532
pub fn unavailable(&self) -> RequestReaction {
531-
RequestReaction::forge_with_error(ExampleDbErrors::unavailable())
533+
RequestReaction::forge_with_error(example_db_errors::unavailable())
532534
}
533535
pub fn overloaded(&self) -> RequestReaction {
534-
RequestReaction::forge_with_error(ExampleDbErrors::overloaded())
536+
RequestReaction::forge_with_error(example_db_errors::overloaded())
535537
}
536538
pub fn is_bootstrapping(&self) -> RequestReaction {
537-
RequestReaction::forge_with_error(ExampleDbErrors::is_bootstrapping())
539+
RequestReaction::forge_with_error(example_db_errors::is_bootstrapping())
538540
}
539541
pub fn truncate_error(&self) -> RequestReaction {
540-
RequestReaction::forge_with_error(ExampleDbErrors::truncate_error())
542+
RequestReaction::forge_with_error(example_db_errors::truncate_error())
541543
}
542544
pub fn read_timeout(&self) -> RequestReaction {
543-
RequestReaction::forge_with_error(ExampleDbErrors::read_timeout())
545+
RequestReaction::forge_with_error(example_db_errors::read_timeout())
544546
}
545547
pub fn write_timeout(&self) -> RequestReaction {
546-
RequestReaction::forge_with_error(ExampleDbErrors::write_timeout())
548+
RequestReaction::forge_with_error(example_db_errors::write_timeout())
547549
}
548550
pub fn read_failure(&self) -> RequestReaction {
549-
RequestReaction::forge_with_error(ExampleDbErrors::read_failure())
551+
RequestReaction::forge_with_error(example_db_errors::read_failure())
550552
}
551553
pub fn write_failure(&self) -> RequestReaction {
552-
RequestReaction::forge_with_error(ExampleDbErrors::write_failure())
554+
RequestReaction::forge_with_error(example_db_errors::write_failure())
553555
}
554556
pub fn unprepared(&self) -> RequestReaction {
555-
RequestReaction::forge_with_error(ExampleDbErrors::unprepared())
557+
RequestReaction::forge_with_error(example_db_errors::unprepared())
556558
}
557559
pub fn server_error(&self) -> RequestReaction {
558-
RequestReaction::forge_with_error(ExampleDbErrors::server_error())
560+
RequestReaction::forge_with_error(example_db_errors::server_error())
559561
}
560562
pub fn protocol_error(&self) -> RequestReaction {
561-
RequestReaction::forge_with_error(ExampleDbErrors::protocol_error())
563+
RequestReaction::forge_with_error(example_db_errors::protocol_error())
562564
}
563565
pub fn other(&self, num: i32) -> RequestReaction {
564-
RequestReaction::forge_with_error(ExampleDbErrors::other(num))
566+
RequestReaction::forge_with_error(example_db_errors::other(num))
565567
}
566568
pub fn random_error(&self) -> RequestReaction {
567569
self.random_error_with_delay(None)
568570
}
569571
pub fn random_error_with_delay(&self, delay: Option<Duration>) -> RequestReaction {
570572
static ERRORS: &[fn() -> DbError] = &[
571-
ExampleDbErrors::invalid,
572-
ExampleDbErrors::already_exists,
573-
ExampleDbErrors::function_failure,
574-
ExampleDbErrors::authentication_error,
575-
ExampleDbErrors::unauthorized,
576-
ExampleDbErrors::config_error,
577-
ExampleDbErrors::unavailable,
578-
ExampleDbErrors::overloaded,
579-
ExampleDbErrors::is_bootstrapping,
580-
ExampleDbErrors::truncate_error,
581-
ExampleDbErrors::read_timeout,
582-
ExampleDbErrors::write_timeout,
583-
ExampleDbErrors::write_failure,
584-
ExampleDbErrors::unprepared,
585-
ExampleDbErrors::server_error,
586-
ExampleDbErrors::protocol_error,
587-
|| ExampleDbErrors::other(2137),
573+
example_db_errors::invalid,
574+
example_db_errors::already_exists,
575+
example_db_errors::function_failure,
576+
example_db_errors::authentication_error,
577+
example_db_errors::unauthorized,
578+
example_db_errors::config_error,
579+
example_db_errors::unavailable,
580+
example_db_errors::overloaded,
581+
example_db_errors::is_bootstrapping,
582+
example_db_errors::truncate_error,
583+
example_db_errors::read_timeout,
584+
example_db_errors::write_timeout,
585+
example_db_errors::write_failure,
586+
example_db_errors::unprepared,
587+
example_db_errors::server_error,
588+
example_db_errors::protocol_error,
589+
|| example_db_errors::other(2137),
588590
];
589591
RequestReaction::forge_with_error_lazy_delay(
590592
Box::new(|| ERRORS[rand::thread_rng().next_u32() as usize % ERRORS.len()]()),

0 commit comments

Comments
 (0)