Skip to content

Apply clippy fixes#148

Merged
NathanLovato merged 1 commit into
GDQuest:mainfrom
fstxz:clippy-fixes
Oct 11, 2025
Merged

Apply clippy fixes#148
NathanLovato merged 1 commit into
GDQuest:mainfrom
fstxz:clippy-fixes

Conversation

@fstxz

@fstxz fstxz commented Oct 11, 2025

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/reorder.rs
};

if needs_spacing {
#[allow(clippy::if_same_then_else)]

@fstxz fstxz Oct 11, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I silenced this warning, because if we collapse all 3 branches into one, the code becomes way less readable:

if is_function
    || (is_inner_class
        && matches!(
            previous_token_kind,
            Some(TokenKind::Method) | Some(TokenKind::InnerClass),
        ))
{
    output.push_str("\n\n");
} else {
    output.push('\n');
}

About this lint: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else

@NathanLovato NathanLovato merged commit c8ec5d2 into GDQuest:main Oct 11, 2025
1 check passed
@NathanLovato

Copy link
Copy Markdown
Contributor

Thank you! What do you think of the unwraps and other warnings suggested in #145 ? If I got it, turning unwraps into expects is just a way to give explicit error messages?

@fstxz

fstxz commented Oct 11, 2025

Copy link
Copy Markdown
Contributor Author

What do you think of the unwraps and other warnings suggested in #145 ?

I think only unwrap_used lint is worth adding, but I personally never seen a project that has it enabled. Other lints are either related to style, or very minor performance improvements. But if someone else wants to fix these, they can do so. We can always disable them later if they are too annoying.

If I got it, turning unwraps into expects is just a way to give explicit error messages?

Yes, but we can also remove some unwraps completely and handle errors more gracefully.

@fstxz fstxz deleted the clippy-fixes branch October 11, 2025 09:13
@NathanLovato

Copy link
Copy Markdown
Contributor

Thanks, makes sense!

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

Successfully merging this pull request may close these issues.

2 participants