You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In general, there is some inconsistency in attributes in ToLexical-like and FromLexical-like implementations.
For example unsigned ints ToLexial implementations lack #[inline] attributes so they do not inlined across crates, while implementations for signed ints have these attributes.
This problem could probably be considered a bug.
Currently
macro
trait
inline attr
$(#[$meta:meta])?
unsigned_to_lexical
ToLexical
no
yes
unsigned_to_lexical
ToLexicalWithOptions
no
yes
signed_to_lexical
ToLexical
#[inline]
yes
signed_to_lexical
ToLexicalWithOptions
#[inline]
duplicated
float_to_lexical
ToLexical
no
yes
float_to_lexical
ToLexicalWithOptions
no
yes
integer_from_lexical
FromLexical
#[cfg_attr(not(feature = "compact"), inline)]
yes
integer_from_lexical
FromLexicalWithOptions
#[cfg_attr(not(feature = "compact"), inline)]
yes
float_from_lexical
FromLexical
#[cfg_attr(not(feature = "compact"), inline)]
no
float_from_lexical
FromLexicalWithOptions
#[cfg_attr(not(feature = "compact"), inline)]
no
Expected
Either:
Same attributes for all implementations, probably: #[cfg_attr(not(feature = "compact"), inline)].
#[cfg_attr(not(feature = "compact"), inline)] for FromLexical-like and #[inline] for ToLexical-like.
Or the comments with the explanation for the inconsistency between attributes
Additionally
$(#[$meta:meta])? are not longer used. Maybe it is better to remove it as well instead of adding where it is missed?
Example diff
Example with all ToLexical and FromLexical methods using #[cfg_attr(not(feature = "compact"), inline)] and with $(#[$meta:meta])? removed.
This was likely introduced with the formatting API which added like many, many different layers of abstraction that needed to be removed at compilation when not used, causing inconsistency with inlining. Ideally, there should be soft inlining, at best, at API boundaries and only have the inlining internally within the crate.
I submitted a PR @zheland but this is all your work so if you'd like to submit it I'd be more than happy to close mine and accept it. All this lgtm. Thank you for this.
I also checked other pub functions and methods with clippy lint missing_inline_in_public_items and haven't find any other missing inline for publicly visible functions.
Description
In general, there is some inconsistency in attributes in
ToLexical
-like andFromLexical
-like implementations.For example unsigned ints
ToLexial
implementations lack#[inline]
attributes so they do not inlined across crates, while implementations for signed ints have these attributes.This problem could probably be considered a bug.
Currently
$(#[$meta:meta])?
unsigned_to_lexical
ToLexical
unsigned_to_lexical
ToLexicalWithOptions
signed_to_lexical
ToLexical
#[inline]
signed_to_lexical
ToLexicalWithOptions
#[inline]
float_to_lexical
ToLexical
float_to_lexical
ToLexicalWithOptions
integer_from_lexical
FromLexical
#[cfg_attr(not(feature = "compact"), inline)]
integer_from_lexical
FromLexicalWithOptions
#[cfg_attr(not(feature = "compact"), inline)]
float_from_lexical
FromLexical
#[cfg_attr(not(feature = "compact"), inline)]
float_from_lexical
FromLexicalWithOptions
#[cfg_attr(not(feature = "compact"), inline)]
Expected
Either:
#[cfg_attr(not(feature = "compact"), inline)]
.#[cfg_attr(not(feature = "compact"), inline)]
forFromLexical
-like and#[inline]
forToLexical
-like.Additionally
$(#[$meta:meta])?
are not longer used. Maybe it is better to remove it as well instead of adding where it is missed?Example diff
Example with all
ToLexical
andFromLexical
methods using#[cfg_attr(not(feature = "compact"), inline)]
and with$(#[$meta:meta])?
removed.The text was updated successfully, but these errors were encountered: