SemverQuery(
id: "trait_associated_const_default_removed",
human_readable_name: "non-sealed trait removed the default value for an associated constant",
description: "A non-sealed trait associated constant lost its default value, 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#trait-item-signature"),
query: r#"
{
CrateDiff {
current {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"])
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
associated_constant {
associated_constant: name @output @tag
default @filter(op: "is_null") @output
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"])
}
associated_constant {
name @filter(op: "=", value: ["%associated_constant"])
default @filter(op: "is_not_null")
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
},
error_message: "A non-sealed trait associated constant lost its default value, which breaks downstream implementations of the trait",
per_result_error_template: Some("trait constant {{join \"::\" path}}::{{associated_constant}} in file {{span_filename}}:{{span_begin_line}}"),
)