Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Use clippy #276

Merged
merged 25 commits into from Mar 22, 2018
Merged

Use clippy #276

merged 25 commits into from Mar 22, 2018

Conversation

pchickey
Copy link
Contributor

This is a start at using clippy throughout Cretonne.

Current issues:

  • Only cargo +nightly clippy works - stable cargo and clippy has a bug that seems to be related to the way arguments are passed when used in the root directory (works in all the other crates)
  • Clippy and the old rustfmt we are using disagree about whether braces belong in some places - rustfmt insists on them, clippy flags them as a problem. (All of the problems clippy flags outside of cretonne were fixed until I ran rustfmt.)

Currently, there are a ton of lints turned off in the cretonne crate. A significant portion of them are fixable without much effort, but others would require doing work on the code generator.

Unfortunately, because generated code is made part of other source files via include!(), I wasn't put top level clippy pragmas in the generated sources only, because it wouldn't be at the top of the source file.

Fixes #264

@pchickey pchickey changed the title Use clippy [WIP] Use clippy Mar 22, 2018
relax_branch(&mut cur, offset, dest_offset, &encinfo, isa);
continue;
}
// This coubd be an out-of-range branch.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coubd -> could

Copy link
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I haven't gone through all the changes in this PR yet, but here are a few comments so far.

/// Deals with a Wasm instruction located in an unreachable portion of the code. Most of them
/// are dropped but special ones like `End` or `Else` signal the potential end of the unreachable
/// portion so the translation state muts be updated accordingly.
fn translate_unreachable_operator(
op: Operator,
op: &Operator,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious; which clippy lint prompted this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-clippy.sh Outdated
echo "* Please install clippy to lint rust code. *"
echo "********************************************************************"
echo "$0 --install"
sleep 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the PR as it currently stands, we don't install clippy for Travis runs, so it seems like the code here should be a little less noisy, and not do "sleep 1". I think we're ok if someone doesn't have clippy installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced this to one-line echo.

assign_op_pattern,
unreadable_literal,
empty_line_after_outer_attr,
// From here on i think theyre solvable:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theyre -> they're. But also, I think it's useful to elaborate on the comment here. If these lints are solvable with reasonable effort, they could make good starter projects.

@@ -141,6 +141,8 @@ impl Function {
}

/// Return an object that can display this function with correct ISA-specific annotations.
// Needless lifetimes lint false positive
#[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like needless_lifetimes has enough false positives that it'd be better to disable this lint globally than clutter up the code disabling it locally every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@pchickey pchickey changed the title [WIP] Use clippy Use clippy Mar 22, 2018
@pchickey
Copy link
Contributor Author

I fixed up the remaining trivial lints, documented the reasons for each lint that is currently allowed, and took care of the various review comments.

@sunfishcode
Copy link
Member

Great, thanks for getting this infrastructure set up!

@sunfishcode sunfishcode merged commit 122249a into bytecodealliance:master Mar 22, 2018
@pchickey pchickey deleted the pch/clippy branch March 22, 2018 20:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use clippy
3 participants