Skip to content

Conversation

@ShoyuVanilla
Copy link
Member

Fixes #121267

Current explicit lifetime suggestions are not showing correct spans for some lifetimes - e.g. elided lifetime generic parameters;

This should be done correctly regarding elided lifetime kind like the following code

let mut spans_suggs: Vec<_> = Vec::new();
let build_sugg = |lt: MissingLifetime| match lt.kind {
MissingLifetimeKind::Underscore => {
debug_assert_eq!(lt.count, 1);
(lt.span, existing_name.to_string())
}
MissingLifetimeKind::Ampersand => {
debug_assert_eq!(lt.count, 1);
(lt.span.shrink_to_hi(), format!("{existing_name} "))
}
MissingLifetimeKind::Comma => {
let sugg: String = std::iter::repeat([existing_name.as_str(), ", "])
.take(lt.count)
.flatten()
.collect();
(lt.span.shrink_to_hi(), sugg)
}
MissingLifetimeKind::Brackets => {
let sugg: String = std::iter::once("<")
.chain(
std::iter::repeat(existing_name.as_str()).take(lt.count).intersperse(", "),
)
.chain([">"])
.collect();
(lt.span.shrink_to_hi(), sugg)
}
};
for &lt in &lifetime_refs {
spans_suggs.push(build_sugg(lt));
}

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2024

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 25, 2024
Copy link
Member

@TaKO8Ki TaKO8Ki left a comment

Choose a reason for hiding this comment

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

Sorry for the late review. I left one suggestion.

Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

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

Please squash your three commits into one.

Move verbose logic to a function

Minor renaming
@ShoyuVanilla
Copy link
Member Author

Please squash your three commits into one.

Thanks! I've squash rebased onto the recent revision 😄

@ShoyuVanilla ShoyuVanilla requested a review from estebank March 21, 2024 02:38
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Mar 21, 2024

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 21, 2024

📌 Commit c270a42 has been approved by TaKO8Ki

It is now in the queue for this repository.

@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 Mar 21, 2024
@bors
Copy link
Collaborator

bors commented Mar 21, 2024

⌛ Testing commit c270a42 with merge 6e1f7b5...

@bors
Copy link
Collaborator

bors commented Mar 21, 2024

☀️ Test successful - checks-actions
Approved by: TaKO8Ki
Pushing 6e1f7b5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 21, 2024
@bors bors merged commit 6e1f7b5 into rust-lang:master Mar 21, 2024
@rustbot rustbot added this to the 1.79.0 milestone Mar 21, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6e1f7b5): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 669.782s -> 669.528s (-0.04%)
Artifact size: 312.72 MiB -> 312.72 MiB (-0.00%)

@ShoyuVanilla ShoyuVanilla deleted the fix-issue-121267 branch March 21, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The output help is incorrect, lifetime appears in an unexpected position

6 participants