Skip to content

task 'rustc' panicked at 'assertion failed: (left == right) && (right == left) (left: None, right: Some(()))' #19851

Closed
@forgemo

Description

@forgemo

when i try to compile my code, i get:

error: the type of this value must be known in this context
/Volumes/secure/rust/ch2/src/main.rs:21         if(c.is_some() && c.unwrap().equiv(v)){
                                                                             ^~~~~~~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'assertion failed: `(left == right) && (right == left)` (left: `None`, right: `Some(())`)', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/librustc_typeck/check/method/confirm.rs:153

rustc info

> src: rustc --version=verbose
rustc 0.13.0-nightly (ffc111889 2014-12-12 21:07:19 +0000)
binary: rustc
commit-hash: ffc111889e93bcd38222d9d74a70fdc26a78fcb5
commit-date: 2014-12-12 21:07:19 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly

my system

Mac OSX 10.10.1 (14B25)
Intel Core 2 Duo    64 bit

the 'bad' code

use std::io;
use std::collections::HashMap;

fn main() {
    let mut input       = io::stdin(); 
    let mut lock        = input.lock(); 
    let mut lines_iter  = lock.lines();

    let mut map         = HashMap::new();

    for line in lines_iter {
        let text = line.ok().unwrap();
        let kv_pair: Vec<&str> = text.words().take(2).collect();

        let k = kv_pair[0].to_string();
        let v = kv_pair[1].to_string();

        let c = map.get(&k);


        if(c.is_some() && c.unwrap().equiv(v)){
            println!("{} {}", k, v);
        }

        map.insert(k, v);
    }

    println!("{}", map.len());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions