Skip to content

Commit

Permalink
style: split (most) string literals over 100-column line width limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Oct 1, 2024
1 parent 1aae134 commit a6ae1a1
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 30 deletions.
5 changes: 4 additions & 1 deletion naga/src/back/pipeline_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions naga/src/front/glsl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down Expand Up @@ -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(),
),
Expand Down Expand Up @@ -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(),
),
Expand Down
3 changes: 2 additions & 1 deletion naga/src/front/glsl/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down
8 changes: 7 additions & 1 deletion naga/src/front/glsl/parser/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down
19 changes: 11 additions & 8 deletions naga/src/front/glsl/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
Expand Down
8 changes: 7 additions & 1 deletion naga/src/front/spv/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 9 additions & 2 deletions wgpu-hal/examples/ray-traced-triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions wgpu-hal/src/auxil/renderdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
}
}
Expand All @@ -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
),
},
}
Expand Down
23 changes: 18 additions & 5 deletions wgpu-hal/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}
Expand Down
7 changes: 4 additions & 3 deletions wgpu-hal/src/gles/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
// <https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-getcontext>
Expand Down
12 changes: 10 additions & 2 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
);
Expand Down
8 changes: 7 additions & 1 deletion wgpu-hal/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
}
Expand Down

0 comments on commit a6ae1a1

Please sign in to comment.