Skip to content

Improve clippy linting situation - #65

Closed
GnomedDev wants to merge 3 commits into
mozilla:mainfrom
GnomedDev:clippy
Closed

GnomedDev wants to merge 3 commits into
mozilla:mainfrom
GnomedDev:clippy

Conversation

@GnomedDev

@GnomedDev GnomedDev commented Oct 10, 2024

Copy link
Copy Markdown
Contributor

Currently some warn-by-default lints fire in the tests, this PR fixes up the existing warnings, then adds pedantic and some nursery lints in for good luck.

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs

@hkBst hkBst left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM except for a few minor things.

@nicoburns

Copy link
Copy Markdown
Collaborator

As noted in #60, I can compile thin-vec with Rust 1.53 today. Until such time as we have a proper MSRV policy (with key consumers consulted) I'm going to try to keep compatibility to 1.53.

@GnomedDev
GnomedDev force-pushed the clippy branch 2 times, most recently from 152d35e to 7e7f407 Compare August 25, 2025 11:42
@GnomedDev

Copy link
Copy Markdown
Contributor Author

@nicoburns Sorted out the MSRV, the CI failures, and hkBst's comments.

Comment thread src/lib.rs
Comment on lines -311 to +316
_len: SizeType,
_cap: SizeType,
len: SizeType,
cap: SizeType,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Given that this crate is designed to support FFI with an equivalent vectors type in Gecko's C++ code, I think we may need to keep the field names as they were. It's probably possible to change them here with an change to Gecko's bindgen code, but also probably not worth the bother?

Can we just ignore this lint?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to do this, the names are already different in Gecko.

Comment thread src/lib.rs
Comment on lines -408 to +422
final_size as usize
final_size
.try_into()
.expect("cannot allocate object larger than isize")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use of try_into for these casts seems like it could cause a perf regression? Which seems a bit unnecessary given that we can be confident that they will always succeed.

Do you have a motivation for changing them other than that the lint says to?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah I'd leave these casts as they are.

Comment thread src/lib.rs
Comment on lines -311 to +316
_len: SizeType,
_cap: SizeType,
len: SizeType,
cap: SizeType,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to do this, the names are already different in Gecko.

Comment thread src/lib.rs
Comment on lines -408 to +422
final_size as usize
final_size
.try_into()
.expect("cannot allocate object larger than isize")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah I'd leave these casts as they are.

Comment thread src/lib.rs
/// ```
pub fn dedup(&mut self) {
self.dedup_by(|a, b| a == b)
self.dedup_by(|a, b| a == b);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These changes also feel pretty random.

@emilio

emilio commented Aug 25, 2025

Copy link
Copy Markdown
Collaborator

Would be good to split this PR (or the commits at least) in formatting changes, then style changes (which shouldn't have perf impact) then others.

@GnomedDev

Copy link
Copy Markdown
Contributor Author

Okay, I don't have the free time for now to work on that. Anyone is free to take up the mantle either from scratch or based on this PR.

@GnomedDev GnomedDev closed this Sep 8, 2025
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.

4 participants