Automatic detection of code that should be optimised away

Currently I am inspecting assembly output to check whether certain asserts have been optimised away by the compiler as expected, I was wondering if there was a neater way to do this, so I get some kind of automated warning when running cargo build. I don't think there is, but maybe I am missing something.

Rust's codegen tests use CHECK: annotations that seem to be from LLVM's tool:

https://llvm.org/docs/CommandGuide/FileCheck.html

I don't know if it's feasible to use that in other projects.