Fixup warnings and test formatting
This commit is contained in:
parent
6e5c6f5ba3
commit
39a91ba292
4 changed files with 20 additions and 14 deletions
11
src/expr.rs
11
src/expr.rs
|
|
@ -1198,11 +1198,11 @@ impl<'a> ControlFlow<'a> {
|
|||
|
||||
// `for event in event`
|
||||
// Do not include label in the span.
|
||||
let lo = self.label.map_or(self.span.lo, |label| label.span.hi);
|
||||
let lo = self.label.map_or(self.span.lo(), |label| label.span.hi());
|
||||
let between_kwd_cond = mk_sp(
|
||||
context
|
||||
.codemap
|
||||
.span_after(mk_sp(lo, self.span.hi), self.keyword.trim()),
|
||||
.span_after(mk_sp(lo, self.span.hi()), self.keyword.trim()),
|
||||
self.pat
|
||||
.map_or(cond_span.lo(), |p| if self.matcher.is_empty() {
|
||||
p.span.lo()
|
||||
|
|
@ -1611,11 +1611,14 @@ fn rewrite_match_arm(
|
|||
));
|
||||
}
|
||||
(
|
||||
mk_sp(arm.attrs[arm.attrs.len() - 1].span.hi(), arm.pats[0].span.lo()),
|
||||
mk_sp(
|
||||
arm.attrs[arm.attrs.len() - 1].span.hi(),
|
||||
arm.pats[0].span.lo(),
|
||||
),
|
||||
try_opt!(arm.attrs.rewrite(context, shape)),
|
||||
)
|
||||
} else {
|
||||
(mk_sp(arm.span().lo, arm.span().lo), String::new())
|
||||
(mk_sp(arm.span().lo(), arm.span().lo()), String::new())
|
||||
};
|
||||
let pats_str = try_opt!(
|
||||
rewrite_match_pattern(context, &arm.pats, &arm.guard, shape).and_then(|pats_str| {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,10 @@ impl Rewrite for ast::Local {
|
|||
context,
|
||||
&attrs_str,
|
||||
"let ",
|
||||
mk_sp(self.attrs.last().map(|a| a.span.hi).unwrap(), self.span.lo),
|
||||
mk_sp(
|
||||
self.attrs.last().map(|a| a.span.hi()).unwrap(),
|
||||
self.span.lo(),
|
||||
),
|
||||
shape,
|
||||
false,
|
||||
))
|
||||
|
|
@ -556,7 +559,7 @@ pub fn format_impl(
|
|||
if generics.where_clause.predicates.is_empty() {
|
||||
if let Some(hi) = where_span_end {
|
||||
match recover_missing_comment_in_span(
|
||||
mk_sp(self_ty.span.hi, hi),
|
||||
mk_sp(self_ty.span.hi(), hi),
|
||||
Shape::indented(offset, context.config),
|
||||
context,
|
||||
last_line_width(&result),
|
||||
|
|
@ -965,7 +968,7 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
|
|||
if let Some(lo) = item_snippet.chars().position(|c| c == '/') {
|
||||
// 1 = `{`
|
||||
let comment_hi = body_lo - BytePos(1);
|
||||
let comment_lo = item.span.lo + BytePos(lo as u32);
|
||||
let comment_lo = item.span.lo() + BytePos(lo as u32);
|
||||
if comment_lo < comment_hi {
|
||||
match recover_missing_comment_in_span(
|
||||
mk_sp(comment_lo, comment_hi),
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ implement_spanned!(ast::Local);
|
|||
impl Spanned for ast::Stmt {
|
||||
fn span(&self) -> Span {
|
||||
match self.node {
|
||||
ast::StmtKind::Local(ref local) => mk_sp(local.span().lo, self.span.hi),
|
||||
ast::StmtKind::Item(ref item) => mk_sp(item.span().lo, self.span.hi),
|
||||
ast::StmtKind::Local(ref local) => mk_sp(local.span().lo(), self.span.hi()),
|
||||
ast::StmtKind::Item(ref item) => mk_sp(item.span().lo(), self.span.hi()),
|
||||
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => {
|
||||
mk_sp(expr.span().lo(), self.span.hi())
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ impl Spanned for ast::Stmt {
|
|||
if attrs.is_empty() {
|
||||
self.span
|
||||
} else {
|
||||
mk_sp(attrs[0].span.lo, self.span.hi)
|
||||
mk_sp(attrs[0].span.lo(), self.span.hi())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ impl<'a> FmtVisitor<'a> {
|
|||
|
||||
let mut unindent_comment = self.is_if_else_block && !b.stmts.is_empty();
|
||||
if unindent_comment {
|
||||
let end_pos = source!(self, b.span).hi - brace_compensation - remove_len;
|
||||
let end_pos = source!(self, b.span).hi() - brace_compensation - remove_len;
|
||||
let snippet = self.snippet(mk_sp(self.last_pos, end_pos));
|
||||
unindent_comment = snippet.contains("//") || snippet.contains("/*");
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ impl<'a> FmtVisitor<'a> {
|
|||
self.format_import(&item.vis, vp, item.span, &item.attrs);
|
||||
}
|
||||
ast::ItemKind::Impl(..) => {
|
||||
self.format_missing_with_indent(source!(self, item.span).lo);
|
||||
self.format_missing_with_indent(source!(self, item.span).lo());
|
||||
let snippet = self.snippet(item.span);
|
||||
let where_span_end = snippet
|
||||
.find_uncommented("{")
|
||||
|
|
@ -667,7 +667,7 @@ impl<'a> FmtVisitor<'a> {
|
|||
}
|
||||
|
||||
let rewrite = attrs.rewrite(&self.get_context(), self.shape());
|
||||
let span = mk_sp(attrs[0].span.lo, attrs[attrs.len() - 1].span.hi);
|
||||
let span = mk_sp(attrs[0].span.lo(), attrs[attrs.len() - 1].span.hi());
|
||||
self.push_rewrite(span, rewrite);
|
||||
|
||||
false
|
||||
|
|
@ -943,7 +943,7 @@ impl<'a> Rewrite for [ast::Attribute] {
|
|||
};
|
||||
|
||||
let comment = try_opt!(recover_missing_comment_in_span(
|
||||
mk_sp(self[i - 1].span.hi, a.span.lo),
|
||||
mk_sp(self[i - 1].span.hi(), a.span.lo()),
|
||||
shape.with_max_width(context.config),
|
||||
context,
|
||||
0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue