Use correct span for match arms with the leading pipe and attributes (#3975)

This commit is contained in:
Seiichi Uchida 2019-12-22 00:31:59 +09:00 committed by Caleb Cartwright
parent c1e9b7b874
commit a36e7c7981
2 changed files with 11 additions and 0 deletions

View File

@ -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()

View File

@ -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"
=> {}
}
}