But it can be easy to make a typo while specifying backend name. Ideally, the code would emit a compilation error for an unknown configuration flag value, but I couldn't find a way to specify a catch-all for #[cfg(foo_backend = ???)]. Am I missing something or Rust simply does not have a way to specify this?
Oh, I thought you meant making a typo in the code. Yeah, there's nothing you can do about that. You would need to add a value that users should specify instead of leaving it blank, so that you can use the else for errors.
The idea is that the configuration flag is used to overwrite default behavior, so raising compilation error in the default branch is not acceptable. (And we don't need const panic for this, since we already have the compile_error! macro.)