oxidecomputer/typify

References to serde are only _mostly_ fully-qualified

Closed this issue · 2 comments

In #634 we started mostly-fully-qualified references to serde.

I say "mostly" because a fully qualified path needs leading ::, or it can refer to a local mod serde;. Yes, a program containing a local module named serde is arguably perverse -- but as the macro, we don't get to decide.

A fully-qualified reference would be: ::serde::Serialize.

ahl commented

We should do this for derive uses as well as for the explicit implementations of Deserialize

I don't really understand the typify derive code, but a pattern that might be useful here: re-exports.

The most reliably hygenic way to reference a crate like this would be to:

  1. Depend on the crate from the crate that provides the macro
  2. Re-export it as, say, #[doc(hidden)] pub use serde;
  3. Reference it from generated code as $crate::serde::Serialize

(There are certain proc-macro cases where this pattern becomes more involved, just to warn you.)