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

Split elided_lifetime_in_paths into tied and untied #120808

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Commits on Oct 15, 2024

  1. Configuration menu
    Copy the full SHA
    158ecff View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    25ca30f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6089ba2 View commit details
    Browse the repository at this point in the history
  4. Emit elided_lifetime_in_paths higher in the call stack

    This will allow us to be smarter about when the lint is emitted, such
    as only when an output type is involved.
    shepmaster committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    3387b3a View commit details
    Browse the repository at this point in the history
  5. Split elided_lifetime_in_paths into tied and untied

    Types that contain a reference can be confusing when lifetime elision
    occurs:
    
    ```rust
    // Confusing
    fn foo(_: &u8) -> Bar { todo!() }
    
    // Less confusing
    fn foo(_: &u8) -> Bar<'_> { todo!() }
    ```
    
    However, the previous lint did not distinguish when these types were
    not "tying" lifetimes across the function inputs / outputs:
    
    ```rust
    // Maybe a little confusing
    fn foo(_: Bar) {}
    
    // More explicit but noisier with less obvious value
    fn foo(_: Bar<'_>) {}
    ```
    
    We now report different lints for each case, hopefully paving the way
    to marking the first case (when lifetimes are tied together) as
    warn-by-default.
    
    Additionally, when multiple errors occur in the same function during
    the tied case, they are coalesced into one error. There is also some
    help text pointing out where the lifetime source is.
    shepmaster committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    0a10b56 View commit details
    Browse the repository at this point in the history