Skip to content
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

ICE in typeck subst #8998

Closed
pnkfelix opened this issue Sep 5, 2013 · 3 comments · Fixed by #11982
Closed

ICE in typeck subst #8998

pnkfelix opened this issue Sep 5, 2013 · 3 comments · Fixed by #11982
Labels
A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Sep 5, 2013

(This may be an artifact of trying to make progress after encountering a different type error.)

Test case:

extern mod extra;

mod g {
    use extra::treemap::TreeMap;

    struct LF<T> { o: ~[T] }

    fn step<T>(rules: &[T]) -> Option<LF<T>> { None }

    fn f<T:Clone+Eq+Ord+TotalOrd>(t:&T) {
        let rules : TreeMap<T, ~[T]> = TreeMap::new();
        let LF { o: _ } = step(rules.get(t)).unwrap();
    }
}

fn main() { }

The ICE:

% RUST_LOG=rustc=1 rustc /tmp/bad.rs
/tmp/bad.rs:12:31: 12:44 error: type `extra::treemap::TreeMap<T,~[T]>` does not implement any method in scope named `get`
/tmp/bad.rs:12         let LF { o: _ } = step(rules.get(t)).unwrap();
                                              ^~~~~~~~~~~~~
task <unnamed> failed at 'index out of bounds: the len is 0 but the index is 0', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/middle/subst.rs:58
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/rustc.rs:376
@nikomatsakis
Copy link
Contributor

cc me

@bill-myers
Copy link
Contributor

Another simpler test case that hits that same out-of-bounds issue:

struct A<T> {
    a: T
}

fn f<T>(v: A<T>) {
    let ~A{a: ref a} = v;
}

The code is incorrect, but shouldn't ICE.

@eddyb
Copy link
Member

eddyb commented Feb 2, 2014

I've replaced the ICE with an error as part of the fix for #11964, is this acceptable?

error: missing type param `T` in the substitution of `T`
<anon>:1:42: 1:54 error: mismatched types: expected `A<T>` but found a ~-box pattern
<anon>:1 struct A<T> {a: T} fn f<T>(v: A<T>) {let ~A{a: ref a} = v;} fn main(){}

@bors bors closed this as completed in 3e0eb3c Feb 2, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 18, 2022
Allow `let_unit_value` in more cases

fixes rust-lang#8998

changelog: Lint `let_unit_value` less aggressively when the type is specified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants