Skip to content

Commit 911a15d

Browse files
committed
Add test for wrong code generation for HashSet creation on arm cpu
This is test for #42918. To reproduce bug you need machine with arm cpu and compile with optimization. I tried with rustc 1.19.0-nightly (3d5b8c6 2017-06-09), if compile test with -C opt-level=3 for target=arm-linux-androideabi and run on "Qualcomm MSM 8974 arm cpu" then assert fails, if compile and run with -C opt-level=2 it gives segmentation fault. So I add `compile-flags: -O`. With rustc 1.19.0 (0ade339 2017-07-17) all works fine. Closes #42918
1 parent a1c3365 commit 911a15d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
//
11+
// compile-flags: -O
12+
13+
use std::collections::HashSet;
14+
15+
#[derive(PartialEq, Debug, Hash, Eq, Clone, PartialOrd, Ord)]
16+
enum MyEnum {
17+
E0,
18+
19+
E1,
20+
21+
E2,
22+
E3,
23+
E4,
24+
25+
E5,
26+
E6,
27+
E7,
28+
}
29+
30+
31+
fn main() {
32+
use MyEnum::*;
33+
let s: HashSet<_> = [E4, E1].iter().cloned().collect();
34+
let mut v: Vec<_> = s.into_iter().collect();
35+
v.sort();
36+
37+
assert_eq!([E1, E4], &v[..]);
38+
}

0 commit comments

Comments
 (0)