- Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Closed
Copy link
Labels
A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code, supplied by @eddyb play:
#![feature(test)] use std::hint::black_box; fn foo() {} const FOO: fn() = foo; fn bar() {} const BAR: fn() = bar; #[inline(never)] fn print(s: &str) { println!("{}", s); } fn main() { match black_box(FOO) { FOO => print("FOO"), BAR => print("BAR"), _ => unreachable!(), } match black_box(FOO) { BAR => print("BAR"), FOO => print("FOO"), _ => unreachable!(), } match black_box(BAR) { FOO => print("FOO"), BAR => print("BAR"), _ => unreachable!(), } match black_box(BAR) { BAR => print("BAR"), FOO => print("FOO"), _ => unreachable!(), } }I expected to see this happen: print out of
FOO FOO BAR BAR (and in debug builds, that is what happens).
Instead, this happened: in release builds, it prints:
FOO BAR FOO BAR Meta
This was on a playpen running 1.44.0-nightly, 2020-04-05.
This all arose from a conversation with @eddyb regarding structural match; you can read it on the zulip archive
cc #31434
scottmcmAaron1011 and stanislav-tkach
Metadata
Metadata
Assignees
Labels
A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.