cargo-semver-checks 0.48.0

Scan your Rust crate for semver violations.
Documentation
SemverQuery(
    id: "unsafe_function_requires_more_target_features",
    human_readable_name: "unsafe fn requires more target features",
    description: "An unsafe function now requires additional CPU target features compared to the previous version.",
    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"])
                        fn_name: name @output

                        # We still want to lint even if the function has become safe.
                        currently_unsafe: unsafe @output

                        importable_path {
                            path @output @tag
                            public_api @filter(op: "=", value: ["$true"])
                        }

                        requires_feature {
                            explicit @filter(op: "=", value: ["$true"])
                            globally_enabled @filter(op: "=", value: ["$false"])
                            new_feature: name @output @tag
                        }

                        # 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 Function {
                        visibility_limit @filter(op: "=", value: ["$public"])
                        unsafe @filter(op: "=", value: ["$true"])

                        importable_path {
                            path @filter(op: "=", value: ["%path"])
                            public_api @filter(op: "=", value: ["$true"])
                        }

                        requires_feature @fold @transform(op: "count") @filter(op: ">", value: ["$zero"]) {
                            explicit @filter(op: "=", value: ["$true"])
                        }

                        requires_feature @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
                            name @filter(op: "=", value: ["%new_feature"])
                        }

                        # Don't trigger the lint if the function wasn't callable on the current target triple.
                        # Nothing could have been using it here in the first place, so there's nothing to break.
                        requires_feature @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
                            valid_for_current_target @filter(op: "=", value: ["$false"])
                        }
                    }
                }
            }
        }
    }"#,
    arguments: {
        "public": "public",
        "true": true,
        "false": false,
        "zero": 0,
    },
    error_message: "A function now requires additional CPU target features to be enabled.",
    per_result_error_template: Some("{{fn_name}} requires {{new_feature}} in {{span_filename}}:{{span_begin_line}}"),
    witness: None,
)