Skip to content

clippy: Apply clippy suggestions#3216

Closed
illia-bobyr wants to merge 2 commits into
rust-lang:masterfrom
illia-bobyr:clippy-warnings
Closed

clippy: Apply clippy suggestions#3216
illia-bobyr wants to merge 2 commits into
rust-lang:masterfrom
illia-bobyr:clippy-warnings

Conversation

@illia-bobyr

Copy link
Copy Markdown
Contributor

CONTRIBUTING.md suggests one runs this, before publishing a change:

cargo clippy --all --all-targets --all-features -- -D warnings

These changes make cargo clippy output on master warning free.

`cargo clippy` says it is better to use `Box::default()` directly.

https://rust-lang.github.io/rust-clippy/master/index.html#box_default

`CONTRIBUTING.md` suggests one runs this, before publishing a change:
```bash
cargo clippy --all --all-targets --all-features -- -D warnings
```
So it would be great if `master` would not generate any warnings.
`cargo clippy` says it is better to use types that have less complex
structure.  Introducing a type alias does provide an additional
intermediate name, that could improve readability a bit.

https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity

`CONTRIBUTING.md` suggests one runs this, before publishing a change:
```bash
cargo clippy --all --all-targets --all-features -- -D warnings
```

This is the last warning, at the moment.  Applying this fix makes `cargo
clippy` output warning free.

@0xPoe 0xPoe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your PR.

We have some discussion about the Box::default() change before. Maybe we can revert it.

Comment thread src/test.rs
// building with i686 toolchain, but on an x86_64 host, so run the
// actual detection logic and trust it.
let tp = Box::new(currentprocess::TestProcess::default());
let tp = Box::<currentprocess::TestProcess>::default();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please see: #3096 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Definitely can, but it is what the stable clippy is suggesting today.
During that discussion, it was still a nightly only check.
Maybe, instead of just removing the patch, I should change it to

#[allow(clippy::box_default)]

For this particular location. With a link to that discussion?
Otherwise, it may come again, as clippy will keep complaining :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I totally agree with the consistency argument.
But, if this is what clippy is suggesting, I wonder if most new code will be written like this now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would like to see a blanket allow on this for rustup.

Comment thread tests/dist.rs
path: &Path,
edit: Option<&dyn Fn(&str, &mut MockChannel)>,
) -> MockDistServer {
pub fn create_mock_dist_server(path: &Path, edit: Option<&EditChannel>) -> MockDistServer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So EditChannel is just defining the function signature that these two functions use as a closure.

We're separating out two things that are tightly coupled. I don't think that increases readability: it increases cognitive load.

Please allow() it at the module level. (I have a PR in flight that refactors this test code towards immutability, so the whole edit concept is going to fade anyhow).

@gautamprikshit1 gautamprikshit1 mentioned this pull request Mar 18, 2023
@0xPoe

0xPoe commented Apr 26, 2023

Copy link
Copy Markdown
Member

Already done at https://github.com/rust-lang/rustup/pull/3276/files. So I am going to close this PR.

Thanks for your contribution!

@0xPoe 0xPoe closed this Apr 26, 2023
@0xPoe

0xPoe commented Apr 26, 2023

Copy link
Copy Markdown
Member

@gautamprikshit1 I would like to suggest asking the original author before picking up the work from their PRs next time. This way people don't race on the same thing and the original author may feel better. ❤️ Thank you all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants