Skip to content

Move trait impls for primitives near trait definition #14464

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

Merged
merged 1 commit into from
May 28, 2014

Conversation

Sawyer47
Copy link
Contributor

This is an attempt of fixing #12925.

This PR moves almost all trait implementations for primitive types ((), bool, char, i_, u_, f*) near trait definitions. Only Float trait implementations weren't moved because they heavily rely on constants defined in f32.rs and f64.rs.

Some trait implementations had cfg(not(test)) attribute. I suspect it's because of issue 2912.
Still, someone who knows the problem better should probably check this code.

Closes #12925

}
)

#[cfg(not(test))] shr_impl!(uint)
Copy link
Member

Choose a reason for hiding this comment

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

The #[cfg(not(test))] annotations may be better placed on the impl itself (inside the macro)

@alexcrichton
Copy link
Member

I think I do like how this has turned out, thank you for tackling this!

@Sawyer47
Copy link
Contributor Author

Thanks for comments, I forgot how awesome Rust's macros are!

)*)
)

totaleq_impl!(() bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
Copy link
Member

Choose a reason for hiding this comment

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

I believe that we specifically don't implement TotalEq for f32 and f64, the rest are fine though.

@Sawyer47
Copy link
Contributor Author

Of course, I'm just really good at making stupid mistakes in code.

bors added a commit that referenced this pull request May 28, 2014
This is an attempt of fixing #12925.

This PR moves almost all trait implementations for primitive types ((), bool, char, i*, u*, f*) near trait definitions. Only Float trait implementations weren't moved because they heavily rely on constants defined in f32.rs and f64.rs.

Some trait implementations had cfg(not(test)) attribute. I suspect it's because of issue 2912.
Still, someone who knows the problem better should probably check this code.

Closes #12925
@bors bors closed this May 28, 2014
@bors bors merged commit dd0d495 into rust-lang:master May 28, 2014
@Sawyer47 Sawyer47 deleted the issue-12925 branch May 31, 2014 16:45
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
lower adjusts in simple index except the last one

fix rust-lang#14463
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.

Put impls of primitives near the traits they implement in std
3 participants