Skip to content

regression: rustc incorrectly claims that enum variant is inaccessible #90113

Closed
@camelid

Description

@camelid
Member

MCVE

mod list {
    pub use List::Cons;

    pub enum List<T> {
        Cons(T, Box<List<T>>),
    }
}

mod alias {
    use crate::list::List;

    pub type Foo = List<String>;
}

fn foo(l: crate::alias::Foo) {
    match l {
        Cons(hd, tl) => {}
    }
}

New error (incorrect)

error[E0531]: cannot find tuple struct or tuple variant `Cons` in this scope
  --> src/lib.rs:17:9
   |
17 |         Cons(hd, tl) => {}
   |         ^^^^ not found in this scope
   |
note: tuple variant `crate::alias::List::Cons` exists but is inaccessible
  --> src/lib.rs:5:9
   |
5  |         Cons(T, Box<List<T>>),
   |         ^^^^^^^^^^^^^^^^^^^^^ not accessible

For more information about this error, try `rustc --explain E0531`.

Old error (correct)

error[E0531]: cannot find tuple struct or tuple variant `Cons` in this scope
  --> src/lib.rs:17:9
   |
17 |         Cons(hd, tl) => {}
   |         ^^^^ not found in this scope
   |
help: consider importing this tuple variant
   |
1  | use crate::alias::List::Cons;
   |

For more information about this error, try `rustc --explain E0531`.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.
on Oct 20, 2021
added this to the 1.57.0 milestone on Oct 20, 2021
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Oct 20, 2021
camelid

camelid commented on Oct 20, 2021

@camelid
MemberAuthor

Bisected to a rollup, but I think it's very likely to be #88838. cc @FabianWolff @estebank

searched nightlies: from nightly-2021-10-01 to nightly-2021-10-19
regressed nightly: nightly-2021-10-02
searched commits: from aa7aca3 to c02371c
regressed commit: 69eb996

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-apple-darwin
Reproduce with:

cargo bisect-rustc --preserve --prompt --start=2021-10-01 --end=2021-10-19 -- check 
camelid

camelid commented on Oct 20, 2021

@camelid
MemberAuthor

The old suggestion was actually incorrect because it suggested crate::alias::List::Cons, which is a private import. However, the new error is "more incorrect" IMO since it says something confusing (and incorrect).

self-assigned this
on Oct 21, 2021
apiraino

apiraino commented on Oct 21, 2021

@apiraino
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

added and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Oct 21, 2021
added a commit that references this issue on Oct 25, 2021

Rollup merge of rust-lang#90127 - JohnTitor:fix-90113, r=estebank

c734a9e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @apiraino@JohnTitor@camelid@rustbot

    Issue actions

      regression: rustc incorrectly claims that enum variant is inaccessible · Issue #90113 · rust-lang/rust