cargo-semver-checks 0.48.0

Scan your Rust crate for semver violations.
Documentation
SemverQuery(
    id: "enum_repr_variant_discriminant_changed",
    human_readable_name: "variant of an enum with explicit repr changed discriminant",
    description: "The variant of an enum with explicit repr() had its discriminant change from its previous value.",
    reference: Some("The variant of an enum with an explicit repr() had its discriminant value change. This breaks downstream code that accessed the discriminant via pointer casting."),
    required_update: Major,
    lint_level: Deny,
    reference_link: Some("https://doc.rust-lang.org/reference/items/enumerations.html#pointer-casting"),
    query: r#"
    {
        CrateDiff {
            baseline {
                item {
                    ... on Enum {
                        visibility_limit @filter(op: "=", value: ["$public"]) @output
                        enum_name: name @output @tag

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

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

                        variant {
                            variant_name: name @output @tag

                            discriminant {
                                old_value: value @output @tag
                            }
                        }
                    }
                }
            }
            current {
                item {
                    ... on Enum {
                        visibility_limit @filter(op: "=", value: ["$public"])
                        name @filter(op: "=", value: ["%enum_name"])

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

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

                        variant {
                            name @filter(op: "=", value: ["%variant_name"])

                            discriminant {
                                new_value: value @output @filter(op: "!=", value: ["%old_value"])
                            }

                            span_: span @optional {
                                filename @output
                                begin_line @output
                                end_line @output
                            }
                        }
                    }
                }
            }
        }
    }"#,
    arguments: {
        "public": "public",
        "repr": "repr",
        "repr_regex": "[ui](\\d+|size)",
        "true": true,
    },
    error_message: "An enum variant has changed its discriminant value. The enum has a defined primitive representation, so this breaks downstream code that used the discriminant value via an unsafe pointer cast.",
    per_result_error_template: Some("variant {{enum_name}}::{{variant_name}} {{old_value}} -> {{new_value}} in {{span_filename}}:{{span_begin_line}}"),
)