Skip to content

ICE when tokio_reactor is used and a borrow() call failed to resolve #50687

Closed
@kennytm

Description

@kennytm

(Non-minimized) Repro case:

extern crate tokio_reactor;

use std::borrow::Borrow;

struct S;
struct T;

impl Borrow<S> for T {
    fn borrow(&self) -> &S {
        &S
    }
}

fn g(a: T) {
    let _: () = <T as Borrow<_>>::borrow(&a);
}

It can correct fail with E0308 "mismatched types" if that extern crate tokio_reactor; line is removed.

Crash log
error: internal compiler error: librustc/traits/structural_impls.rs:180: impossible case reached

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::session::opt_span_bug_fmt
  13: rustc::session::bug_fmt
  14: rustc::traits::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::traits::SelectionError<'a>>::lift_to_tcx
  15: rustc::traits::select::SelectionContext::candidate_from_obligation
  16: rustc::traits::select::SelectionContext::evaluate_stack
  17: rustc::ty::context::tls::with_context
  18: rustc::dep_graph::graph::DepGraph::with_anon_task
  19: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  20: rustc::traits::select::SelectionContext::evaluate_candidate
  21: <&'a mut I as core::iter::iterator::Iterator>::next
  22: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  23: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  24: rustc::ty::context::tls::with_context
  25: rustc::dep_graph::graph::DepGraph::with_anon_task
  26: rustc::traits::select::SelectionContext::candidate_from_obligation
  27: rustc::traits::select::SelectionContext::evaluate_stack
  28: rustc::ty::context::tls::with_context
  29: rustc::dep_graph::graph::DepGraph::with_anon_task
  30: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  31: rustc::traits::select::SelectionContext::evaluate_candidate
  32: <&'a mut I as core::iter::iterator::Iterator>::next
  33: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  34: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  35: rustc::ty::context::tls::with_context
  36: rustc::dep_graph::graph::DepGraph::with_anon_task
  37: rustc::traits::select::SelectionContext::candidate_from_obligation
  38: rustc::traits::select::SelectionContext::evaluate_stack
  39: rustc::ty::context::tls::with_context
  40: rustc::dep_graph::graph::DepGraph::with_anon_task
  41: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  42: rustc::traits::select::SelectionContext::evaluate_candidate
  43: <&'a mut I as core::iter::iterator::Iterator>::next
  44: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  45: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  46: rustc::ty::context::tls::with_context
  47: rustc::dep_graph::graph::DepGraph::with_anon_task
  48: rustc::traits::select::SelectionContext::candidate_from_obligation
  49: rustc::traits::select::SelectionContext::evaluate_stack
  50: rustc::ty::context::tls::with_context
  51: rustc::dep_graph::graph::DepGraph::with_anon_task
  52: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  53: rustc::traits::select::SelectionContext::evaluate_candidate
  54: <&'a mut I as core::iter::iterator::Iterator>::next
  55: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  56: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  57: rustc::ty::context::tls::with_context
  58: rustc::dep_graph::graph::DepGraph::with_anon_task
  59: rustc::traits::select::SelectionContext::candidate_from_obligation
  60: rustc::traits::select::SelectionContext::evaluate_stack
  61: rustc::ty::context::tls::with_context
  62: rustc::dep_graph::graph::DepGraph::with_anon_task
  63: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  64: rustc::traits::select::SelectionContext::evaluate_candidate
  65: <&'a mut I as core::iter::iterator::Iterator>::next
  66: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  67: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  68: rustc::ty::context::tls::with_context
  69: rustc::dep_graph::graph::DepGraph::with_anon_task
  70: rustc::traits::select::SelectionContext::candidate_from_obligation
  71: rustc::traits::select::SelectionContext::evaluate_stack
  72: rustc::ty::context::tls::with_context
  73: rustc::dep_graph::graph::DepGraph::with_anon_task
  74: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  75: rustc::traits::select::SelectionContext::evaluate_candidate
  76: <&'a mut I as core::iter::iterator::Iterator>::next
  77: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  78: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  79: rustc::ty::context::tls::with_context
  80: rustc::dep_graph::graph::DepGraph::with_anon_task
  81: rustc::traits::select::SelectionContext::candidate_from_obligation
  82: rustc::traits::select::SelectionContext::evaluate_stack
  83: rustc::ty::context::tls::with_context
  84: rustc::dep_graph::graph::DepGraph::with_anon_task
  85: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  86: rustc::traits::select::SelectionContext::evaluate_candidate
  87: <&'a mut I as core::iter::iterator::Iterator>::next
  88: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  89: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  90: rustc::ty::context::tls::with_context
  91: rustc::dep_graph::graph::DepGraph::with_anon_task
  92: rustc::traits::select::SelectionContext::candidate_from_obligation
  93: rustc::traits::select::SelectionContext::evaluate_stack
  94: rustc::ty::context::tls::with_context
  95: rustc::dep_graph::graph::DepGraph::with_anon_task
  96: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  97: rustc::traits::select::SelectionContext::evaluate_candidate
  98: <&'a mut I as core::iter::iterator::Iterator>::next
  99: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `&'_ _: std::io::Write`
#1 [typeck_tables_of] processing `g`
#2 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to previous error


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.27.0-nightly (acd3871ba 2018-05-10) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

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

The ICE is repro with 1.27-beta and nightly.

On 1.26-stable, this will produce an infinite recursion instead.
error[E0275]: overflow evaluating the requirement `_: std::marker::Sized`
  --> src/main.rs:15:17
   |
15 |     let _: () = <T as Borrow<_>>::borrow(&a);
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider adding a `#![recursion_limit="32"]` attribute to your crate
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<_>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>>>>>>>`
   = note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<tokio_reactor::PollEvented<_>>>>>>>>>>>>>>>>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.
error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Maybe the same as #50439.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions