I agree unsafe is still unsafe, but perhaps I can better clarify the overall framework of my proposal.
Modeled as an access control decision, and looking at it a bit through a more traditional OCap lens, there is an access control decision involving three different “principals”, or perhaps more precisely in cargo terminology (at least in the context of my proposal) “packages”. I’ll call them A, B, and C:
-
A: the parent package attempting to consume two different dependent packages: the first (B) as a direct dependency, and the second (C) as a transitive dependency
-
B: a direct dependency of package A
-
C: a transitive dependency of package B exporting unsafe behavior
My proposal attempts to attenuate/minimize package B's ability to vicariously/transitively call functions with “interior unsafety” in package C.
Another way of describing this concept is package A wishes to delegate the authority to make use of certain unsafe features of C to package B. However, because they’re tied to cargo features, each usage of unsafe is “tagged” and tied to a particular cargo feature.
B itself would not contain unsafe and could even be #![forbid(unsafe_code)], but instead of being able to call any function in C which makes use of unsafe, its visibility of C (at least in the context of “interior unsafety”) would be scoped to the explicitly whitelisted features in C which A has delegated it the authority to call.
It’s true within the scope of C, when it makes use of unsafe, it has unbounded authority. However, the idea is to catalogue and whitelist these usages, so changes to them are visible.
It’s worth noting delegation is tricky to get right, and often a bit counterintuitive because most access control systems implement delegation poorly. Here’s one of my favorite papers on the matter:
http://waterken.sourceforge.net/aclsdont/current.pdf