Skip to content

Cross-crate enum struct variants exporting bug #8746

Closed
@nsf

Description

@nsf

The bug occurs only in a cross-crate scenario, probably related to metadata encoding/decoding, have no idea. Here's a quick way to make a mockup:

test.rs:

extern mod testenum;

fn main() {
        let x = testenum::A;
        match x {
                //test.rs:6:2: 6:13 error: `testenum::B` does not name a structure
                //testenum::B{_} => println("oops"),
                testenum::B(_, _) => println("sweet"),
                _ => println("nothing"),
        }
}

.rust/src/testenum/lib.rs

#[link(name = "testenum",
       vers = "0.0")];

pub enum Test {
        A,
        B{f1: int, f2: int},
        C,
}

Then build the crate: rustpkg install testenum. And compile the test.rs: rustc -o test test.rs. It compiles just fine, when it actually shouldn't. Because testenum::B is a struct variant, not a tuple. Uncommenting the struct variant and commenting out the tuple variant results in a compilation error:

test.rs:7:2: 7:13 error: `testenum::B` does not name a structure
test.rs:7               testenum::B{_} => println("oops"),
                        ^~~~~~~~~~~
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-metadataArea: Crate metadata

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions