cargo-semver-checks 0.30.0

Scan your Rust crate for semver violations.
Documentation
SemverQuery(
    id: "enum_repr_int_changed",
    human_readable_name: "enum repr(u*)/repr(i*) changed",
    description: "An enum's repr attribute changed integer types.",
    reference: Some("The repr(u*) or repr(i*) attribute on an enum was changed to another integer type. This can cause its memory representation to change, breaking FFI use cases."),
    required_update: Major,

    reference_link: Some("https://doc.rust-lang.org/cargo/reference/semver.html#repr-int-enum-change"),
    query: r#"
    {
        CrateDiff {
            baseline {
                item {
                    ... on Enum {
                        visibility_limit @filter(op: "=", value: ["$public"]) @output

                        attribute {
                            old_attr: raw_attribute @output
                            content {
                                base @filter(op: "=", value: ["$repr"])
                                argument {
                                    old_attr_value: base @filter(op: "regex", value: ["$repr_regex"])
                                                         @tag
                                }
                            }
                        }

                        importable_path {
                            path @tag @output
                            public_api @filter(op: "=", value: ["$true"])
                        }
                    }
                }
            }
            current {
                item {
                    ... on Enum {
                        visibility_limit @filter(op: "=", value: ["$public"])
                        name @output

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

                        # Check that there exists an attribute that:
                        # - looks like repr(i*) or repr(u*)
                        # - but is not the same repr(i*) or repr(u*) that we had before.
                        # This is the breaking change.
                        attribute @fold @transform(op: "count") @filter(op: ">", value: ["$zero"]) {
                            raw_attribute @output(name: "new_attr")
                            content {
                                base @filter(op: "=", value: ["$repr"])
                                argument {
                                    base @filter(op: "regex", value: ["$repr_regex"])
                                         @filter(op: "!=", value: ["%old_attr_value"])
                                }
                            }
                        }

                        span_: span @optional {
                            filename @output
                            begin_line @output
                        }
                    }
                }
            }
        }
    }"#,
    arguments: {
        "public": "public",
        "repr": "repr",
        "repr_regex": "[ui](\\d+|size)",
        "true": true,
        "zero": 0,
    },
    error_message: "The repr(u*) or repr(i*) attribute on an enum was changed to another integer type. This can cause its memory representation to change, breaking FFI use cases.",
    per_result_error_template: Some("enum {{name}} {{old_attr}} -> {{new_attr.0}} in {{span_filename}}:{{span_begin_line}}"),
)