Skip to content

ICE: "cannot relate bound region" when using conservative_impl_trait #39665

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
kryptan opened this issue Feb 9, 2017 · 1 comment
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@kryptan
Copy link
Contributor

kryptan commented Feb 9, 2017

Playground

#![feature(conservative_impl_trait)]

fn batches(n: &u32) -> impl Iterator<Item=&u32> {
    std::iter::once(n)
}

fn main() {}

Output:

E:\mega3\projects\ice\ice>cargo build
   Compiling ice v0.1.0 (file:///E:/mega3/projects/ice/ice)
error: internal compiler error: C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\librustc\infer\region_inference/mod.rs:744: cannot relate bound region: '_#1r <= ReLateBound(DebruijnIndex { depth: 2 }, BrAnon(0))
 --> src\main.rs:3:24
  |
3 | fn batches(n: &u32) -> impl Iterator<Item=&u32> {
  |                        ^^^^^^^^^^^^^^^^^^^^^^^^

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 'Box<Any>', C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\librustc_errors\lib.rs:376
stack backtrace:
   0:     0x7ffbf9a60d58 - std::panicking::Location::line::ha91c35bc276d0b51
   1:     0x7ffbf9a601e2 - std::panicking::Location::line::ha91c35bc276d0b51
   2:     0x7ffbf9a63c1d - std::panicking::rust_panic_with_hook::hf12525c539cafb95
   3:     0x7ffbf6d1288b - <unknown>
   4:     0x7ffbf6efbd99 - rustc::session::bug_fmt::h2b4624f40b53342d
   5:     0x7ffbf6efb7e2 - rustc::session::bug_fmt::h2b4624f40b53342d
   6:     0x7ffbf6efaf54 - rustc::session::bug_fmt::h2b4624f40b53342d
   7:     0x7ffbf6e378a4 - rustc::infer::region_inference::RegionVarBindings::make_subregion::h7d1c928b417a379e
   8:     0x7ffbf6e37177 - rustc::infer::region_inference::RegionVarBindings::make_eqregion::h7aba2537086b9605
   9:     0x7ffbf6e18347 - <rustc::infer::equate::Equate<'combine, 'infcx, 'gcx, 'tcx> as rustc::ty::relate::TypeRelation<'infcx, 'gcx, 'tcx>>::regions::h3e5abdb2851963c5
  10:     0x7ffbf6f66209 - rustc::ty::outlives::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::outlives_components::h006225a62a2484ea
  11:     0x7ffbf6e17a98 - <rustc::infer::equate::Equate<'combine, 'infcx, 'gcx, 'tcx> as rustc::ty::relate::TypeRelation<'infcx, 'gcx, 'tcx>>::tys::h0e345c52eceb6db5
  12:     0x7ffbf6e4ce89 - rustc::infer::InferCtxt::combine_fields::h8d78780cd9bc1f89
  13:     0x7ffbf6e537c4 - rustc::infer::InferCtxt::eq_types::h341a931021d55886
  14:     0x7ffbf6f15081 - rustc::traits::fulfill::GlobalFulfilledPredicates::check_duplicate_trait::h93cb52b260fb1258
  15:     0x7ffbf6e51365 - rustc::infer::InferCtxt::commit_from::h79f349c198c8b4f0
  16:     0x7ffbf6f12969 - <rustc::traits::fulfill::FulfillProcessor<'a, 'b, 'gcx, 'tcx> as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation::h80789c9225e6da16
  17:     0x7ffbf6f104a4 - rustc::traits::fulfill::FulfillmentContext::take_deferred_obligations::h59157437f621c52e
  18:     0x7ffbf6f0fdb7 - rustc::traits::fulfill::FulfillmentContext::select_where_possible::hedb3ea6dfe818e1e
  19:     0x7ffbf79ef1a5 - rustc_typeck::check::FnCtxt::field_ty::h387f0899108f3c54
  20:     0x7ffbf79edfac - rustc_typeck::check::FnCtxt::field_ty::h387f0899108f3c54
  21:     0x7ffbf79dd506 - rustc_typeck::check::check_drop_impls::h632d17e4d693e43d
  22:     0x7ffbf79d9db0 - rustc_typeck::check::check_item_bodies::h9a3914a42542ad06
  23:     0x7ffbf7a5d7a0 - rustc_typeck::check_crate::h26811b192a872b84
  24:     0x7ffbf9e15c7e - rustc_driver::driver::count_nodes::h80b2ce48c34d37f0
  25:     0x7ffbf9d663c6 - <unknown>
  26:     0x7ffbf9df13f6 - rustc_driver::driver::compile_input::hc2e887bda4c69183
  27:     0x7ffbf9e42dfb - rustc_driver::run_compiler::h94efe000e99b91da
  28:     0x7ffbf9d1efbe - <unknown>
  29:     0x7ffbf9a66c51 - _rust_maybe_catch_panic
  30:     0x7ffbf9d4c806 - <unknown>
  31:     0x7ffbf9a5e1ce - std::sys::imp::thread::Thread::new::hd3ea3fbc2b0bf083
  32:     0x7ffc1abd8363 - BaseThreadInitThunk

error: Could not compile `ice`.

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

Other example (possibly different bug):

#![feature(conservative_impl_trait)]

fn batches(n: &u32) -> impl Iterator<Item=&u32> {
    std::iter::empty()
}

fn main() {}

Output:

E:\mega3\projects\ice\ice>cargo build
   Compiling ice v0.1.0 (file:///E:/mega3/projects/ice/ice)
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: !obligation.predicate.has_escaping_regions()', C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\librustc\traits\select.rs:409
stack backtrace:
   0:     0x7ffbf9a60d58 - std::panicking::Location::line::ha91c35bc276d0b51
   1:     0x7ffbf9a601e2 - std::panicking::Location::line::ha91c35bc276d0b51
   2:     0x7ffbf9a63c1d - std::panicking::rust_panic_with_hook::hf12525c539cafb95
   3:     0x7ffbf6d12843 - <unknown>
   4:     0x7ffbf6f2236a - rustc::traits::select::SelectionContext::select::h1761016ce8ef2f1e
   5:     0x7ffbf6f1268d - <rustc::traits::fulfill::FulfillProcessor<'a, 'b, 'gcx, 'tcx> as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation::h80789c9225e6da16
   6:     0x7ffbf6f104a4 - rustc::traits::fulfill::FulfillmentContext::take_deferred_obligations::h59157437f621c52e
   7:     0x7ffbf6f0fdb7 - rustc::traits::fulfill::FulfillmentContext::select_where_possible::hedb3ea6dfe818e1e
   8:     0x7ffbf783f1a5 - rustc_typeck::check::FnCtxt::field_ty::h387f0899108f3c54
   9:     0x7ffbf7838ea8 - rustc_typeck::check::FnCtxt::resolve_type_vars_with_obligations::h09ff96390f67faf0
  10:     0x7ffbf77de126 - rustc_typeck::check::demand::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::demand_coerce::h839b40a8b211aade
  11:     0x7ffbf782ebba - <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_pat::h8fcdbeae3dbc14f2
  12:     0x7ffbf782d4f3 - rustc_typeck::check::check_drop_impls::h632d17e4d693e43d
  13:     0x7ffbf7829db0 - rustc_typeck::check::check_item_bodies::h9a3914a42542ad06
  14:     0x7ffbf78ad7a0 - rustc_typeck::check_crate::h26811b192a872b84
  15:     0x7ffbf9e15c7e - rustc_driver::driver::count_nodes::h80b2ce48c34d37f0
  16:     0x7ffbf9d663c6 - <unknown>
  17:     0x7ffbf9df13f6 - rustc_driver::driver::compile_input::hc2e887bda4c69183
  18:     0x7ffbf9e42dfb - rustc_driver::run_compiler::h94efe000e99b91da
  19:     0x7ffbf9d1efbe - <unknown>
  20:     0x7ffbf9a66c51 - _rust_maybe_catch_panic
  21:     0x7ffbf9d4c806 - <unknown>
  22:     0x7ffbf9a5e1ce - std::sys::imp::thread::Thread::new::hd3ea3fbc2b0bf083
  23:     0x7ffc1abd8363 - BaseThreadInitThunk

error: Could not compile `ice`.

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

Meta

rustc 1.17.0-nightly (c49d10207 2017-02-07)
binary: rustc
commit-hash: c49d10207a7e105525fb3bd71c18fde6fc2f5aed
commit-date: 2017-02-07
host: x86_64-pc-windows-msvc
release: 1.17.0-nightly
LLVM version: 3.9
@Michael-F-Bryan
Copy link

I just got the same ICE on linux with both the 2017-02-07 and 2017-02-09 builds.

My case is essentially the same. You create an iterator of references to sub-elements of some thing which has been passed in by reference. The compiler should figure out that the iterator can only live as long as the original object, but ICEs instead.

(playground)

rustc 1.17.0-nightly (24a70eb59 2017-02-09)
binary: rustc
commit-hash: 24a70eb598a76edb0941f628a87946b40f2a1c83
commit-date: 2017-02-09
host: x86_64-unknown-linux-gnu
release: 1.17.0-nightly
LLVM version: 3.9

@frewsxcv frewsxcv added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 4, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
topecongiro added a commit to topecongiro/rust that referenced this issue Dec 30, 2017
bors added a commit that referenced this issue Dec 31, 2017
Add tests on fixed ICEs

Closes #29924. Closes #38857. Closes #39665. Closes #39872.
Closes #41210. Closes #41880. Closes #43483.

Note that compile-fail/E0599.rs is for #41210.
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants