Remove unnecessary config parameter from format_missing_with_indent.

This commit is contained in:
Pavel Sountsov
2015-09-19 10:44:28 -07:00
committed by SiegeLord
parent 05c8c28935
commit 01bdcd0014
3 changed files with 19 additions and 20 deletions
+3 -4
View File
@@ -26,7 +26,7 @@
impl<'a> FmtVisitor<'a> {
pub fn visit_let(&mut self, local: &ast::Local, span: Span) {
self.format_missing_with_indent(span.lo, self.config);
self.format_missing_with_indent(span.lo);
// String that is placed within the assignment pattern and expression.
let infix = {
@@ -497,8 +497,7 @@ pub fn visit_enum(&mut self,
}
self.block_indent = self.block_indent.block_unindent(self.config);
self.format_missing_with_indent(span.lo + BytePos(enum_snippet.rfind('}').unwrap() as u32),
self.config);
self.format_missing_with_indent(span.lo + BytePos(enum_snippet.rfind('}').unwrap() as u32));
self.buffer.push_str("}");
}
@@ -508,7 +507,7 @@ fn visit_variant(&mut self, field: &ast::Variant, last_field: bool, next_span_st
return;
}
self.format_missing_with_indent(field.span.lo, self.config);
self.format_missing_with_indent(field.span.lo);
let result = match field.node.kind {
ast::VariantKind::TupleVariantKind(ref types) => {
+2 -2
View File
@@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use config::Config;
use visitor::FmtVisitor;
use syntax::codemap::{self, BytePos};
@@ -20,7 +19,8 @@ pub fn format_missing(&mut self, end: BytePos) {
self.format_missing_inner(end, |this, last_snippet, _| this.buffer.push_str(last_snippet))
}
pub fn format_missing_with_indent(&mut self, end: BytePos, config: &Config) {
pub fn format_missing_with_indent(&mut self, end: BytePos) {
let config = self.config;
self.format_missing_inner(end,
|this, last_snippet, snippet| {
this.buffer.push_str(last_snippet.trim_right());
+14 -14
View File
@@ -58,7 +58,7 @@ fn visit_stmt(&mut self, stmt: &'v ast::Stmt) {
}
}
ast::Stmt_::StmtExpr(ref ex, _) | ast::Stmt_::StmtSemi(ref ex, _) => {
self.format_missing_with_indent(stmt.span.lo, self.config);
self.format_missing_with_indent(stmt.span.lo);
let suffix = if let ast::Stmt_::StmtExpr(..) = stmt.node {
""
} else {
@@ -78,7 +78,7 @@ fn visit_stmt(&mut self, stmt: &'v ast::Stmt) {
}
}
ast::Stmt_::StmtMac(ref _mac, _macro_style) => {
self.format_missing_with_indent(stmt.span.lo, self.config);
self.format_missing_with_indent(stmt.span.lo);
visit::walk_stmt(self, stmt);
}
}
@@ -108,7 +108,7 @@ fn visit_block(&mut self, b: &'v ast::Block) {
match b.expr {
Some(ref e) => {
self.format_missing_with_indent(e.span.lo, self.config);
self.format_missing_with_indent(e.span.lo);
self.visit_expr(e);
}
None => {}
@@ -116,7 +116,7 @@ fn visit_block(&mut self, b: &'v ast::Block) {
self.block_indent = self.block_indent.block_unindent(self.config);
// TODO: we should compress any newlines here to just one
self.format_missing_with_indent(b.span.hi - brace_compensation, self.config);
self.format_missing_with_indent(b.span.hi - brace_compensation);
self.buffer.push_str("}");
self.last_pos = b.span.hi;
}
@@ -165,7 +165,7 @@ fn visit_fn(&mut self,
};
if let Some(fn_str) = rewrite {
self.format_missing_with_indent(s.lo, self.config);
self.format_missing_with_indent(s.lo);
self.buffer.push_str(&fn_str);
} else {
self.format_missing(b.span.lo);
@@ -200,26 +200,26 @@ fn visit_item(&mut self, item: &'v ast::Item) {
self.block_indent = self.block_indent.block_unindent(self.config);
}
ast::Item_::ItemExternCrate(_) => {
self.format_missing_with_indent(item.span.lo, self.config);
self.format_missing_with_indent(item.span.lo);
let new_str = self.snippet(item.span);
self.buffer.push_str(&new_str);
self.last_pos = item.span.hi;
}
ast::Item_::ItemStruct(ref def, ref generics) => {
self.format_missing_with_indent(item.span.lo, self.config);
self.format_missing_with_indent(item.span.lo);
self.visit_struct(item.ident, item.vis, def, generics, item.span);
}
ast::Item_::ItemEnum(ref def, ref generics) => {
self.format_missing_with_indent(item.span.lo, self.config);
self.format_missing_with_indent(item.span.lo);
self.visit_enum(item.ident, item.vis, def, generics, item.span);
self.last_pos = item.span.hi;
}
ast::Item_::ItemMod(ref module) => {
self.format_missing_with_indent(item.span.lo, self.config);
self.format_missing_with_indent(item.span.lo);
self.format_mod(module, item.span, item.ident);
}
ast::Item_::ItemMac(..) => {
self.format_missing_with_indent(item.span.lo, self.config);
self.format_missing_with_indent(item.span.lo);
// TODO: we cannot format these yet, because of a bad span.
// See rust lang issue #28424.
// visit::walk_item(self, item);
@@ -236,7 +236,7 @@ fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) {
}
if let ast::TraitItem_::MethodTraitItem(ref sig, None) = ti.node {
self.format_missing_with_indent(ti.span.lo, self.config);
self.format_missing_with_indent(ti.span.lo);
let indent = self.block_indent;
let new_fn = self.rewrite_required_fn(indent, ti.ident, sig, ti.span);
@@ -300,7 +300,7 @@ pub fn visit_attrs(&mut self, attrs: &[ast::Attribute]) -> bool {
}
let first = &attrs[0];
self.format_missing_with_indent(first.span.lo, self.config);
self.format_missing_with_indent(first.span.lo);
if utils::contains_skip(attrs) {
true
@@ -366,12 +366,12 @@ fn format_import(&mut self, vis: ast::Visibility, vp: &ast::ViewPath, span: Span
}
Some(ref s) => {
let s = format!("{}use {};", vis, s);
self.format_missing_with_indent(span.lo, self.config);
self.format_missing_with_indent(span.lo);
self.buffer.push_str(&s);
self.last_pos = span.hi;
}
None => {
self.format_missing_with_indent(span.lo, self.config);
self.format_missing_with_indent(span.lo);
self.format_missing(span.hi);
}
}