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

using 'self in return values doesn't appear to require a 'self parameter #5671

Closed
thestinger opened this issue Apr 1, 2013 · 2 comments
Closed
Assignees
Labels
A-lifetimes Area: Lifetimes / regions

Comments

@thestinger
Copy link
Contributor

as shown by https://github.com/mozilla/rust/pull/5670/files

I was already using 'self in the return values for find and find_mut in the Map trait.

I'm not entirely sure this is a bug.... but it's an inconsistency.

@ghost ghost assigned nikomatsakis Apr 1, 2013
@nikomatsakis
Copy link
Contributor

It's a bug, if a minor one. cc #4846

@graydon
Copy link
Contributor

graydon commented Jun 6, 2013

This testcase:

fn main() { }
struct Foo { x: int }
impl Foo {
    fn bleh(&self) -> &'self int {
        return &self.x
    }
}

Now produces the error:

t.rs:4:29: 4:32 error: Illegal lifetime 'self: the `self` lifetime must be declared
t.rs:4     fn bleh(&self) -> &'self int {
                                    ^~~

And the error goes away if I change the impl to:

impl<'self> Foo {
    fn bleh(&'self self) -> &'self int {
        return &self.x
    }
}

So I'm going to say this is closed. Reopen if I misunderstood.

@graydon graydon closed this as completed Jun 6, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

3 participants