Merge pull request #2471 from topecongiro/issue-2470
Return the original snippet if the attribute contains invalid syntax
This commit is contained in:
commit
b060f6473e
@ -813,9 +813,11 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
|
||||
}
|
||||
// 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)),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,3 +77,11 @@ macro_rules! m (
|
||||
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;
|
||||
}
|
||||
|
@ -68,3 +68,11 @@ macro_rules! m (
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user