-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this compile?
*def_index = *def_index + 1; | |
*def_index += 1; |
There was a problem hiding this comment.
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`
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be related to the newtype_index!()
macro that is used when the struct is declared
https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_span/def_id.rs.html#119
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_index/macro.newtype_index.html
There was a problem hiding this comment.
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.
@bors r+ |
📌 Commit ec50a20 has been approved by |
avoid converting types into themselves (clippy::useless_conversion)
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
No description provided.