4 ms·
> unsafe, of course, [] disables a lot of the checks that the compiler makes. This is, of course, not true. It allows only two things: (1) allow access through
by puffoflogic 4y ago
> unsafe, of course, [] disables a lot of the checks that the compiler makes.
This is, of course, not true. It allows only two things: (1) allow access through pointers and union fields (2) allow calling unsafe or external functions.
Neither of these is really a "check", more like "some operation that just isn't present in safe rust and is present in unsafe rust". They aren't conditionally allowed in safe rust; they just aren't allowed.
In particular unsafe does not alter the operation of borrowck by one jot.
- steveklabnik 4y agoWhen I’m back at my computer I’m going to reply in thread, ha. It’s very strange to see something you’ve written being presented as authoritatively saying something you didn’t say! (And it’s more than those two things, but you’re still right in general that unsafe adds, it does not remove.)
- puffoflogic 4y agoI'm trying to think what "more" is. I guess I missed inline asm, although I'd probably lump it in with "external function". Static mut, technically, but I don't really consider those part of the current rust language; a historical accident which should be read as `UnsafeCell`. Therefore I'm going to lump that in with unsafe functions too, albeit an invisible one. ETA: I found your lwn comment. I forgot entirely about unsafe traits and I would say those are entirely different from my two categories. So, three things.