SemverQuery(
id: "struct_no_longer_non_exhaustive",
human_readable_name: "struct no longer #[non_exhaustive]",
description: "A pub struct is no longer #[non_exhaustive]. It can now be constructed using a struct literal outside its crate.",
required_update: Minor,
lint_level: Allow,
reference_link: Some("https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute"),
query: r#"
{
CrateDiff {
current {
item {
... on Struct {
visibility_limit @filter(op: "=", value: ["$public"]) @output
name @output
struct_type @output
attrs @filter(op: "not_contains", value: ["$non_exhaustive"])
# ensure all fields are public (no private fields).
field @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
visibility_limit @filter(op: "!=", value: ["$public"])
}
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
}
}
}
baseline {
item {
... on Struct {
visibility_limit @filter(op: "=", value: ["$public"])
attrs @filter(op: "contains", value: ["$non_exhaustive"])
# ensure all fields are public (no private fields).
field @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
visibility_limit @filter(op: "!=", value: ["$public"])
}
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"non_exhaustive": "#[non_exhaustive]",
"true": true,
"zero": 0,
},
error_message: "A public struct is no longer #[non_exhaustive]. It can newly be constructed using a struct literal outside its crate.",
per_result_error_template: Some("struct {{name}} in {{span_filename}}:{{span_begin_line}}"),
)