-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rust is confused by variants and structs #19293
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
Comments
It looks like the underlying problem here is that cross-crate variants are not namespaced under their enum:
pub enum MyEnum {
Foo(int),
}
extern crate meow;
#[test]
fn test() {
// This compiles, but shouldn’t; it should have to be meow::MyEnum::Foo(5)
let _: meow::MyEnum = meow::Foo(5);
} If these two files are combined into a single crate, it behaves as expected (i.e., fails to compile). |
Should be an easy fix. This chunk of code was deleted at one point but must have come back in a rebase or something: https://github.com/rust-lang/rust/blob/master/src/librustc/metadata/encoder.rs#L509-L516 |
The chunk of code in encoder.rs was at one point deleted, but must have come back in a rebase or something :( Closes rust-lang#19293
(the title of this issue is terrible, sorry!)
As demonstrated in this repository
lib.rs
test.rs
Shouldn't this test work? Right now, it thinks the inner
Foo
is theMyEnum::Foo
variant, which is not the case.I feel like this is one of those moment where I'm doing something very obviously wrong.
The text was updated successfully, but these errors were encountered: