diff --git a/clippy.toml b/clippy.toml index 67975f69d..670bd498b 100644 --- a/clippy.toml +++ b/clippy.toml @@ -8,3 +8,10 @@ disallowed-types = [ # The default large-error-threshold is 128. We have a bunch of complex error # types that are slightly larger than that. large-error-threshold = 192 + +# This relatively small stack frame limit is set to avoid problems in several deeply +# recursive functions in naga. If your function has a genuine need for a larger stack frame, +# and is not at risk of deep recursion based on shader structure, it is okay to waive the +# associated `clippy::large_stack_frames` lint. +# TODO(https://github.com/gfx-rs/wgpu/issues/9456): Consider reducing this further +stack-size-threshold = 40_960 diff --git a/naga/src/back/glsl/writer.rs b/naga/src/back/glsl/writer.rs index 3fc045471..3668a6c51 100644 --- a/naga/src/back/glsl/writer.rs +++ b/naga/src/back/glsl/writer.rs @@ -2405,6 +2405,7 @@ impl<'a, W: Write> Writer<'a, W> { /// /// # Notes /// Doesn't add any newlines or leading/trailing spaces + #[allow(clippy::large_stack_frames)] // TODO(https://github.com/gfx-rs/wgpu/issues/9456) fn write_expr( &mut self, expr: Handle, diff --git a/naga/src/front/glsl/context.rs b/naga/src/front/glsl/context.rs index 1b681068d..14230be53 100644 --- a/naga/src/front/glsl/context.rs +++ b/naga/src/front/glsl/context.rs @@ -540,6 +540,7 @@ impl<'a> Context<'a> { } /// Internal implementation of [`lower`](Self::lower) + #[allow(clippy::large_stack_frames)] // TODO(https://github.com/gfx-rs/wgpu/issues/9456) fn lower_inner( &mut self, stmt: &StmtContext, diff --git a/naga/src/front/spv/next_block.rs b/naga/src/front/spv/next_block.rs index 82cfb0879..698ed37e8 100644 --- a/naga/src/front/spv/next_block.rs +++ b/naga/src/front/spv/next_block.rs @@ -18,6 +18,7 @@ impl> Frontend { /// Except for the function's entry block, `block_id` should be the label of /// a block we've seen mentioned before, with an entry in /// `block_ctx.body_for_label` to tell us which `Body` it contributes to. + #[allow(clippy::large_stack_frames)] // TODO(https://github.com/gfx-rs/wgpu/issues/9456) pub(in crate::front::spv) fn next_block( &mut self, block_id: spirv::Word, diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index c744d5fb1..1f2953ef5 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -525,6 +525,9 @@ pub(crate) struct ConcretizationFailedError { impl<'a> Error<'a> { #[cold] #[inline(never)] + // This function is not recursive, so it can exceed our conservatively-set + // `stack-frame-limit` without causing problems. + #[allow(clippy::large_stack_frames)] pub(crate) fn as_parse_error(&self, source: &'a str) -> ParseError { match *self { Error::Unexpected(unexpected_span, expected) => { diff --git a/naga/src/lib.rs b/naga/src/lib.rs index 9fc1e3a21..ff486ba8e 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -82,10 +82,11 @@ void main() { trivial_numeric_casts, unused_extern_crates, unused_qualifications, + clippy::large_stack_frames, clippy::match_wildcard_for_single_variants, clippy::missing_const_for_fn, clippy::pattern_type_mismatch, - clippy::rest_pat_in_fully_bound_structs, + clippy::rest_pat_in_fully_bound_structs )] #![deny(clippy::exit)] #![cfg_attr( diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 8017a0ae7..953388bdf 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -779,6 +779,7 @@ impl super::Validator { Ok(()) } + #[allow(clippy::large_stack_frames)] // TODO(https://github.com/gfx-rs/wgpu/issues/9456) fn validate_block_impl( &mut self, statements: &crate::Block,