Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merge activity
|
CodSpeed Performance ReportMerging #9240 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
I'm not sure if I like this lint.
In some cases, using Self is a big improvement, like here:
impl Serialize for AssignmentOperator {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
match self {
- AssignmentOperator::Assign => {
- serializer.serialize_unit_variant("AssignmentOperator", 0, "=")
- }
- AssignmentOperator::Addition => {
- serializer.serialize_unit_variant("AssignmentOperator", 1, "+=")
- }
- AssignmentOperator::Subtraction => {
- serializer.serialize_unit_variant("AssignmentOperator", 2, "-=")
- }
+ Self::Assign => serializer.serialize_unit_variant("AssignmentOperator", 0, "="),
+ Self::Addition => serializer.serialize_unit_variant("AssignmentOperator", 1, "+="),
+ Self::Subtraction => serializer.serialize_unit_variant("AssignmentOperator", 2, "-="),But sometimes explicit type makes for clearer code, like this one:
impl<'alloc> String<'alloc> {
// ...
// 120 lines of code
// ...
pub unsafe fn from_raw_parts_in(
buf: *mut u8,
length: usize,
capacity: usize,
allocator: &'alloc Allocator,
- ) -> String<'alloc> {
+ ) -> Self {There's 2 reasons I think String<'alloc> is preferable here:
- There's 120 lines between where
Selfis defined, and where it's used, so when you're looking atfn from_raw_parts_in, you need to scroll up to find out whatSelfis (VSCode helps with this, but no such help when reviewing a PR on Github). String<'alloc>makes it clearer that the lifetime in param&'alloc Allocatorand return valueString<'alloc>are related.&'alloc Allocator->Selfhides that relationship.
In my view, I think it'd be preferable to cherry-pick the good parts from this PR, but keep the lint rule disabled. Doing that wouldn't take long.
I've reviewed since you requested that I do. But if you feel differently, merge it!
|
Hahaha you didn't actually request a review! It was just Github requesting my review as a "code owner". Oh well, that's my opinion anyway... |
|
This rule is pretty annoying, we don't have the muscle memory to always apply And I think applying Hence I'm going to nuke this rule given the bad dx. |

No description provided.