Skip to content

Commit

Permalink
chore(query): bump up rust toolchain to 2024-11-28 (databendlabs#16981)
Browse files Browse the repository at this point in the history
* update

* update

* update

* update

* update

* update

* update

* update
  • Loading branch information
sundy-li authored Dec 9, 2024
1 parent 9700a3b commit 5e2b4b8
Show file tree
Hide file tree
Showing 217 changed files with 1,141 additions and 1,027 deletions.
10 changes: 6 additions & 4 deletions .github/actions/check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ runs:
taplo check
taplo fmt --check
- name: Audit dependencies
shell: bash
if: "!contains(github.event.head_commit.message, 'skip audit')"
run: cargo audit --db ./target/advisory-db
# TODO: enable it later
# - name: Audit dependencies
# shell: bash
# if: "!contains(github.event.head_commit.message, 'skip audit')"
# run: cargo audit --db ./target/advisory-db

- name: Clippy
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-07-02"
channel = "nightly-2024-11-28"
components = ["rustfmt", "clippy", "rust-src", "miri", "rust-analyzer"]
4 changes: 2 additions & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
edition = "2021"
version = "Two"
style_edition = "2021"
reorder_imports = true
imports_granularity = "Item"
group_imports = "StdExternalCrate"
where_single_line = true
trailing_comma = "Vertical"
overflow_delimited_expr = true
format_code_in_doc_comments = true
normalize_comments = true
normalize_comments = true
2 changes: 1 addition & 1 deletion src/common/base/src/base/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Semaphore {
}
}

impl<'a> Drop for SemaphoreGuard<'a> {
impl Drop for SemaphoreGuard<'_> {
fn drop(&mut self) {
self.sem.release();
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/base/src/base/stoppable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ pub trait Stoppable {
///
/// Calling `stop()` twice should get an error.
async fn stop(&mut self, mut force: Option<broadcast::Receiver<()>>)
-> Result<(), Self::Error>;
-> Result<(), Self::Error>;
}
2 changes: 1 addition & 1 deletion src/common/base/src/display/display_option/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::fmt;
/// implementation for T.
pub struct DisplayOption<'a, T: fmt::Display>(pub &'a Option<T>);

impl<'a, T: fmt::Display> fmt::Display for DisplayOption<'a, T> {
impl<T: fmt::Display> fmt::Display for DisplayOption<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 {
None => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/base/src/display/display_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::fmt;
/// - `DisplaySlice(&[1,2,3,4,5,6])` outputs: `"[1,2,3,4,...,6]"`.
pub struct DisplaySlice<'a, T: fmt::Display, const MAX: usize = 5>(pub &'a [T]);

impl<'a, T: fmt::Display, const MAX: usize> fmt::Display for DisplaySlice<'a, T, MAX> {
impl<T: fmt::Display, const MAX: usize> fmt::Display for DisplaySlice<'_, T, MAX> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let slice = self.0;
let len = slice.len();
Expand Down
40 changes: 15 additions & 25 deletions src/common/base/src/runtime/memory/mem_stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,9 @@ mod tests {
mem_stat.set_limit(MINIMUM_MEMORY_LIMIT);

mem_stat.record_memory::<false>(1, 1).unwrap();
assert!(
mem_stat
.record_memory::<false>(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT)
.is_err()
);
assert!(mem_stat
.record_memory::<false>(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT)
.is_err());
assert_eq!(
mem_stat.used.load(Ordering::Relaxed),
1 + MINIMUM_MEMORY_LIMIT
Expand Down Expand Up @@ -358,11 +356,9 @@ mod tests {
child_mem_stat.set_limit(MINIMUM_MEMORY_LIMIT);

mem_stat.record_memory::<false>(1, 1).unwrap();
assert!(
mem_stat
.record_memory::<false>(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT)
.is_ok()
);
assert!(mem_stat
.record_memory::<false>(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT)
.is_ok());
assert_eq!(
mem_stat.used.load(Ordering::Relaxed),
1 + MINIMUM_MEMORY_LIMIT
Expand All @@ -375,11 +371,9 @@ mod tests {
assert_eq!(child_mem_stat.peak_used.load(Ordering::Relaxed), 0);

child_mem_stat.record_memory::<false>(1, 1).unwrap();
assert!(
child_mem_stat
.record_memory::<false>(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT)
.is_err()
);
assert!(child_mem_stat
.record_memory::<false>(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT)
.is_err());
assert_eq!(
mem_stat.used.load(Ordering::Relaxed),
1 + MINIMUM_MEMORY_LIMIT + 1 + MINIMUM_MEMORY_LIMIT
Expand All @@ -404,11 +398,9 @@ mod tests {
MemStat::create_child("TEST_CHILD".to_string(), vec![mem_stat.clone()]);
child_mem_stat.set_limit(MINIMUM_MEMORY_LIMIT * 2);

assert!(
child_mem_stat
.record_memory::<true>(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT)
.is_err()
);
assert!(child_mem_stat
.record_memory::<true>(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT)
.is_err());
assert_eq!(mem_stat.used.load(Ordering::Relaxed), 0);
assert_eq!(mem_stat.peak_used.load(Ordering::Relaxed), 0);
assert_eq!(child_mem_stat.used.load(Ordering::Relaxed), 0);
Expand All @@ -421,11 +413,9 @@ mod tests {
MemStat::create_child("TEST_CHILD".to_string(), vec![mem_stat.clone()]);
child_mem_stat.set_limit(MINIMUM_MEMORY_LIMIT);

assert!(
child_mem_stat
.record_memory::<true>(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT)
.is_err()
);
assert!(child_mem_stat
.record_memory::<true>(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT)
.is_err());
assert_eq!(mem_stat.used.load(Ordering::Relaxed), 0);
// assert_eq!(mem_stat.peak_used.load(Ordering::Relaxed), 0);
assert_eq!(child_mem_stat.used.load(Ordering::Relaxed), 0);
Expand Down
4 changes: 2 additions & 2 deletions src/common/base/src/runtime/profile/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub static PROFILES_INDEX: OnceCell<
Arc<[Option<ProfileStatisticsName>; std::mem::variant_count::<ProfileStatisticsName>()]>,
> = OnceCell::new();

pub fn get_statistics_name_index()
-> Arc<[Option<ProfileStatisticsName>; std::mem::variant_count::<ProfileStatisticsName>()]> {
pub fn get_statistics_name_index(
) -> Arc<[Option<ProfileStatisticsName>; std::mem::variant_count::<ProfileStatisticsName>()]> {
PROFILES_INDEX
.get_or_init(|| {
let statistics_desc = get_statistics_desc();
Expand Down
2 changes: 1 addition & 1 deletion src/common/base/tests/it/fixed_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn test_is_full() {
#[derive(PartialEq, Eq, PartialOrd, Ord)]
struct DropCounted<'a>(&'a RefCell<usize>);

impl<'a> Drop for DropCounted<'a> {
impl Drop for DropCounted<'_> {
fn drop(&mut self) {
*self.0.borrow_mut() += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/base/tests/it/memory/mem_stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn test_mem_tracker_with_string_type() {

let str = "".repeat(length);
drop(_guard);
assert_eq!(mem_stat.get_memory_usage(), str.as_bytes().len() as i64);
assert_eq!(mem_stat.get_memory_usage(), str.len() as i64);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/cache/src/cache/lru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ impl<'a, K, V> DoubleEndedIterator for Iter<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {
impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
fn len(&self) -> usize {
self.0.len()
}
Expand Down Expand Up @@ -515,7 +515,7 @@ impl<'a, K, V> DoubleEndedIterator for IterMut<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> {
impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
fn len(&self) -> usize {
self.0.len()
}
Expand Down
1 change: 0 additions & 1 deletion src/common/cloud_control/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub mod task_utils;

#[allow(clippy::derive_partial_eq_without_eq)]
#[allow(clippy::large_enum_variant)]

/// ProtoBuf generated files.
pub mod pb {
// taskproto is proto package name.
Expand Down
4 changes: 2 additions & 2 deletions src/common/cloud_control/src/task_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn format_schedule_options(s: &ScheduleOptions) -> Result<String> {
)));
}
};
return match schedule_type {
match schedule_type {
ScheduleType::IntervalType => {
if s.milliseconds_interval.is_some() {
return Ok(format!(
Expand All @@ -119,7 +119,7 @@ pub fn format_schedule_options(s: &ScheduleOptions) -> Result<String> {
}
Ok(res)
}
};
}
}

// convert from crate::pb::task to struct task
Expand Down
13 changes: 9 additions & 4 deletions src/common/column/src/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@ impl BinaryColumn {

pub fn index(&self, index: usize) -> Option<&[u8]> {
if index + 1 < self.offsets.len() {
Some(&self.data[(self.offsets[index] as usize)..(self.offsets[index + 1] as usize)])
Some(self.value(index))
} else {
None
}
}

pub fn value(&self, index: usize) -> &[u8] {
assert!(index + 1 < self.offsets.len());
&self.data[(self.offsets[index] as usize)..(self.offsets[index + 1] as usize)]
}

Expand All @@ -92,7 +91,13 @@ impl BinaryColumn {
pub unsafe fn index_unchecked(&self, index: usize) -> &[u8] {
let start = *self.offsets.get_unchecked(index) as usize;
let end = *self.offsets.get_unchecked(index + 1) as usize;
self.data.get_unchecked(start..end)
// here we use checked slice to avoid UB
// Less regressed perfs:
// bench_kernels/binary_sum_len_unchecked/20
// time: [45.234 µs 45.278 µs 45.312 µs]
// change: [+1.4430% +1.5796% +1.7344%] (p = 0.00 < 0.05)
// Performance has regressed.
&self.data[start..end]
}

pub fn slice(&self, range: Range<usize>) -> Self {
Expand All @@ -113,7 +118,7 @@ impl BinaryColumn {
pub fn option_iter<'a>(
&'a self,
validity: Option<&'a Bitmap>,
) -> ZipValidity<&'a [u8], BinaryColumnIter, BitmapIter<'a>> {
) -> ZipValidity<&'a [u8], BinaryColumnIter<'a>, BitmapIter<'a>> {
let bitmap_iter = validity.as_ref().map(|v| v.iter());
ZipValidity::new(self.iter(), bitmap_iter)
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/column/src/binview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl<T: ViewType + ?Sized> BinaryViewColumnGeneric<T> {
pub fn option_iter<'a>(
&'a self,
validity: Option<&'a Bitmap>,
) -> ZipValidity<&'a T, BinaryViewColumnIter<T>, BitmapIter<'a>> {
) -> ZipValidity<&'a T, BinaryViewColumnIter<'a, T>, BitmapIter<'a>> {
let bitmap_iter = validity.as_ref().map(|v| v.iter());
ZipValidity::new(self.iter(), bitmap_iter)
}
Expand Down
6 changes: 3 additions & 3 deletions src/common/column/src/bitmap/bitmap_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +247,23 @@ impl PartialEq for Bitmap {
}
}

impl<'a, 'b> BitOr<&'b Bitmap> for &'a Bitmap {
impl<'b> BitOr<&'b Bitmap> for &Bitmap {
type Output = Bitmap;

fn bitor(self, rhs: &'b Bitmap) -> Bitmap {
or(self, rhs)
}
}

impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap {
impl<'b> BitAnd<&'b Bitmap> for &Bitmap {
type Output = Bitmap;

fn bitand(self, rhs: &'b Bitmap) -> Bitmap {
and(self, rhs)
}
}

impl<'a, 'b> BitXor<&'b Bitmap> for &'a Bitmap {
impl<'b> BitXor<&'b Bitmap> for &Bitmap {
type Output = Bitmap;

fn bitxor(self, rhs: &'b Bitmap) -> Bitmap {
Expand Down
1 change: 0 additions & 1 deletion src/common/column/src/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ impl Bitmap {
/// Create a new [`Bitmap`] from an arrow [`NullBuffer`]
///
/// [`NullBuffer`]: arrow_buffer::buffer::NullBuffer
pub fn from_null_buffer(value: arrow_buffer::buffer::NullBuffer) -> Self {
let offset = value.offset();
let length = value.len();
Expand Down
4 changes: 2 additions & 2 deletions src/common/column/src/bitmap/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'a> TrueIdxIter<'a> {
}
}

impl<'a> Iterator for TrueIdxIter<'a> {
impl Iterator for TrueIdxIter<'_> {
type Item = usize;

#[inline]
Expand Down Expand Up @@ -85,7 +85,7 @@ impl<'a> Iterator for TrueIdxIter<'a> {
}
}

unsafe impl<'a> TrustedLen for TrueIdxIter<'a> {}
unsafe impl TrustedLen for TrueIdxIter<'_> {}

/// This crates' equivalent of [`std::vec::IntoIter`] for [`Bitmap`].
#[derive(Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions src/common/column/src/bitmap/utils/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'a> BitmapIter<'a> {
}
}

impl<'a> Iterator for BitmapIter<'a> {
impl Iterator for BitmapIter<'_> {
type Item = bool;

#[inline]
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<'a> Iterator for BitmapIter<'a> {
}
}

impl<'a> DoubleEndedIterator for BitmapIter<'a> {
impl DoubleEndedIterator for BitmapIter<'_> {
#[inline]
fn next_back(&mut self) -> Option<bool> {
if self.index == self.end {
Expand Down
2 changes: 1 addition & 1 deletion src/common/column/src/bitmap/utils/slice_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<'a> SlicesIterator<'a> {
}
}

impl<'a> Iterator for SlicesIterator<'a> {
impl Iterator for SlicesIterator<'_> {
type Item = (usize, usize);

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/common/column/tests/it/bitmap/utils/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use databend_common_column::bitmap::utils::fmt;

struct A<'a>(&'a [u8], usize, usize);

impl<'a> std::fmt::Debug for A<'a> {
impl std::fmt::Debug for A<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
fmt(self.0, self.1, self.2, f)
}
Expand Down
10 changes: 4 additions & 6 deletions src/common/column/tests/it/bitmap/utils/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ fn rev() {
let result = iter.rev().collect::<Vec<_>>();
assert_eq!(
result,
vec![
false, true, true, false, true, false, true, true, false, true, true, false, true
]
.into_iter()
.rev()
.collect::<Vec<_>>()
vec![false, true, true, false, true, false, true, true, false, true, true, false, true]
.into_iter()
.rev()
.collect::<Vec<_>>()
)
}
2 changes: 1 addition & 1 deletion src/common/exception/src/exception_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl From<tonic::Status> for ErrorCode {
tonic::Code::Unknown => {
let details = status.details();
if details.is_empty() {
if status.source().map_or(false, |e| e.is::<hyper::Error>()) {
if status.source().is_some_and(|e| e.is::<hyper::Error>()) {
return ErrorCode::CannotConnectNode(format!(
"{}, source: {:?}",
status.message(),
Expand Down
Loading

0 comments on commit 5e2b4b8

Please sign in to comment.