# This is used by `scripts/rust_checks.py` wasm checks so we can forbid some methods that are not available in wasm. # # Use it with `pixi run rs-check --only wasm` # # We cannot forbid all these methods in the main `clippy.toml` because of # https://github.com/rust-lang/rust-clippy/issues/10406 # ----------------------------------------------------------------------------- # Section identical to the main clippy.toml: msrv = "1.92" allow-unwrap-in-tests = true # https://doc.rust-lang.org/nightly/clippy/lint_configuration.html#avoid-breaking-exported-api # We want suggestions, even if it changes public API. avoid-breaking-exported-api = false excessive-nesting-threshold = 16 # TODO(emilk): lower this max-fn-params-bools = 1 # https://rust-lang.github.io/rust-clippy/master/index.html#/large_include_file max-include-file-size = 1000000 too-many-lines-threshold = 600 # TODO(emilk): decrease this # ----------------------------------------------------------------------------- # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros disallowed-macros = [ 'std::dbg', { path = "egui::hex_color", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "std::debug_assert", reason = "Use `re_log::debug_assert` instead" }, { path = "std::debug_assert_eq", reason = "Use `re_log::debug_assert_eq` instead" }, # TODO(emilk): consider forbidding these to encourage the use of proper log stream, and then explicitly allow legitimate uses # 'std::eprint', # 'std::eprintln', # 'std::print', # 'std::println', # 'std::unimplemented', # generated by ArrowDeserialize derive-macro :( ] # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods disallowed-methods = [ { path = "arrow::compute::concat", reason = "Use `re_arrow_util::arrow_util::concat_arrays` instead, which has better memory management" }, { path = "arrow::compute::filter", reason = "Use `re_arrow_util::arrow_util::filter_array` instead" }, { path = "arrow::compute::take", reason = "Use `re_arrow_util::arrow_util::take_array` instead" }, { path = "arrow::datatypes::Schema::new", reason = "Use `arrow::datatypes::Schema::new_with_metadata` instead. There is usually some metadata you want to preserve." }, { path = "camino::Utf8Path::is_dir", reason = "Can't access files on web" }, { path = "camino::Utf8Path::is_file", reason = "Can't access files on web" }, { path = "camino::Utf8Path::metadata", reason = "Can't access files on web" }, { path = "camino::Utf8Path::read_dir", reason = "Can't access files on web" }, { path = "crossbeam::channel::bounded", reason = "Cannot block on Web. Use unbounded channels on web, and bounded channels on native." }, { path = "crossbeam::channel::Receiver::iter", reason = "Cannot block on Web" }, { path = "crossbeam::channel::Receiver::recv_timeout", reason = "Cannot block on Web" }, { path = "crossbeam::channel::Receiver::recv", reason = "Cannot block on Web" }, { path = "crossbeam::channel::Sender::send_deadline", reason = "Cannot block on Web" }, { path = "crossbeam::channel::Sender::send_timeout", reason = "Cannot block on Web" }, { path = "ecolor::Color32::from_additive_luminance", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Color32::from_black_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Color32::from_gray", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Color32::from_rgb", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Color32::from_rgba_premultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Color32::from_rgba_unmultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Color32::from_white_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Rgba::from_black_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Rgba::from_gray", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Rgba::from_luminance_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Rgba::from_rgb", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Rgba::from_rgba_premultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Rgba::from_rgba_unmultiplied", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "ecolor::Rgba::from_white_alpha", reason = "Do not hard-code colors - declare them design_tokens.rs instead, and define in light/dark_theme.json" }, { path = "egui_extras::TableBody::row", reason = "`row` doesn't scale. Use `rows` instead." }, { path = "egui::Ui::checkbox", reason = "Use `re_checkbox` from `re_ui::UiEx" }, { path = "egui::Ui::radio_value", reason = "Use `re_radio_value` from `re_ui::UiEx" }, { path = "egui::Ui::spinner", reason = "Use `ui.loading_indicator` from `re_ui::UiEx" }, { path = "glam::Vec2::normalize", reason = "normalize() can create NaNs. Use try_normalize or normalize_or_zero" }, { path = "glam::Vec3::normalize", reason = "normalize() can create NaNs. Use try_normalize or normalize_or_zero" }, { path = "macaw::BoundingBox::from_points", reason = "from_points propagates NaN/inf. Use re_renderer::util::bounding_box_from_points instead" }, { path = "poll_promise::Promise::block_and_take", reason = "Cannot block on Web" }, { path = "poll_promise::Promise::block_until_ready_mut", reason = "Cannot block on Web" }, { path = "poll_promise::Promise::block_until_ready", reason = "Cannot block on Web" }, { path = "pollster::block_on", reason = "Cannot block on Web" }, { path = "rayon::spawn", reason = "Cannot spawn threads on wasm" }, { path = "sha1::Digest::new", reason = "SHA1 is cryptographically broken" }, { path = "std::env::temp_dir", reason = "Use the tempdir crate instead" }, { path = "std::fs::metadata", reason = "Can't access files on web" }, { path = "std::fs::Path::is_dir", reason = "Can't access files on web" }, { path = "std::fs::Path::is_file", reason = "Can't access files on web" }, { path = "std::fs::Path::read_dir", reason = "Can't access files on web" }, { path = "std::fs::read", reason = "Can't access files on web" }, { path = "std::fs::write", reason = "Can't access files on web" }, { path = "std::panic::catch_unwind", reason = "We compile with `panic = 'abort'`" }, { path = "std::path::Path::metadata", reason = "Can't access files on web" }, { path = "std::sync::mpsc::channel", reason = "Use bounded channels (like re_quota_channel) to apply backpressure." }, { path = "std::sync::mpsc::Receiver::iter", reason = "Cannot block on Web" }, { path = "std::sync::mpsc::Receiver::recv_timeout", reason = "Cannot block on Web" }, { path = "std::sync::mpsc::Receiver::recv", reason = "Cannot block on Web" }, { path = "std::sync::mpsc::sync_channel", reason = "Cannot block on Web" }, { path = "std::thread::sleep", reason = "Can't block on web" }, { path = "std::thread::spawn", reason = "Cannot spawn threads on wasm" }, { path = "std::time::Instant::elapsed", reason = "use `web-time` crate instead for wasm/web compatibility" }, { path = "std::time::Instant::now", reason = "use `web-time` crate instead for wasm/web compatibility" }, { path = "std::time::SystemTime::now", reason = "use `web-time` or `time` crates instead for wasm/web compatibility" }, { path = "tokio::spawn", reason = "no Tokio runtime on web" }, { path = "tokio::sync::mpsc::unbounded_channel", reason = "Use bounded channels on native to apply backpressure." }, { path = "tokio::task::spawn_blocking", reason = "no Tokio runtime on web" }, { path = "tokio::task::spawn", reason = "no Tokio runtime on web" }, { path = "tokio::time::sleep", reason = "no Tokio runtime on web" }, ] # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types disallowed-types = [ { path = "egui::Checkbox", reason = "Use `re_checkbox` from `re_ui::UiEx" }, { path = "egui::Spinner", reason = "Use re_ui::loading_indicator" }, { path = "instant::SystemTime", reason = "Known bugs. Use web-time." }, { path = "once_cell::sync::OnceCell", reason = "Use `std::sync::OnceLock` instead" }, { path = "std::fs::File", reason = "Can't access files on web" }, { path = "std::sync::Condvar", reason = "Use parking_lot instead" }, { path = "std::sync::mpsc::SyncSender", reason = "Cannot block on Web" }, { path = "std::sync::Mutex", reason = "Use parking_lot instead" }, { path = "std::sync::RwLock", reason = "Use parking_lot instead" }, { path = "std::thread::Builder", reason = "Cannot spawn threads on wasm" }, # { path = "std::path::PathBuf" }, # We allow having paths, just not resolving them to files { path = "wgpu::PollType", reason = "Cannot block on Web. Technically only `wgpu::PollType::Wait` is disallowed, but we can't check for that. `wgpu::PollType::Poll` is technically fine, but it is a no-op on WebGPU, so if we rely on it this may hint at a problem." }, ] # Allow-list of words for markdown in docstrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown doc-valid-idents = [ # You must also update the same list in the root `clippy.toml`! "..", "AOMedia", "DataFusion", "GiB", "GitHub", "GLB", "GLTF", "GoP", # Group of Pictures - common video term "GoPs", # Group of Pictures - common video term "iOS", "IPv4", "IPv6", "macOS", "MessagePack", "MiB", "MiMalloc", "NaN", "OBJ", "OpenGL", "OpenID", "PyPI", "sRGB", "sRGBA", "WebCodec", "WebGL", "WebGPU", "WebSocket", "WebSockets", ]