Skip to content

ICE for impl Trait with missing lifetime #42479

Closed
@wagnerf42

Description

@wagnerf42

Hi, the compiler (nightly) panics on this code:

#![feature(conservative_impl_trait)]
use std::iter::once;

struct Foo {
    x: i32,
}

impl Foo {
    fn inside(&self) -> impl Iterator<Item = &i32> {
        once(&self.x)
    }
}

fn main() {
    println!("hi");
}

I know this code is not ok. in fact once the lifetime is added, the compiler does not panic anymore.

here is the log:

/tmp ❯❯❯ rustc --version
rustc 1.19.0-nightly (e0cc22b4b 2017-05-31)
/tmp ❯❯❯ rustc test.rs
error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:582: escaping regions in predicate Obligatio
n(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <_ as std::iter::Iterator>, item_name: Item(92) }, &i3
2)),depth=0)
 --> test.rs:9:25
  |
9 |     fn inside(&self) -> impl Iterator<Item = &i32> {
  |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^

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:421
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:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:365
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   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::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  15: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  16: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  17: rustc_typeck::check::typeck_item_bodies
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  19: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  20: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  21: rustc_typeck::check_crate
  22: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  23: rustc_driver::driver::phase_3_run_analysis_passes
  24: rustc_driver::driver::compile_input
  25: rustc_driver::run_compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions