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

more clippy fixes #70187

Merged
merged 2 commits into from
Mar 21, 2020
Merged

more clippy fixes #70187

merged 2 commits into from
Mar 21, 2020

Conversation

matthiaskrgr
Copy link
Member

@matthiaskrgr matthiaskrgr commented Mar 20, 2020

* remove redundant returns (clippy::needless_return)
* remove redundant import (clippy::single_component_path_imports)
* remove redundant format!() call (clippy::useless_format)
* don't use ok() before calling expect() (clippy::ok_expect)

Copy link
Contributor

@ecstatic-morse ecstatic-morse left a comment

Choose a reason for hiding this comment

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

Most of this is a clear improvement IMO. However, I don't like eliding lifetimes everywhere possible, since some lifetime names ('tcx) have a specific meaning in rustc.

@matthiaskrgr I assume that your ultimate goal is to enable clippy as part of x.py fmt, which I am generally supportive of. However, I think the needless_lifetimes lint in specific may not be a good fit for the compiler. Obviously this is subjective. Perhaps enabling and configuring clippy should go through the major change process so people can weigh in? In any case, I'll defer to someone with more seniority.

src/librustc/hir/map/mod.rs Outdated Show resolved Hide resolved
@ecstatic-morse
Copy link
Contributor

r? @Centril

@Dylan-DPC-zz
Copy link

@bors r+

@bors
Copy link
Contributor

bors commented Mar 20, 2020

📌 Commit 85e608c503a8abf7fdb1c4613f000409354570a1 has been approved by Dylan-DPC

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 20, 2020
@Mark-Simulacrum
Copy link
Member

@bors r-

I don't think eliding 'tcx is a good idea for now, or at least we should have a broader discussion.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 20, 2020
remove redundant format!() call (clippy::useless_format)
don't use ok() before calling expect() (clippy::ok_expect)
@matthiaskrgr
Copy link
Member Author

I removed the lifetime elision commit.

@Mark-Simulacrum
Copy link
Member

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 20, 2020

📌 Commit ad00e91 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 20, 2020
@matthiaskrgr
Copy link
Member Author

@ecstatic-morse I personally don't think clippy is ready to be part of x.py fmt or something like that.
There are a lot of false positives (also involving #[cfg(..)], and some lints just suggest "hey, you should check that out just in case" and do not provides an actual clue on what to change.
I don't think scattering #![allow(clippy::...)] around the codebase is something people would want.
When I check rustc with clippy, I actually explicitly disable around 70 lints before having a detailed look at the findings.

I'm sifting through the clippy logs, can report false positives to clippy and fix the true positives in the codebase so I guess it's a win win.

@Centril
Copy link
Contributor

Centril commented Mar 20, 2020

For what it's worth, I would have r+ed this PR as well with the lifetime elision. It just seems like standard practice, and I don't think there's anything special about the compiler as compared to other codebases here. The fact that there might be arena allocation involved can often be inferred by e.g. Ty<'_> alone, e.g. you know it because that type is allocated on an arena. Also, ask yourself... is the fact that something is arena allocated important semantic information as compared to e.g., the type checking logic? Having 'tcx just adds unnecessary noise. Similarly, for new code, I don't think we should e.g., reject code with explicit named lifetimes, and so it seems strange that we would reject it when old code is improved too.

In some cases however, e.g., involving unsafe code in the standard library, or unsafe code in general, we should be more careful wrt. lifetime elision. But most of the time, there's no unsafe code in sight.

r? @Mark-Simulacrum

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 21, 2020
more clippy fixes

    * remove redundant returns (clippy::needless_return)
    * remove redundant import (clippy::single_component_path_imports)
    * remove redundant format!() call (clippy::useless_format)
    * don't use ok() before calling expect() (clippy::ok_expect)
Centril added a commit to Centril/rust that referenced this pull request Mar 21, 2020
more clippy fixes

    * remove redundant returns (clippy::needless_return)
    * remove redundant import (clippy::single_component_path_imports)
    * remove redundant format!() call (clippy::useless_format)
    * don't use ok() before calling expect() (clippy::ok_expect)
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 21, 2020
Rollup of 16 pull requests

Successful merges:

 - rust-lang#65097 (Make std::sync::Arc compatible with ThreadSanitizer)
 - rust-lang#69033 (Use generator resume arguments in the async/await lowering)
 - rust-lang#69997 (add `Option::{zip,zip_with}` methods under "option_zip" gate)
 - rust-lang#70038 (Remove the call that makes miri fail)
 - rust-lang#70058 (can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.)
 - rust-lang#70111 (BTreeMap: remove shared root)
 - rust-lang#70139 (add delay_span_bug to TransmuteSizeDiff, just to be sure)
 - rust-lang#70165 (Remove the erase regions MIR transform)
 - rust-lang#70166 (Derive PartialEq, Eq and Hash for RangeInclusive)
 - rust-lang#70176 (Add tests for rust-lang#58319 and rust-lang#65131)
 - rust-lang#70177 (Fix oudated comment for NamedRegionMap)
 - rust-lang#70184 (expand_include: set `.directory` to dir of included file.)
 - rust-lang#70187 (more clippy fixes)
 - rust-lang#70188 (Clean up E0439 explanation)
 - rust-lang#70189 (Abi::is_signed: assert that we are a Scalar)
 - rust-lang#70194 (#[must_use] on split_off())

Failed merges:

r? @ghost
@bors bors merged commit 3e6b1ac into rust-lang:master Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants