SemverQuery(
id: "trait_associated_const_marked_deprecated",
human_readable_name: "trait associated constant #[deprecated] added",
description: "A trait's associated constant has been newly marked with #[deprecated].",
required_update: Minor,
lint_level: Deny,
reference_link: Some("https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute"),
query: r#"
{
CrateDiff {
current {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"])
name @output
# Filter out deprecated traits since rustdoc automatically marks their associated constants as deprecated.
# This ensures we only detect constants that are explicitly marked with #[deprecated].
deprecated @filter(op: "!=", value: ["$true"])
importable_path {
path @tag @output
public_api @filter(op: "=", value: ["$true"])
}
associated_constant {
associated_constant: name @output @tag
public_api_eligible @filter(op: "=", value: ["$true"])
deprecated @filter(op: "=", value: ["$true"])
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
}
}
}
}
baseline {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"]) @output
deprecated @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"])
public_api_eligible @filter(op: "=", value: ["$true"])
deprecated @filter(op: "!=", value: ["$true"])
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
},
error_message: "A trait associated constant is now #[deprecated]. Downstream crates will get a compiler warning when using it.",
per_result_error_template: Some("associated constant {{associated_constant}} in trait {{join \"::\" path}} in {{span_filename}}:{{span_begin_line}}"),
)