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: cannot relate bound region (likely caused by conservative_impl_trait) #39872

Closed
jmegaffin opened this issue Feb 16, 2017 · 3 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jmegaffin
Copy link

jmegaffin commented Feb 16, 2017

Related code:

pub struct PhysicalDevice<'a> {
	instance: &'a ::Instance<'a>,
	physical_device: VkPhysicalDevice,
	queue_families: Box<[QueueFamily]>
}

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct QueueFamily {
	pub graphics: bool,
	pub compute: bool,
	pub transfer: bool,
	pub sparse_binding: bool
}

impl<'a> PhysicalDevice<'a> {
	// broken type signature
	pub fn queue_families(&self) -> impl Iterator<Item=&QueueFamily> {
		self.queue_families.iter()
	}
}

Compiler panic:

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: '_#4r <= ReLateBound(DebruijnIndex { depth: 2 }, BrAnon(0))
  --> galvan\src\instance\device/mod.rs:56:34
   |
56 |    pub fn queue_families(&self) -> impl Iterator<Item=&QueueFamily> {
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note that everything is fine if I annotate the lifetimes:

// working type signature
pub fn queue_families(&'a self) -> impl Iterator<Item=&'a QueueFamily> {
	self.queue_families.iter()
}

I am running rustc 1.17.0-nightly (ba7cf7cc5 2017-02-11), the MSVC x64 version.

@jmegaffin jmegaffin changed the title Internal compiler error: cannot relate bound region Internal compiler error: cannot relate bound region (likely caused by conservative_impl_trait) Feb 16, 2017
@kryptan
Copy link
Contributor

kryptan commented Feb 17, 2017

#39665

@JaniM
Copy link
Contributor

JaniM commented Feb 20, 2017

I just ran into this. Managed to reduce the crash to

pub fn f(v: &Vec<i32>) -> impl Iterator<Item=&i32> {
    v.iter()
}

Explicit lifetimes indeed fix it:

pub fn f<'a>(v: &'a Vec<i32>) -> impl Iterator<Item=&'a i32> {
    v.iter()
}

@jsen-
Copy link
Contributor

jsen- commented Mar 30, 2017

don't know if this helps, but I came up with minimal test case

#![feature(conservative_impl_trait)]
fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
}
$ RUST_BACKTRACE=full rustc src/lib.rs --crate-type=lib
error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:1710: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <_ as std::iter::Iterator>, item_name: Item(88) }, &u32)),depth=0)
 --> src/lib.rs:2:33
  |
2 | fn will_ice(something: &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>', /checkout/src/librustc_errors/lib.rs:377
stack backtrace:
   0:     0x7fd7beb20173 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h0c49f46a3545f908
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7fd7beb1a8a4 - std::sys_common::backtrace::_print::hcef39a9816714c4c
                               at /checkout/src/libstd/sys_common/backtrace.rs:71
   2:     0x7fd7beb2e227 - std::panicking::default_hook::{{closure}}::h7c3c94835e02f846
                               at /checkout/src/libstd/sys_common/backtrace.rs:60
                               at /checkout/src/libstd/panicking.rs:355
   3:     0x7fd7beb2dd4b - std::panicking::default_hook::h0bf7bc3112fb107d
                               at /checkout/src/libstd/panicking.rs:365
   4:     0x7fd7beb2e6fb - std::panicking::rust_panic_with_hook::ha27630c950090fec
                               at /checkout/src/libstd/panicking.rs:549
   5:     0x7fd7bd42ebb8 - std::panicking::begin_panic::h63c8743b74308765
   6:     0x7fd7bd455325 - rustc::session::opt_span_bug_fmt::{{closure}}::h0399ec9f6fdc80f4
   7:     0x7fd7bd45513a - rustc::session::span_bug_fmt::h91d1439893b8a5d4
   8:     0x7fd7bd4e1f1c - rustc_typeck::check::FnCtxt::register_predicate::he6d13886b1ff3937
   9:     0x7fd7bd42a5a8 - <rustc::ty::fold::BottomUpFolder<'a, 'gcx, 'tcx, F> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty::h16e93d791bf416ce
  10:     0x7fd7bd4d883e - rustc_typeck::check::check_fn::hc87bd2602316e434
  11:     0x7fd7bd4d73f6 - rustc_typeck::check::typeck_tables::h9b4c3ea40474b1b2
  12:     0x7fd7bbbfb30c - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::try_get::h50e18962037fb36f
  13:     0x7fd7bbbfb4d1 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::get::h0b200a289899fb66
  14:     0x7fd7bbbb1062 - rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::item_tables::ha0531bf6c24dcec8
  15:     0x7fd7bd4d6003 - rustc_typeck::check::check_item_bodies::h4f3e40f875ac7e76
  16:     0x7fd7bd5429e2 - rustc_typeck::check_crate::h6ea76d8b10d9239d
  17:     0x7fd7bef10fd0 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h45ea055410817656
  18:     0x7fd7bee55bf9 - rustc::ty::context::TyCtxt::create_and_enter::hb63d87ce6018d148
  19:     0x7fd7bef02bfd - rustc_driver::driver::phase_3_run_analysis_passes::h303bc0d75d32173b
  20:     0x7fd7beedc275 - rustc_driver::driver::compile_input::h446a5d2d354ecae7
  21:     0x7fd7bef3c046 - rustc_driver::run_compiler::h427b60825e751999
  22:     0x7fd7bee021ab - std::panicking::try::do_call::hc1fa4f624bc07e15
  23:     0x7fd7beb375ea - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:98
  24:     0x7fd7bee49a31 - <F as alloc::boxed::FnBox<A>>::call_box::h69b187d2a58a3ac6
  25:     0x7fd7beb2cfa4 - std::sys::imp::thread::Thread::new::thread_start::h75b208405df6dcf1
                               at /checkout/src/liballoc/boxed.rs:650
                               at /checkout/src/libstd/sys_common/thread.rs:21
                               at /checkout/src/libstd/sys/unix/thread.rs:84
  26:     0x7fd7b6abf6c9 - start_thread
  27:     0x7fd7be7df0ae - __clone
  28:                0x0 - <unknown>
$ rustc -V
rustc 1.17.0-nightly (ccce2c6eb 2017-03-27)

@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

6 participants