To expand a bit, you can write your own macros that only accept literals (playground):
macro_rules! takes_literal {
($foo:literal) => { dbg!($foo); }
}
fn main() {
takes_literal!("foo"); // [src/main.rs:7:5] "foo" = "foo"
let foo = "foo";
takes_literal!(foo); // does not compile
const FOO: &str = "foo";
takes_literal!(FOO); // does not compile either
}
although it's not possible to implement a print-like macro from scratch yourself, as it needs compiler support to parse and validate the format string.