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

avoid converting types into themselves (clippy::useless_conversion) #82236

Merged
merged 1 commit into from
Feb 18, 2021

Conversation

matthiaskrgr
Copy link
Member

No description provided.

@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 17, 2021
@@ -161,7 +161,7 @@ impl<'tcx> DocContext<'tcx> {
}
Entry::Occupied(e) => e.into_mut(),
};
*def_index = DefIndex::from(*def_index + 1);
*def_index = *def_index + 1;
Copy link
Member

Choose a reason for hiding this comment

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

Does this compile?

Suggested change
*def_index = *def_index + 1;
*def_index += 1;

Copy link
Member Author

Choose a reason for hiding this comment

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

nope :(

error[E0368]: binary assignment operation `+=` cannot be applied to type `DefIndex`
   --> src/librustdoc/core.rs:164:9
    |
164 |         *def_index += 1;
    |         ----------^^^^^
    |         |
    |         cannot use `+=` on type `DefIndex`

Copy link
Member

@jyn514 jyn514 Feb 17, 2021

Choose a reason for hiding this comment

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

Now I'm confused, how does this code work at all? DefIndex implements neither Deref nor Add: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefIndex.html

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah, ok. It would be nice to add AddAssign there. But no need to do it here.

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 17, 2021
@jyn514
Copy link
Member

jyn514 commented Feb 17, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Feb 17, 2021

📌 Commit ec50a20 has been approved by jyn514

@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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 17, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 18, 2021
avoid converting types into themselves (clippy::useless_conversion)
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#81546 ([libtest] Run the test synchronously when hitting thread limit)
 - rust-lang#82066 (Ensure valid TraitRefs are created for GATs)
 - rust-lang#82112 (const_generics: Dont evaluate array length const when handling yet another error )
 - rust-lang#82194 (In some limited cases, suggest `where` bounds for non-type params)
 - rust-lang#82215 (Replace if-let and while-let with `if let` and `while let`)
 - rust-lang#82218 (Make sure pdbs are copied along with exe and dlls when bootstrapping)
 - rust-lang#82236 (avoid converting types into themselves (clippy::useless_conversion))
 - rust-lang#82246 (Add long explanation for E0549)
 - rust-lang#82248 (Optimize counting digits in line numbers during error reporting)
 - rust-lang#82256 (Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 04df75a into rust-lang:master Feb 18, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants