Skip to content

Commit 7849d80

Browse files
jszwedkodsmith3197
andauthored
chore(deps): Bump to Rust 1.72.0 (#18389)
* chore(deps): Bump to Rust 1.72.0 Signed-off-by: Jesse Szwedko <[email protected]> * clippy --fix Signed-off-by: Jesse Szwedko <[email protected]> * clippy Signed-off-by: Jesse Szwedko <[email protected]> * clippy Signed-off-by: Jesse Szwedko <[email protected]> * Add panic documentation Signed-off-by: Jesse Szwedko <[email protected]> * Spelling Signed-off-by: Jesse Szwedko <[email protected]> * Add clippy allow for arc_with_non_send_sync Signed-off-by: Jesse Szwedko <[email protected]> * additional clippy allow Signed-off-by: Jesse Szwedko <[email protected]> * Correct clippy name Signed-off-by: Jesse Szwedko <[email protected]> * cargo fmt Signed-off-by: Jesse Szwedko <[email protected]> * Move clippy allow up Couldn't figure out how to get it working when applying directly to structs with derivative Signed-off-by: Jesse Szwedko <[email protected]> * Update lib/vector-buffers/src/topology/acks.rs Co-authored-by: Doug Smith <[email protected]> --------- Signed-off-by: Jesse Szwedko <[email protected]> Co-authored-by: Doug Smith <[email protected]>
1 parent fd0ccd5 commit 7849d80

File tree

76 files changed

+289
-231
lines changed

Some content is hidden

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

76 files changed

+289
-231
lines changed

Tiltfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ load('ext://helm_resource', 'helm_resource', 'helm_repo')
77
docker_build(
88
ref='timberio/vector',
99
context='.',
10-
build_args={'RUST_VERSION': '1.71.1'},
10+
build_args={'RUST_VERSION': '1.72.0'},
1111
dockerfile='tilt/Dockerfile'
1212
)
1313

lib/prometheus-parser/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ mod test {
468468

469469
#[test]
470470
fn test_parse_text() {
471-
let input = r##"
471+
let input = r#"
472472
# HELP http_requests_total The total number of HTTP requests.
473473
# TYPE http_requests_total counter
474474
http_requests_total{method="post",code="200"} 1027 1395066363000
@@ -512,7 +512,7 @@ mod test {
512512
rpc_duration_seconds{quantile="0.99"} 76656
513513
rpc_duration_seconds_sum 1.7560473e+07
514514
rpc_duration_seconds_count 4.588206224e+09
515-
"##;
515+
"#;
516516
let output = parse_text(input).unwrap();
517517
assert_eq!(output.len(), 7);
518518
match_group!(output[0], "http_requests_total", Counter => |metrics: &MetricMap<SimpleMetric>| {
@@ -651,7 +651,7 @@ mod test {
651651

652652
#[test]
653653
fn test_errors() {
654-
let input = r##"name{registry="default" content_type="html"} 1890"##;
654+
let input = r#"name{registry="default" content_type="html"} 1890"#;
655655
let error = parse_text(input).unwrap_err();
656656
assert!(matches!(
657657
error,
@@ -681,7 +681,7 @@ mod test {
681681
}
682682
));
683683

684-
let input = r##"name{registry="} 1890"##;
684+
let input = r#"name{registry="} 1890"#;
685685
let error = parse_text(input).unwrap_err();
686686
assert!(matches!(
687687
error,

lib/prometheus-parser/src/line.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ mod test {
412412
assert_eq!(left, tail);
413413
assert_eq!(r, "");
414414

415-
let input = wrap(r#"a\\ asdf"#);
415+
let input = wrap(r"a\\ asdf");
416416
let (left, r) = Metric::parse_escaped_string(&input).unwrap();
417417
assert_eq!(left, tail);
418418
assert_eq!(r, "a\\ asdf");
@@ -427,7 +427,7 @@ mod test {
427427
assert_eq!(left, tail);
428428
assert_eq!(r, "\"\\\n");
429429

430-
let input = wrap(r#"\\n"#);
430+
let input = wrap(r"\\n");
431431
let (left, r) = Metric::parse_escaped_string(&input).unwrap();
432432
assert_eq!(left, tail);
433433
assert_eq!(r, "\\n");
@@ -671,7 +671,7 @@ mod test {
671671

672672
#[test]
673673
fn test_parse_line() {
674-
let input = r##"
674+
let input = r#"
675675
# HELP http_requests_total The total number of HTTP requests.
676676
# TYPE http_requests_total counter
677677
http_requests_total{method="post",code="200"} 1027 1395066363000
@@ -708,7 +708,7 @@ mod test {
708708
rpc_duration_seconds{quantile="0.99"} 76656
709709
rpc_duration_seconds_sum 1.7560473e+07
710710
rpc_duration_seconds_count 2693
711-
"##;
711+
"#;
712712
assert!(input.lines().map(Line::parse).all(|r| r.is_ok()));
713713
}
714714
}

lib/vector-buffers/src/test/helpers.rs

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ macro_rules! await_timeout {
4040
}};
4141
}
4242

43+
/// Run a future with a temporary directory.
44+
///
45+
/// # Panics
46+
///
47+
/// Will panic if function cannot create a temp directory.
4348
pub async fn with_temp_dir<F, Fut, V>(f: F) -> V
4449
where
4550
F: FnOnce(&Path) -> Fut,

lib/vector-buffers/src/test/messages.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ macro_rules! message_wrapper {
3333
}
3434

3535
impl EventCount for $id {
36+
#[allow(clippy::redundant_closure_call)]
3637
fn event_count(&self) -> usize {
3738
usize::try_from($event_count(self)).unwrap_or(usize::MAX)
3839
}

lib/vector-buffers/src/test/variant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Variant {
7272
let (sender, receiver) = builder
7373
.build(String::from("benches"), Span::none())
7474
.await
75-
.expect("topology build should not fail");
75+
.unwrap_or_else(|_| unreachable!("topology build should not fail"));
7676

7777
(sender, receiver)
7878
}

lib/vector-buffers/src/topology/acks.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ where
208208
///
209209
/// Acknowledgements should be given by the caller to update the acknowledgement state before
210210
/// trying to get any eligible markers.
211+
///
212+
/// # Panics
213+
///
214+
/// Will panic if adding ack amount overflows.
211215
pub fn add_acknowledgements(&mut self, amount: N) {
212216
self.unclaimed_acks = self
213217
.unclaimed_acks
@@ -315,6 +319,10 @@ where
315319
///
316320
/// When other pending markers are present, and the given ID is logically behind the next
317321
/// expected marker ID, `Err(MarkerError::MonotonicityViolation)` is returned.
322+
///
323+
/// # Panics
324+
///
325+
/// Panics if pending markers is empty when last pending marker is an unknown size.
318326
pub fn add_marker(
319327
&mut self,
320328
id: N,
@@ -341,7 +349,7 @@ where
341349
let last_marker = self
342350
.pending_markers
343351
.back_mut()
344-
.expect("pending markers should not be empty");
352+
.unwrap_or_else(|| unreachable!("pending markers should not be empty"));
345353

346354
last_marker.len = PendingMarkerLength::Assumed(len);
347355
}
@@ -425,13 +433,15 @@ where
425433
let PendingMarker { id, data, .. } = self
426434
.pending_markers
427435
.pop_front()
428-
.expect("pending markers cannot be empty");
436+
.unwrap_or_else(|| unreachable!("pending markers cannot be empty"));
429437

430438
if acks_to_claim > N::min_value() {
431439
self.unclaimed_acks = self
432440
.unclaimed_acks
433441
.checked_sub(&acks_to_claim)
434-
.expect("should not be able to claim more acks than are unclaimed");
442+
.unwrap_or_else(|| {
443+
unreachable!("should not be able to claim more acks than are unclaimed")
444+
});
435445
}
436446

437447
self.acked_marker_id = id.wrapping_add(&len.len());

lib/vector-buffers/src/topology/builder.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ impl<T: Bufferable> TopologyBuilder<T> {
183183
/// This is a convenience method for `vector` as it is used for inter-transform channels, and we
184184
/// can simplifying needing to require callers to do all the boilerplate to create the builder,
185185
/// create the stage, installing buffer usage metrics that aren't required, and so on.
186+
///
187+
#[allow(clippy::print_stderr)]
186188
pub async fn standalone_memory(
187189
max_events: NonZeroUsize,
188190
when_full: WhenFull,
@@ -193,7 +195,7 @@ impl<T: Bufferable> TopologyBuilder<T> {
193195
let (sender, receiver) = memory_buffer
194196
.into_buffer_parts(usage_handle.clone())
195197
.await
196-
.expect("should not fail to directly create a memory buffer");
198+
.unwrap_or_else(|_| unreachable!("should not fail to directly create a memory buffer"));
197199

198200
let mode = match when_full {
199201
WhenFull::Overflow => WhenFull::Block,
@@ -228,7 +230,7 @@ impl<T: Bufferable> TopologyBuilder<T> {
228230
let (sender, receiver) = memory_buffer
229231
.into_buffer_parts(usage_handle.clone())
230232
.await
231-
.expect("should not fail to directly create a memory buffer");
233+
.unwrap_or_else(|_| unreachable!("should not fail to directly create a memory buffer"));
232234

233235
let mode = match when_full {
234236
WhenFull::Overflow => WhenFull::Block,

lib/vector-buffers/src/topology/channel/limited_queue.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ impl<T: Bufferable> LimitedSender<T> {
107107
.limiter
108108
.clone()
109109
.acquire_many_owned(permits_required)
110-
.await else {
111-
return Err(SendError(item))
110+
.await
111+
else {
112+
return Err(SendError(item));
112113
};
113114

114115
self.inner
115116
.data
116117
.push((permits, item))
117-
.expect("acquired permits but channel reported being full");
118+
.unwrap_or_else(|_| unreachable!("acquired permits but channel reported being full"));
118119
self.inner.read_waker.notify_one();
119120

120121
trace!("Sent item.");
@@ -130,6 +131,10 @@ impl<T: Bufferable> LimitedSender<T> {
130131
/// `Err(TrySendError::Disconnected)` be returned with the given `item`. If the channel has
131132
/// insufficient capacity for the item, then `Err(TrySendError::InsufficientCapacity)` will be
132133
/// returned with the given `item`.
134+
///
135+
/// # Panics
136+
///
137+
/// Will panic if adding ack amount overflows.
133138
pub fn try_send(&mut self, item: T) -> Result<(), TrySendError<T>> {
134139
// Calculate how many permits we need, and try to acquire them all without waiting.
135140
let permits_required = self.get_required_permits_for_item(&item);
@@ -151,7 +156,7 @@ impl<T: Bufferable> LimitedSender<T> {
151156
self.inner
152157
.data
153158
.push((permits, item))
154-
.expect("acquired permits but channel reported being full");
159+
.unwrap_or_else(|_| unreachable!("acquired permits but channel reported being full"));
155160
self.inner.read_waker.notify_one();
156161

157162
trace!("Attempt to send item succeeded.");

lib/vector-buffers/src/topology/channel/sender.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<T: Bufferable> BufferSender<T> {
201201
sent_to_base = false;
202202
self.overflow
203203
.as_mut()
204-
.expect("overflow must exist")
204+
.unwrap_or_else(|| unreachable!("overflow must exist"))
205205
.send(item)
206206
.await?;
207207
}

lib/vector-buffers/src/variants/disk_v2/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ where
348348
return Err(BuildError::InvalidParameter {
349349
param_name: "max_record_size",
350350
reason: "must be less than 2^64 bytes".to_string(),
351-
})
351+
});
352352
};
353353

354354
if max_record_size_converted > max_data_file_size {

lib/vector-buffers/src/variants/disk_v2/ledger.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,6 @@ where
735735
)
736736
.field("writer_done", &self.writer_done.load(Ordering::Acquire))
737737
.field("last_flush", &self.last_flush.load())
738-
.finish()
738+
.finish_non_exhaustive()
739739
}
740740
}

lib/vector-buffers/src/variants/disk_v2/reader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ where
855855
// If there's an error decoding the item, just fall back to the slow path,
856856
// because this file might actually be where we left off, so we don't want
857857
// to incorrectly skip ahead or anything.
858-
break
858+
break;
859859
};
860860

861861
// We have to remove 1 from the event count here because otherwise the ID would

lib/vector-buffers/src/variants/disk_v2/tests/model/record.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl fmt::Debug for Record {
8080
.field("event_count", &self.event_count)
8181
.field("encoded_len", &self.encoded_len())
8282
.field("archived_len", &self.archived_len())
83-
.finish()
83+
.finish_non_exhaustive()
8484
}
8585
}
8686

lib/vector-common/src/event_test_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn contains_name_once(pattern: &str) -> Result<(), String> {
1515
EVENTS_RECORDED.with(|events| {
1616
let mut n_events = 0;
1717
let mut names = String::new();
18-
for event in events.borrow().iter() {
18+
for event in &*events.borrow() {
1919
if event.ends_with(pattern) {
2020
if n_events > 0 {
2121
names.push_str(", ");
@@ -44,7 +44,7 @@ pub fn clear_recorded_events() {
4444
#[allow(clippy::print_stdout)]
4545
pub fn debug_print_events() {
4646
EVENTS_RECORDED.with(|events| {
47-
for event in events.borrow().iter() {
47+
for event in &*events.borrow() {
4848
println!("{event}");
4949
}
5050
});

lib/vector-common/src/finalization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl EventFinalizers {
7676

7777
/// Merges the event finalizers from `other` into the collection.
7878
pub fn merge(&mut self, other: Self) {
79-
self.0.extend(other.0.into_iter());
79+
self.0.extend(other.0);
8080
}
8181

8282
/// Updates the status of all event finalizers in the collection.

lib/vector-config-common/src/schema/json_schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl<T: Clone> Extend<T> for SingleOrVec<T> {
563563
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
564564
match self {
565565
Self::Single(item) => {
566-
*self = Self::Vec(iter::once(*item.clone()).chain(iter.into_iter()).collect());
566+
*self = Self::Vec(iter::once(*item.clone()).chain(iter).collect());
567567
}
568568
Self::Vec(items) => items.extend(iter),
569569
}

lib/vector-config-macros/src/ast/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use serde_derive_internals::{ast as serde_ast, attr as serde_attr};
44

55
mod container;
66
mod field;
7-
pub(self) mod util;
7+
mod util;
88
mod variant;
99

1010
pub use container::Container;

lib/vector-config/src/schema/visitors/merge.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ fn merge_schema_instance_type(
128128
source: Option<&SingleOrVec<InstanceType>>,
129129
) {
130130
merge_optional_with(destination, source, |existing, new| {
131-
let mut deduped = existing
132-
.into_iter()
133-
.chain(new.into_iter())
134-
.cloned()
135-
.collect::<Vec<_>>();
131+
let mut deduped = existing.into_iter().chain(new).cloned().collect::<Vec<_>>();
136132
deduped.dedup();
137133

138134
*existing = deduped.into();

lib/vector-config/src/schema/visitors/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub mod scoped_visit;
55
mod unevaluated;
66

77
#[cfg(test)]
8-
pub(self) mod test;
8+
mod test;
99

1010
pub use self::human_name::GenerateHumanFriendlyNameVisitor;
1111
pub use self::inline_single::InlineSingleUseReferencesVisitor;

lib/vector-core/src/config/log_schema.rs

+4
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ impl LogSchema {
120120
///
121121
/// This should only be used where the result will either be cached,
122122
/// or performance isn't critical, since this requires memory allocation.
123+
///
124+
/// # Panics
125+
///
126+
/// Panics if the path in `self.message_key` is invalid.
123127
pub fn owned_message_path(&self) -> OwnedTargetPath {
124128
self.message_key
125129
.path

lib/vector-core/src/event/discriminant.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ fn hash_f64<H: Hasher>(hasher: &mut H, value: f64) {
145145
}
146146

147147
fn hash_array<H: Hasher>(hasher: &mut H, array: &[Value]) {
148-
for val in array.iter() {
148+
for val in array {
149149
hash_value(hasher, val);
150150
}
151151
}
152152

153153
fn hash_map<H: Hasher>(hasher: &mut H, map: &BTreeMap<String, Value>) {
154-
for (key, val) in map.iter() {
154+
for (key, val) in map {
155155
hasher.write(key.as_bytes());
156156
hash_value(hasher, val);
157157
}

lib/vector-core/src/event/log_event.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl LogEvent {
476476
for field in fields {
477477
let field_path = event_path!(field.as_ref());
478478
let Some(incoming_val) = incoming.remove(field_path) else {
479-
continue
479+
continue;
480480
};
481481
match self.get_mut(field_path) {
482482
None => {

lib/vector-core/src/event/lua/event.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a> FromLua<'a> for Event {
4141
from: value.type_name(),
4242
to: "Event",
4343
message: Some("Event should be a Lua table".to_string()),
44-
})
44+
});
4545
};
4646
match (table.raw_get("log")?, table.raw_get("metric")?) {
4747
(LuaValue::Table(log), LuaValue::Nil) => {

lib/vector-core/src/event/lua/util.rs

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ pub fn table_is_timestamp(t: &LuaTable<'_>) -> LuaResult<bool> {
4141
/// # Errors
4242
///
4343
/// This function will fail if the table is malformed.
44+
///
45+
/// # Panics
46+
///
47+
/// Panics if the resulting timestamp is invalid.
4448
#[allow(clippy::needless_pass_by_value)] // constrained by mlua types
4549
pub fn table_to_timestamp(t: LuaTable<'_>) -> LuaResult<DateTime<Utc>> {
4650
let year = t.raw_get("year")?;

0 commit comments

Comments
 (0)