SemverQuery(
id: "trait_added_supertrait",
human_readable_name: "non-sealed trait added new supertraits",
description: "A non-sealed trait added one or more supertraits, which breaks downstream implementations of the trait",
required_update: Major,
lint_level: Deny,
reference_link: Some("https://doc.rust-lang.org/cargo/reference/semver.html#generic-bounds-tighten"),
query: r#"
{
CrateDiff {
current {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"])
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
supertrait {
supertrait: name @output @tag
}
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
}
}
}
baseline {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"]) @output
public_api_sealed @filter(op: "!=", value: ["$true"])
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
supertrait @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
name @filter(op: "=", value: ["%supertrait"])
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
"zero": 0,
},
error_message: "A non-sealed trait added one or more supertraits, which breaks downstream implementations of the trait",
per_result_error_template: Some("trait {{join \"::\" path}} gained {{supertrait}} in file {{span_filename}}:{{span_begin_line}}"),
)