Skip to content

Wrong reordering of match arms with ranges #18060

Closed
@lifthrasiir

Description

Adopted and minimized from the HTTP method parsing routine of hyperium/hyper:

println!("{}", match (1u, 3u) { (0, 2...5) => 1, (1, 3) => 2, (_, 2...5) => 3, (_, _) => 4u });
println!("{}", match (1u, 3u) {                  (1, 3) => 2, (_, 2...5) => 3, (_, _) => 4u });
println!("{}", match (1u, 7u) { (0, 2...5) => 1, (1, 7) => 2, (_, 2...5) => 3, (_, _) => 4u });

All three lines should print 2, but the first line prints 3 on the current nightly (rustc 0.13.0-nightly (40b244973 2014-10-14 23:22:20 +0000)). The match trans apparantly groupped the second pattern even when it may result in the wrong result.

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions