Skip to content

Commit 1f1fbd6

Browse files
authored
Upgrade to Rust 1.90 (#5909)
1 parent 0de3d84 commit 1f1fbd6

File tree

59 files changed

+465
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+465
-515
lines changed

quickwit/quickwit-cli/src/generate_markdown.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ fn markdown_for_command_helper(
8181
if !about.trim().is_empty() {
8282
println!("{about} ");
8383
}
84-
} else if let Some(about) = subcommand.get_about() {
85-
if !about.to_string().trim().is_empty() {
86-
println!("{about} ");
87-
}
84+
} else if let Some(about) = subcommand.get_about()
85+
&& !about.to_string().trim().is_empty()
86+
{
87+
println!("{about} ");
8888
}
8989

9090
if let Some(note) = note {
@@ -181,10 +181,10 @@ fn generate_markdown_from_clap(command: &Command) {
181181
for command in commands {
182182
let command_name = command.get_name(); // index, split, source
183183
println!("## {command_name}");
184-
if let Some(about) = command.get_long_about().or_else(|| command.get_about()) {
185-
if !about.to_string().trim().is_empty() {
186-
println!("{about}\n");
187-
}
184+
if let Some(about) = command.get_long_about().or_else(|| command.get_about())
185+
&& !about.to_string().trim().is_empty()
186+
{
187+
println!("{about}\n");
188188
}
189189

190190
if command.get_subcommands().count() == 0 {

quickwit/quickwit-cli/src/index.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,14 +1061,14 @@ pub async fn ingest_docs_cli(args: IngestDocsArgs) -> anyhow::Result<()> {
10611061
// TODO(#5604) remove unwrap
10621062
.unwrap_or(response.num_docs_for_processing),
10631063
);
1064-
if let Some(rejected) = response.num_rejected_docs {
1065-
if rejected > 0 {
1066-
println!(
1067-
"{} Rejected {} document(s).",
1068-
"✖".color(RED_COLOR),
1069-
rejected
1070-
);
1071-
}
1064+
if let Some(rejected) = response.num_rejected_docs
1065+
&& rejected > 0
1066+
{
1067+
println!(
1068+
"{} Rejected {} document(s).",
1069+
"✖".color(RED_COLOR),
1070+
rejected
1071+
);
10721072
}
10731073
if let Some(parse_failures) = response.parse_failures {
10741074
if !parse_failures.is_empty() {

quickwit/quickwit-cli/src/logger.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ pub(super) mod jemalloc_profiled {
266266
seen = true;
267267

268268
let ext = span.extensions();
269-
if let Some(fields) = &ext.get::<FormattedFields<N>>() {
270-
if !fields.is_empty() {
271-
write!(writer, "{{{fields}}}:")?;
272-
}
269+
if let Some(fields) = &ext.get::<FormattedFields<N>>()
270+
&& !fields.is_empty()
271+
{
272+
write!(writer, "{{{fields}}}:")?;
273273
}
274274
}
275275

quickwit/quickwit-common/src/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<O: Ord, T> Ord for OrderItemPair<O, T> {
103103

104104
impl<O: Ord, T> PartialOrd for OrderItemPair<O, T> {
105105
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
106-
Some(self.order.cmp(&other.order))
106+
Some(self.cmp(other))
107107
}
108108
}
109109

quickwit/quickwit-common/src/tower/buffer.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ where E: error::Error + From<BufferError> + Clone + 'static {
9292
return BufferError::Closed.into();
9393
}
9494
// This happens when the inner service returns an error on `poll_ready`.
95-
if let Some(service_error) = error.downcast_ref::<ServiceError>() {
96-
if let Some(source) = service_error.source() {
97-
if let Some(inner) = source.downcast_ref::<E>() {
98-
return inner.clone();
99-
}
100-
}
95+
if let Some(service_error) = error.downcast_ref::<ServiceError>()
96+
&& let Some(source) = service_error.source()
97+
&& let Some(inner) = source.downcast_ref::<E>()
98+
{
99+
return inner.clone();
101100
}
102101
// This will happen only if the buffer service implementation adds a new error type.
103102
BufferError::Unknown.into()

quickwit/quickwit-common/src/uri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl Uri {
139139
}
140140

141141
/// Strips sensitive information such as credentials from URI.
142-
fn as_redacted_str(&self) -> Cow<str> {
142+
fn as_redacted_str(&self) -> Cow<'_, str> {
143143
if self.protocol().is_database() {
144144
static DATABASE_URI_PATTERN: OnceCell<Regex> = OnceCell::new();
145145
DATABASE_URI_PATTERN

quickwit/quickwit-config/src/config_value.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,18 @@ where
6767
env_vars: &HashMap<String, String>,
6868
) -> anyhow::Result<Option<T>> {
6969
// QW env vars take precedence over the config file values.
70-
if E > QW_NONE {
71-
if let Some(env_var_key) = QW_ENV_VARS.get(&E) {
72-
if let Some(env_var_value) = env_vars.get(*env_var_key) {
73-
let value = env_var_value.parse::<T>().map_err(|error| {
74-
anyhow::anyhow!(
75-
"failed to convert value `{env_var_value}` read from environment \
76-
variable `{env_var_key}` to type `{}`: {error:?}",
77-
any::type_name::<T>(),
78-
)
79-
})?;
80-
return Ok(Some(value));
81-
}
82-
}
70+
if E > QW_NONE
71+
&& let Some(env_var_key) = QW_ENV_VARS.get(&E)
72+
&& let Some(env_var_value) = env_vars.get(*env_var_key)
73+
{
74+
let value = env_var_value.parse::<T>().map_err(|error| {
75+
anyhow::anyhow!(
76+
"failed to convert value `{env_var_value}` read from environment variable \
77+
`{env_var_key}` to type `{}`: {error:?}",
78+
any::type_name::<T>(),
79+
)
80+
})?;
81+
return Ok(Some(value));
8382
}
8483
Ok(self.provided.or(self.default))
8584
}

quickwit/quickwit-config/src/source_config/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ impl TryFrom<FileSourceParamsForSerde> for FileSourceParams {
386386
value.notifications.remove(0),
387387
))
388388
} else if value.notifications.len() > 1 {
389-
return Err("Only one notification can be specified for now".into());
389+
Err("Only one notification can be specified for now".into())
390390
} else {
391-
return Err(
391+
Err(
392392
"Either `notifications` or `filepath` must be specified as file source parameters"
393393
.into(),
394-
);
394+
)
395395
}
396396
}
397397
}

quickwit/quickwit-control-plane/src/control_plane.rs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,11 @@ impl Handler<PruneShardsRequest> for ControlPlane {
845845
),
846846
interval,
847847
);
848-
if let CooldownStatus::Ready = status {
849-
if let Err(metastore_error) = self.metastore.prune_shards(request).await {
850-
return convert_metastore_error(metastore_error);
851-
};
852-
}
848+
if let CooldownStatus::Ready = status
849+
&& let Err(metastore_error) = self.metastore.prune_shards(request).await
850+
{
851+
return convert_metastore_error(metastore_error);
852+
};
853853
// Return ok regardless of whether the call was successful or debounced
854854
Ok(Ok(EmptyResponse {}))
855855
}
@@ -951,27 +951,25 @@ impl ControlPlaneEventSubscriber {
951951
#[async_trait]
952952
impl EventSubscriber<LocalShardsUpdate> for ControlPlaneEventSubscriber {
953953
async fn handle_event(&mut self, local_shards_update: LocalShardsUpdate) {
954-
if let Some(control_plane_mailbox) = self.0.upgrade() {
955-
if let Err(error) = control_plane_mailbox
954+
if let Some(control_plane_mailbox) = self.0.upgrade()
955+
&& let Err(error) = control_plane_mailbox
956956
.send_message(local_shards_update)
957957
.await
958-
{
959-
error!(error=%error, "failed to forward local shards update to control plane");
960-
}
958+
{
959+
error!(error=%error, "failed to forward local shards update to control plane");
961960
}
962961
}
963962
}
964963

965964
#[async_trait]
966965
impl EventSubscriber<ShardPositionsUpdate> for ControlPlaneEventSubscriber {
967966
async fn handle_event(&mut self, shard_positions_update: ShardPositionsUpdate) {
968-
if let Some(control_plane_mailbox) = self.0.upgrade() {
969-
if let Err(error) = control_plane_mailbox
967+
if let Some(control_plane_mailbox) = self.0.upgrade()
968+
&& let Err(error) = control_plane_mailbox
970969
.send_message(shard_positions_update)
971970
.await
972-
{
973-
error!(error=%error, "failed to forward shard positions update to control plane");
974-
}
971+
{
972+
error!(error=%error, "failed to forward shard positions update to control plane");
975973
}
976974
}
977975
}
@@ -1096,17 +1094,17 @@ async fn watcher_indexers(
10961094
};
10971095
match cluster_change {
10981096
ClusterChange::Add(node) => {
1099-
if node.enabled_services().contains(&QuickwitService::Indexer) {
1100-
if let Err(error) = mailbox.send_message(IndexerJoined(node)).await {
1101-
error!(error=%error, "failed to forward `IndexerJoined` event to control plane");
1102-
}
1097+
if node.enabled_services().contains(&QuickwitService::Indexer)
1098+
&& let Err(error) = mailbox.send_message(IndexerJoined(node)).await
1099+
{
1100+
error!(error=%error, "failed to forward `IndexerJoined` event to control plane");
11031101
}
11041102
}
11051103
ClusterChange::Remove(node) => {
1106-
if node.enabled_services().contains(&QuickwitService::Indexer) {
1107-
if let Err(error) = mailbox.send_message(IndexerLeft(node)).await {
1108-
error!(error=%error, "failed to forward `IndexerLeft` event to control plane");
1109-
}
1104+
if node.enabled_services().contains(&QuickwitService::Indexer)
1105+
&& let Err(error) = mailbox.send_message(IndexerLeft(node)).await
1106+
{
1107+
error!(error=%error, "failed to forward `IndexerLeft` event to control plane");
11101108
}
11111109
}
11121110
ClusterChange::Update(_) => {

quickwit/quickwit-control-plane/src/cooldown_map.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ impl<K: Hash + Eq> CooldownMap<K> {
5353
}
5454
} else {
5555
let capacity: usize = self.0.cap().into();
56-
if self.0.len() == capacity {
57-
if let Some((_, deadline)) = self.0.peek_lru() {
58-
if *deadline > now {
59-
// the oldest entry is not outdated, grow the LRU
60-
self.0.resize(NonZeroUsize::new(capacity * 2).unwrap());
61-
}
62-
}
56+
if self.0.len() == capacity
57+
&& let Some((_, deadline)) = self.0.peek_lru()
58+
&& *deadline > now
59+
{
60+
// the oldest entry is not outdated, grow the LRU
61+
self.0.resize(NonZeroUsize::new(capacity * 2).unwrap());
6362
}
6463
self.0.push(key, now + cooldown_interval);
6564
CooldownStatus::Ready

0 commit comments

Comments
 (0)