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

Impl Trait ICE: escaping regions in predicate #44198

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

Impl Trait ICE: escaping regions in predicate #44198

TyOverby opened this issue Aug 30, 2017 · 6 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@TyOverby
Copy link
Contributor

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
Copy link
Contributor Author

@alexcrichton
Copy link
Member

cc @Zoxc

@alexcrichton alexcrichton added the A-generators Area: Generators label Aug 31, 2017
@alexcrichton
Copy link
Member

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!)

@alexcrichton alexcrichton added A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. and removed A-generators Area: Generators labels Aug 31, 2017
@bugaevc
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
@shepmaster shepmaster added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 1, 2017
@cramertj
Copy link
Member

cramertj commented Jan 5, 2018

This has been fixed.

@alexcrichton
Copy link
Member

Yay!

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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants