`&pin!()` stopped being deref-coerced in rust 1.88
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
I expected the following code to compile, since Pin implements Deref, so it should be possible to do a deref coercion from the type &Pin<i32> to the type &i32.
fn main() {
let _x: &i32 = &std::pin::pin!(1i32);
}
The above code compiles without errors in rust 1.87.0. However, it produces the following compile error in rust 1.88.0
error[E0308]: mismatched types
--> <source>:2:21
|
2 | let _x: &i32 = &std::pin::pin!(1i32);
| ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Pin<&mut i32>`
|
= note: expected type `i32`
found struct `Pin<&mut i32>`
= note: this error originates in the macro `std::pin::pin` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
This presumably regressed in #139114, which changed pin!() to use super let. This uses a block expression in the syntax, which then presumably runs into the bug in #23014.
I don't know if there are any realistic use cases which run into this problem. (Hopefully not.)
cc @dianne @m-ou-se (who worked on super let).
cc @jackh726 (who seemed to have recently been working on coercions).
Meta
Tested on Godbolt with rustc versions 1.87.0 and 1.88.0.
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
Reproduce the snippet with rustc 1.87.0 and 1.88.0, then inspect the pin!() change in #139114 and the block-expression coercion issue in #23014. Done means the reported reference coercion works again without regressing the super let behavior.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100