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

Impl Trait ICE: escaping regions in predicate #44198

Closed
TyOverby opened this Issue Aug 30, 2017 · 6 comments

Comments

Projects
None yet
5 participants
@TyOverby
Copy link
Contributor

TyOverby commented Aug 30, 2017

error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:632: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: Slice([_]), item_def_id: DefId { krate: CrateNum(2), node: DefIndex(911) => core/bdc9c6a::ops[0]::generator[0]::Generator[0]::Yield[0] } }, &T)),depth=0)
@TyOverby

This comment has been minimized.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 31, 2017

cc @Zoxc

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 31, 2017

Ah actually I believe this is an impl Trait bug, this code doesn't work:

#![feature(generators, generator_trait, conservative_impl_trait)]

use std::ops::{Generator, GeneratorState};

struct Tree<T> {
  left: Option<Box<Tree<T>>>,
  value: T,
  right: Option<Box<Tree<T>>>,
}

fn walk<T>(tree: &Tree<T>) -> impl Generator<Yield=&T, Return=()> {
    panic!()
}

fn main() {}

yielding

warning: unused import: `GeneratorState`
 --> src/main.rs:3:27
  |
3 | use std::ops::{Generator, GeneratorState};
  |                           ^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:632: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: Slice([_]), item_def_id: DefId { krate: CrateNum(2), node: DefIndex(911) => core/bdc9c6a::ops[0]::generator[0]::Generator[0]::Yield[0] } }, &T)),depth=0)
  --> src/main.rs:11:31
   |
11 | fn walk<T>(tree: &Tree<T>) -> impl Generator<Yield=&T, Return=()> {
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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: rustc 1.21.0-nightly (c11f689d2 2017-08-29) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:443:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

whereas this code works:

#![feature(generators, generator_trait, conservative_impl_trait)]

use std::ops::{Generator, GeneratorState};

struct Tree<T> {
  left: Option<Box<Tree<T>>>,
  value: T,
  right: Option<Box<Tree<T>>>,
}

fn walk<T>(tree: &Tree<T>) -> Box<Generator<Yield=&T, Return=()>> {
    panic!()
}

fn main() {}

(sorry for the stray cc @Zoxc!)

@bugaevc

This comment has been minimized.

Copy link

bugaevc commented Aug 31, 2017

Not related to generators, just an impl Trait bug:

#![feature(conservative_impl_trait)]

fn foo(_: &u8) -> impl Iterator<Item = &u8> {
    unimplemented!()
}

fn main() {}

Playground

@TyOverby TyOverby changed the title Generators ICE: escaping regions in predicate Impl Trait ICE: escaping regions in predicate Aug 31, 2017

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Jan 5, 2018

This has been fixed.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 5, 2018

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment