httparse icon indicating copy to clipboard operation
httparse copied to clipboard

simd: reduce pub functions visibility

Open lucab opened this issue 1 year ago • 4 comments

This tweaks all SIMD pub functions, moving them to pub(crate) instead.

Refs:

  • https://github.com/seanmonstar/httparse/pull/175#issuecomment-2323411076
  • https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unreachable-pub

lucab avatar Sep 02 '24 10:09 lucab

What's the broader rationale ?

Wouldn't this "violate" redundant_pub_crate ?

AaronO avatar Sep 02 '24 11:09 AaronO

FWIW, I am not convinced by the description at the clippy lint at all.

Why is this bad?

Writing pub(crate) is misleading when it’s redundant due to the parent module’s visibility.

There's nothing misleading about it. It doesn't cause any harm.

seanmonstar avatar Sep 02 '24 13:09 seanmonstar

There's nothing misleading about it. It doesn't cause any harm.

You could say it doesn't "harm", but in this instance it doesn't solve or address anything either ... (I'd consider it if it served some clear ulterior motive, but at face value seems like a pointless change)

I'd argue it's somewhat a responsibility leak... Do we care about inner interface visibility much or predominantly the one exposed by lib.rs ? mod simd; already covers this, it's redundant IMO.

AaronO avatar Sep 02 '24 14:09 AaronO

Apologies, I should've added some breadcrumbs upfront; I've update the PR description with some refs now.

I think this rustc builtin lint description describes it better than what I could do with my own words. Unfortunately it is not enforced by default due to historical reasons (pub(_) did not exist until 1.18). I personally did this locally to lower the cognitive load, not having to check for possible API breakages in the middle of other refactors.

I can't speak for the clippy lint, however I did notice that it is in nursery (it has been demoted there 4 years ago) and with a bunch of open issues and people voicing for its removal.

lucab avatar Sep 02 '24 14:09 lucab