Can anyone explain why? It seems like there is no way to violate any kind of safety just swapping some bytes around. Some of the other intrinsics are only safe to call if a particular feature is supported on the processor, so I understand why those would be unsafe, but that is not the case for bswap.
My default answer was going to be "because it uses target_feature." But it doesn't actually. My guess is that it's an oversight, or more likely, everything in std::arch was assigned an unsafe label in order to be conservative.
I'd say probably submitting a PR to std removing the unsafe would be appropriate.
I think it's because of an expectation that you'd only use it if you're using other unsafe intrinsics anyway, perhaps because you're porting over C code that used said intrinsics.
If you just want to swap bytes in an i32, then you want i32 - Rust which is safe and cross-platform and just as fast.