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: rustc panics on trait bound with array associated type (stable) #48984

Closed
fspmarshall opened this issue Mar 13, 2018 · 0 comments
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@fspmarshall
Copy link

I came across a compiler error (stable channel) while working with a trait which extends another trait (eg: trait Dog: Mammal { .. }). After some experimenting, it appears the error occurs when the base trait has at least one associated type, and the extending trait specifies the associated type as an array of some kind. In order to trigger the error, the extending trait must be defined in an external crate, and used to constrain a generic type parameter.

Here is the simplest replication of the error I could come up with:

define my_crate like so:

pub trait Foo { type Item; } // can be any trait w/ an associated type

pub trait Bar: Foo<Item=[u8;1]> {  } // length & type of array does not seem to matter

pull in my_crate from another crate:

extern crate my_crate;
use my_crate::Bar;

fn do_thing<T: Bar>() { } // bounds on structs and impls also trigger bug

attempting to compile the above generates this error:

error: internal compiler error: unexpected panic

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.24.1 (d3ae9a9e0 2018-02-27) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:335:21

Judging by the backtrace it seems likely that the offending unwrap is one of these two, but that is just a guess.

I've replicated this bug with my local rust install as well as the latest version of the official rust docker image.

Verbose rustc version info for my local install:

rustc 1.24.1 (d3ae9a9e0 2018-02-27)
binary: rustc
commit-hash: d3ae9a9e08edf12de0ed82af57ba2a56c26496ea
commit-date: 2018-02-27
host: x86_64-unknown-linux-gnu
release: 1.24.1
LLVM version: 4.0
@fspmarshall fspmarshall changed the title rustc panics on trait bound with array associated type (stable) ICE: rustc panics on trait bound with array associated type (stable) Mar 13, 2018
@oli-obk oli-obk added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Mar 14, 2018
bors added a commit that referenced this issue Apr 29, 2018
Fix ICE #48984

* ~~fbf6423  The tail type was not normalized.~~
* d0839d5  The method had a wrong assumption that something whose parent is a trait is an associated item. Fixes #48984.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants