Skip to content

Type inference ICE: assertion failed: !self.obligations_in_snapshot.get() #36053

Closed
@Stebalien

Description

@Stebalien

Type inference is barfing on:

use std::iter::once;
fn main() {
    once::<&str>("str").fuse().filter(|a: &str| true).count();
}

This only happens to iterators over &strs types with lifetime parameters and only happens when fused, mapped or filtered, than "operated" on (e.g., counted).

The following works:

use std::iter::once;
use std::marker::PhantomData;

struct Test(&'static str);

fn main() {
    once(Test("asdf")).fuse().filter(|_| true).count();
}

Trace:

error: internal compiler error: unexpected panic

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: !self.obligations_in_snapshot.get()', ../src/librustc/infer/mod.rs:892
stack backtrace:
   1:      0x385616e5833 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:      0x385616f611d - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:      0x385616f466d - std::panicking::default_hook::h9e30d428ee3b0c43
   4:      0x385616f4d68 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:      0x3855e7daf2f - std::panicking::begin_panic::h6da27a7ee15843ce
   6:      0x3855e9365e2 - rustc::infer::InferCtxt::rollback_to::ha2f21524af8937ee
   7:      0x3855fea7ca3 - rustc_typeck::check::method::probe::ProbeContext::consider_candidates::_{{closure}}::hd73cab1de5c62a79
   8:      0x3855fdebe5c - rustc_typeck::check::method::probe::ProbeContext::consider_candidates::hc4fd590b3d2a253e
   9:      0x3855fdebb77 - rustc_typeck::check::method::probe::ProbeContext::pick_method::ha1525cf018083b3f
  10:      0x3855fdeb0ca - rustc_typeck::check::method::probe::ProbeContext::pick_core::h8fe845d303e00275
  11:      0x3855fea4ecc - rustc_typeck::check::method::probe::_<impl rustc_typeck..check..FnCtxt<'a, 'gcx, 'tcx>>::probe_method::_{{closure}}::h4cc364b0888ee90b
  12:      0x3855fde7fda - rustc_typeck::check::method::probe::_<impl rustc_typeck..check..FnCtxt<'a, 'gcx, 'tcx>>::probe_method::h5bcb89eaeb8b15c2
  13:      0x3855fdf278c - rustc_typeck::check::method::_<impl rustc_typeck..check..FnCtxt<'a, 'gcx, 'tcx>>::lookup_method::ha4b60fa1e48e18d1
  14:      0x3855fe4c2df - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h057aec20877fc49f
  15:      0x3855fe4ed90 - rustc_typeck::check::FnCtxt::check_stmt::h0a693585a954d704
  16:      0x3855fe4f177 - rustc_typeck::check::FnCtxt::check_block_with_expected::he043b17dca8afd62
  17:      0x3855fe2245f - rustc_typeck::check::check_fn::hd55e09cd766201af
  18:      0x3855fe20c1d - rustc_typeck::check::check_bare_fn::h56d8f43b26a6d362
  19:      0x3855fe240a9 - rustc_typeck::check::check_item_body::h7d7e664619f18e7f
  20:      0x3855fe1e088 - rustc_typeck::check::check_item_bodies::h7d884d53a15202d6
  21:      0x3855fe89f53 - rustc_typeck::check_crate::h8ec8b2f490f5dc28
  22:      0x38561ad739e - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h45e03cee16dcf298
  23:      0x38561a2ca9f - rustc::ty::context::TyCtxt::create_and_enter::h0021bc4caf3a2e06
  24:      0x38561a9dfb4 - rustc_driver::driver::compile_input::hd9ecc57abd3cba85
  25:      0x38561ac40ad - rustc_driver::run_compiler::h184264500271cc39
  26:      0x38561a05b63 - std::panicking::try::do_call::h17a7a17ad7240c5c
  27:      0x38561704336 - __rust_maybe_catch_panic
  28:      0x38561a22f59 - _<F as alloc..boxed..FnBox<A>>::call_box::h95ef76c8d48c6f60
  29:      0x385616f2ba0 - std::sys::thread::Thread::new::thread_start::he0bf102845911132
  30:      0x38559b60453 - start_thread
  31:      0x385613437de - __GI___clone
  32:                0x0 - <unknown>

Metadata

Metadata

Labels

I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions