cargo-semver-checks 0.48.0

Scan your Rust crate for semver violations.
Documentation
SemverQuery(
    id: "enum_variant_added",
    human_readable_name: "enum variant added on exhaustive enum",
    description: "An exhaustive enum has a new variant.",
    required_update: Major,
    lint_level: Deny,
    reference_link: Some("https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new"),
    query: r#"
    {
        CrateDiff {
            current {
                item {
                    ... on Enum {
                        enum_name: name @output
                        visibility_limit @filter(op: "=", value: ["$public"]) @output
                        attrs @filter(op: "not_contains", value: ["$non_exhaustive"])

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

                        variant {
                            variant_name: name @output @tag

                            span_: span @optional {
                                filename @output
                                begin_line @output
                                end_line @output
                            }
                        }
                    }
                }
            }
            baseline {
                item {
                    ... on Enum {
                        visibility_limit @filter(op: "=", value: ["$public"])
                        attrs @filter(op: "not_contains", value: ["$non_exhaustive"])

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

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

                        variant @fold {
                            baseline_variant_kinds: __typename @output

                            baseline_variant_names: name @output
                        }
                    }
                }
            }
        }
    }"#,
    arguments: {
        "public": "public",
        "true": true,
        "zero": 0,
        "non_exhaustive": "#[non_exhaustive]",
    },
    error_message: "A publicly-visible enum without #[non_exhaustive] has a new variant.",
    per_result_error_template: Some("variant {{enum_name}}:{{variant_name}} in {{span_filename}}:{{span_begin_line}}"),
    witness: (
        hint_template: r#"match value {
{{#each baseline_variant_kinds }}
    {{ join "::" ../path }}::{{lookup ../baseline_variant_names @index}}{{#if (eq this "StructVariant")}} { .. }{{/if}}{{#if (eq this "TupleVariant")}}(..){{/if}} => (),
{{/each}}
}
"#,
    ),
)