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 when tokio_reactor is used and a borrow() call failed to resolve #50687

Closed
kennytm opened this issue May 12, 2018 · 3 comments · Fixed by #72548
Closed

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

kennytm opened this issue May 12, 2018 · 3 comments · Fixed by #72548
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kennytm
Copy link
Member

kennytm commented May 12, 2018

(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.

@kennytm kennytm added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels May 12, 2018
@jakubadamw
Copy link
Contributor

This, I think, can be closed: in nightly and 1.36.0 the code no longer produces an ICE and instead fails with an error "just fine".

@Centril Centril added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 25, 2019
@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

@kennytm Do you think you could create a minimal test to close this issue with?

@Centril Centril added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 20, 2020
@rylev
Copy link
Member

rylev commented Mar 20, 2020

This still needs a more minimal reproduction. I can't get tokio_reactor to build using any of the compilers that are problematic. The reproduction should show what is happening from including tokio_reactor that causes this issue.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 27, 2020
…=nikomatsakis

Add test for old compiler ICE when using `Borrow`

The original issue was caused by implementing `Borrow` on a local type and using the tokio-reactor crate which had this impl: https://github.com/tokio-rs/tokio/blob/tokio-0.1.4/tokio-reactor/src/poll_evented.rs#L547-L577

This causes an ICE on Rust 1.27.0:

```console
$ RUSTUP_TOOLCHAIN=1.27.0 rustc src/test/ui/issues/issue-50687-ice-on-borrow.rs
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
note: Run with `RUST_BACKTRACE=1` for a backtrace.
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 (3eda71b 2018-06-19) running on x86_64-apple-darwin
```

Closes rust-lang#50687
@bors bors closed this as completed in 2b3b115 May 27, 2020
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. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants