Stable -> beta regression, or I missed something?

I have problem with my code, it behaves in different ways, if compiled with different versions of rustc.

Here simplified code (the real one compiled and run on android, and f and main in different crates):

use std::collections::HashSet;

#[derive(PartialEq, Debug, Hash, Eq, Clone)]
enum SentenceType {
    None,
    AAM,
    //...many
    RMC,
    GGA,
    //..many
}

fn f(s: HashSet<SentenceType>) {
    println!("s: {:?}", s);
}

fn main() {
    f([SentenceType::RMC, SentenceType::GGA]
          .iter()
          .cloned()
          .collect());
}

if I compiled with stable (rustc 1.18.0 (03fc9d622 2017-06-06)), all works fine, and it prints s: {GGA, RMC}, but if code compiled with beta or nightly (.19.0-beta.2 (a175ee509 2017-06-15)/1.20.0-nightly (622e7e648 2017-06-21)) it prints:

s: {XTE, HTD, HMR, LRI, BWW, XTR, ZDA, RMC, LRF, TTM, GXA, DBT, APB, ACA, ZTG, ALM, RMA, RTE, LR1, HDG, HDT, GLC, TRF, MLA, VHW, VLW, SFI, APA, DSC, RPM, STN, HSC, DSR, HDM, VDR, TLL, LR3, BWC, AAM, ASD, DSE, RSA, GSV, DBK, DPT, GBS, BWR, GNS, ROO, None, ACK, RMB, VSD, ZFO, AIR, OSD, GGA, MSS, ACS, LR2, TXT, HMS, ALR, DBS, SSD, MWD, ABK, FSI, DSI, GSA, OLN, LCD, DTM, GTD, GMP, BEC, MTW, DCN, ZDL, VBW, GLL, VPW, GRS, VWR, MWV, TLB, CUR, VTG, BOD, WNC}

I can fix problem for beta/nightly with such code:

        let mut s = HashSet::new();
        s.insert(SentenceType::RMC);
        s.insert(SentenceType::GGA);

Because of problem can be reprodiciable only on Android/arm and in partly closed source program, before make attempt to dig it farther, I want to make sure:

  1. May be something wrong in code in question?
  2. Any known rustc bugs that may cause this?
  3. Any hints to debug this?

Rust 1.19 has updated to LLVM 4, so there could well be some regression in ARM codegen. FWIW, it works fine on all stable/beta/nightly on the playground: https://is.gd/zgo7my

1 Like

Rust 1.19 has updated to LLVM 4, so there could well be some regression in ARM codegen. FWIW, it works fine on all stable/beta/nightly on the playground: Rust Playground

It is not reproducible on x86 32/64 bits machines, only on android/arm

but I am able to reduce problem to two crates case, so I post bug here: wrong code regression: HashSet initialization · Issue #42918 · rust-lang/rust · GitHub

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.