Skip to content

Format error in suggestion for needless_lifetimes #12789

Open
@rodrigorc

Description

@rodrigorc

Summary

The suggested fix for this clippy warning makes no sense.

Reproducer

I tried this code:

pub trait Foo {
    fn test<'s>(&'s self) -> impl Iterator<Item = i32> + 's;
}

I expected to see this happen:

-     fn test<'s>(&'s self) -> impl Iterator<Item = i32> + 's;
+     fn test(&self) -> impl Iterator<Item = i32> + '_;

Instead, this happened:

-     fn test<'s>(&'s self) -> impl Iterator<Item = i32> + 's;
+     fn test'_>(&self) -> impl Iterator<Item = i32> + 's;

That isn't syntactically valid.

There may be some interaction with the 2024 edition feature "RPIT lifetime capture"?

Version

rustc 1.79.0-beta.2 (4bf9354b9 2024-05-02)
binary: rustc
commit-hash: 4bf9354b9e6f07fc6dd881a2d313be0f63cdb8cb
commit-date: 2024-05-02
host: x86_64-unknown-linux-gnu
release: 1.79.0-beta.2
LLVM version: 18.1.4

Additional Labels

No response

Metadata

Metadata

Labels

C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions