SemverQuery(
id: "enum_repr_int_added",
human_readable_name: "enum repr(u*)/repr(i*) added",
description: "An enum gained an integer repr attribute.",
required_update: Minor,
lint_level: Allow,
reference_link: Some("https://doc.rust-lang.org/nomicon/other-reprs.html#repru-repri"),
query: r#"
{
CrateDiff {
current {
item {
... on Enum {
visibility_limit @filter(op: "=", value: ["$public"]) @output
name @output
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
attribute {
content {
base @filter(op: "=", value: ["$repr"])
argument {
base @filter(op: "regex", value: ["$repr_regex"])
}
}
}
span_: span @optional {
filename @output
begin_line @output
}
}
}
}
baseline {
item {
... on Enum {
importable_path {
path @filter(op: "=", value: ["%path"])
}
attribute @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
content {
base @filter(op: "=", value: ["$repr"])
argument {
base @filter(op: "regex", value: ["$repr_regex"])
}
}
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"repr": "repr",
"repr_regex": "[ui](\\d+|size)",
"true": true,
"zero": 0,
},
error_message: "repr(u*) or repr(i*) was added to an enum. Downstream code may now begin to depend on this enum's binary representation. Undoing this change in the future would be a major breaking change.",
per_result_error_template: Some("enum {{name}} in {{span_filename}}:{{span_begin_line}}"),
)