Skip to content
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

never patterns: ! argument not detected as diverging on async fn #120240

Open
Tracked by #118155
Nadrieril opened this issue Jan 22, 2024 · 4 comments
Open
Tracked by #118155

never patterns: ! argument not detected as diverging on async fn #120240

Nadrieril opened this issue Jan 22, 2024 · 4 comments
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. F-never_patterns `#![feature(never_patterns)]` requires-incomplete-features This issue requires the use of incomplete features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-async Working group: Async & await

Comments

@Nadrieril
Copy link
Member

With #120104, a function with a ! pattern in a binding is detected as diverging:

fn never_arg(!: Void) -> ! {}
fn never_let(x: Void) -> ! {
  let ! = x;
}

This doesn't work the arguments of an async fn however:

async fn never_let(x: Void) -> ! {
  let ! = x;
} // ok
async fn never_arg(!: Void) -> ! {} // ERROR mistmatched types
@Nadrieril Nadrieril added C-bug Category: This is a bug. F-never_patterns `#![feature(never_patterns)]` labels Jan 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 22, 2024
@Nadrieril Nadrieril removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 22, 2024
@fmease fmease added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-async-await Area: Async & Await requires-incomplete-features This issue requires the use of incomplete features. labels Jan 22, 2024
@traviscross
Copy link
Contributor

@rustbot labels +AsyncAwait-Triaged +WG-async

We reviewed this today in WG-async triage. We agree this is a bug.

@rustbot rustbot added AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. WG-async Working group: Async & await labels Feb 26, 2024
@compiler-errors
Copy link
Member

I looked into this and it has to do with the fact that we desugar the latter (never_arg) into something like:

fn never_arg(x: Void) -> ! {
    async move {
        let ! = x;
        let body = {
        };
        body
    }
}

I don't believe this is going to be easy or perhaps even possible to fix given the way that we don't/can't(?) make the inner body block (which corresponds to the body of the original async fn) to be diverging based off of a pattern in the outer block.

@Nadrieril
Copy link
Member Author

And I presume the desugaring is this way because of drop order subtleties?

@compiler-errors
Copy link
Member

yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. F-never_patterns `#![feature(never_patterns)]` requires-incomplete-features This issue requires the use of incomplete features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-async Working group: Async & await
Projects
None yet
Development

No branches or pull requests

5 participants