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

Implementation with existential lifetime issue #33273

Closed
zakarumych opened this issue Apr 29, 2016 · 3 comments
Closed

Implementation with existential lifetime issue #33273

zakarumych opened this issue Apr 29, 2016 · 3 comments
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@zakarumych
Copy link
Contributor

zakarumych commented Apr 29, 2016

I believe the next code should compile:

trait Trait<'a> {}
struct SomeType<'a> { data: &'a str }
impl<'a, 'b: 'a> Trait<'a> for SomeType<'b> {}

fn foo<T: for<'a> Trait<'a>>(t: T) {}

fn main() {
    let data = "qwerty";
    let some_type: SomeType<'static> = SomeType { data: data };
    foo(some_type);
}

Because 'static: 'a for any 'a
Or, maybe I missed something?

@zakarumych
Copy link
Contributor Author

Of course if implementation could be rewritten as such impl<'a, 'b> Trait<'a> for SomeType<'b> {}. i.e. removing relation between 'b and 'a. Than this synthetic example would compile. But it could be impossible in many cases.

@nikomatsakis nikomatsakis added A-trait-system Area: Trait system I-wrong T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 3, 2017
@nikomatsakis
Copy link
Contributor

I agree it should compile; there are some long-standing issues with our handling of for<> bounds. The plan is to clean up them via a larger initiative (rust-lang/rust-roadmap-2017#8).

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. and removed I-wrong labels Jul 25, 2017
@cjgillot
Copy link
Contributor

cjgillot commented Mar 4, 2022

This now compiles.

@cjgillot cjgillot closed this as completed Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. 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

4 participants