Skip to content

ICE when combining impl_trait and lifetime elision #44145

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
Pratyush opened this issue Aug 29, 2017 · 2 comments
Closed

ICE when combining impl_trait and lifetime elision #44145

Pratyush opened this issue Aug 29, 2017 · 2 comments

Comments

@Pratyush
Copy link
Contributor

Hi! The following code snippet utilizing impl Trait and lifetime elision fails to compile (resulting in a ICE) on the latest nightly, as well as nightlies stretching back to (at least) 2017/08/02. If I explicitly specify the lifetimes, I don't get the ICE.

// lib.rs
#![feature(conservative_impl_trait)]
use std::collections::BTreeMap;

pub struct Wrapper<T> {
    map: BTreeMap<T, T>
}

impl<T> Wrapper<T> {
    pub fn iter(&self) -> impl Iterator<Item = &T> {
        self.block.iter() // notice that there is no field named block. The same error happens even when using self.map
    }
}

I get the following error:

error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:626: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: Slice([_]), item_def_id: DefId { krate: CrateNum(2), node: DefIndex(1588) => core/ded319f::iter[0]::iterator[0]::Iterator[0]::Item[0] } }, &T)),depth=0)
 --> lib.rs:9:27
  |
9 |     pub fn iter(&self) -> impl Iterator<Item = &T> {
  |                           ^^^^^^^^^^^^^^^^^^^^^^^^

The backtrace is:

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:436:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::span_bug
   7: rustc::session::opt_span_bug_fmt::{{closure}}
   8: rustc::session::span_bug_fmt
   9: rustc_typeck::check::Inherited::register_predicate
  10: <rustc::ty::fold::BottomUpFolder<'a, 'gcx, 'tcx, F> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  11: rustc_typeck::check::check_fn
  12: rustc_typeck::check::typeck_tables_of::{{closure}}
  13: rustc_typeck::check::typeck_tables_of
  14: rustc::dep_graph::graph::DepGraph::with_task
  15: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  16: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  17: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  18: rustc_typeck::check::typeck_item_bodies
  19: rustc::dep_graph::graph::DepGraph::with_task
  20: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  21: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  22: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  23: rustc_typeck::check_crate
  24: rustc::ty::context::TyCtxt::create_and_enter
  25: rustc_driver::driver::compile_input
  26: rustc_driver::run_compiler
@cramertj
Copy link
Member

Duplicate of #43396.

@shepmaster
Copy link
Member

Closing as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants