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

const fn: reported test for a simple match with a wildcard-only arm #66758

Closed
Centril opened this issue Nov 25, 2019 · 3 comments · Fixed by #66786
Closed

const fn: reported test for a simple match with a wildcard-only arm #66758

Centril opened this issue Nov 25, 2019 · 3 comments · Fixed by #66786
Assignees
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Nov 25, 2019

This works; let's consider adding a test for it since it's a bit of a special case. Reported to be working in #49146 (comment) by @jyn514.

// check-pass

#![feature(const_if_match)]

enum E {
    A,
    B,
    C
}

const fn f(e: E) {
    match e {
        _ => {}
    }
}
@Centril Centril added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-const_if_match labels Nov 25, 2019
@ecstatic-morse ecstatic-morse self-assigned this Nov 25, 2019
@jyn514
Copy link
Member

jyn514 commented Nov 26, 2019

@ecstatic-morse do you mind if I add this? My laptop is no longer broken ^^ so I can actually get some work done without disappearing for a week at a time.

I put this in a file called src/test/ui/consts/control-flow/empty-match.rs and ran ./x.py test --stage 1, is that about the right approach?

@Centril
Copy link
Contributor Author

Centril commented Nov 26, 2019

@jyn514 It is, but I'd recommend using --pass check to make it go faster. Also use --test-args empty-match to just test that file. Also, I'd rename the test to not suggest match x {}... something like single-arm-match-wild.rs.

@jyn514
Copy link
Member

jyn514 commented Nov 26, 2019

I ran ./x.py test src/test/ui/consts --stage 1 about an hour ago and that worked fine (although it took a while ^^). However, since then I updated nightly and I'm now getting compile errors when building stage 1:

cargo:warning=In file included from ../rustllvm/PassWrapper.cpp:6:0:
cargo:warning=../rustllvm/rustllvm.h:1:10: fatal error: llvm-c/BitReader.h: No such file or directory
cargo:warning= #include "llvm-c/BitReader.h"
cargo:warning=          ^~~~~~~~~~~~~~~~~~~~

What am I doing wrong?

Full error: https://pastebin.com/pbnpgmK9

(cross posted from https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp)

ecstatic-morse added a commit to ecstatic-morse/rust that referenced this issue Nov 26, 2019
tmandry added a commit to tmandry/rust that referenced this issue Nov 26, 2019
Add wildcard test for const_if_match

Closes rust-lang#66758

Many thanks to @Centril for his help getting me started!
@bors bors closed this as completed in 37f440f Nov 27, 2019
@RalfJung RalfJung added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants