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 "internal compiler error: cannot relate bound region" using associated type in method sig #20831

Closed
nikomatsakis opened this issue Jan 9, 2015 · 0 comments
Labels
A-associated-items Area: Associated items such as associated types and consts. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nikomatsakis
Copy link
Contributor

use std::ops::{Shl, Shr};
use std::cell::RefCell;

pub trait Subscriber {
    type Input;
}

pub trait Publisher<'a> {
    type Output;

    fn subscribe(&mut self, Box<Subscriber<Input=Self::Output> + 'a>);

}

pub trait Processor<'a> : Subscriber + Publisher<'a> { }

impl<'a, P> Processor<'a> for P
where P : Subscriber + Publisher<'a> { }


struct MyStruct<'a> {
    sub: Box<Subscriber<Input=u64> + 'a>
}

impl<'a> Publisher<'a> for MyStruct<'a> {
    type Output = u64;

    fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
        self.subscriber = t;
    }

}

fn main() {}

yields:

lunch-box. rustc ~/tmp/rovar.rs
/home/nmatsakis/tmp/rovar.rs:28:5: 30:6 error: internal compiler error: cannot relate bound region: ReFree(88, BrNamed(DefId { krate: 0u32, node: 96u32 }, 'a)) <= ReLateBound(DebruijnIndex { depth: 3u32
}, BrAnon(1))
/home/nmatsakis/tmp/rovar.rs:28     fn subscribe(&mut self, t : Box<Subscriber<Input=<MyStruct<'a> as Publisher>::Output> + 'a>) {
/home/nmatsakis/tmp/rovar.rs:29         self.subscriber = t;
/home/nmatsakis/tmp/rovar.rs:30     }
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>', /home/nmatsakis/versioned/rust-1/src/libsyntax/diagnostic.rs:123

Backtrace:

stack backtrace:
   1:     0x7f2b4a0904b0 - sys::backtrace::write::hc33c0f30f6bee48dCzt
   2:     0x7f2b4a0b26c0 - failure::on_fail::hb963d0c36b10514daPz
   3:     0x7f2b4a020240 - rt::unwind::begin_unwind_inner::hdae086d0b79f35712tz
   4:     0x7f2b450aa860 - rt::unwind::begin_unwind::h13484122622889777099
   5:     0x7f2b450aa7f0 - diagnostic::SpanHandler::span_bug::headb6283b29a226fIRF
   6:     0x7f2b4848f890 - middle::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h4c7a20a638c31a25Kfw
   7:     0x7f2b4843f920 - middle::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::regions::h6359f29cf9bb6e07Xoy
   8:     0x7f2b4843ddc0 - middle::infer::combine::Combine::substs_variances::h24213547863999897
   9:     0x7f2b4843dd00 - middle::infer::combine::Combine::substs::h12473875684778725248
  10:     0x7f2b4843da60 - middle::infer::combine::Combine::trait_refs::h5280693724941496106
  11:     0x7f2b48442d30 - middle::infer::combine::Combine::projection_tys::h14373726893306599401
  12:     0x7f2b48426930 - middle::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::tys::h22d46133309df1a2Wvy
  13:     0x7f2b48442bd0 - middle::infer::combine::Combine::projection_predicates::h11220478815809982305
  14:     0x7f2b48441560 - middle::infer::higher_ranked::C.HigherRankedRelations<'tcx>::higher_ranked_sub::unboxed_closure.73888
  15:     0x7f2b48440e70 - middle::infer::higher_ranked::C.HigherRankedRelations<'tcx>::higher_ranked_sub::h8741887278504938399
  16:     0x7f2b484a6130 - result::Result<V, E>.FromIterator<Result<A, E>>::from_iter::Adapter<Iter, E>.Iterator::next::h12275455710249568012
  17:     0x7f2b484a5eb0 - result::Result<V, E>.FromIterator<Result<A, E>>::from_iter::h4394336484059744225
  18:     0x7f2b484a5b60 - middle::infer::combine::Combine::existential_bounds::h1684376140490263861
  19:     0x7f2b48426930 - middle::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::tys::h22d46133309df1a2Wvy
  20:     0x7f2b48426930 - middle::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::tys::h22d46133309df1a2Wvy
  21:     0x7f2b48445960 - middle::infer::combine::Combine::args::h1520184800584367187
  22:     0x7f2b484457b0 - vec::Vec<T>.FromIterator<T>::from_iter::h7679049291035860243
  23:     0x7f2b484453a0 - middle::infer::combine::Combine::fn_sigs::h16564086657495642215
  24:     0x7f2b48443b10 - middle::infer::higher_ranked::C.HigherRankedRelations<'tcx>::higher_ranked_sub::unboxed_closure.73930
  25:     0x7f2b48443400 - middle::infer::higher_ranked::C.HigherRankedRelations<'tcx>::higher_ranked_sub::h8904585972080634262
  26:     0x7f2b484a6400 - middle::infer::combine::Combine::bare_fn_tys::h7458720669919803527
  27:     0x7f2b48426930 - middle::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::tys::h22d46133309df1a2Wvy
  28:     0x7f2b484a9320 - middle::infer::InferCtxt<'a, 'tcx>::sub_types::h0c797a62be34ef88KYA
  29:     0x7f2b484a8e00 - middle::infer::mk_subty::hc58e5329cc8f3127sqA
  30:     0x7f2b49832d10 - check::compare_method::compare_impl_method::ha3cace0054dac102ZAj
  31:     0x7f2b4983ebf0 - check::check_item::h94f685b036503098RNk
  32:     0x7f2b49903c40 - check_crate::unboxed_closure.30436
  33:     0x7f2b498fe780 - check_crate::h326f19254f8388eauSx
  34:     0x7f2b4a5dcee0 - driver::phase_3_run_analysis_passes::h21c032817652340ahwa
  35:     0x7f2b4a5c5c40 - driver::compile_input::h0fc2c0f3b0492b65wba
  36:     0x7f2b4a694ec0 - thunk::F.Invoke<A, R>::invoke::h7309714978540172785
  37:     0x7f2b4a693c40 - rt::unwind::try::try_fn::h11574143453518770554
  38:     0x7f2b4a117b10 - rust_try_inner
  39:     0x7f2b4a117b00 - rust_try
  40:     0x7f2b4a693f30 - thunk::F.Invoke<A, R>::invoke::h11037746254120548559
  41:     0x7f2b4a0a0570 - sys::thread::thread_start::h8705f831408525e7qrw
  42:     0x7f2b448c70c0 - start_thread
  43:     0x7f2b49cc3f89 - __clone
  44:                0x0 - <unknown>

Based on the backtrace, I think that @jroesch's PR will help here.

@nikomatsakis nikomatsakis added A-associated-items Area: Associated items such as associated types and consts. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 9, 2015
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Jan 13, 2015
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Jan 13, 2015
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Jan 14, 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 such as associated types and consts. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

1 participant