Skip to content

unpretty=hir,typed output confusing for futures::select! macro #97090

Open
@pnkfelix

Description

@pnkfelix

I tried this code:

#![feature(lang_items)]
#![feature(stmt_expr_attributes)]
#![allow(dead_code)]

use futures::FutureExt;

async fn other() { }

async fn async_main_exansion_is_strange() { futures::select! { _ignored = other().fuse() => { } } }

fn main() { }

with this Cargo.toml:

[package]
name = "confusing"
version = "0.1.0"
edition = "2021"

[dependencies]
futures = "0.3.21"

[workspace]

and I built it like this:

cargo +nightly build && touch src/main.rs && cargo +nightly rustc -- -Zunpretty=hir,typed > expanded.rs

I expected to see this happen: I had hoped the output expanded.rs would resemble legible Rust code

Instead, this happened: The output in expanded.rs included portions like this:

(match ((#[lang = "into_future"] as
                    fn(Yield) -> <Yield as std::future::IntoFuture>::IntoFuture {<Yield as std::future::IntoFuture>::into_future})(((...

In other words, its got this weird #[attribute] as Type construction that is not valid Rust.

The -Zunpretty=hir output does not share this problem, it looks something like:

match #[lang = "into_future"](__futures_crate::future::poll_fn(__poll_fn))

Meta

rustc --version --verbose:

rustc 1.62.0-nightly (a5ad0d29a 2022-05-12)
binary: rustc
commit-hash: a5ad0d29a401007b51715852cc702e441ac2248c
commit-date: 2022-05-12
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-HIRArea: The high-level intermediate representation (HIR)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions