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

feat: Add "Bind unused parameter" assist #15524

Merged
merged 5 commits into from Sep 8, 2023
Merged

Conversation

vsrs
Copy link
Contributor

@vsrs vsrs commented Aug 28, 2023

This PR introduces a new Bind unused parameter assistant.

While we do have a QuickFix from rustc (prefixing the parameter with an underscore), it's sometimes more convenient to suppress the warning using the following approach:

 fn some_function(unused: i32) {}

->

fn some_function(unused: i32) {
    let _ = unused;
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 28, 2023
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have this as a diagnostic quickfix oncew e have a diagnostic for unused vars

crates/ide-assists/src/handlers/bind_unused_param.rs Outdated Show resolved Hide resolved
crates/ide-assists/src/handlers/bind_unused_param.rs Outdated Show resolved Hide resolved
@vsrs
Copy link
Contributor Author

vsrs commented Aug 29, 2023

Would be nice to have this as a diagnostic quickfix oncew e have a diagnostic for unused vars

remove_unused_param assist from

AssistId("remove_unused_param", AssistKind::Refactor),
has AssistKind::Refactor kind; I belive it's worth to have the same (or change both to QuickFix)

@Veykril
Copy link
Member

Veykril commented Aug 29, 2023

Yes, that one I'd say should also ideally be a diagnostic quickfix, but that's a different issue not relevant to this right now

@vsrs
Copy link
Contributor Author

vsrs commented Aug 29, 2023

Just realized that this assist is different from 'remove_unused_param' one and can work for trait impl methods too. So, rollbacked all refactorings in remove_unused_param code.

@Veykril
Copy link
Member

Veykril commented Sep 8, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 8, 2023

📌 Commit 1eb6d2e has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Sep 8, 2023

⌛ Testing commit 1eb6d2e with merge 829e777...

@bors
Copy link
Collaborator

bors commented Sep 8, 2023

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 829e777 to master...

@bors bors merged commit 829e777 into rust-lang:master Sep 8, 2023
10 checks passed
@bors bors mentioned this pull request Sep 8, 2023
@vsrs vsrs deleted the bind_unused_param branch September 9, 2023 01:55
@lnicola lnicola changed the title Bind unused parameter assistant feat: Add "Bind unused parameter" assist Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants