error: local ambiguity when calling macro test_p: multiple parsing options: built-in NTs expr ('e3') or 1 other option.
However, if change the punctuator # to any one of ~, @, :, ?, then it will be compiled. IIUC, no token sequence that has the form #identifier can compose a valid expression, which should have the same reason as @identifier to make the code compile. Why does the # not work here?
To add to @quinedot's comment: I don't believe the macro_rules processor looks ahead more than one token when trying to resolve these sorts of branches. So, because #could start an expression, it assumes it's ambiguous. Putting extra tokens after it that "disqualifies" that part of the input from being an expression doesn't help, because the processor has to have already made its decision before it even sees them.
I'm not sure whether the macro-invocation considers a token sequence to be an expression if the sequence is a valid expression in the macro-invocation context or if it just considers whether it can be an expression as long as it is permitted in some contexts.