Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct variants define a ctor function as if they were regular variants #18252

Closed
osa1 opened this issue Oct 23, 2014 · 3 comments · Fixed by #18324
Closed

struct variants define a ctor function as if they were regular variants #18252

osa1 opened this issue Oct 23, 2014 · 3 comments · Fixed by #18324
Labels
E-needs-test Call for participation: Writing correctness tests.

Comments

@osa1
Copy link
Contributor

osa1 commented Oct 23, 2014

lib.rs:

#![feature(struct_variant)]
pub mod en {
    pub enum MyEnum {
        Variant1(int),
        Variant2{pub name: String}
    }
}

main.rs:

extern crate lib;

use lib::en;

fn main() {
    let enu = en::Variant1(2i);
    let enu2 = en::Variant2("Joe".to_string());
}

error:

main.rs:7:16: 7:28 error: unresolved name `en::Variant2`.
main.rs:7     let enu2 = en::Variant2("Joe".to_string());
                         ^~~~~~~~~~~~
error: aborting due to previous error

But this works:

#![feature(struct_variant)]
pub mod en {
    pub enum MyEnum {
        Variant1(int),
        Variant2{pub name: String}
    }
}

fn main() {
    let enu = en::Variant1(2i);
    let enu2 = en::Variant2("Joe".to_string());
}
@osa1
Copy link
Contributor Author

osa1 commented Oct 23, 2014

Looks similar to #4577.

@sfackler
Copy link
Member

It seems like the bug is that this works within the same crate imo.

@ghost
Copy link

ghost commented Oct 23, 2014

@sfackler Agreed. I sneaked in a fix for that in #18171 but maybe I should split it out.

@ghost ghost added the E-needs-test Call for participation: Writing correctness tests. label Oct 23, 2014
@ghost ghost changed the title struct variant constructors doesn't work with function call syntax when used in different crate struct variants define a ctor function as if they were regular variants Oct 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: Writing correctness tests.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants