SemverQuery(
id: "trait_unsafe_added",
human_readable_name: "pub trait became unsafe",
description: "A public trait became unsafe, requiring `unsafe impl` blocks to implement it.",
required_update: Major,
lint_level: Deny,
reference_link: Some("https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#implementing-an-unsafe-trait"),
query: r#"
{
CrateDiff {
baseline {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"]) @output
unsafe @filter(op: "!=", value: ["$true"])
public_api_sealed @filter(op: "!=", value: ["$true"])
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
}
}
}
current {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"])
name @output
unsafe @filter(op: "=", value: ["$true"])
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
},
error_message: "A publicly-visible trait became `unsafe`, so implementing it now requires an `unsafe impl` block.",
per_result_error_template: Some("trait {{join \"::\" path}} in file {{span_filename}}:{{span_begin_line}}"),
witness: (
hint_template: r#"struct Witness;
impl {{join "::" path}} for Witness {...}"#,
),
)