Skip to content

For loops should not be desugared #15392

Closed
@LemmingAvalanche

Description

@LemmingAvalanche

Using a constant in an enum with the same name as another constant from another enum in the std module - namely Option in this case - causes an error in a (seemingly) unrelated for-loop. "Mangling" the name of this constant - say from None to NoneN - makes the code compile.

Compiler used:

rustc 0.11.0-pre-nightly (eda75bcf42ad99e3e4c99585d39705fccac606ee 2014-07-03 16:56:51 +0000)

Code:

fn main() {
    enum Test { None }
    for i in range(0, 10u) {
        println!("{}", i)
    }
}

Output:

$ rustc debug_2.rs
debug_2.rs:3:5: 6:2 error: mismatched types: expected `core::option::Option<uint>` but found `main::Test` (expected enum core::option::Option but found enum main::Test)
debug_2.rs:3     for i in range(0, 10u) {
debug_2.rs:4         println!("{}", i)
debug_2.rs:5     }
debug_2.rs:6 }
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions