SemverQuery(
id: "unsafe_inherent_method_target_feature_added",
human_readable_name: "unsafe inherent method now requires target features",
description: "A pub unsafe inherent method or associated fn gained one or more #[target_feature] requirements.",
required_update: Major,
lint_level: Deny,
reference_link: Some("https://doc.rust-lang.org/reference/attributes/codegen.html#the-target_feature-attribute"),
query: r#"
{
CrateDiff {
current {
item {
... on ImplOwner {
visibility_limit @filter(op: "=", value: ["$public"]) @output
name @output
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
inherent_impl {
method {
method_visibility: visibility_limit @filter(op: "=", value: ["$public"]) @output @tag
method_name: name @output @tag
public_api_eligible @filter(op: "=", value: ["$true"])
# We don't care if the method is still unsafe. Lint anyway.
currently_unsafe: unsafe @output
requires_feature @fold @transform(op: "count") @filter(op: ">", value: ["$zero"]) {
feature_names: name @output
explicit @filter(op: "=", value: ["$true"])
globally_enabled @filter(op: "=", value: ["$false"])
}
# Don't trigger the lint if the function became uncallable on the current target triple.
# We have a separate lint for that.
requires_feature @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
valid_for_current_target @filter(op: "=", value: ["$false"])
}
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
}
}
}
}
}
baseline {
item {
... on ImplOwner {
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
inherent_impl {
method {
visibility_limit @filter(op: "=", value: ["%method_visibility"])
name @filter(op: "=", value: ["%method_name"])
unsafe @filter(op: "=", value: ["$true"])
requires_feature @fold @transform(op: "count") @filter(op: "=", value: ["$zero"])
}
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
"false": false,
"zero": 0,
},
error_message: "A publicly-visible unsafe method or associated fn now requires additional CPU features to be enabled.",
per_result_error_template: Some(r#"{{name}}::{{method_name}} now requires {{join ", " feature_names}} in {{span_filename}}:{{span_begin_line}}"#),
witness: None,
)