cargo-semver-checks icon indicating copy to clipboard operation
cargo-semver-checks copied to clipboard

Add more witness hints to currently-existing lints.

Open suaviloquence opened this issue 5 months ago • 4 comments

Describe your use case

With the new unstable flag cargo semver-checks -Z unstable-options --witness-hints, cargo-semver-checks is now capable of printing 1-3 line witness hints that give a brief example of how downstream breakage could occur for each instance of a lint finding breakage of a SemVer guarantee.

For example, with the function_missing lint:

Failed in:
  function function_missing::pub_use_removed_fn, previously in file /home/m/dev/cargo-semver-checks/test_crates/function_missing/old/src/lib.rs:4
note: downstream code similar to the following would break:
function_missing::pub_use_removed_fn(...);

  function function_missing::will_be_removed_fn, previously in file /home/m/dev/cargo-semver-checks/test_crates/function_missing/old/src/lib.rs:1
note: downstream code similar to the following would break:
function_missing::will_be_removed_fn(...);

Describe the solution you'd like

For each of the currently existing lints in cargo-semver-checks, we want to either add a witness hint or determine that we can't write one.

The process for adding a witness hint is in the contributor docs. Briefly, once you've determined that you can write a witness hint, add a witness key to the <lint_name>.ron file:

SemverQuery(
     // --- rest of lint declaration --- 
    witness: (
         hint_template: "write the hint here as a {{handlebars}} template",
    ),
)

More details can be found in the CONTRIBUTING.md section linked above.

If it's not possible to write a witness hint, it would be great to explicitly set witness: None in the <lint_name>.ron file, accompanied by a comment explaining why it is not (currently) possible to write a hint.

Alternatives, if applicable

No response

Additional Context

This is a new feature, and if any questions or bugs come up when adding a witness hint, please ask me @suaviloquence so we can help improve the docs and contributor experience for the future!

suaviloquence avatar Sep 19 '24 19:09 suaviloquence