From 6e528aaf2416eb591e727596c3752f56b5d77df1 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 1 Oct 2024 15:02:51 -0400 Subject: [PATCH] style: split (most) string literals over 100-column line width limit --- naga/src/back/pipeline_constants.rs | 5 +++- naga/src/front/glsl/context.rs | 9 +++++--- naga/src/front/glsl/functions.rs | 3 ++- naga/src/front/glsl/parser/expressions.rs | 8 ++++++- naga/src/front/glsl/variables.rs | 19 ++++++++------- naga/src/front/spv/error.rs | 8 ++++++- wgpu-hal/examples/ray-traced-triangle/main.rs | 11 +++++++-- wgpu-hal/src/auxil/renderdoc.rs | 6 +++-- wgpu-hal/src/gles/mod.rs | 23 +++++++++++++++---- wgpu-hal/src/gles/web.rs | 7 +++--- wgpu-hal/src/vulkan/instance.rs | 12 ++++++++-- wgpu-hal/src/vulkan/mod.rs | 8 ++++++- 12 files changed, 89 insertions(+), 30 deletions(-) diff --git a/naga/src/back/pipeline_constants.rs b/naga/src/back/pipeline_constants.rs index 5f82862f7..0005cbcb0 100644 --- a/naga/src/back/pipeline_constants.rs +++ b/naga/src/back/pipeline_constants.rs @@ -14,7 +14,10 @@ use thiserror::Error; pub enum PipelineConstantError { #[error("Missing value for pipeline-overridable constant with identifier string: '{0}'")] MissingValue(String), - #[error("Source f64 value needs to be finite (NaNs and Inifinites are not allowed) for number destinations")] + #[error( + "Source f64 value needs to be finite ({}) for number destinations", + "NaNs and Inifinites are not allowed" + )] SrcNeedsToBeFinite, #[error("Source f64 value doesn't fit in destination")] DstRangeTooSmall, diff --git a/naga/src/front/glsl/context.rs b/naga/src/front/glsl/context.rs index ee1fcc04b..b4cb1c874 100644 --- a/naga/src/front/glsl/context.rs +++ b/naga/src/front/glsl/context.rs @@ -630,7 +630,8 @@ impl<'a> Context<'a> { frontend.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "Cannot apply operation to {left_inner:?} and {right_inner:?}" + "Cannot apply operation to {:?} and {:?}", + left_inner, right_inner ) .into(), ), @@ -828,7 +829,8 @@ impl<'a> Context<'a> { frontend.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "Cannot apply operation to {left_inner:?} and {right_inner:?}" + "Cannot apply operation to {:?} and {:?}", + left_inner, right_inner ) .into(), ), @@ -908,7 +910,8 @@ impl<'a> Context<'a> { frontend.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "Cannot apply operation to {left_inner:?} and {right_inner:?}" + "Cannot apply operation to {:?} and {:?}", + left_inner, right_inner ) .into(), ), diff --git a/naga/src/front/glsl/functions.rs b/naga/src/front/glsl/functions.rs index a1a603826..2a63c7a02 100644 --- a/naga/src/front/glsl/functions.rs +++ b/naga/src/front/glsl/functions.rs @@ -634,7 +634,8 @@ impl Frontend { self.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "'{name}': image needs {overload_access:?} access but only {call_access:?} was provided" + "'{}': image needs {:?} access but only {:?} was provided", + name, overload_access, call_access ) .into(), ), diff --git a/naga/src/front/glsl/parser/expressions.rs b/naga/src/front/glsl/parser/expressions.rs index 594ad6a6c..c218e7b11 100644 --- a/naga/src/front/glsl/parser/expressions.rs +++ b/naga/src/front/glsl/parser/expressions.rs @@ -38,7 +38,13 @@ impl<'source> ParsingContext<'source> { TokenValue::FloatConstant(float) => { if float.width != 32 { frontend.errors.push(Error { - kind: ErrorKind::SemanticError("Unsupported floating-point value (expected single-precision floating-point number)".into()), + kind: ErrorKind::SemanticError( + concat!( + "Unsupported floating-point value ", + "(expected single-precision floating-point number)" + ) + .into(), + ), meta: token.meta, }); } diff --git a/naga/src/front/glsl/variables.rs b/naga/src/front/glsl/variables.rs index 6b74b254b..16c5bb65d 100644 --- a/naga/src/front/glsl/variables.rs +++ b/naga/src/front/glsl/variables.rs @@ -294,14 +294,17 @@ impl Frontend { .any(|i| components[i..].contains(&components[i - 1])); if not_unique { self.errors.push(Error { - kind: - ErrorKind::SemanticError( - format!( - "swizzle cannot have duplicate components in left-hand-side expression for \"{name:?}\"" - ) - .into(), - ), - meta , + kind: ErrorKind::SemanticError( + format!( + concat!( + "swizzle cannot have duplicate components in ", + "left-hand-side expression for \"{:?}\"" + ), + name + ) + .into(), + ), + meta, }) } } diff --git a/naga/src/front/spv/error.rs b/naga/src/front/spv/error.rs index 219048e10..898113d44 100644 --- a/naga/src/front/spv/error.rs +++ b/naga/src/front/spv/error.rs @@ -47,7 +47,13 @@ pub enum Error { UnsupportedBinaryOperator(spirv::Word), #[error("Naga supports OpTypeRuntimeArray in the StorageBuffer storage class only")] UnsupportedRuntimeArrayStorageClass, - #[error("unsupported matrix stride {stride} for a {columns}x{rows} matrix with scalar width={width}")] + #[error( + "unsupported matrix stride {} for a {}x{} matrix with scalar width={}", + stride, + columns, + rows, + width + )] UnsupportedMatrixStride { stride: u32, columns: u8, diff --git a/wgpu-hal/examples/ray-traced-triangle/main.rs b/wgpu-hal/examples/ray-traced-triangle/main.rs index dd9184373..4eedfe781 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -124,7 +124,12 @@ impl AccelerationStructureInstance { &mut self, shader_binding_table_record_offset: u32, ) { - debug_assert!(shader_binding_table_record_offset <= Self::MAX_U24, "shader_binding_table_record_offset uses more than 24 bits! {shader_binding_table_record_offset} > {}", Self::MAX_U24); + debug_assert!( + shader_binding_table_record_offset <= Self::MAX_U24, + "shader_binding_table_record_offset uses more than 24 bits! {} > {}", + shader_binding_table_record_offset, + Self::MAX_U24 + ); self.shader_binding_table_record_offset_and_flags = (shader_binding_table_record_offset & Self::LOW_24_MASK) | (self.shader_binding_table_record_offset_and_flags & !Self::LOW_24_MASK) @@ -151,7 +156,9 @@ impl AccelerationStructureInstance { ); debug_assert!( shader_binding_table_record_offset <= Self::MAX_U24, - "shader_binding_table_record_offset uses more than 24 bits! {shader_binding_table_record_offset} > {}", Self::MAX_U24 + "shader_binding_table_record_offset uses more than 24 bits! {} > {}", + shader_binding_table_record_offset, + Self::MAX_U24 ); AccelerationStructureInstance { transform: Self::affine_to_rows(transform), diff --git a/wgpu-hal/src/auxil/renderdoc.rs b/wgpu-hal/src/auxil/renderdoc.rs index 3b08955fa..3879bb954 100644 --- a/wgpu-hal/src/auxil/renderdoc.rs +++ b/wgpu-hal/src/auxil/renderdoc.rs @@ -74,7 +74,8 @@ impl RenderDoc { Err(e) => { return RenderDoc::NotAvailable { reason: format!( - "Unable to get RENDERDOC_GetAPI from renderdoc library '{renderdoc_filename}': {e:?}" + "Unable to get RENDERDOC_GetAPI from renderdoc library '{}': {e:?}", + renderdoc_filename ), } } @@ -89,7 +90,8 @@ impl RenderDoc { }, return_value => RenderDoc::NotAvailable { reason: format!( - "Unable to get API from renderdoc library '{renderdoc_filename}': {return_value}" + "Unable to get API from renderdoc library '{}': {}", + renderdoc_filename, return_value ), }, } diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index df5977806..8eb280089 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -457,11 +457,24 @@ impl Texture { }; log::error!( - "wgpu-hal heuristics assumed that the view dimension will be equal to `{got}` rather than `{view_dimension:?}`.\n{}\n{}\n{}\n{}", - "`D2` textures with `depth_or_array_layers == 1` are assumed to have view dimension `D2`", - "`D2` textures with `depth_or_array_layers > 1` are assumed to have view dimension `D2Array`", - "`D2` textures with `depth_or_array_layers == 6` are assumed to have view dimension `Cube`", - "`D2` textures with `depth_or_array_layers > 6 && depth_or_array_layers % 6 == 0` are assumed to have view dimension `CubeArray`", + concat!( + "wgpu-hal heuristics assumed that ", + "the view dimension will be equal to `{}` rather than `{:?}`.\n", + "`D2` textures with ", + "`depth_or_array_layers == 1` ", + "are assumed to have view dimension `D2`\n", + "`D2` textures with ", + "`depth_or_array_layers > 1` ", + "are assumed to have view dimension `D2Array`\n", + "`D2` textures with ", + "`depth_or_array_layers == 6` ", + "are assumed to have view dimension `Cube`\n", + "`D2` textures with ", + "`depth_or_array_layers > 6 && depth_or_array_layers % 6 == 0` ", + "are assumed to have view dimension `CubeArray`\n", + ), + got, + view_dimension, ); } } diff --git a/wgpu-hal/src/gles/web.rs b/wgpu-hal/src/gles/web.rs index ae7f83622..06bd87124 100644 --- a/wgpu-hal/src/gles/web.rs +++ b/wgpu-hal/src/gles/web.rs @@ -64,9 +64,10 @@ impl Instance { // “not supported” could include “insufficient GPU resources” or “the GPU process // previously crashed”. So, we must return it as an `Err` since it could occur // for circumstances outside the application author's control. - return Err(crate::InstanceError::new(String::from( - "canvas.getContext() returned null; webgl2 not available or canvas already in use" - ))); + return Err(crate::InstanceError::new(String::from(concat!( + "canvas.getContext() returned null; ", + "webgl2 not available or canvas already in use" + )))); } Err(js_error) => { // diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 5673859e4..6d56ecf96 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -745,7 +745,12 @@ impl crate::Instance for super::Instance { Ok(sdk_ver) => sdk_ver, Err(err) => { log::error!( - "Couldn't parse Android's ro.build.version.sdk system property ({val}): {err}" + concat!( + "Couldn't parse Android's ", + "ro.build.version.sdk system property ({}): {}", + ), + val, + err, ); 0 } @@ -931,7 +936,10 @@ impl crate::Instance for super::Instance { if version < (21, 2) { // See https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688 log::warn!( - "Disabling presentation on '{}' (id {:?}) due to NV Optimus and Intel Mesa < v21.2", + concat!( + "Disabling presentation on '{}' (id {:?}) ", + "due to NV Optimus and Intel Mesa < v21.2" + ), exposed.info.name, exposed.adapter.raw ); diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 843b836f4..3b0f026fd 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -418,7 +418,13 @@ impl Surface { swapchain.next_present_time = Some(present_timing); } else { // Ideally we'd use something like `device.required_features` here, but that's in `wgpu-core`, which we are a dependency of - panic!("Tried to set display timing properties without the corresponding feature ({features:?}) enabled."); + panic!( + concat!( + "Tried to set display timing properties ", + "without the corresponding feature ({:?}) enabled." + ), + features + ); } } }