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

internal compiler error: impossible case reached #52688

Closed
jbg opened this issue Jul 25, 2018 · 7 comments
Closed

internal compiler error: impossible case reached #52688

jbg opened this issue Jul 25, 2018 · 7 comments
Labels
C-bug Category: This is a bug. 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

@jbg
Copy link

jbg commented Jul 25, 2018

rustc 1.29.0-nightly (6a1c063 2018-07-23) running on x86_64-apple-darwin

The below code has a bug (passing &f instead of f to wait) which should trigger a compilation error. The bug is that after printing the error the compiler panics.

fn wait<I, E>(f: Box<Future<Item=I, Error=E>>) -> Result<I, E> {
    f.wait()
}

fn or_default<I, E>(r: Result<I, E>) -> I where I: Default {
    r.unwrap_or_else(|_| I::default())
}

let f: Box<Future<Item=rust_decimal::Decimal, Error=String> + Send> = Box::new(something_returning_a_future());

or_default(wait(&f));

Compiler output (note that the above code is a simplified testcase; the actual error happens in an askama template)

error[E0308]: mismatched types
   --> src/templates.rs:122:10
    |
122 | #[derive(Template)]
    |          ^^^^^^^^ expected struct `std::boxed::Box`, found reference
    |
    = note: expected type `std::boxed::Box<(dyn futures::Future<Item=_, Error=_> + 'static)>`
               found type `&std::boxed::Box<dyn futures::Future<Item=rust_decimal::Decimal, Error=std::string::String> + std::marker::Send>`

error: internal compiler error: librustc/traits/structural_impls.rs:178: impossible case reached

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:580: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::ty::context::TyCtxt::lift_to_global
  16: rustc::traits::select::SelectionContext::candidate_from_obligation
  17: rustc::traits::select::SelectionContext::evaluate_stack
  18: rustc::dep_graph::graph::DepGraph::with_anon_task
  19: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  20: rustc::infer::InferCtxt::probe
  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::dep_graph::graph::DepGraph::with_anon_task
  25: rustc::traits::select::SelectionContext::candidate_from_obligation
  26: rustc::traits::select::SelectionContext::evaluate_stack
  27: rustc::dep_graph::graph::DepGraph::with_anon_task
  28: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  29: rustc::infer::InferCtxt::probe
  30: <&'a mut I as core::iter::iterator::Iterator>::next
  31: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  32: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  33: rustc::dep_graph::graph::DepGraph::with_anon_task
  34: rustc::traits::select::SelectionContext::candidate_from_obligation
  35: rustc::traits::select::SelectionContext::evaluate_stack
  36: rustc::dep_graph::graph::DepGraph::with_anon_task
  37: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  38: rustc::infer::InferCtxt::probe
  39: <&'a mut I as core::iter::iterator::Iterator>::next
  40: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  41: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  42: rustc::dep_graph::graph::DepGraph::with_anon_task
  43: rustc::traits::select::SelectionContext::candidate_from_obligation
  44: rustc::traits::select::SelectionContext::evaluate_stack
  45: rustc::dep_graph::graph::DepGraph::with_anon_task
  46: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  47: rustc::infer::InferCtxt::probe
  48: <&'a mut I as core::iter::iterator::Iterator>::next
  49: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  50: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  51: rustc::dep_graph::graph::DepGraph::with_anon_task
  52: rustc::traits::select::SelectionContext::candidate_from_obligation
  53: rustc::traits::select::SelectionContext::evaluate_stack
  54: rustc::dep_graph::graph::DepGraph::with_anon_task
  55: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  56: rustc::infer::InferCtxt::probe
  57: <&'a mut I as core::iter::iterator::Iterator>::next
  58: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  59: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  60: rustc::dep_graph::graph::DepGraph::with_anon_task
  61: rustc::traits::select::SelectionContext::candidate_from_obligation
  62: rustc::traits::select::SelectionContext::evaluate_stack
  63: rustc::dep_graph::graph::DepGraph::with_anon_task
  64: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  65: rustc::infer::InferCtxt::probe
  66: <&'a mut I as core::iter::iterator::Iterator>::next
  67: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  68: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  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::dep_graph::graph::DepGraph::with_anon_task
  73: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  74: rustc::infer::InferCtxt::probe
  75: <&'a mut I as core::iter::iterator::Iterator>::next
  76: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  77: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  78: rustc::dep_graph::graph::DepGraph::with_anon_task
  79: rustc::traits::select::SelectionContext::candidate_from_obligation
  80: rustc::traits::select::SelectionContext::evaluate_stack
  81: rustc::dep_graph::graph::DepGraph::with_anon_task
  82: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  83: rustc::infer::InferCtxt::probe
  84: <&'a mut I as core::iter::iterator::Iterator>::next
  85: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  86: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  87: rustc::dep_graph::graph::DepGraph::with_anon_task
  88: rustc::traits::select::SelectionContext::candidate_from_obligation
  89: rustc::traits::select::SelectionContext::evaluate_stack
  90: rustc::dep_graph::graph::DepGraph::with_anon_task
  91: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  92: rustc::infer::InferCtxt::probe
  93: <&'a mut I as core::iter::iterator::Iterator>::next
  94: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  95: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  96: rustc::dep_graph::graph::DepGraph::with_anon_task
  97: rustc::traits::select::SelectionContext::candidate_from_obligation
  98: rustc::traits::select::SelectionContext::evaluate_stack
  99: rustc::dep_graph::graph::DepGraph::with_anon_task
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `&'_ _: tokio::io::AsyncWrite`
#1 [typeck_tables_of] processing `<templates::Template<'a> as templates::Template>::render_block_content_into`
#2 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.

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.29.0-nightly (6a1c0637c 2018-07-23) running on x86_64-apple-darwin
note: compiler flags: -C opt-level=3 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
@estebank estebank added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 25, 2018
@estebank
Copy link
Contributor

Can you provide a full repro case, as I am unable to reproduce the ICE with the supplied code.

@jbg
Copy link
Author

jbg commented Jul 26, 2018

OK, I'll work on extracting the code that triggered this into a better repro case.

@dpc
Copy link
Contributor

dpc commented Aug 1, 2018

@willglynn
Copy link

I hit this trying to cargo doc a project shortly after upgrading to 1.30.0. Repro:

$ cargo new --bin rust_52688_repro
     Created binary (application) `rust_52688_repro` project
$ cd rust_52688_repro/
$ echo 'typenum = "=1.10.0"' >> Cargo.toml 
$ cargo doc
    Updating crates.io index
   Compiling typenum v1.10.0                                                                                                      
 Documenting typenum v1.10.0                                                                                                      
error: internal compiler error: librustc/traits/structural_impls.rs:178: impossible case reached                                  
                                                                                                                                  
thread '<unnamed>' panicked at 'Box<Any>', librustc_errors/lib.rs:587:9                                                           
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                
                                                                                                                                  
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.30.0 (da5f414c2 2018-10-24) running on x86_64-apple-darwin                                                          
                                                                                                                                  
error: Could not document `typenum`.                                                                                              

Caused by:
  process didn't exit successfully: `rustdoc --crate-name typenum /Users/willglynn/.cargo/registry/src/github.com-1ecc6299db9ec823/typenum-1.10.0/src/lib.rs --cap-lints allow --color always -o /Users/delta407/rust/rust_52688_repro/target/doc -L dependency=/Users/willglynn/rust/rust_52688_repro/target/debug/deps` (exit code: 1)

@Aaron1011
Copy link
Member

@willglynn: Duplicate of #53505

@jbg
Copy link
Author

jbg commented Dec 25, 2018

I can't reproduce this any more with latest nightlies.

@estebank estebank added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 26, 2018
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2019
@rossmacarthur
Copy link
Contributor

rossmacarthur commented Dec 24, 2019

I think this issue can be closed.

A related issue was fixed in #54199 and a regression test at src/test/rustdoc/issue-52873.rs was added. This test is probably good enough as a test for this?

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

No branches or pull requests

7 participants