Merge pull request #1888 from topecongiro/no-panic-against-invalid-attr
Do not panic against files with invalid attributes
This commit is contained in:
commit
c166004e6d
@ -684,18 +684,13 @@ pub fn visit_attrs(&mut self, attrs: &[ast::Attribute], style: ast::AttrStyle) -
|
||||
return false;
|
||||
}
|
||||
|
||||
let first = &attrs[0];
|
||||
self.format_missing_with_indent(source!(self, first.span).lo);
|
||||
let rewrite = attrs.rewrite(
|
||||
&self.get_context(),
|
||||
Shape::indented(self.block_indent, self.config),
|
||||
);
|
||||
let span = mk_sp(attrs[0].span.lo, attrs[attrs.len() - 1].span.hi);
|
||||
self.push_rewrite(span, rewrite);
|
||||
|
||||
let rewrite = attrs
|
||||
.rewrite(
|
||||
&self.get_context(),
|
||||
Shape::indented(self.block_indent, self.config),
|
||||
)
|
||||
.unwrap();
|
||||
self.buffer.push_str(&rewrite);
|
||||
let last = attrs.last().unwrap();
|
||||
self.last_pos = source!(self, last.span).hi;
|
||||
false
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test attributes and doc comments are preserved.
|
||||
|
||||
#[invalid attribute]
|
||||
fn foo() {}
|
||||
|
||||
/// Blah blah blah.
|
||||
/// Blah blah blah.
|
||||
/// Blah blah blah.
|
||||
|
@ -1,6 +1,9 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test attributes and doc comments are preserved.
|
||||
|
||||
#[invalid attribute]
|
||||
fn foo() {}
|
||||
|
||||
/// Blah blah blah.
|
||||
/// Blah blah blah.
|
||||
/// Blah blah blah.
|
||||
|
Loading…
Reference in New Issue
Block a user