Rustc validation of Ordering values in compare_exchange

When I'm using AtomicBool in std::sync::atomic - Rust, rustc validates the Ordering I'm using. For example, I cannot use Release for the failure parameter.

I've looked at the types, and I don't see any thing generic being used here to validate which Ordering values are being used. Is it something built in ad-hoc in rustc? Or is it a generic validation that I've missed?
Which information is being used to emit a compilation error when Release is being used for example?

It's a lint: rust/compiler/rustc_lint/src/types.rs at 3e353d7353b0cd6fa4eefd5c882457cc2708184c · rust-lang/rust · GitHub

Thanks for the reply. So it's something only rustc can use.

In this case yes.
Though of course you could build your own lint.
e.g. clippy implements a bunch more lints and could be extended with general lints.
And with dylint you can also write your own.