Skip to content

Commit

Permalink
Fix a bunch of 1.83.0 clippy stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Nov 28, 2024
1 parent d2b45d5 commit 3c8b1ef
Show file tree
Hide file tree
Showing 46 changed files with 89 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct Visitor<'a> {
visited: HashSet<String>,
}

impl<'a> Visitor<'a> {
impl Visitor<'_> {
fn push(&mut self, id: &str, name: String, description: String, uri: impl Display) {
if self.visited.contains(id) {
return;
Expand Down
4 changes: 2 additions & 2 deletions crates/build/re_types_builder/src/codegen/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub enum ImageUrl<'a> {
Other(&'a str),
}

impl<'a> ImageUrl<'a> {
impl ImageUrl<'_> {
pub fn parse(s: &str) -> ImageUrl<'_> {
RerunImageUrl::parse(s).map_or(ImageUrl::Other(s), ImageUrl::Rerun)
}
Expand Down Expand Up @@ -178,7 +178,7 @@ impl<'a> ImageStack<'a> {

pub struct SnippetId<'a>(pub &'a str);

impl<'a> std::fmt::Display for SnippetId<'a> {
impl std::fmt::Display for SnippetId<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "snippets/{}", self.0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn arrow_datatype_docs(page: &mut String, indent: usize, datatype: &DataType
arrow::datatypes::UnionMode::Dense => page.push_str("DenseUnion {\n"),
}
for (index, field) in union_fields.iter() {
page.push_indented(indent + 1, &format!("{index} = {:?}: ", field.name()), 0);
page.push_indented(indent + 1, format!("{index} = {:?}: ", field.name()), 0);
if field.is_nullable() {
page.push_str("nullable ");
}
Expand Down
12 changes: 6 additions & 6 deletions crates/build/re_types_builder/src/codegen/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,15 @@ impl PythonCodeGenerator {
.extend(names.iter().cloned());

let mut code = String::new();
code.push_indented(0, &format!("# {}", autogen_warning!()), 1);
code.push_indented(0, format!("# {}", autogen_warning!()), 1);
if let Some(source_path) = obj.relative_filepath() {
code.push_indented(0, &format!("# Based on {:?}.", format_path(source_path)), 2);
code.push_indented(0, format!("# Based on {:?}.", format_path(source_path)), 2);

if obj.kind != ObjectKind::View {
// View type extension isn't implemented yet (shouldn't be hard though to add if needed).
code.push_indented(
0,
&format!(
format!(
"# You can extend this class by creating a {:?} class in {:?}.",
ext_class.name, ext_class.file_name
),
Expand Down Expand Up @@ -514,7 +514,7 @@ fn write_init_file(
let path = kind_path.join("__init__.py");
let mut code = String::new();
let manifest = quote_manifest(mods.iter().flat_map(|(_, names)| names.iter()));
code.push_indented(0, &format!("# {}", autogen_warning!()), 2);
code.push_indented(0, format!("# {}", autogen_warning!()), 2);
code.push_unindented(
"
from __future__ import annotations
Expand All @@ -524,7 +524,7 @@ fn write_init_file(
);
for (module, names) in mods {
let names = names.join(", ");
code.push_indented(0, &format!("from .{module} import {names}"), 1);
code.push_indented(0, format!("from .{module} import {names}"), 1);
}
if !manifest.is_empty() {
code.push_unindented(format!("\n__all__ = [{manifest}]"), 0);
Expand Down Expand Up @@ -2022,7 +2022,7 @@ fn quote_arrow_serialization(

code.push_indented(0, "from typing import cast", 1);
code.push_indented(0, quote_local_batch_type_imports(&obj.fields), 2);
code.push_indented(0, &format!("if isinstance(data, {name}):"), 1);
code.push_indented(0, format!("if isinstance(data, {name}):"), 1);
code.push_indented(1, "data = [data]", 2);

code.push_indented(0, "return pa.StructArray.from_arrays(", 1);
Expand Down
10 changes: 5 additions & 5 deletions crates/build/re_types_builder/src/codegen/python/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,26 @@ This will be addressed in <https://github.com/rerun-io/rerun/issues/6673>.".to_o
let property_type = &objects[property_type_fqname];
let property_name = &property_type.name;
let property_type_name = format!("blueprint_archetypes.{}", &property_type.name);
code.push_indented(1, &format!("if {parameter_name} is not None:"), 1);
code.push_indented(1, format!("if {parameter_name} is not None:"), 1);
code.push_indented(
2,
&format!("if not isinstance({parameter_name}, {property_type_name}):"),
format!("if not isinstance({parameter_name}, {property_type_name}):"),
1,
);
code.push_indented(
3,
&format!("{parameter_name} = {property_type_name}({parameter_name})"),
format!("{parameter_name} = {property_type_name}({parameter_name})"),
1,
);
code.push_indented(
2,
&format!(r#"properties["{property_name}"] = {parameter_name}"#),
format!(r#"properties["{property_name}"] = {parameter_name}"#),
2,
);
}
code.push_indented(
1,
&format!(r#"super().__init__(class_identifier="{identifier}", origin=origin, contents=contents, name=name, visible=visible, properties=properties, defaults=defaults, overrides=overrides)"#),
format!(r#"super().__init__(class_identifier="{identifier}", origin=origin, contents=contents, name=name, visible=visible, properties=properties, defaults=defaults, overrides=overrides)"#),
1,
);

Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_chunk/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl TransportChunk {
pub fn columns<'a>(
&'a self,
kind: &'a str,
) -> impl Iterator<Item = (&ArrowField, &'a Box<dyn Arrow2Array>)> + 'a {
) -> impl Iterator<Item = (&'a ArrowField, &'a Box<dyn Arrow2Array>)> + 'a {
self.schema
.fields
.iter()
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_chunk_store/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ impl ChunkStore {
let datatype = self
.lookup_datatype(&component_name)
.cloned()
.unwrap_or_else(|| Arrow2Datatype::Null);
.unwrap_or(Arrow2Datatype::Null);

ComponentColumnDescriptor {
entity_path: selector.entity_path.clone(),
Expand Down
7 changes: 4 additions & 3 deletions crates/store/re_dataframe/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,10 @@ impl<E: StorageEngineLike> QueryHandle<E> {
.try_with(|store, cache| self._next_row(store, cache));

let engine = self.engine.clone();
std::future::poll_fn(move |cx| match &res {
Some(row) => std::task::Poll::Ready(row.clone()),
None => {
std::future::poll_fn(move |cx| {
if let Some(row) = &res {
std::task::Poll::Ready(row.clone())
} else {
// The lock is already held by a writer, we have to yield control back to the async
// runtime, for now.
// Before we do so, we need to schedule a callback that will be in charge of waking up
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_format_arrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl std::fmt::Display for DisplayDatatype<'_> {

struct DisplayMetadata<'a>(&'a Metadata, &'a str);

impl<'a> std::fmt::Display for DisplayMetadata<'a> {
impl std::fmt::Display for DisplayMetadata<'_> {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let Self(metadata, prefix) = self;
Expand Down
4 changes: 2 additions & 2 deletions crates/store/re_log_types/src/path/parse_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ fn join(tokens: &[&str]) -> String {

/// `"/foo/bar"` -> `["/", "foo", "/", "bar"]`
fn tokenize_entity_path(path: &str) -> Vec<&str> {
tokenize_by(path, &[b'/'])
tokenize_by(path, b"/")
}

/// `"/foo/bar[#42]:Color"` -> `["/", "foo", "/", "bar", "[", "#42:", "]", ":", "Color"]`
fn tokenize_data_path(path: &str) -> Vec<&str> {
tokenize_by(path, &[b'/', b'[', b']', b':'])
tokenize_by(path, b"/[]:")
}

fn tokenize_by<'s>(path: &'s str, special_chars: &[u8]) -> Vec<&'s str> {
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_log_types/src/time_point/non_min_i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl From<core::convert::Infallible> for TryFromIntError {
}
}

/// ---
// ---

/// An integer that is known not to equal its minimum value.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_types/src/components/media_type_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl MediaType {
pub const STL: &'static str = "model/stl";

// -------------------------------------------------------
/// Videos:
// Videos:

/// [MP4 video](https://en.wikipedia.org/wiki/MP4_file_format): `video/mp4`.
///
Expand Down
20 changes: 10 additions & 10 deletions crates/store/re_types_core/src/loggable_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ impl<'a> std::ops::Deref for MaybeOwnedComponentBatch<'a> {
}
}

impl<'a> LoggableBatch for MaybeOwnedComponentBatch<'a> {
impl LoggableBatch for MaybeOwnedComponentBatch<'_> {
#[inline]
fn to_arrow2(&self) -> SerializationResult<Box<dyn ::arrow2::array::Array>> {
self.as_ref().to_arrow2()
}
}

impl<'a> ComponentBatch for MaybeOwnedComponentBatch<'a> {
impl ComponentBatch for MaybeOwnedComponentBatch<'_> {
#[inline]
fn name(&self) -> ComponentName {
self.as_ref().name()
Expand Down Expand Up @@ -203,14 +203,14 @@ impl<C: Component, const N: usize> ComponentBatch for [Option<C>; N] {

// --- Slice ---

impl<'a, L: Loggable> LoggableBatch for &'a [L] {
impl<L: Loggable> LoggableBatch for &[L] {
#[inline]
fn to_arrow2(&self) -> SerializationResult<Box<dyn ::arrow2::array::Array>> {
L::to_arrow2(self.iter().map(|v| std::borrow::Cow::Borrowed(v)))
}
}

impl<'a, C: Component> ComponentBatch for &'a [C] {
impl<C: Component> ComponentBatch for &[C] {
#[inline]
fn name(&self) -> ComponentName {
C::name()
Expand All @@ -219,7 +219,7 @@ impl<'a, C: Component> ComponentBatch for &'a [C] {

// --- Slice<Option> ---

impl<'a, L: Loggable> LoggableBatch for &'a [Option<L>] {
impl<L: Loggable> LoggableBatch for &[Option<L>] {
#[inline]
fn to_arrow2(&self) -> SerializationResult<Box<dyn ::arrow2::array::Array>> {
L::to_arrow2_opt(
Expand All @@ -229,7 +229,7 @@ impl<'a, L: Loggable> LoggableBatch for &'a [Option<L>] {
}
}

impl<'a, C: Component> ComponentBatch for &'a [Option<C>] {
impl<C: Component> ComponentBatch for &[Option<C>] {
#[inline]
fn name(&self) -> ComponentName {
C::name()
Expand All @@ -238,14 +238,14 @@ impl<'a, C: Component> ComponentBatch for &'a [Option<C>] {

// --- ArrayRef ---

impl<'a, L: Loggable, const N: usize> LoggableBatch for &'a [L; N] {
impl<L: Loggable, const N: usize> LoggableBatch for &[L; N] {
#[inline]
fn to_arrow2(&self) -> SerializationResult<Box<dyn ::arrow2::array::Array>> {
L::to_arrow2(self.iter().map(|v| std::borrow::Cow::Borrowed(v)))
}
}

impl<'a, C: Component, const N: usize> ComponentBatch for &'a [C; N] {
impl<C: Component, const N: usize> ComponentBatch for &[C; N] {
#[inline]
fn name(&self) -> ComponentName {
C::name()
Expand All @@ -254,7 +254,7 @@ impl<'a, C: Component, const N: usize> ComponentBatch for &'a [C; N] {

// --- ArrayRef<Option> ---

impl<'a, L: Loggable, const N: usize> LoggableBatch for &'a [Option<L>; N] {
impl<L: Loggable, const N: usize> LoggableBatch for &[Option<L>; N] {
#[inline]
fn to_arrow2(&self) -> SerializationResult<Box<dyn ::arrow2::array::Array>> {
L::to_arrow2_opt(
Expand All @@ -264,7 +264,7 @@ impl<'a, L: Loggable, const N: usize> LoggableBatch for &'a [Option<L>; N] {
}
}

impl<'a, C: Component, const N: usize> ComponentBatch for &'a [Option<C>; N] {
impl<C: Component, const N: usize> ComponentBatch for &[Option<C>; N] {
#[inline]
fn name(&self) -> ComponentName {
C::name()
Expand Down
1 change: 0 additions & 1 deletion crates/store/re_types_core/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl SpaceViewClassIdentifier {
/// In addition to the data that it contains via `SpaceViewContents`, each view
/// has several view properties that configure how it behaves. Each view property
/// is a [`crate::Archetype`] that is stored in the viewer's blueprint database.
pub trait View {
fn identifier() -> SpaceViewClassIdentifier;
}
2 changes: 1 addition & 1 deletion crates/store/re_video/src/demux/mp4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl VideoData {
.tracks()
.values()
.find(|t| t.kind == Some(re_mp4::TrackKind::Video))
.ok_or_else(|| VideoLoadError::NoVideoTrack)?;
.ok_or(VideoLoadError::NoVideoTrack)?;

let stsd = track.trak(&mp4).mdia.minf.stbl.stsd.clone();

Expand Down
16 changes: 6 additions & 10 deletions crates/top/rerun/src/commands/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,6 @@ fn stream_to_rrd_on_disk(
path: &std::path::PathBuf,
) -> Result<(), re_log_encoding::FileSinkError> {
use re_log_encoding::FileSinkError;
use re_smart_channel::RecvError;

if path.exists() {
re_log::warn!("Overwriting existing file at {path:?}");
Expand All @@ -1018,16 +1017,13 @@ fn stream_to_rrd_on_disk(
)?;

loop {
match rx.recv() {
Ok(msg) => {
if let Some(payload) = msg.into_data() {
encoder.append(&payload)?;
}
}
Err(RecvError) => {
re_log::info!("Log stream disconnected, stopping.");
break;
if let Ok(msg) = rx.recv() {
if let Some(payload) = msg.into_data() {
encoder.append(&payload)?;
}
} else {
re_log::info!("Log stream disconnected, stopping.");
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/utils/re_crash_handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ fn backtrace_to_string(backtrace: &backtrace::Backtrace) -> String {

struct AnonymizedBacktrace<'a>(&'a backtrace::Backtrace);

impl<'a> std::fmt::Display for AnonymizedBacktrace<'a> {
impl std::fmt::Display for AnonymizedBacktrace<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
format_backtrace(self.0, f)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/utils/re_int_histogram/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub struct Iter<'a> {
iter: TreeIterator<'a>,
}

impl<'a> Iterator for Iter<'a> {
impl Iterator for Iter<'_> {
type Item = (RangeI64, u64);

#[inline]
Expand Down Expand Up @@ -741,7 +741,7 @@ struct NodeIterator<'a> {
index: usize,
}

impl<'a> Iterator for TreeIterator<'a> {
impl Iterator for TreeIterator<'_> {
/// Am inclusive range, and the total count in that range.
type Item = (RangeU64, u64);

Expand Down
2 changes: 1 addition & 1 deletion crates/utils/re_memory/src/backtrace_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn backtrace_to_string(backtrace: &backtrace::Backtrace) -> String {

struct AnonymizedBacktrace<'a>(&'a backtrace::Backtrace);

impl<'a> std::fmt::Display for AnonymizedBacktrace<'a> {
impl std::fmt::Display for AnonymizedBacktrace<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
format_backtrace_with_fmt(self.0, f)
}
Expand Down
9 changes: 3 additions & 6 deletions crates/utils/re_smart_channel/src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ impl<T: Send> Receiver<T> {

#[cfg(not(target_arch = "wasm32"))] // Cannot block on web
pub fn recv(&self) -> Result<SmartMessage<T>, crate::RecvError> {
let msg = match self.rx.recv() {
Ok(x) => x,
Err(crate::RecvError) => {
self.connected.store(false, Relaxed);
return Err(crate::RecvError);
}
let Ok(msg) = self.rx.recv() else {
self.connected.store(false, Relaxed);
return Err(crate::RecvError);
};

let latency_ns = msg.time.elapsed().as_nanos() as u64;
Expand Down
2 changes: 1 addition & 1 deletion crates/utils/re_tuid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl std::fmt::Debug for Tuid {
}
}

impl<'a> From<Tuid> for std::borrow::Cow<'a, Tuid> {
impl From<Tuid> for std::borrow::Cow<'_, Tuid> {
#[inline]
fn from(value: Tuid) -> Self {
std::borrow::Cow::Owned(value)
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_chunk_store_ui/src/arrow_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(crate) fn arrow_ui(ui: &mut egui::Ui, array: &dyn arrow2::array::Array) {

if data_type_formatted.len() < 20 {
// e.g. "4.2 KiB of Float32"
ui.label(&format!("{bytes} of {data_type_formatted}"));
ui.label(format!("{bytes} of {data_type_formatted}"));
} else {
// Huge datatype, probably a union horror show
ui.label(format!("{bytes} of data"));
Expand Down
Loading

0 comments on commit 3c8b1ef

Please sign in to comment.