diff options
| author | Caleb Cartwright <caleb.cartwright@outlook.com> | 2020-03-27 22:00:00 -0500 |
|---|---|---|
| committer | Caleb Cartwright <caleb.cartwright@outlook.com> | 2020-03-27 22:00:00 -0500 |
| commit | 537d746e08dc7feda17e07a3cf4442837aec0030 (patch) | |
| tree | fb361202df7646d09dc919e619ef02a4a051f80d /src | |
| parent | bea7209d0a7e7cfe713f1dcd1250810348cb528e (diff) | |
fix: use correct ForeignItem span
Diffstat (limited to 'src')
| -rw-r--r-- | src/items.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/items.rs b/src/items.rs index 31c1c193c4b..04bef1cef5f 100644 --- a/src/items.rs +++ b/src/items.rs @@ -298,8 +298,14 @@ impl<'a> FmtVisitor<'a> { fn format_foreign_item(&mut self, item: &ast::ForeignItem) { let rewrite = item.rewrite(&self.get_context(), self.shape()); - self.push_rewrite(item.span, rewrite); - self.last_pos = item.span.hi(); + let hi = item.span.hi(); + let span = if item.attrs.is_empty() { + item.span + } else { + mk_sp(item.attrs[0].span.lo(), hi) + }; + self.push_rewrite(span, rewrite); + self.last_pos = hi; } pub(crate) fn rewrite_fn_before_block( |
