Move trait impls for primitives near trait definition

Closes #12925