Skip to content

A shebang is displaced in HIR & expanded outputs #134643

Open
@fluiderson

Description

I tried this code:

#!/usr/bin/env rust

fn test() {}

After running rustc -Zunpretty=hir test.rs, I expected to see this happen:

#!/usr/bin/env rust
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;

fn test() { }

Instead, this happened:

#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
#!/usr/bin/env rust

fn test() { }

A shebang should remain at the beginning of an output but instead is placed in-between. The same happens with rustc -Zunpretty=expanded test.rs.

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (5f23ef7d3 2024-12-20)
binary: rustc
commit-hash: 5f23ef7d3f7a8c3e0ca5c4e1978829c0448a3686
commit-date: 2024-12-20
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-prettyArea: Pretty printing (including `-Z unpretty`)C-enhancementCategory: An issue proposing an enhancement or a PR with one.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