Skip to content

avoid spurious lifetime diagnostic in async generic case - #158153

Open
pbkx wants to merge 1 commit into
rust-lang:mainfrom
pbkx:issue-115376-async-spurious-static-bound
Open

avoid spurious lifetime diagnostic in async generic case#158153
pbkx wants to merge 1 commit into
rust-lang:mainfrom
pbkx:issue-115376-async-spurious-static-bound

Conversation

@pbkx

@pbkx pbkx commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #115376.

Issue #115376 reports duplicate lifetime diagnostics for a small async generic example where rustc already emits the real T: 'static error. Additionally, it emits diagnostics requiring the same generic type to outlive a shorter anonymous lifetime

My PR keeps the real static-bound diagnostic and filters same-span weaker type-test diagnostics for the same generic when the failed G: 'static bound already covers them. New regression test verifies that the async example emits only the real E0310 diagnostic. One existing borrowck test was updated for the same diagnostic cleanup

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 19, 2026
@pbkx
pbkx marked this pull request as ready for review June 19, 2026 21:56
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 19, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 19, 2026
@rustbot

rustbot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 18 candidates

@folkertdev

Copy link
Copy Markdown
Contributor

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Jun 19, 2026
@rustbot rustbot assigned jackh726 and unassigned folkertdev Jun 19, 2026

@jackh726 jackh726 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This definitely feels like a hack...but with an appropriate enough comment (link to the test, describe why you're doing what you are), should be okay.

View changes since this review

Comment on lines +623 to +633
let static_scc = self.constraint_sccs.scc(self.universal_regions().fr_static);
let static_bound_errors: FxIndexSet<_> = failed_type_tests
.iter()
.filter_map(|&(erased_generic_kind, type_test)| {
if self.constraint_sccs.scc(type_test.lower_bound) == static_scc {
Some((erased_generic_kind, type_test.span))
} else {
None
}
})
.collect();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This (entire addition) deserves a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

multiple spurious errors when T: 'static is required in async fn

4 participants