Skip to content

Conversation

veera-sivarajan
Copy link
Contributor

The compiler (rustc 1.77.0) error for and_without_explicit_lifetime() in the erroneous code example suggests using a HRTB. But, the corrected example uses an explicit lifetime parameter.

This PR fixes it so that the documentation and the compiler suggestion for error code E0637 are consistent with each other.

@rustbot
Copy link
Collaborator

rustbot commented Mar 30, 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. labels Mar 30, 2024
@fmease
Copy link
Member

fmease commented Apr 24, 2024

The compiler (rustc 1.77.0) error for and_without_explicit_lifetime() in the erroneous code example suggests using a HRTB.

That's true but that particular suggestion is not super smart and has many issues (that are currently being worked on though) like #123713, #122714 or #122025. Therefore, it shouldn't be taken as a source of absolute truth.

For example, rustc currently suggests for<'a> ... 'a here:

fn and_without_explicit_lifetime<T>()
where
    T: Iterator<Item = &u32>,
{
}

which is not correct (#122025).

@fmease
Copy link
Member

fmease commented Apr 24, 2024

As a middle ground instead of replacing the <'a, T>-suggestion with the for<'a> one, could we maybe have both?

@rustbot author
r? fmease

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2024
@rustbot rustbot assigned fmease and unassigned TaKO8Ki Apr 24, 2024
@veera-sivarajan
Copy link
Contributor Author

Sure, mentioning both sounds good to me.

I've also fixed the grammar in the first line: used on illegal place to used in an illegal place.

@veera-sivarajan
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 26, 2024
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Thanks, very nice! Could you squash the commits? Then I will approve.

@veera-sivarajan veera-sivarajan force-pushed the fix-error-code-E0637-example-code branch from 9e5d607 to 26ed429 Compare April 27, 2024 22:22
@veera-sivarajan veera-sivarajan changed the title Use HRTB in E0637 documentation Mention Both HRTB and Generic Lifetime Param in E0637 documentation Apr 27, 2024
@fmease
Copy link
Member

fmease commented Apr 30, 2024

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 30, 2024

📌 Commit 26ed429 has been approved by fmease

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 Apr 30, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2024
…iaskrgr

Rollup of 3 pull requests

Successful merges:

 - rust-lang#123247 (Mention Both HRTB and Generic Lifetime Param in `E0637` documentation)
 - rust-lang#124511 (Remove many `#[macro_use] extern crate foo` items)
 - rust-lang#124550 (Remove redundant union check in `KnownPanicsLint` const prop)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7427812 into rust-lang:master Apr 30, 2024
@rustbot rustbot added this to the 1.80.0 milestone Apr 30, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2024
Rollup merge of rust-lang#123247 - veera-sivarajan:fix-error-code-E0637-example-code, r=fmease

Mention Both HRTB and Generic Lifetime Param in `E0637` documentation

The compiler (rustc 1.77.0) error for `and_without_explicit_lifetime()` in the erroneous code example suggests using a HRTB. But, the corrected example uses an explicit lifetime parameter.

This PR fixes it so that the documentation and the compiler suggestion for error code `E0637` are consistent with each other.
@veera-sivarajan veera-sivarajan deleted the fix-error-code-E0637-example-code branch May 8, 2024 23:29
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. 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.

5 participants