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

[feature request] Auto-fix for extra_unused_lifetimes #13612

Open
hamirmahal opened this issue Oct 27, 2024 · 1 comment
Open

[feature request] Auto-fix for extra_unused_lifetimes #13612

hamirmahal opened this issue Oct 27, 2024 · 1 comment

Comments

@hamirmahal
Copy link
Contributor

Description

extra_unused_lifetimes doesn't have an auto-fix for the unused lifetimes it flags, but it'd be nice if it did.

fn unused_lt<'a>(x: u8) {}

could become

fn unused_lt<>(x: u8) {}

which I've seen my editor change to

fn unused_lt(x: u8) {}

on save.


I've thought about widening the range of the lint so it changes

fn unused_lt<'a>(x: u8) {}

to

fn unused_lt(x: u8) {}

but that could become messy in the case with

fn unused_lt<'a, 'b, 'c, 'd>(x: u8) {}

so I think it's fine to just have the auto-fix remove the unused lifetime and have a formatter remove any stray <>.

Edge Case

I've looked into this, and there's an edge case with

trait _Foo {
    fn hey();
}
impl<'a, T: ?Sized> _Foo for &mut T {
    fn hey() {}
}

since just removing 'a' results in

trait _Foo {
    fn hey();
}
impl<, T: ?Sized> _Foo for &mut T {
    fn hey() {}
}

and an error.

Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

@rustbot label +

@rustbot
Copy link
Collaborator

rustbot commented Oct 27, 2024

Error: Label can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants