Skip to content

Commit

Permalink
Fix warnings when compiling with nightly (rerun-io#5184)
Browse files Browse the repository at this point in the history
### What
This allows us to compile with the nightly rust compiler without
warnings, which is just a nice convenience.

It is especially nice for rerun-io#4780
which relies on compiling with the nightly compiler.

Also fixes some new clippy warnings.

I needed to update `ahash` to compile on bleeding edge nightly.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5184/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5184/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5184/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5184)
- [Docs
preview](https://rerun.io/preview/a43b20b9c39030cf6c06e62bdb2b3cc1a6e1e9e6/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/a43b20b9c39030cf6c06e62bdb2b3cc1a6e1e9e6/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
emilk authored Feb 13, 2024
1 parent 7b096ef commit cb95c81
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 56 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions crates/re_analytics/src/native/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use std::sync::Arc;
use super::AbortSignal;
use crate::{Event, PostHogBatch, PostHogEvent};

#[derive(Debug, Clone)]
struct Url(String);

#[derive(Default, Debug, Clone)]
pub(crate) struct PostHogSink {}

Expand Down
4 changes: 2 additions & 2 deletions crates/re_log_types/src/path/parse_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@ fn join(tokens: &[&str]) -> String {
s
}

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

/// "/foo/bar[#42]:Color" -> ["/", "foo", "/", "bar", "[", "#42:", "]", ":", "Color"]
/// `"/foo/bar[#42]:Color"` -> `["/", "foo", "/", "bar", "[", "#42:", "]", ":", "Color"]`
fn tokenize_data_path(path: &str) -> Vec<&str> {
tokenize_by(path, &[b'/', b'[', b']', b':'])
}
Expand Down
2 changes: 1 addition & 1 deletion crates/re_memory/src/accounting_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ thread_local! {
///
/// Tracking an allocation (taking its backtrace etc) can itself create allocations.
/// We don't want to track those allocations, or we will have infinite recursion.
static IS_THREAD_IN_ALLOCATION_TRACKER: std::cell::Cell<bool> = std::cell::Cell::new(false);
static IS_THREAD_IN_ALLOCATION_TRACKER: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
}

// ----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion crates/re_renderer/src/allocator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub use cpu_write_gpu_read_belt::{
};
pub use gpu_readback_belt::{
GpuReadbackBelt, GpuReadbackBuffer, GpuReadbackError, GpuReadbackIdentifier,
GpuReadbackUserDataStorage,
};
pub use uniform_buffer_fill::{
create_and_fill_uniform_buffer, create_and_fill_uniform_buffer_batch,
Expand Down
8 changes: 3 additions & 5 deletions crates/re_renderer/src/allocator/uniform_buffer_fill.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use re_log::ResultExt;

pub use super::cpu_write_gpu_read_belt::{CpuWriteGpuReadBelt, CpuWriteGpuReadBuffer};

use crate::{wgpu_resources::BindGroupEntry, DebugLabel, RenderContext};

struct UniformBufferAlignmentCheck<T> {
Expand All @@ -22,11 +20,11 @@ impl<T> UniformBufferAlignmentCheck<T> {
/// Alternatively to enforcing this alignment on the type we could:
/// * only align on the gpu buffer
/// -> causes more fine grained `copy_buffer_to_buffer` calls on the gpu encoder
/// * only align on the [`CpuWriteGpuReadBuffer`] & gpu buffer
/// -> causes more complicated offset computation on [`CpuWriteGpuReadBuffer`] as well as either
/// * only align on the [`CpuWriteGpuReadBuffer`][crate::allocator::CpuWriteGpuReadBuffer] & gpu buffer
/// -> causes more complicated offset computation on [`CpuWriteGpuReadBuffer`][crate::allocator::CpuWriteGpuReadBuffer] as well as either
/// holes at padding (-> undefined values & slow for write combined!) or complicated nulling of padding
///
/// About the [`bytemuck::Pod`] requirement (dragged in by [`CpuWriteGpuReadBuffer`]):
/// About the [`bytemuck::Pod`] requirement (dragged in by [`CpuWriteGpuReadBuffer`][crate::allocator::CpuWriteGpuReadBuffer]):
/// [`bytemuck::Pod`] forces us to be explicit about padding as it doesn't allow invisible padding bytes!
/// We could drop this and thus make it easier to define uniform buffer types.
/// But this leads to more unsafe code, harder to avoid holes in write combined memory access
Expand Down
15 changes: 4 additions & 11 deletions crates/re_renderer/src/wgpu_resources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ pub use bind_group_layout_pool::{
};

mod bind_group_pool;
pub use bind_group_pool::{
BindGroupDesc, BindGroupEntry, GpuBindGroup, GpuBindGroupHandle, GpuBindGroupPool,
};
pub use bind_group_pool::{BindGroupDesc, BindGroupEntry, GpuBindGroup, GpuBindGroupPool};

mod buffer_pool;
pub use buffer_pool::{BufferDesc, GpuBuffer, GpuBufferHandle, GpuBufferPool};
pub use buffer_pool::{BufferDesc, GpuBuffer, GpuBufferPool};

mod pipeline_layout_pool;
pub use pipeline_layout_pool::{
GpuPipelineLayoutHandle, GpuPipelineLayoutPool, PipelineLayoutDesc,
};
pub use pipeline_layout_pool::{GpuPipelineLayoutPool, PipelineLayoutDesc};

mod render_pipeline_pool;
pub use render_pipeline_pool::{
Expand All @@ -38,16 +34,13 @@ mod shader_module_pool;
pub use shader_module_pool::{GpuShaderModuleHandle, GpuShaderModulePool, ShaderModuleDesc};

mod texture_pool;
pub use texture_pool::{
GpuTexture, GpuTextureHandle, GpuTextureInternal, GpuTexturePool, TextureDesc,
};
pub use texture_pool::{GpuTexture, GpuTextureHandle, GpuTexturePool, TextureDesc};

mod resource;
pub use resource::PoolError;

mod dynamic_resource_pool;
mod static_resource_pool;
pub use static_resource_pool::StaticResourcePoolAccessor;

/// Collection of all wgpu resource pools.
///
Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ pub fn create_labels(
// Closest last (painters algorithm)
labels.sort_by_key(|label| {
if let UiLabelTarget::Position3D(pos) = label.target {
OrderedFloat::try_from(-ui_from_world_3d.transform_point3(pos).z).ok()
OrderedFloat::from(-ui_from_world_3d.transform_point3(pos).z)
} else {
Default::default()
OrderedFloat::from(0.0)
}
});

Expand Down
4 changes: 1 addition & 3 deletions crates/re_space_view_spatial/src/visualizers/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ fn to_textured_rect(
) -> Option<re_renderer::renderer::TexturedRect> {
re_tracing::profile_function!();

let Some([height, width, _]) = tensor.image_height_width_channels() else {
return None;
};
let [height, width, _] = tensor.image_height_width_channels()?;

let debug_name = ent_path.to_string();
let tensor_stats = ctx
Expand Down
4 changes: 2 additions & 2 deletions crates/re_types/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ where
///
/// For instance: `[1, 640, 480, 3, 1]` would return `[1, 2, 3]`,
/// the indices of the `[640, 480, 3]` dimensions.
pub fn find_non_empty_dim_indices(shape: &Vec<TensorDimension>) -> SmallVec<[usize; 4]> {
pub fn find_non_empty_dim_indices(shape: &[TensorDimension]) -> SmallVec<[usize; 4]> {
match shape.len() {
0 => return smallvec![],
1 => return smallvec![0],
Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn find_non_empty_dim_indices(shape: &Vec<TensorDimension>) -> SmallVec<[usi
#[test]
fn test_find_non_empty_dim_indices() {
fn expect(shape: &[u64], expected: &[usize]) {
let dim = shape
let dim: Vec<_> = shape
.iter()
.map(|s| TensorDimension {
size: *s,
Expand Down
1 change: 0 additions & 1 deletion crates/re_types_builder/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ mod docs;
mod python;
mod rust;

pub use self::common::write_file;
pub use self::cpp::CppCodeGenerator;
pub use self::docs::DocsCodeGenerator;
pub use self::python::PythonCodeGenerator;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn guess_query_and_store_for_selected_entity<'a>(
{
(
ctx.blueprint_cfg.time_ctrl.read().current_query(),
&ctx.store_context.blueprint.store(),
ctx.store_context.blueprint.store(),
)
} else {
(
Expand Down
14 changes: 3 additions & 11 deletions crates/re_viewer/src/ui/top_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,17 +407,9 @@ fn e2e_latency_ui(
ui: &mut egui::Ui,
store_context: Option<&StoreContext<'_>>,
) -> Option<egui::Response> {
let Some(store_context) = store_context else {
return None;
};

let Some(recording) = store_context.recording else {
return None;
};

let Some(e2e_latency_sec) = recording.ingestion_stats().current_e2e_latency_sec() else {
return None;
};
let store_context = store_context?;
let recording = store_context.recording?;
let e2e_latency_sec = recording.ingestion_stats().current_e2e_latency_sec()?;

if e2e_latency_sec > 60.0 {
return None; // Probably an old recording and not live data.
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer_context/src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Clipboard {
pub fn with<R>(f: impl FnOnce(&mut Clipboard) -> R) -> R {
use std::cell::RefCell;
thread_local! {
static CLIPBOARD: RefCell<Option<Clipboard>> = RefCell::new(None);
static CLIPBOARD: RefCell<Option<Clipboard>> = const { RefCell::new(None) };
}

CLIPBOARD.with(|clipboard| {
Expand Down
12 changes: 3 additions & 9 deletions crates/re_viewport/src/viewport_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ impl ViewportBlueprint {
space_view_id: &SpaceViewId,
ctx: &ViewerContext<'_>,
) -> Option<SpaceViewId> {
let Some(space_view) = self.space_view(space_view_id) else {
return None;
};
let space_view = self.space_view(space_view_id)?;

let new_space_view = space_view.duplicate(ctx.store_context.blueprint, ctx.blueprint_query);
let new_space_view_id = new_space_view.id;
Expand Down Expand Up @@ -358,9 +356,7 @@ impl ViewportBlueprint {
return Some(Contents::Container(*container_id));
}

let Some(container) = self.container(container_id) else {
return None;
};
let container = self.container(container_id)?;

for contents in &container.contents {
if predicate(contents) {
Expand Down Expand Up @@ -412,9 +408,7 @@ impl ViewportBlueprint {
contents: &Contents,
container_id: &ContainerId,
) -> Option<(ContainerId, usize)> {
let Some(container) = self.container(container_id) else {
return None;
};
let container = self.container(container_id)?;

for (pos, child_contents) in container.contents.iter().enumerate() {
if child_contents == contents {
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/rust_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, cwd: str, start_time: float) -> None:


def run_cargo(command: str, args: str) -> Timing:
cwd = f"cargo {command} {args}"
cwd = f"cargo {command} --quiet {args}"
print(f"Running '{cwd}'")
start = time.time()
result = subprocess.call(cwd, shell=True)
Expand Down

0 comments on commit cb95c81

Please sign in to comment.