Skip to content

-Zunpretty=expanded does not preserve hygiene #13573

Open
@klutzy

Description

@klutzy

rustc internally converts for val in iter { ... } to:

match &mut iter {
    i =>
    loop  { match i.next() { None => break , Some(val) => { ... } } }
}

where i is created by let local_ident = token::gensym_ident("i");, so i does not clash with other local variables.

However, pprust just prints it as plain i. So the following code:

let mut i: int = 0;
for _ in iter {
    i += 1;
}

is prettified by rustc as:

let mut i: int = 0;
match &mut iter {
    i =>
    loop  { match i.next() { None => break , Some(_) => { i += 1; } } }
}

which is not correct anymore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-hygieneArea: Macro hygieneA-prettyArea: Pretty printing (including `-Z unpretty`)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.P-lowLow priorityT-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