SemverQuery(
id: "trait_method_unsafe_removed",
human_readable_name: "pub trait method became safe",
description: "A method in a public trait became safe",
required_update: Major,
lint_level: Deny,
reference_link: Some("https://doc.rust-lang.org/stable/reference/unsafe-keyword.html#unsafe-functions-unsafe-fn"),
query: r#"
{
CrateDiff {
baseline {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"]) @output
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
supertrait @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
trait {
importable_path @fold @transform(op: "count") @filter(op: "=", value: ["$zero"])
}
}
method {
unsafe @filter(op: "=", value: ["$true"])
public_api_eligible @filter(op: "=", value: ["$true"])
method_name: name @output @tag
}
}
}
}
current {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"])
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
method {
unsafe @filter(op: "!=", value: ["$true"])
public_api_eligible @filter(op: "=", value: ["$true"])
name @filter(op: "=", value: ["%method_name"])
span_: span @optional {
filename @output
begin_line @output
}
}
}
}
}
}
}"#,
arguments: {
"true": true,
"public": "public",
"zero": 0,
},
error_message: "A publicly-visible trait method is no longer `unsafe`, so implementations must remove the `unsafe` qualifier.",
per_result_error_template: Some("trait method <{{join \"::\" path}}>::{{method_name}} in file {{span_filename}}:{{span_begin_line}}"),
)