Skip to content

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

Closed
@camelid

Description

@camelid

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`.

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

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions