Skip to content

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

Closed

Description

@thestinger

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.

Activity

  1. nikomatsakis commented on Apr 2, 2013

    @nikomatsakis
    Contributor

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

  2. graydon commented on Jun 6, 2013

    @graydon
    Contributor

    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.

  3. added a commit that references this issue on Jun 5, 2020
  4. added 2 commits that reference this issue on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-lifetimes

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions