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

type parameter bounds can't use already defined lifetimes #5715

Closed
doy opened this issue Apr 4, 2013 · 1 comment
Closed

type parameter bounds can't use already defined lifetimes #5715

doy opened this issue Apr 4, 2013 · 1 comment

Comments

@doy
Copy link
Contributor

doy commented Apr 4, 2013

trait Base<'self,A> {
    fn foo(&self, blk: &fn(v: &'self A));
}

struct Bar<A> {
    a: A,
}

impl<'self,A> Base<'self,A> for Bar<A> {
    fn foo(&self, blk: &fn(v: &'self A)) {
        blk(&self.a);
    }
}

fn bar<'r,A,IA:Base<'r,A>>(b: &'r Bar<A>, blk: &fn(&'r A)) {
    b.foo(blk);
}
test3.rs:15:22: 15:23 error: Illegal lifetime 'r: only 'static is allowed here
test3.rs:15 fn bar<'r,A,IA:Base<'r,A>>(b: &'r Bar<A>, blk: &fn(&'r A)) {
                                  ^
error: aborting due to previous error

Seems like this should work, since without the lifetimes involved, fn bar<A,IA:Base<A>>(...) works fine - the earlier type declaration of A makes it possible to use A as a parameter in the type bound.

@nikomatsakis
Copy link
Contributor

dup of #5121

flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 28, 2020
Add unnecessary lazy evaluation lint

changelog: Add [`unnecessary_lazy_evaluations`] lint that checks for usages of `unwrap_or_else` and similar functions that can be simplified.

Closes rust-lang#5715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants