Irrefutable bindings don't work for references to !
Open
Nobody has claimed this yet.
C-bug
needs-triage
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Irrefutable bindings are great. I love that this works:
fn foo() {
fn always_ok() -> Result<(), !> {
Ok(())
}
let Ok(_) = always_ok();
}
Sadly, this doesn't work:
fn bar() {
fn always_ok(_: &()) -> Result<(), &!> {
Ok(())
}
let Ok(_) = always_ok(&());
}
It would be nice if it did. I think it is sound for it to do so—because you can never create !, you can never create a valid reference to !.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two Rust examples from the issue and compare how irrefutable bindings treat Result<(), !> with Result<(), &!>. Investigate the compiler's handling of references to the never type; done means the second example is accepted while preserving soundness.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100