Skip to content

Commit

Permalink
Use correct span for match arms with the leading pipe and attributes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro authored and calebcartwright committed Jun 27, 2020
1 parent c1e9b7b commit a36e7c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/matches.rs
Expand Up @@ -45,6 +45,7 @@ impl<'a> ArmWrapper<'a> {
impl<'a> Spanned for ArmWrapper<'a> {
fn span(&self) -> Span {
if let Some(lo) = self.beginning_vert {
let lo = std::cmp::min(lo, self.arm.span().lo());
mk_sp(lo, self.arm.span().hi())
} else {
self.arm.span()
Expand Down
10 changes: 10 additions & 0 deletions tests/target/issue-3974.rs
@@ -0,0 +1,10 @@
fn emulate_foreign_item() {
match link_name {
// A comment here will duplicate the attribute
#[rustfmt::skip]
| "pthread_mutexattr_init"
| "pthread_mutexattr_settype"
| "pthread_mutex_init"
=> {}
}
}

0 comments on commit a36e7c7

Please sign in to comment.