My pet feature request could do this too. User defined attributes combined with a list of functions called by a function.
=== @custom("mysafe") void foo() {} void bar() {} @custom("mysafe") void main() { foo(); bar(); } CheckCustomSafety!("mysafe", main); template CheckCustomSafety(string attribute, alias func) { static if(!__traits(hasCustomAttribute(func, attribute)) pragma(error, func.stringof ~ " is not " ~ attribute); foreach(f; __traits(getCalledFunctions, func)) CheckCustomSafety!(attribute, f); } ==== And throw in an or for trusted. The reason I want this is to check for things more like custom purity, but I think it'd work for your custom safety too. (and user defined attributes are just useful for other things too!) The biggest problem I see with using my idea is the error message will probably suck.