Skip to content

internal compiler error: librustc/traits/structural_impls.rs:180: impossible case reached #53008

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
malikolivier opened this issue Aug 2, 2018 · 3 comments

Comments

@malikolivier
Copy link

malikolivier commented Aug 2, 2018

I get an internal compiler error. I met with this while randomly moving code around while working on a project. I tried to reduce it to a minimal reproducible example.

I tried this code:

extern crate reqwest; // <- If I remove this line, rustc does not crash
extern crate select;

use select::{
    document::Document, predicate::{Class, Name},
};

fn main() {
    let document = Document::from("");
    for node in document.find(Class("foo")) {
        let mut img_url = None;
        if let Some(img_link) = node.attr("src") {
            img_url = img_link.as_ref(); // <- If I remove this line, rustc does not crash
        }
    }
}

Full reproducible code is available here: https://github.com/malikolivier/rust-structural_impls-internal_compiler_error

I expected to see this happen: Something different from "internal compiler error". Probably this output:

error[E0308]: mismatched types
  --> src/main.rs:10:23
   |
10 |             img_url = img_link.as_ref();
   |                       ^^^^^^^^^^^^^^^^^
   |                       |
   |                       expected enum `std::option::Option`, found reference
   |                       help: try using a variant of the expected type: `Some(img_link.as_ref())`
   |
   = note: expected type `std::option::Option<_>`
              found type `&_`

Instead, this happened: internal compiler error: librustc/traits/structural_impls.rs:180: impossible case reached

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.27.2 (58cc626de 2018-07-18)
binary: rustc
commit-hash: 58cc626de3301192d5d8c6dcbde43b5b44211ae2
commit-date: 2018-07-18
host: x86_64-unknown-linux-gnu
release: 1.27.2
LLVM version: 6.0

The same bug happens on rustc 1.29.0-nightly (97085f9fb 2018-08-01).

Backtrace:

$ RUST_BACKTRACE=1 cargo run --verbose
       Fresh version_check v0.1.4
       Fresh nodrop v0.1.12
       Fresh libc v0.2.42
       Fresh cfg-if v0.1.4
       Fresh byteorder v1.2.4
       Fresh lazy_static v1.0.2
       Fresh memoffset v0.2.1
       Fresh siphasher v0.2.3
       Fresh unicode-xid v0.1.0
       Fresh scopeguard v0.3.3
       Fresh pkg-config v0.3.12
       Fresh cc v1.0.18
       Fresh lazycell v0.6.0
       Fresh futures v0.1.23
       Fresh slab v0.4.0
       Fresh void v1.0.2
       Fresh string_cache_shared v0.3.0
       Fresh unicode-xid v0.0.4
       Fresh foreign-types-shared v0.1.1
       Fresh build_const v0.2.1
       Fresh rustc-serialize v0.3.24
       Fresh bitflags v0.9.1
       Fresh mac v0.1.1
       Fresh quote v0.3.15
       Fresh matches v0.1.7
       Fresh try-lock v0.1.0
       Fresh utf-8 v0.7.4
       Fresh safemem v0.2.0
       Fresh unicode-normalization v0.1.7
       Fresh scoped-tls v0.1.2
       Fresh precomputed-hash v0.1.1
       Fresh lazy_static v0.2.11
       Fresh language-tags v0.2.2
       Fresh percent-encoding v1.0.1
       Fresh adler32 v1.0.3
       Fresh dtoa v0.4.3
       Fresh bit-vec v0.4.4
       Fresh itoa v0.4.2
       Fresh arrayvec v0.4.7
       Fresh iovec v0.1.2
       Fresh rand v0.4.2
       Fresh num_cpus v1.8.0
       Fresh time v0.1.40
       Fresh crossbeam-utils v0.3.2
       Fresh log v0.4.3
       Fresh net2 v0.2.33
       Fresh encoding_rs v0.7.2
       Fresh proc-macro2 v0.3.8
       Fresh tokio-executor v0.1.2
       Fresh tokio-service v0.1.0
       Fresh relay v0.1.1
       Fresh unreachable v1.0.0
       Fresh unreachable v0.1.1
       Fresh synom v0.11.3
       Fresh foreign-types v0.3.2
       Fresh unicode-bidi v0.3.4
       Fresh base64 v0.9.2
       Fresh bit-set v0.4.0
       Fresh bytes v0.4.9
       Fresh uuid v0.6.5
       Fresh futures-cpupool v0.1.8
       Fresh crossbeam-epoch v0.4.3
       Fresh want v0.0.4
       Fresh log v0.3.9
       Fresh mio v0.6.15
       Fresh quote v0.5.2
       Fresh tokio-timer v0.2.4
       Fresh new_debug_unreachable v1.0.1
       Fresh debug_unreachable v0.1.1
       Fresh syn v0.11.11
       Fresh serde v1.0.70
       Fresh httparse v1.3.2
       Fresh idna v0.1.5
       Fresh unicase v1.4.2
       Fresh unicase v2.1.0
       Fresh tokio-io v0.1.7
       Fresh crossbeam-deque v0.3.1
       Fresh openssl-sys v0.9.33
       Fresh futf v0.1.4
       Fresh serde_json v1.0.24
       Fresh crc v1.8.1
       Fresh url v1.7.1
       Fresh phf_shared v0.7.22
       Fresh mime v0.3.8
       Fresh tokio-reactor v0.1.2
       Fresh tokio-codec v0.1.0
       Fresh tokio-threadpool v0.1.5
       Fresh openssl v0.9.24
       Fresh tendril v0.3.1
       Fresh libflate v0.1.16
       Fresh serde_urlencoded v0.5.2
       Fresh phf_generator v0.7.22
       Fresh phf v0.7.22
       Fresh tokio-tcp v0.1.0
       Fresh tokio-udp v0.1.1
       Fresh tokio-fs v0.1.2
       Fresh native-tls v0.1.5
       Fresh string_cache_codegen v0.4.1
       Fresh phf_codegen v0.7.22
       Fresh tokio v0.1.7
       Fresh tokio-core v0.1.17
       Fresh hyper v0.11.27
       Fresh tokio-tls v0.1.4
       Fresh string_cache v0.6.2
       Fresh mime_guess v2.0.0-alpha.6
       Fresh hyper-tls v0.1.4
       Fresh markup5ever v0.3.2
       Fresh reqwest v0.8.7
       Fresh html5ever v0.18.0
       Fresh select v0.4.2
   Compiling select-test v0.1.0 (file:///home/malik/workspace/veille/mercari-scrap)
     Running `rustc --crate-name select_test src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=822bd59bde9136c9 -C extra-filename=-822bd59bde9136c9 --out-dir /home/malik/workspace/veille/mercari-scrap/target/debug/deps -C incremental=/home/malik/workspace/veille/mercari-scrap/target/debug/incremental -L dependency=/home/malik/workspace/veille/mercari-scrap/target/debug/deps --extern select=/home/malik/workspace/veille/mercari-scrap/target/debug/deps/libselect-5ca4f723d69fde13.rlib --extern reqwest=/home/malik/workspace/veille/mercari-scrap/target/debug/deps/libreqwest-c3068e3d2875fc5b.rlib`
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
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:467
   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::Read`
#1 [typeck_tables_of] processing `main`
#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.2 (58cc626de 2018-07-18) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `select-test`.

Caused by:
  process didn't exit successfully: `rustc --crate-name select_test src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=822bd59bde9136c9 -C extra-filename=-822bd59bde9136c9 --out-dir /home/malik/workspace/veille/mercari-scrap/target/debug/deps -C incremental=/home/malik/workspace/veille/mercari-scrap/target/debug/incremental -L dependency=/home/malik/workspace/veille/mercari-scrap/target/debug/deps --extern select=/home/malik/workspace/veille/mercari-scrap/target/debug/deps/libselect-5ca4f723d69fde13.rlib --extern reqwest=/home/malik/workspace/veille/mercari-scrap/target/debug/deps/libreqwest-c3068e3d2875fc5b.rlib` (exit code: 101)
@hellow554
Copy link
Contributor

hellow554 commented Aug 3, 2018

Occurs in 1.28.0, beta and nightly

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

@jamesray1
Copy link

Should be a duplicate of #52873.

@estebank
Copy link
Contributor

estebank commented Jan 8, 2019

ICE no longer repros.

@estebank estebank closed this as completed Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants