cargo-semver-checks 0.43.0

Scan your Rust crate for semver violations.
Documentation
SemverQuery(
    id: "inherent_method_must_use_added",
    human_readable_name: "inherent method #[must_use] added",
    description: "An inherent method or associated fn has been marked #[must_use].",
    required_update: Minor,
    lint_level: Deny,

    // TODO: Change the reference link to point to the cargo semver reference
    //       once it has a section on attribute #[must_use].
    reference_link: Some("https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"),
    query: r#"
    {
        CrateDiff {
            current {
                item {
                    ... on ImplOwner {
                        visibility_limit @filter(op: "=", value: ["$public"]) @output
                        name @output
                        owner_type: __typename @tag @output

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

                        inherent_impl {
                            method {
                                method_visibility: visibility_limit @filter(op: "=", value: ["$public"]) @output
                                method_name: name @tag @output
                                public_api_eligible @filter(op: "=", value: ["$true"])

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

                                span_: span @optional {
                                    filename @output
                                    begin_line @output
                                    end_line @output
                                }
                            }
                        }
                    }
                }
            }
            baseline {
                item {
                    ... on ImplOwner {
                        visibility_limit @filter(op: "=", value: ["$public"])
                        __typename @filter(op: "=", value: ["%owner_type"])

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

                        inherent_impl {
                            method {
                                visibility_limit @filter(op: "=", value: ["$public"])
                                name @filter(op: "=", value: ["%method_name"])
                                public_api_eligible @filter(op: "=", value: ["$true"])

                                attribute @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
                                    content {
                                        base @filter(op: "=", value: ["$must_use"])
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }"#,
    arguments: {
        "public": "public",
        "must_use": "must_use",
        "true": true,
        "zero": 0,
    },
    error_message: "An inherent method is now #[must_use]. Downstream crates that did not use its return value will get a compiler lint.",
    per_result_error_template: Some("method {{join \"::\" path}}::{{method_name}} in {{span_filename}}:{{span_begin_line}}"),
)