Skip to content

Commit a36e7c7

Browse files
topecongirocalebcartwright
authored andcommitted
Use correct span for match arms with the leading pipe and attributes (rust-lang#3975)
1 parent c1e9b7b commit a36e7c7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/matches.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl<'a> ArmWrapper<'a> {
4545
impl<'a> Spanned for ArmWrapper<'a> {
4646
fn span(&self) -> Span {
4747
if let Some(lo) = self.beginning_vert {
48+
let lo = std::cmp::min(lo, self.arm.span().lo());
4849
mk_sp(lo, self.arm.span().hi())
4950
} else {
5051
self.arm.span()

tests/target/issue-3974.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn emulate_foreign_item() {
2+
match link_name {
3+
// A comment here will duplicate the attribute
4+
#[rustfmt::skip]
5+
| "pthread_mutexattr_init"
6+
| "pthread_mutexattr_settype"
7+
| "pthread_mutex_init"
8+
=> {}
9+
}
10+
}

0 commit comments

Comments
 (0)