Open
Description
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