This allows us to keep formatting the macro def with attributes that become
invalid syntax when the `$` is replaced with `z`, e.g. `#[doc = $expr]`.
}
// 1 = `[`
let shape = shape.offset_left(prefix.len() + 1)?;
- self.meta()?
- .rewrite(context, shape)
- .map(|rw| format!("{}[{}]", prefix, rw))
+ Some(
+ self.meta()
+ .and_then(|meta| meta.rewrite(context, shape))
+ .map_or_else(|| snippet.to_owned(), |rw| format!("{}[{}]", prefix, rw)),
+ )
}
}
}
macro_rules! m [
() => ()
];
+
+// #2470
+macro foo($type_name: ident, $docs: expr) {
+ #[allow(non_camel_case_types)]
+ #[doc=$docs]
+ #[derive(Debug, Clone, Copy)]
+ pub struct $type_name;
+}
macro_rules! m [
() => ()
];
+
+// #2470
+macro foo($type_name: ident, $docs: expr) {
+ #[allow(non_camel_case_types)]
+ #[doc=$docs]
+ #[derive(Debug, Clone, Copy)]
+ pub struct $type_name;
+}