SemverQuery(
id: "struct_repr_c_removed",
human_readable_name: "struct repr(C) removed",
description: "A struct that used to be repr(C) is no longer repr(C).",
reference: Some("A struct that used to be repr(C) is no longer repr(C). This can cause its memory layout to change, breaking FFI use cases."),
required_update: Major,
// TODO: Change the reference link to point to the cargo semver reference
// once it has a section on repr(C).
reference_link: Some("https://doc.rust-lang.org/nomicon/other-reprs.html#reprc"),
query: r#"
{
CrateDiff {
baseline {
item {
... on Struct {
visibility_limit @filter(op: "=", value: ["$public"]) @output
attribute {
old_attr: raw_attribute @output
content {
base @filter(op: "=", value: ["$repr"])
argument {
base @filter(op: "=", value: ["$c"])
}
}
}
importable_path {
path @tag @output
}
}
}
}
current {
item {
... on Struct {
visibility_limit @filter(op: "=", value: ["$public"])
name @output
attribute @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
content {
base @filter(op: "=", value: ["$repr"])
argument {
base @filter(op: "=", value: ["$c"])
}
}
}
importable_path {
path @filter(op: "=", value: ["%path"])
}
span_: span @optional {
filename @output
begin_line @output
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"repr": "repr",
"c": "C",
"zero": 0,
},
error_message: "repr(C) was removed from a struct. This can cause its memory layout to change, breaking FFI use cases.",
per_result_error_template: Some("struct {{name}} in {{span_filename}}:{{span_begin_line}}"),
)