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

eliding lifetimes in impl trait leads to a compiler panic #39553

Closed
0x7CFE opened this Issue Feb 5, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@0x7CFE
Copy link

0x7CFE commented Feb 5, 2017

My code contained the following method:

pub fn iter<'b>(&'b self) -> impl Iterator<Item=(&'b FragmentKey, &'b Box<Fragment>)> {
    self.map.iter()
}

Clippy suggested me that lifetime specifiers are redundant here and they may be elided completely. So I simplified the code like this:

pub fn iter(&self) -> impl Iterator<Item=(&FragmentKey, &Box<Fragment>)> {
    self.map.iter()
}

But when it tried to rebuild the project, compiler crashed:

$ RUST_BACKTRACE=1  cargo build                   
   Compiling cortex v0.1.0 (file:///home/korvin/work/research/redozubov/cortex)
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: match *region { ty::ReLateBound(..) => false, _ => true, }', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/infer/higher_ranked/mod.rs:492
stack backtrace:
   1:     0x7f0cee64145c - std::sys::imp::backtrace::tracing::imp::write::hf7294f5e24536b4a
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7f0cee64f90e - std::panicking::default_hook::{{closure}}::h9a07d0b00c43fbee
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7f0cee64f4b3 - std::panicking::default_hook::hf25feff2d08bf39b
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7f0cee64fdab - std::panicking::rust_panic_with_hook::h4cb8c6fbb8386ccf
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7f0ceb5be72f - std::panicking::begin_panic::h9e2767cec6fae47f
   6:     0x7f0ceb6bcae7 - rustc::infer::higher_ranked::fold_regions_in::{{closure}}::hfdfe0b774688fbf9
   7:     0x7f0ceb7b3ebe - rustc::ty::fold::TypeFolder::fold_ty::h9973aa2c13a5eff1
   8:     0x7f0ceb5b1fa4 - <rustc_data_structures::accumulate_vec::AccumulateVec<A> as core::iter::traits::FromIterator<<A as rustc_data_structures::array_vec::Array>::Element>>::from_iter::h3c0bd810cda7086d
   9:     0x7f0ceb7f1499 - rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::Slice<&'tcx rustc::ty::TyS<'tcx>>>::super_fold_with::h1b503259b5d3b322
  10:     0x7f0ceb7b3dc4 - rustc::ty::fold::TypeFolder::fold_ty::h9973aa2c13a5eff1
  11:     0x7f0ceb6e5bf4 - rustc::infer::InferCtxt::match_poly_projection_predicate::h9b3155fdc343189c
  12:     0x7f0ceb78e6fd - rustc::traits::project::confirm_param_env_candidate::h824a2cb6e91e204f
  13:     0x7f0ceb78b03f - rustc::traits::project::opt_normalize_projection_type::h9f3de06b07283d8b
  14:     0x7f0ceb7886ef - rustc::traits::project::normalize_projection_type::h79a91c393ed89b1d
  15:     0x7f0ceb78836c - <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty::hdd75b6b51662ff62
  16:     0x7f0ceb789c94 - rustc::traits::project::opt_normalize_projection_type::h9f3de06b07283d8b
  17:     0x7f0ceb78604c - rustc::traits::project::project_and_unify_type::hac56b6032c41964c
  18:     0x7f0ceb6dd9e2 - rustc::infer::InferCtxt::commit_if_ok::hd2912d20d4e08c55
  19:     0x7f0ceb783d13 - <rustc::traits::fulfill::FulfillProcessor<'a, 'b, 'gcx, 'tcx> as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation::hcaed46acd96ba11a
  20:     0x7f0ceb6210d7 - <rustc_data_structures::obligation_forest::ObligationForest<O>>::process_obligations::h0a39d2a7dea0d69b
  21:     0x7f0ceb7825cf - rustc::traits::fulfill::FulfillmentContext::select_where_possible::h1de446b26cc56aea
  22:     0x7f0cebe28439 - rustc_typeck::check::FnCtxt::select_obligations_where_possible::h3d9dc81d4ec899ba
  23:     0x7f0cebe29700 - rustc_typeck::check::FnCtxt::check_argument_types::h1645086727026c10
  24:     0x7f0cebe02be6 - rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::confirm_builtin_call::h4317ad5b85dc5c65
  25:     0x7f0cebe01ac5 - rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_call::h1be9195a210d695b
  26:     0x7f0cebe3599f - rustc_typeck::check::FnCtxt::check_expr_kind::h2c29b2633d90fef5
  27:     0x7f0cebe3488d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hc0ab5cf329ed3bb9
  28:     0x7f0cebdb85b4 - rustc_typeck::check::_match::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_match::h5d3c9633e773daac
  29:     0x7f0cebe34fd1 - rustc_typeck::check::FnCtxt::check_expr_kind::h2c29b2633d90fef5
  30:     0x7f0cebe3488d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hc0ab5cf329ed3bb9
  31:     0x7f0cebe4618d - rustc_typeck::check::FnCtxt::check_decl_initializer::h5e55f2dd6081fe5f
  32:     0x7f0cebe46294 - rustc_typeck::check::FnCtxt::check_decl_local::h1a92ec3283fc5732
  33:     0x7f0cebe465c6 - rustc_typeck::check::FnCtxt::check_stmt::hd5c04fea4080a98c
  34:     0x7f0cebe4691e - rustc_typeck::check::FnCtxt::check_block_with_expected::h03584e43fc04a13e
  35:     0x7f0cebe34cc6 - rustc_typeck::check::FnCtxt::check_expr_kind::h2c29b2633d90fef5
  36:     0x7f0cebe3488d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hc0ab5cf329ed3bb9
  37:     0x7f0cebe4655c - rustc_typeck::check::FnCtxt::check_stmt::hd5c04fea4080a98c
  38:     0x7f0cebe4691e - rustc_typeck::check::FnCtxt::check_block_with_expected::h03584e43fc04a13e
  39:     0x7f0cebe34cc6 - rustc_typeck::check::FnCtxt::check_expr_kind::h2c29b2633d90fef5
  40:     0x7f0cebe3488d - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hc0ab5cf329ed3bb9
  41:     0x7f0cebe1aef1 - rustc_typeck::check::check_fn::hdcc283c26b22bc9e
  42:     0x7f0cebe19f04 - rustc_typeck::check::check_bare_fn::hf15cf554a01d6e48
  43:     0x7f0cebe170f5 - rustc_typeck::check::check_item_bodies::ha330650a58a36448
  44:     0x7f0cebe84a47 - rustc_typeck::check_crate::h06f4ceb61c7f6528
  45:     0x7f0cee9ede57 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h074ad5edbf4a7db7
  46:     0x7f0cee9e0286 - rustc_driver::driver::phase_3_run_analysis_passes::h380fa931cb354859
  47:     0x7f0cee9ce090 - rustc_driver::driver::compile_input::hab977ae496b3a6f1
  48:     0x7f0ceea189c4 - rustc_driver::run_compiler::h81290683db66a63c
  49:     0x7f0cee924deb - std::panicking::try::do_call::h00942d7a5d04424f
  50:     0x7f0cee658bea - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  51:     0x7f0cee94d052 - <F as alloc::boxed::FnBox<A>>::call_box::hd87f7ab2fccbd670
  52:     0x7f0cee64e764 - std::sys::imp::thread::Thread::new::thread_start::hc16926852e47c008
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:623
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  53:     0x7f0ce640a6b9 - start_thread
  54:     0x7f0cee30482c - clone
  55:                0x0 - <unknown>

error: Could not compile `cortex`.
$ rustc --version --verbose
rustc 1.17.0-nightly (0648517fa 2017-02-03)
binary: rustc
commit-hash: 0648517faf1e2cf37c8b6770cbd0180a816ed9a0
commit-date: 2017-02-03
host: x86_64-unknown-linux-gnu
release: 1.17.0-nightly
LLVM version: 3.9
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented May 20, 2017

No longer ICEs today. E-needstest.

@venkatagiri

This comment has been minimized.

Copy link
Contributor

venkatagiri commented May 22, 2017

@Mark-Simulacrum, the example attached in duplicate issue #39929 is stilling ICEing. https://is.gd/yWRQML

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented May 22, 2017

I'll reopen that one then since it apparently was not a duplicate.

@venkatagiri

This comment has been minimized.

Copy link
Contributor

venkatagiri commented May 25, 2017

It still ICEs on nightly.

$ git diff
diff --git a/src/memory.rs b/src/memory.rs
index 09529ab..0eb0aa2 100644
--- a/src/memory.rs
+++ b/src/memory.rs
@@ -558,7 +558,7 @@ impl Dictionary {
         prototype.get_key(freq_range, detectors)
     }

-    pub fn iter<'b>(&'b self) -> impl Iterator<Item=(&'b FragmentKey, &'b Box<Fragment>)> {
+    pub fn iter(&self) -> impl Iterator<Item=(&FragmentKey, &Box<Fragment>)> {
         self.map.iter()
     }

$ cargo +nightly build
   Compiling cortex v0.1.0 (file:///tmp/cortex)
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

thread 'rustc' panicked at 'assertion failed: match *region { ty::ReLateBound(..) => false, _ => true, }', /checkout/src/librustc/infer/higher_ranked/mod.rs:493
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `cortex`.

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

$ rustup run nightly rustc --version --verbose
rustc 1.19.0-nightly (5b13bff52 2017-05-23)
binary: rustc
commit-hash: 5b13bff5203c1bdc6ac6dc87f69b5359a9503078
commit-date: 2017-05-23
host: x86_64-unknown-linux-gnu
release: 1.19.0-nightly
LLVM version: 4.0
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jun 18, 2017

Minimal test case (possibly also above, but I found it hard to find last time I triaged..)

#![feature(conservative_impl_trait)]

pub fn iter(x: &usize) -> impl Iterator<Item=(&i32, &Box<i32>)> {
    unimplemented!()
}

fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment