Skip to content

Compiler Error - Unexpected variant TyInfer(?0). #49131

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

Closed
shingtaklam1324 opened this issue Mar 18, 2018 · 1 comment
Closed

Compiler Error - Unexpected variant TyInfer(?0). #49131

shingtaklam1324 opened this issue Mar 18, 2018 · 1 comment

Comments

@shingtaklam1324
Copy link

Code

src/lib.rs

use std::ops::Index;
use std::cmp::Ordering;

#[inline]
pub fn bsearch<T: PartialOrd + PartialEq>(data: &[T], item: &T) -> Option<usize> {
    let (mut l, mut u) = (0, data.len());
    loop {
        let mp = (l + u) / 2;
        match data[mp].partial_cmp(item)? {
            Ordering::Equal => return Some(mp),
            Ordering::Less => l = mp,
            Ordering::Greater => u = mp,
        }
        if l == u {
            return None;
        }
    }
}

tests/test.rs

extern crate bsearch;

use test::bench::Bencher;

use bsearch::bsearch;

#[bench]
fn test_one_item(b: &mut Bencher) {
    assert_eq!(bsearch(&[1], &1), Some(0));
}

Command ran

cargo test

Error

error: internal compiler error: librustc/ich/impls_ty.rs:906: ty::TypeVariants::hash_stable() - Unexpected variant TyInfer(?0).

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:540:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.26.0-nightly (55c984ee5 2018-03-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `bsearch`.

To learn more, run the command again with --verbose.
@shingtaklam1324 shingtaklam1324 changed the title Compiler Error Compiler Error - Unexpected variant TyInfer(?0). Mar 18, 2018
@kennytm
Copy link
Member

kennytm commented Mar 18, 2018

Thanks for the report! This is likely a duplicate of #49043, so closing.

@kennytm kennytm closed this as completed Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants