cargo-semver-checks 0.48.0

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

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

                        variant {
                            ... on TupleVariant {
                                # If the variant is newly marked `#[non_exhaustive]`,
                                # that's already a breaking change that has its own rule.
                                # Don't also report new field additions, since the programmer has
                                # clearly stated that they don't consider it exhaustive anymore.
                                attrs @filter(op: "not_contains", value: ["$non_exhaustive"])

                                # If the variant is newly marked `#[doc(hidden)]`,
                                # that's already a breaking change with its own rule.
                                # Don't report new field additions, since the programmer has
                                # clearly stated they don't consider it public API anymore.
                                public_api_eligible @filter(op: "=", value: ["$true"])

                                variant_name: name @output @tag

                                field {
                                    field_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"])
                        name @filter(op: "=", value: ["%enum_name"])

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

                        variant {
                            ... on TupleVariant {
                                name @filter(op: "=", value: ["%variant_name"])
                                attrs @filter(op: "not_contains", value: ["$non_exhaustive"])
                                public_api_eligible @filter(op: "=", value: ["$true"])

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

                                field @fold @transform(op: "count") @output(name: "field_count")
                            }
                        }
                    }
                }
            }
        }
    }"#,
    arguments: {
        "public": "public",
        "true": true,
        "zero": 0,
        "non_exhaustive": "#[non_exhaustive]",
    },
    error_message: "An enum's exhaustive tuple variant has a new field, which has to be included when constructing or matching on this variant.",
    per_result_error_template: Some("field {{field_name}} of variant {{enum_name}}::{{variant_name}} in {{span_filename}}:{{span_begin_line}}"),
    witness: (
        hint_template: r#"match value {
    {{ join "::" path }}::{{ variant_name }} ({{#repeat field_count }}_{{#unless @last}}, {{/unless}}{{/repeat}}) => (),
    _ => (),
}
"#,
    ),
)