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

rustc cannot see impls for other lifetimes in presence of specific where clause #38308

Closed
djzin opened this issue Dec 11, 2016 · 3 comments
Closed
Labels
A-traits Area: Trait system

Comments

@djzin
Copy link
Contributor

djzin commented Dec 11, 2016

The following code fails to compile:

trait Foo {
    fn foo(&self) {}
}

fn fail<'a>() where &'a (): Foo {
    (&()).foo()
}

impl<'a> Foo for &'a () {}

fn main() {}

The temporary &() is deduced to have type &'a () because of the where clause. If this where clause is removed, the code compiles. For some reason the compiler cannot see that &() still implements Foo for other lifetimes because of this where clause.

n.b. this came from reducing this reddit post
https://www.reddit.com/r/rust/comments/5hm2b6/my_lifetime_snafu/

@bluss
Copy link
Member

bluss commented Dec 11, 2016

This looks like a duplicate of #38071

@hanna-kruppe
Copy link
Contributor

hanna-kruppe commented Dec 11, 2016

I'm not sure if #38071 is a duplicate of #24066 but this looks like a duplicate of #24066 in any case.

@steveklabnik steveklabnik added the A-traits Area: Trait system label Dec 14, 2016
@Mark-Simulacrum
Copy link
Member

Closing in favor of #38071, which may be a duplicate of #24066, but since we're uncertain not closing both--these two issues (this and #38071) are highly likely to be identical, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system
Projects
None yet
Development

No branches or pull requests

5 participants