With Rust, we help mitigate this by running code examples in API documentation as tests. That doesn't stop people from opting out, and it doesn't solve every problem, but it's still quite useful!
Then it just takes some self-control and gold code reviews to make sure you're writing good documentation rather than just short stubs to silence the error.
It checks for rust snippets in markdown files and attempts to build them when you run `cargo test`. It helps keep docs and code in sync.