Skip to content

ICE 'type' was a a subtype of 'type' but now it is not #20971

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
Marwes opened this issue Jan 11, 2015 · 5 comments
Closed

ICE 'type' was a a subtype of 'type' but now it is not #20971

Marwes opened this issue Jan 11, 2015 · 5 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Marwes
Copy link
Contributor

Marwes commented Jan 11, 2015

Got an ICE when trying to return a Box<_> which contains associated types

pub trait Parser {
    type Input;
    fn parse(&mut self, input: <Self as Parser>::Input);
}
impl Parser for () {
    type Input = ();
    fn parse(&mut self, input: ()) {

    }
}
pub fn many() -> Box<Parser<Input=<() as Parser>::Input> + 'static> {
    panic!()
}

fn main() {
    many()
        .parse(());
}

Error and backtrace:

`error.rs:18:10: 18:19 error: internal compiler error: &mut Parser + 'static was
a subtype of &mut Parser + 'static but now is not?
error.rs:18         .parse(());
                     ^~~~~~~~~
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
thread 'rustc' panicked at 'Box<Any>', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libsyntax\diagnostic.rs:123

stack backtrace:
   1:         0x69bec997 - sys::backtrace::write::h62d87c63e18a3ea5JRt
   2:         0x69c00672 - rt::unwind::register::haa3a38fa07bfa9beVGz
   3:         0x69b834a7 - rt::unwind::begin_unwind_inner::hbebf9f8c0125ffc9tEz
   4:         0x6f898116 - diagnostic::SpanHandler::span_bug::hebc2106d060dd9d6xSF
   5:         0x6f8980cb - diagnostic::SpanHandler::span_bug::hebc2106d060dd9d6xSF
   6:           0x5e1d0a - session::Session::span_bug::h08799ba60bf74646cQq
   7:         0x6d50bbe4 - check::method::probe::Pick<'tcx>.Repr<'tcx>::repr::h1c3027b8aeb1b724Qjh
   8:         0x6d587cd1 - check::LvaluePreference...std..cmp..Eq::assert_receiver_is_total_eq::h22fc9549f98e035eaom
   9:         0x6d5a6750 - check::LvaluePreference...std..cmp..Eq::assert_receiver_is_total_eq::h22fc9549f98e035eaom
  10:         0x6d566063 - check::GatherLocalsVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h6a396874613b07b20dk
  11:         0x6d553fdd - check::FnCtxt<'a, 'tcx>.RegionScope::anon_regions::hdbf64e315fb3c7658mm
  12:         0x6d56319e - check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'v>::visit_ty::h8db07a75f4d7ec1c31j
  13:         0x6d55ae70 - check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h6010e6ec5a0a2b14G1j
  14:         0x6d625870 - check_crate::hd6caa8c10c4dd23523x
  15:         0x6d620844 - check_crate::hd6caa8c10c4dd23523x
  16:         0x70b1e6bf - driver::phase_3_run_analysis_passes::hca97b7f3e7dde725gwa
  17:         0x70b02abd - driver::compile_input::hf5b2f58693da03b5xba
  18:         0x70bd1eec - run::ha65e56249318cc0dV3b
  19:         0x70bd04cc - run::ha65e56249318cc0dV3b
  20:         0x70bcf16a - run::ha65e56249318cc0dV3b
  21:         0x69c2881c - rust_try
  22:         0x69c287f9 - rust_try
  23:         0x70bcf854 - run::ha65e56249318cc0dV3b
  24:         0x69bf14a7 - sys::tcp::TcpListener::bind::hc4a8da4adad0f541bsw
  25:     0x7fff4c8816ad - BaseThreadInitThunk
rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)
binary: rustc
commit-hash: 44a287e6eb22ec3c2a687fc156813577464017f7
commit-date: 2015-01-08 17:03:40 -0800
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly
@Aatch Aatch added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 12, 2015
@Aatch
Copy link
Contributor

Aatch commented Jan 12, 2015

Looks like it might be an associated items issue? @nikomatsakis?

@nikomatsakis nikomatsakis added the A-associated-items Area: Associated items (types, constants & functions) label Jan 13, 2015
@nikomatsakis
Copy link
Contributor

Indeed, it works fine if I remove the associated type:

pub trait Parser {
    type Input;
    fn parse(&mut self, input: <Self as Parser>::Input);
}
impl Parser for () {
    type Input = ();
    fn parse(&mut self, input: ()) {

    }
}
pub fn many() -> Box<Parser<Input=()> + 'static> {
    panic!()
}

fn main() {
    many()
        .parse(());
}

Presumably we're failing to normalize somewhere.

@nikomatsakis
Copy link
Contributor

This works for me now.

@nikomatsakis nikomatsakis added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 16, 2015
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Jan 16, 2015
@goffrie
Copy link
Contributor

goffrie commented Jan 26, 2015

Looks like the fixing commit had a typo in the bug number - this ought to be closed now, right?

@Aatch
Copy link
Contributor

Aatch commented Jan 26, 2015

I can't figure out which PR fixed this. But I'm going to assume that it's fixed.

@Aatch Aatch closed this as completed Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants