Reminds me of LLVM's EfficiencySanitizer that will probably land in 3.9: http://lists.llvm.org/pipermail/llvm-dev/2016-April/098355.h...
An example of this is the escape analysis lint in rust-clippy, which can detect if an allocation via Box/Vec/String is unnecessary (though right now it only supports one of those and I need to work on it more) and tell you how to remove it.