]> git.lizzy.rs Git - rust.git/blobdiff - src/matches.rs
Use correct span for match arms with the leading pipe and attributes (#3975)
[rust.git] / src / matches.rs
index 5f2d9d9e85ef6fe22710a125322827044fe3a38b..b5ca49b38bca846f5309183335c49347cc185554 100644 (file)
@@ -2,8 +2,8 @@
 
 use std::iter::repeat;
 
+use rustc_ast::{ast, ptr};
 use rustc_span::{BytePos, Span};
-use syntax::{ast, ptr};
 
 use crate::comment::{combine_strs_with_missing_comments, rewrite_comment};
 use crate::config::lists::*;
@@ -45,6 +45,7 @@ fn new(arm: &'a ast::Arm, is_last: bool, beginning_vert: Option<BytePos>) -> Arm
 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()