mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Give front::wgsl::Error::InitializationTypeMismatch named fields.
This commit is contained in:
committed by
Teodor Tanasoaia
parent
946745d38f
commit
528bca75f7
@@ -177,7 +177,11 @@ pub enum Error<'a> {
|
||||
InconsistentBinding(Span),
|
||||
TypeNotConstructible(Span),
|
||||
TypeNotInferrable(Span),
|
||||
InitializationTypeMismatch(Span, String, String),
|
||||
InitializationTypeMismatch {
|
||||
name: Span,
|
||||
expected: String,
|
||||
got: String,
|
||||
},
|
||||
MissingType(Span),
|
||||
MissingAttribute(&'static str, Span),
|
||||
InvalidAtomicPointer(Span),
|
||||
@@ -475,15 +479,15 @@ impl<'a> Error<'a> {
|
||||
labels: vec![(span, "type can't be inferred".into())],
|
||||
notes: vec![],
|
||||
},
|
||||
Error::InitializationTypeMismatch(name_span, ref expected_ty, ref got_ty) => {
|
||||
Error::InitializationTypeMismatch { name, ref expected, ref got } => {
|
||||
ParseError {
|
||||
message: format!(
|
||||
"the type of `{}` is expected to be `{}`, but got `{}`",
|
||||
&source[name_span], expected_ty, got_ty,
|
||||
&source[name], expected, got,
|
||||
),
|
||||
labels: vec![(
|
||||
name_span,
|
||||
format!("definition of `{}`", &source[name_span]).into(),
|
||||
name,
|
||||
format!("definition of `{}`", &source[name]).into(),
|
||||
)],
|
||||
notes: vec![],
|
||||
}
|
||||
|
||||
@@ -911,22 +911,22 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
if let Some(explicit) = explicit_ty {
|
||||
if explicit != inferred_type {
|
||||
let ty = &ctx.module.types[explicit];
|
||||
let explicit = ty
|
||||
let expected = ty
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| ty.inner.to_wgsl(ctx.module.to_ctx()));
|
||||
|
||||
let ty = &ctx.module.types[inferred_type];
|
||||
let inferred = ty
|
||||
let got = ty
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| ty.inner.to_wgsl(ctx.module.to_ctx()));
|
||||
|
||||
return Err(Error::InitializationTypeMismatch(
|
||||
c.name.span,
|
||||
explicit,
|
||||
inferred,
|
||||
));
|
||||
return Err(Error::InitializationTypeMismatch {
|
||||
name: c.name.span,
|
||||
expected,
|
||||
got,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1113,11 +1113,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
.inner
|
||||
.equivalent(&ctx.module.types[init_ty].inner, &ctx.module.types)
|
||||
{
|
||||
return Err(Error::InitializationTypeMismatch(
|
||||
l.name.span,
|
||||
ctx.format_type(ty),
|
||||
ctx.format_type(init_ty),
|
||||
));
|
||||
return Err(Error::InitializationTypeMismatch {
|
||||
name: l.name.span,
|
||||
expected: ctx.format_type(ty),
|
||||
got: ctx.format_type(init_ty),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1152,11 +1152,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
.inner
|
||||
.equivalent(initializer_ty, &ctx.module.types)
|
||||
{
|
||||
return Err(Error::InitializationTypeMismatch(
|
||||
v.name.span,
|
||||
ctx.format_type(explicit),
|
||||
ctx.format_typeinner(initializer_ty),
|
||||
));
|
||||
return Err(Error::InitializationTypeMismatch {
|
||||
name: v.name.span,
|
||||
expected: ctx.format_type(explicit),
|
||||
got: ctx.format_typeinner(initializer_ty),
|
||||
});
|
||||
}
|
||||
explicit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user