7 ms·
I don't think that's really true, let's suppose that your unsafe code has a presupposition that cause an UB if not met. If this is a bug and you can remove the
by renox 7y ago
I don't think that's really true, let's suppose that your unsafe code has a presupposition that cause an UB if not met.
If this is a bug and you can remove the presupposition, great, but is-it always possible without performance issue?
If not, then you have to audit all the usage of the unsafe part.
- masklinn 7y ago> I don't think that's really true It is though. > let's suppose that your unsafe code has a presupposition that cause an UB if not met. If this is a bug It is, or the code should not present as being safe. > but is-it always possible without performance issue? If not, then you have to audit all the usage of the unsafe part. If it's not possible to fix it (or if you don't want to fix it) then the wrapper for that unsafe code should also be unsafe, and it should document its assumptions such that callers can know what to look for. The tautological contract is that safe rust is safe. If it's possible to trigger UB by passing the "wrong" value to a rust function then that function is not safe and must be marked as unsafe itself. An unsafe block means the compiler trusts that you know what you're doing, which is different from lying to the compiler, which is what you're apparently advocating / defending.