-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
&pin!() stopped being deref-coerced in rust 1.88 #153425
Copy link
Copy link
Open
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-pinArea: PinArea: PinC-bugCategory: This is a bug.Category: This is a bug.F-super_letit's super, let's go!it's super, let's go!P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-pinArea: PinArea: PinC-bugCategory: This is a bug.Category: This is a bug.F-super_letit's super, let's go!it's super, let's go!P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.