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

Original pin!() macro behavior cannot be expressed in Rust 2024 #138718

Open
m-ou-se opened this issue Mar 19, 2025 · 3 comments
Open

Original pin!() macro behavior cannot be expressed in Rust 2024 #138718

m-ou-se opened this issue Mar 19, 2025 · 3 comments
Labels
A-edition-2024 Area: The 2024 edition C-bug Category: This is a bug. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Mar 19, 2025

See #138596

It looks like Rust 2024 regressed in expressivity. The exact original behavior of the pin!() macro cannot be expressed in Rust 2024.

As a temporary workaround for pin!() itself, #138717 adds #[rustc_macro_edition_2021].

Both #138622 (comment) and #138717 mention super let as the proper solution.

One could argue that pin!() cannot be expressed in any Rust edition, because it relies on an unstable public (hidden) field and #[allow_internal_unstable]. This problem is also solved by super let.

@m-ou-se m-ou-se added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Mar 19, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 19, 2025
@fmease fmease added the A-edition-2024 Area: The 2024 edition label Mar 19, 2025
@fmease fmease added C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 19, 2025
@joshtriplett joshtriplett added the I-lang-radar Items that are on lang's radar and will need eventual work or consideration. label Mar 19, 2025
@m-ou-se
Copy link
Member Author

m-ou-se commented Mar 26, 2025

Update: Turns out super let is quite simple to implement. Starting an experiment and posting an implementation soon.

@m-ou-se m-ou-se changed the title pin!() macro cannot be expressed in Rust 2024 Original pin!() macro behavior cannot be expressed in Rust 2024 Mar 27, 2025
@m-ou-se
Copy link
Member Author

m-ou-se commented Mar 27, 2025

@conradludgate In your bug report, you report this code snippet as getting broken:

fn main() {
    match std::pin::pin!(foo(&mut 0)) {
        _f => {}
    }
}

async fn foo(_s: &mut usize) {}

Do you have the real code where this popped up? I'd love to see a more realistic example to understand in which cases supporting this is important.

@conradludgate
Copy link
Contributor

It's not code I'm particularly proud of, but here https://github.com/neondatabase/neon/blob/939354abea3915d9a2a3ccd6b1f7547fe2ab2cd6/proxy/src/serverless/sql_over_http.rs#L874

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2024 Area: The 2024 edition C-bug Category: This is a bug. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants