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

Diagnostic regression for struct-like enum variant constructors from private modules when missing fields #80363

Closed
RadicalZephyr opened this issue Dec 25, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@RadicalZephyr
Copy link

Code

I tried this code:

mod inner {
    pub enum MyEnum {
        EscapeSequence { sequence: String, bad: bool },
    }
}

fn main() {
    let x = inner::MyEnum::EscapeSequence {
        sequence: String::from(""),
    };
}

Playground

I expected to see this happen:

The compiler used to correctly suggest that a field was missing from the enum constructor:

error[E0063]: missing field `bad` in initializer of `inner::MyEnum`
 --> src/main.rs:8:13
  |
8 |     let x = inner::MyEnum::EscapeSequence {
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bad`

Instead, this happened:

Now the compiler erroneously reports:

error: cannot construct `MyEnum` with struct literal syntax due to inaccessible fields
 --> src/main.rs:8:13
  |
8 |     let x = inner::MyEnum::EscapeSequence {
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Version it worked on

It most recently worked on: Rust 1.47

Version with regression

rustc --version --verbose:

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
@camelid camelid added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. labels Dec 25, 2020
@camelid
Copy link
Member

camelid commented Dec 25, 2020

Duplicate of #79593. Will be fixed in 1.50.

@camelid camelid closed this as completed Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants