mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 13:13:40 +00:00
Update FmtVisitor::from_codemap()
This commit is contained in:
parent
0928762562
commit
69a15b2eee
@ -629,7 +629,7 @@ pub fn rewrite_block_with_visitor(
|
||||
return rw;
|
||||
}
|
||||
|
||||
let mut visitor = FmtVisitor::from_codemap(context.parse_session, context.config);
|
||||
let mut visitor = FmtVisitor::from_codemap(context.parse_session, context.config, block.span);
|
||||
visitor.block_indent = shape.indent;
|
||||
visitor.is_if_else_block = context.is_if_else_block;
|
||||
match block.rules {
|
||||
|
@ -657,7 +657,8 @@ pub fn format_impl(
|
||||
let open_pos = snippet.find_uncommented("{")? + 1;
|
||||
|
||||
if !items.is_empty() || contains_comment(&snippet[open_pos..]) {
|
||||
let mut visitor = FmtVisitor::from_codemap(context.parse_session, context.config);
|
||||
let mut visitor =
|
||||
FmtVisitor::from_codemap(context.parse_session, context.config, item.span);
|
||||
visitor.block_indent = offset.block_only().block_indent(context.config);
|
||||
visitor.last_pos = item.span.lo() + BytePos(open_pos as u32);
|
||||
|
||||
@ -1055,7 +1056,8 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
|
||||
let open_pos = snippet.find_uncommented("{")? + 1;
|
||||
|
||||
if !trait_items.is_empty() || contains_comment(&snippet[open_pos..]) {
|
||||
let mut visitor = FmtVisitor::from_codemap(context.parse_session, context.config);
|
||||
let mut visitor =
|
||||
FmtVisitor::from_codemap(context.parse_session, context.config, item.span);
|
||||
visitor.block_indent = offset.block_only().block_indent(context.config);
|
||||
visitor.last_pos = item.span.lo() + BytePos(open_pos as u32);
|
||||
|
||||
|
@ -317,7 +317,7 @@ where
|
||||
if config.verbose() {
|
||||
println!("Formatting {}", path_str);
|
||||
}
|
||||
let mut visitor = FmtVisitor::from_codemap(parse_session, config);
|
||||
let mut visitor = FmtVisitor::from_codemap(parse_session, config, module.inner);
|
||||
let filemap = visitor.codemap.lookup_char_pos(module.inner.lo()).file;
|
||||
// Format inner attributes if available.
|
||||
if !krate.attrs.is_empty() && path == main_file {
|
||||
|
@ -530,7 +530,11 @@ impl<'a> FmtVisitor<'a> {
|
||||
self.last_pos = source!(self, span).hi();
|
||||
}
|
||||
|
||||
pub fn from_codemap(parse_session: &'a ParseSess, config: &'a Config) -> FmtVisitor<'a> {
|
||||
pub fn from_codemap(
|
||||
parse_session: &'a ParseSess,
|
||||
config: &'a Config,
|
||||
span: Span,
|
||||
) -> FmtVisitor<'a> {
|
||||
FmtVisitor {
|
||||
parse_session: parse_session,
|
||||
codemap: parse_session.codemap(),
|
||||
|
Loading…
Reference in New Issue
Block a user