Skip to content

Cross-crate enum struct variants exporting bug #8746

New issue

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

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

Already on GitHub? # to your account

Closed
nsf opened this issue Aug 25, 2013 · 3 comments
Closed

Cross-crate enum struct variants exporting bug #8746

nsf opened this issue Aug 25, 2013 · 3 comments
Labels
A-metadata Area: Crate metadata

Comments

@nsf
Copy link
Contributor

nsf commented Aug 25, 2013

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
@nsf
Copy link
Contributor Author

nsf commented Aug 25, 2013

Forgot to add the version, it's fairly recent:

[nsf @ ~]$ rustc --version
rustc 0.8-pre (59ca7a8 2013-08-24 11:02:14 -0700)
host: x86_64-unknown-linux-gnu

@nsf
Copy link
Contributor Author

nsf commented Aug 25, 2013

There is an existing issue describing a similar bug. #5557

Sorry for not searching before actually submitting, but maybe it's worth bringing the attention to it, as it's not marked with A-metadata tag.

bors added a commit that referenced this issue Sep 11, 2013
Fixes issues #5557 and #8746.

This patch adds an additional family for struct-like variants, and encodes some struct-like aspects of such variants that can then be properly decoded by resolve.

Note that I am not 100% sure how this fix works, but it fixes the issue without breaking any of the tests on my machine.
@alexcrichton
Copy link
Member

Closed by #9064

flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 30, 2022
try reading rust-version from Cargo.toml

Cargo.toml can contain a field `rust-version`, that acts like a MSRV of
clippy.toml file: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
This will try to read that field and use it, if the clippy.toml config
has no `msrv` entry

changelog: respect `rust-version` from `Cargo.toml`

closes rust-lang#8746
closes rust-lang#7765
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-metadata Area: Crate metadata
Projects
None yet
Development

No branches or pull requests

2 participants