Skip to content

add lint infallible_try_from #14813

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ComputerDruid
Copy link

@ComputerDruid ComputerDruid commented May 15, 2025

Looks for TryFrom implementations with uninhabited error types and suggests to implement From instead.

Fixes #2144


changelog: Added [infallible_try_from] to nursery

@rustbot
Copy link
Collaborator

rustbot commented May 15, 2025

r? @blyxyas

rustbot has assigned @blyxyas.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 15, 2025
@rustbot

This comment has been minimized.

@ComputerDruid
Copy link
Author

r? @llogiq

Written at the workshop during RustWeek

@rustbot rustbot assigned llogiq and unassigned blyxyas May 15, 2025
Looks for `TryFrom` implementations with uninhabited error types and
suggests to implement `From` instead.
@ComputerDruid ComputerDruid force-pushed the infallible_try_from branch from d4eee17 to 5c0bd96 Compare May 15, 2025 11:27
}
for ii in imp.items {
if ii.kind == AssocItemKind::Type {
let ii_id = ii.id;
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit: We should either inline that variable (because the compiler will unify the access anyway) or use it everywhere (like one line below this).

@llogiq
Copy link
Contributor

llogiq commented May 16, 2025

This is a good start. The code is still failing dogfood, where clippy lints itself. Looking at the suggestions, you should change the "default lint description" in the lint definition block, and use a sym instead of comparing idents with strs in line 55. Apart from that, I have only a very small nit. Once that's dealt with, I'll start the Final Comment Period for adding this lint.

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.

Lint TryFrom with infalliable error type
4 participants