Skip to content

Commit e9828e0

Browse files
committed
abi layout compiletest: fix invalid-matrix-type
1 parent fdbef58 commit e9828e0

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
@@ -982,6 +982,10 @@ fn def_id_for_spirv_type_adt(layout: TyAndLayout<'_>) -> Option<DefId> {
982982
}
983983
}
984984

985+
fn span_for_spirv_type_adt(cx: &CodegenCx<'_>, layout: TyAndLayout<'_>) -> Option<Span> {
986+
def_id_for_spirv_type_adt(layout).map(|did| cx.tcx.def_span(did))
987+
}
988+
985989
/// Minimal and cheaply comparable/hashable subset of the information contained
986990
/// in `TyLayout` that can be used to generate a name (assuming a nominal type).
987991
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
@@ -1231,6 +1235,7 @@ fn trans_intrinsic_type<'tcx>(
12311235
}
12321236
}
12331237
IntrinsicType::Matrix => {
1238+
let span = span_for_spirv_type_adt(cx, ty).unwrap();
12341239
let (element, count) =
12351240
trans_glam_like_struct(cx, span, ty, args, "`#[spirv(matrix)]`")?;
12361241
match cx.lookup_type(element) {
@@ -1247,6 +1252,7 @@ fn trans_intrinsic_type<'tcx>(
12471252
Ok(SpirvType::Matrix { element, count }.def(span, cx))
12481253
}
12491254
IntrinsicType::Vector => {
1255+
let span = span_for_spirv_type_adt(cx, ty).unwrap();
12501256
let (element, count) =
12511257
trans_glam_like_struct(cx, span, ty, args, "`#[spirv(vector)]`")?;
12521258
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)