Skip to content

function lifetime elision changed in 1.64 #103330

Closed
@QuineDot

Description

@QuineDot

I tried this code:

fn foo<'a>(_: &'a str, _: &'a str) -> &str { "" }

I expected to see this happen:

error[E0106]: missing lifetime specifier
 --> <source>:1:39
  |
1 | fn foo<'a>(_: &'a str, _: &'a str) -> &str { "" }
  |               -------     -------     ^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2
help: consider using the `'a` lifetime
  |
1 | fn foo<'a>(_: &'a str, _: &'a str) -> &'a str { "" }
  |                                       ~~~

error: aborting due to previous error

Instead, this happened: Successful compilation

Meta

Tested on the playground, all versions and editions.

  • Stable channel: 1.64.0
  • Beta channel: 1.65.0-beta.3 (2022-10-10 da7ffa2)
  • Nightly channel: 1.66.0-nightly (2022-10-19 4b8f431)

Notes

I'm labeling this as a regression as I believe it is severe enough of an unplanned change (at best an accidental stabilization?) that I should draw attention to it, even though I haven't found a way to cause miscompilation for example. I also have not tried to do so at all yet.

@rustbot label +T-compiler +A-lifetimes +regression-from-stable-to-stable

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions