Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure workspace lints, enable running some Clippy lints on CI #7561

Merged
merged 9 commits into from
Nov 20, 2023

Conversation

alexcrichton
Copy link
Member

This PR is a series of commits building up to the ability to selectively enable clippy lints to prevent issues such as #7558 from occurring. The root cause of the issue is the behavior of casting a smaller integer to a larger integer and switching signs. For example casting an i8 to a u32. I certainly don't remember whether this is a zero-extend or a sign-extend, and I suspect that I'm not alone. Ideally I was looking for a lint to help weed these out on CI.

Unfortunately rustc does not have a lint for this. Clippy, however, has a somewhat similar lint called cast_sign_loss. Empowered with Rust's 1.74 release and Cargo's addition of a [lints] configuration for workspaces, I realized this seemed like a reasonable time to kick the tires. Historically Wasmtime hasn't enabled Clippy because it's too noisy by default and it's too cumbersome to turn it off for all crates. With [lints] however it's a single line to turn off all clippy for the entire workspace, which felt like a much better balance to me at least.

First configuring [lints] as well as [workspace.lints] helped moved some lint configuration for various crates into one location. Afterwards all clippy lints were then disabled and then cargo clippy was added to CI. It turns out that cast_sign_loss is still too noisy for our purposes to enable for the whole workspace, but it can be selectively enabled for a few crates in question which do at least much of the casting for values at runtime.

This is intended to be somewhat of a trial run to see if we can make running Clippy in CI useful. I'm sure Clippy has other useful lints for helping to catch issues as well as helping with stylistic things for contributors. For now everything is left disabled but if desired selective lints can be enabled as necessary.

This commit adds necessary configuration knobs to have lints configured
at the workspace level in Wasmtime rather than the crate level. This
uses a feature of Cargo first released with 1.74.0 (last week) of the
`[workspace.lints]` table. This should help create a more consistent set
of lints applied across all crates in our workspace in addition to
possibly running select clippy lints on CI as well.
This commit configures a `deny` lint level for the
`unused_extern_crates` lint to the workspace level rather than the
previous configuration at the individual crate level.
CI will ensure that these don't get checked into the codebase and
otherwise provide fewer speed bumps for in-process development.
This commit configures our CI to run `cargo clippy --workspace` for all
merged PRs. Historically this hasn't been all the feasible due to the
amount of configuration required to control the number of warnings on
CI, but with Cargo's new `[lint]` table it's possible to have a
one-liner to silence all lints from Clippy by default. This commit by
default sets the `all` lint in Clippy to `allow` to by-default disable
warnings from Clippy. The goal of this PR is to enable selective access
to Clippy lints for Wasmtime on CI.
This would have fixed bytecodealliance#7558 so try to head off future issues with that
by warning against this situation in a few crates. This lint is still
quite noisy though for Cranelift for example so it's not worthwhile at
this time to enable it for the whole workspace.
@alexcrichton alexcrichton requested review from a team as code owners November 20, 2023 21:07
@alexcrichton alexcrichton requested review from abrown and pchickey and removed request for a team November 20, 2023 21:07
@alexcrichton alexcrichton added this pull request to the merge queue Nov 20, 2023
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:meta Everything related to the meta-language. cranelift:module isle Related to the ISLE domain-specific language labels Nov 20, 2023
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:meta", "cranelift:module", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 20, 2023
prtest:full
@alexcrichton alexcrichton added this pull request to the merge queue Nov 20, 2023
Merged via the queue into bytecodealliance:main with commit 5856590 Nov 20, 2023
40 checks passed
@alexcrichton alexcrichton deleted the lint-config branch November 20, 2023 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:meta Everything related to the meta-language. cranelift:module cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants