8000 Fix Clippy warnings seen with Rust 1.59 beta by edmorley · Pull Request #288 · heroku/libcnb.rs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix Clippy warnings seen with Rust 1.59 beta #288

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

Merged
merged 2 commits into from
Jan 24, 2022

Conversation

edmorley
Copy link
Member
@edmorley edmorley commented Jan 22, 2022

New Rust versions come with new Clippy versions, that can add new lints or adjust existing lints.

Locally I'm running Rust 1.59 beta, and it reports a few new Clippy warnings, that this PR resolves:

warning: missing `#[must_use]` attribute on a method returning `Self`
  --> libcnb-data/src/build_plan.rs:48:5
   |
48 | /     pub fn provides(mut self, name: impl AsRef<str>) -> Self {
49 | |         self.current_provides.push(Provide::new(name.as_ref()));
50 | |         self
51 | |     }
   | |_____^
   |
   = note: `#[warn(clippy::return_self_not_must_use)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use

warning: missing `#[must_use]` attribute on a method returning `Self`
  --> libcnb-data/src/build_plan.rs:53:5
   |
53 | /     pub fn requires(mut self, name: impl AsRef<str>) -> Self {
54 | |         self.current_requires.push(Require::new(name.as_ref()));
55 | |         self
56 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use

warning: `libcnb-data` (lib) generated 2 warnings
warning: single-character string constant used as pattern
   --> libcnb-cargo/src/lib.rs:206:47
    |
206 |     buildpack_descriptor.buildpack.id.replace("/", "_")
    |                                               ^^^ help: try using a `char` instead: `'/'`
    |
    = note: `#[warn(clippy::single_char_pattern)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern

GUS-W-10473558.

Resolves:

```
warning: missing `#[must_use]` attribute on a method returning `Self`
  --> libcnb-data/src/build_plan.rs:48:5
   |
48 | /     pub fn provides(mut self, name: impl AsRef<str>) -> Self {
49 | |         self.current_provides.push(Provide::new(name.as_ref()));
50 | |         self
51 | |     }
   | |_____^
   |
   = note: `#[warn(clippy::return_self_not_must_use)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use

warning: missing `#[must_use]` attribute on a method returning `Self`
  --> libcnb-data/src/build_plan.rs:53:5
   |
53 | /     pub fn requires(mut self, name: impl AsRef<str>) -> Self {
54 | |         self.current_requires.push(Require::new(name.as_ref()));
55 | |         self
56 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use

warning: `libcnb-data` (lib) generated 2 warnings
warning: single-character string constant used as pattern
   --> libcnb-cargo/src/lib.rs:206:47
    |
206 |     buildpack_descriptor.buildpack.id.replace("/", "_")
    |                                               ^^^ help: try using a `char` instead: `'/'`
    |
    = note: `#[warn(clippy::single_char_pattern)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
```
@edmorley
Copy link
Member Author

I've added an extra commit that isn't necessary for Clippy, but cleans up the usages of #[must_use] by favouring adding them to the struct of builders rather than having to add them to every single method on the struct.

@edmorley edmorley merged commit 02f352a into main Jan 24, 2022
@edmorley edmorley deleted the edmorley/fix-clippy-rust-1.59 branch January 24, 2022 12:20
@edmorley edmorley added this to the libcnb 0.6.0 milestone Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0