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

Unfortunate error message for enum variant used in alt branch but not imported #2848

Closed
jdm opened this issue Jul 9, 2012 · 2 comments
Closed
Labels
A-resolve Area: Path resolution
Milestone

Comments

@jdm
Copy link
Contributor

jdm commented Jul 9, 2012

mod bar {
    enum foo {
        alpha,
        beta,
        charlie
    }
}

fn main() {
    import bar::{alpha, charlie};
    alt alpha {
      alpha | beta {}
      charlie {}
    }
}

yields

binding.rs:12:14: 12:18 error: inconsistent number of bindings
binding.rs:12       alpha | beta {}
                            ^~~~

I flailed around for a while before I figured out what was going on.

@ghost ghost assigned catamorphism Jul 9, 2012
@catamorphism
Copy link
Contributor

This is also a resolve issue, hence postponing until resolve3 is live.

@catamorphism
Copy link
Contributor

Technically, the compiler was behaving correctly: beta is a variable here, since you forgot the import. But I agree it's very confusing. In f39477d I added a new hint to the error message that prints out all the pattern bindings when resolve fails with "inconsistent number of bindings". Try it out and let me know what you think!

RalfJung pushed a commit to RalfJung/rust that referenced this issue Apr 28, 2023
disable preemption in tokio tests again

The comment even still says we need preemption disabled, but the flag got lost in rust-lang/miri#2764.
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Update to the latest Rust toolchain (2023-11-06).

The relevant changes are:
- rust-lang#117507: this required changing
the import of `Span` from `rustc_span::source_map::Span` to
`rustc_span::Span`.
- rust-lang#114208: this changed the data
field for the `OffsetOf` variant of `NullOp` from `List<FieldIdx>` to
`List<(VariantIdx, FieldIdx)>`, which required updating the relevant
code in `rvalue.rs`.
- rust-lang#115626: the unchecked shift
operators have been separated from the `unchecked_math` feature, so this
required changing the feature annotation in
`tests/ui/should-panic-attribute/unexpected-failures/test.rs`
- Some rustc change (not sure which one) result in a line in
`tests/coverage/unreachable/variant/main.rs` getting optimized out. To
maintain what this test is testing, I changed the `match` to make it a
bit less-prone to optimization.
- A change in `cargo` (rust-lang/cargo#12779)
resulted in an update to Kani's workspace `Cargo.toml` when `cargo add`
is executed inside `tests/script-based-pre/build-cache-bin`. This is
apparently intended behavior, so I had to make the `exclude` in the
`Cargo.toml` more specific to make sure this doesn't happen (I tried
using a glob, but that didn't work, apparently because of
rust-lang/cargo#6009.

Resolves rust-lang#2848 

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Path resolution
Projects
None yet
Development

No branches or pull requests

2 participants