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 for impl Trait with missing lifetime #42479

Closed
wagnerf42 opened this issue Jun 6, 2017 · 4 comments
Closed

ICE for impl Trait with missing lifetime #42479

wagnerf42 opened this issue Jun 6, 2017 · 4 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@wagnerf42
Copy link

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

@eddyb eddyb changed the title Box<Any> panic for impl Trait with missing lifetime ICE for impl Trait with missing lifetime Jun 6, 2017
@eddyb eddyb added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 6, 2017
@tirr-c
Copy link
Contributor

tirr-c commented Jun 17, 2017

There are some duplicate open issues I can find: #39553, #39929, #41182, #42399. It seems that the ICE occurs whenever there is elided lifetime parameter in impl Trait.

@fhahn
Copy link
Contributor

fhahn commented Jun 18, 2017

I'd like to look into this.

@kennytm
Copy link
Member

kennytm commented Sep 20, 2017

I think this should be closed in favor of #43396, which is tracked by #42183.

@petrochenkov
Copy link
Contributor

Fixed, needs a test.

@petrochenkov petrochenkov added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Dec 23, 2017
topecongiro added a commit to topecongiro/rust that referenced this issue Dec 26, 2017
bors added a commit that referenced this issue Dec 27, 2017
Add tests to fixed ICEs

Closes #27078. Closes #27985. Closes #39848. Closes #42164.
Closes #42479. Closes #45662. Closes #45965. Closes #46152.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

7 participants