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

ICE in conservative_impl_trait over VecDeque<String> Iterator #42399

Closed
Ruin0x11 opened this issue Jun 3, 2017 · 3 comments
Closed

ICE in conservative_impl_trait over VecDeque<String> Iterator #42399

Ruin0x11 opened this issue Jun 3, 2017 · 3 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Ruin0x11
Copy link

Ruin0x11 commented Jun 3, 2017

The following produces an ICE on nightly:

#![feature(conservative_impl_trait)]

use std::collections::VecDeque;

struct Dude {
    pets: VecDeque<String>
}

impl Dude {
    pub fn new() -> Self {
        let mut pets = VecDeque::new();
        pets.push_front("Ardo".to_string());
        pets.push_front("Jamie".to_string());
        pets.push_front("Bowser".to_string());

        Dude {
            pets: pets
        }
    }

    pub fn iter_pets(&self) -> impl Iterator<Item=&str> {
        self.pets.iter()
    }
}

fn main() {
    let dude = Dude::new();
    for pet in dude.iter_pets() {
        println!("Pet: {}", pet);
    }
}

Backtrace:

error: internal compiler error: src/librustc_typeck/check/mod.rs:582: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <_ as std::iter::Iterator>, item_name: Item(100) }, &str)),depth=0)
  --> /var/folders/ps/gxj98yzj1hl7s0nbh2p67yrh0000gn/T/scratch.rs18590rMs:21:32
   |
21 |     pub fn iter_pets(&self) -> impl Iterator<Item=&str> {
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^

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 'Box<Any>', src/librustc_errors/lib.rs:421
stack backtrace:
   0:        0x10e7591a3 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h884a721e113c3303
   1:        0x10e766b78 - std::panicking::default_hook::{{closure}}::h7a7d734b2824d103
   2:        0x10e76673f - std::panicking::default_hook::h3eb11bd6cbfdc331
   3:        0x10e768fc7 - std::panicking::rust_panic_with_hook::h8b9b25777425677b
   4:        0x10cf92a9b - std::panicking::begin_panic::h061689b360c0bfb1
   5:        0x10cf8e566 - rustc_errors::Handler::span_bug::h2b4146ff57268dfc
   6:        0x10cfb764e - rustc::session::opt_span_bug_fmt::{{closure}}::h34cfa07f23f68d87
   7:        0x10cfb74ca - rustc::session::span_bug_fmt::h4f2cfdfd2015bbe7
   8:        0x10d02dc14 - rustc_typeck::check::Inherited::register_predicate::h75c22e95f0c57291
   9:        0x10cf8f671 - <rustc::ty::fold::BottomUpFolder<'a, 'gcx, 'tcx, F> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty::hfc1c4aa50b73a811
  10:        0x10d033131 - rustc_typeck::check::check_fn::hb3437296de08eb34
  11:        0x10d02fc2c - rustc_typeck::check::typeck_tables_of::{{closure}}::h1b6d5d70ecf6005f
  12:        0x10d02f6e5 - rustc_typeck::check::typeck_tables_of::h4c463db39374b891
  13:        0x10d5c5b87 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get::hfdb673b8a48ec6b9
  14:        0x10d5e686a - rustc::ty::maps::TyCtxtAt::typeck_tables_of::hdf5c872430b487bf
  15:        0x10d5e2a3e - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of::h306d67d8b4c45cea
  16:        0x10d02ea5f - rustc_typeck::check::typeck_item_bodies::h8dfd9fcfc53b0892
  17:        0x10d5c4fe0 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get::hf3e901ad43954fdf
  18:        0x10d5e66f6 - rustc::ty::maps::TyCtxtAt::typeck_item_bodies::hc4d4754d193e0320
  19:        0x10d5e2a02 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies::hc8ecc5004e34ae46
  20:        0x10d08b8c0 - rustc_typeck::check_crate::h775d5fd81d3a9471
  21:        0x109062998 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h0ecedd6aa323696d
  22:        0x1090533ca - rustc_driver::driver::phase_3_run_analysis_passes::h7d4e4be12a652e17
  23:        0x109041910 - rustc_driver::driver::compile_input::h348e0421a5ad9950
  24:        0x109087818 - rustc_driver::run_compiler::hcb92b90602044806
  25:        0x108fb3c8b - std::sys_common::backtrace::__rust_begin_short_backtrace::h77667a403996a54f
  26:        0x10e76c15a - __rust_maybe_catch_panic
  27:        0x108fda02f - <F as alloc::boxed::FnBox<A>>::call_box::hf344d772b8631f42
  28:        0x10e765bf5 - std::sys::imp::thread::Thread::new::thread_start::h993b7e5cb7871f66
  29:        0x10f02baaa - _pthread_body
  30:        0x10f02b9f6 - _pthread_start

$ rustc --version
rustc 1.19.0-nightly (e0cc22b4b 2017-05-31)
@est31
Copy link
Member

est31 commented Jun 3, 2017

Minimized:

#![feature(conservative_impl_trait)]

struct D;

impl D {
    fn i(&self) -> impl Iterator<Item=&str> {
        &[].iter()
    }
}

fn main() {
    let d = D;
    for _ in d.i() {}
}

Looks like a dupe of #41182 in any case.

@frewsxcv frewsxcv added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 4, 2017
@Boscop
Copy link

Boscop commented Jun 9, 2017

I ran into this:

#![feature(conservative_impl_trait)]

trait F {}

pub struct A<'a, T: 'a + F> {
    i: Vec<&'a [T]>,
    o: Vec<&'a [T]>,
}
impl<'a, T: 'a + F> A<'a, T> {
    pub fn z<'b: 'a>(&self) -> impl Iterator<Item = (&'b &[T], &'b &[T])> {
        self.i.iter().zip(self.o.iter())
    }
}

fn main() {}
rustc 1.19.0-nightly (f062832b2 2017-06-07)
error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:578: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <_ as std::iter::Iterator>, item_def_id: DefId { krate: CrateNum(2), node: DefIndex(1495) => core/ce488d1::iter[0]::iterator[0]::Iterator[0]::Item[0] } }, (&'b &[T], &'b &[T]))),depth=0)
  --> <anon>:10:32
   |
10 |     pub fn z<'b: 'a>(&self) -> impl Iterator<Item = (&'b &[T], &'b &[T])> {
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@cramertj
Copy link
Member

cramertj commented Jan 5, 2018

This is fixed on the current nightly.

@pietroalbini pietroalbini added the A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. label Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. 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

7 participants