Skip to content

Commit d440784

Browse files
committed
abi layout compiletest: fix invalid-matrix-type
1 parent eb7ef13 commit d440784

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,10 @@ fn def_id_for_spirv_type_adt(layout: TyAndLayout<'_>) -> Option<DefId> {
973973
}
974974
}
975975

976+
fn span_for_spirv_type_adt(cx: &CodegenCx<'_>, layout: TyAndLayout<'_>) -> Option<Span> {
977+
def_id_for_spirv_type_adt(layout).map(|did| cx.tcx.def_span(did))
978+
}
979+
976980
/// Minimal and cheaply comparable/hashable subset of the information contained
977981
/// in `TyLayout` that can be used to generate a name (assuming a nominal type).
978982
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
@@ -1222,6 +1226,7 @@ fn trans_intrinsic_type<'tcx>(
12221226
}
12231227
}
12241228
IntrinsicType::Matrix => {
1229+
let span = span_for_spirv_type_adt(cx, ty).unwrap();
12251230
let (element, count) =
12261231
trans_glam_like_struct(cx, span, ty, args, "`#[spirv(matrix)]`")?;
12271232
match cx.lookup_type(element) {
@@ -1238,6 +1243,7 @@ fn trans_intrinsic_type<'tcx>(
12381243
Ok(SpirvType::Matrix { element, count }.def(span, cx))
12391244
}
12401245
IntrinsicType::Vector => {
1246+
let span = span_for_spirv_type_adt(cx, ty).unwrap();
12411247
let (element, count) =
12421248
trans_glam_like_struct(cx, span, ty, args, "`#[spirv(vector)]`")?;
12431249
match cx.lookup_type(element) {

tests/compiletests/ui/spirv-attr/invalid-matrix-type-empty.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: #[spirv(matrix)] type must have at least two fields
1+
error: `#[spirv(matrix)]` member types must all be the same
22
--> $DIR/invalid-matrix-type-empty.rs:7:1
33
|
44
7 | pub struct EmptyStruct {}

tests/compiletests/ui/spirv-attr/invalid-matrix-type.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: #[spirv(matrix)] type must have at least two fields
1+
error: `#[spirv(matrix)]` must have at least 2 members
22
--> $DIR/invalid-matrix-type.rs:7:1
33
|
44
7 | pub struct _FewerFields {
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66

7-
error: #[spirv(matrix)] type fields must all be vectors
7+
error: `#[spirv(matrix)]` type fields must all be vectors
88
--> $DIR/invalid-matrix-type.rs:12:1
99
|
1010
12 | pub struct _NotVectorField {
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
|
1313
= note: field type is f32
1414

15-
error: #[spirv(matrix)] type fields must all be the same type
15+
error: `#[spirv(matrix)]` member types must all be the same
1616
--> $DIR/invalid-matrix-type.rs:19:1
1717
|
1818
19 | pub struct _DifferentType {

0 commit comments

Comments
 (0)