-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Context
Attribute macros replace the item they were attached to. This is not the same behaviour you get with derive macros: in that case, the decorated item is left untouched, no matter what the macro expands to.
Issue
Let's consider a simple route definition:
#[pavex::get]
pub fn my_route() -> pavex::Response {
// [...]
}#[pavex::get] will emit an error, since no path argument was provided.
Since it didn't expand successfully, no code will be emitted. As a consequence, there will be no definition for my_route in the crate that gets compiled by cargo.
Every single reference to my_route anywhere else in the codebase (e.g. in a unit test) will trigger an "undefined item" error from rustc.
Desired behaviour
Pavex attribute macros should always re-emit the item they were attached to in case of error, thus reducing noise for the end-user.
Otherwise, our own error gets lost in the flood of artificial issues that ended up causing by "swallowing" the item definition.