SemverQuery(
id: "safe_function_target_feature_added",
human_readable_name: "pub fn now requires target features",
description: "A safe function added a #[target_feature] requirement.",
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 Function {
visibility_limit @filter(op: "=", value: ["$public"])
name @output
# If the function has since become unsafe, that's already breaking.
# Let that lint take precedence.
unsafe @filter(op: "!=", value: ["$true"])
requires_feature @fold @transform(op: "count") @filter(op: "!=", value: ["$zero"]) {
explicit @filter(op: "=", value: ["$true"])
feature: name @output
}
# 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"])
}
importable_path {
path @tag
public_api @filter(op: "=", value: ["$true"])
}
span_: span @optional {
filename @output
begin_line @output
end_line @output
}
}
}
}
baseline {
item {
... on Function {
visibility_limit @filter(op: "=", value: ["$public"]) @output
unsafe @filter(op: "=", value: ["$false"])
requires_feature @fold @transform(op: "count") @filter(op: "=", value: ["$zero"])
importable_path {
path @filter(op: "=", value: ["%path"]) @output
public_api @filter(op: "=", value: ["$true"])
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
"false": false,
"zero": 0,
},
error_message: "A safe function now requires CPU target features to be enabled. It no longer implements Fn() traits as a result.",
per_result_error_template: Some("{{join \"::\" path}} requires {{join \", \" feature}} in {{span_filename}}:{{span_begin_line}}"),
witness: None,
)