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

Conservative Impl Trait #46565

Closed
Hittherhod opened this issue Dec 7, 2017 · 1 comment
Closed

Conservative Impl Trait #46565

Hittherhod opened this issue Dec 7, 2017 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Hittherhod
Copy link

Hittherhod commented Dec 7, 2017

I tried to use the conservative impl trait to let me return an iterator over &str. I used the following code:

struct Parent
{
    children: Option<Vec<String>>
}

impl Parent {
    pub fn children() -> impl Iterator<Item=&str> {
        self.children.unwrap_or(Vec::new()).iter()
    }
}

I expected an iterator to be returned, but I got this odd error and a message asking me to submit a bug.

error: internal compiler error: src/librustc_typeck/check/mod.rs:670: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: Slice([_]), item_def_id: DefId(2/0:1695 ~ core[b72a]::iter[0]::iterator[0]::Iterator[0]::Item[0]) }, &str)),depth=0)
  --> lib.rs:36:31
   |
36 |     pub fn children(&self) -> impl Iterator<Item=&str>
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^

note: the compiler unexpectedly panicked. this is a bug.

note: rustc 1.24.0-nightly (5a2465e2b 2017-12-06) running on x86_64-apple-darwin

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:448:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 7, 2017
@nikomatsakis
Copy link
Contributor

Duplicate of #43396, I believe. (Closing in favor of that bug.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants