mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
[naga wgsl-in] Use a better span for errors in constructors.
When reporting errors in construction expressions, use the span of the constructor itself (that is, the type name) in preference to the span of the overall expression. This makes errors easier to follow.
This commit is contained in:
parent
1823f8bbdf
commit
07b83ab6c0
@ -448,7 +448,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
ctx.try_automatic_conversions_slice(
|
||||
&mut components,
|
||||
&Tr::Value(component_ty),
|
||||
span,
|
||||
ty_span,
|
||||
)?;
|
||||
expr = crate::Expression::Compose { ty, components };
|
||||
}
|
||||
@ -497,7 +497,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
// Array constructor, explicit type
|
||||
(components, Constructor::Type((ty, &crate::TypeInner::Array { base, .. }))) => {
|
||||
let mut components = components.into_components_vec();
|
||||
ctx.try_automatic_conversions_slice(&mut components, &Tr::Handle(base), span)?;
|
||||
ctx.try_automatic_conversions_slice(&mut components, &Tr::Handle(base), ty_span)?;
|
||||
expr = crate::Expression::Compose { ty, components };
|
||||
}
|
||||
|
||||
|
@ -213,9 +213,8 @@ fn constructor_parameter_type_mismatch() {
|
||||
┌─ wgsl:3:21
|
||||
│
|
||||
3 │ _ = mat2x2<f32>(array(0, 1), vec2(2, 3));
|
||||
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
│ │ │
|
||||
│ │ this expression has type array<{AbstractInt}, 2>
|
||||
│ ^^^^^^^^^^^ ^^^^^^^^^^^ this expression has type array<{AbstractInt}, 2>
|
||||
│ │
|
||||
│ a value of type vec2<f32> is required here
|
||||
|
||||
"#,
|
||||
|
Loading…
Reference in New Issue
Block a user