mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
Format source codes
This commit is contained in:
parent
789abf063d
commit
10c3632078
16
src/expr.rs
16
src/expr.rs
@ -968,13 +968,15 @@ impl<'a> Rewrite for ControlFlow<'a> {
|
||||
};
|
||||
|
||||
// for event in event
|
||||
let between_kwd_cond = mk_sp(context.codemap.span_after(self.span, self.keyword.trim()),
|
||||
self.pat
|
||||
.map_or(cond_span.lo, |p| if self.matcher.is_empty() {
|
||||
p.span.lo
|
||||
} else {
|
||||
context.codemap.span_before(self.span, self.matcher.trim())
|
||||
}));
|
||||
let between_kwd_cond = mk_sp(
|
||||
context.codemap.span_after(self.span, self.keyword.trim()),
|
||||
self.pat
|
||||
.map_or(cond_span.lo, |p| if self.matcher.is_empty() {
|
||||
p.span.lo
|
||||
} else {
|
||||
context.codemap.span_before(self.span, self.matcher.trim())
|
||||
}),
|
||||
);
|
||||
|
||||
let between_kwd_cond_comment = extract_comment(between_kwd_cond, context, shape);
|
||||
|
||||
|
28
src/lib.rs
28
src/lib.rs
@ -610,22 +610,24 @@ pub fn format_input<T: Write>(input: Input,
|
||||
|
||||
let mut report = FormatReport::new();
|
||||
|
||||
match format_ast(&krate,
|
||||
&parse_session,
|
||||
&main_file,
|
||||
config,
|
||||
|file_name, file| {
|
||||
// For some reason, the codemap does not include terminating
|
||||
// newlines so we must add one on for each file. This is sad.
|
||||
filemap::append_newline(file);
|
||||
match format_ast(
|
||||
&krate,
|
||||
&parse_session,
|
||||
&main_file,
|
||||
config,
|
||||
|file_name, file| {
|
||||
// For some reason, the codemap does not include terminating
|
||||
// newlines so we must add one on for each file. This is sad.
|
||||
filemap::append_newline(file);
|
||||
|
||||
format_lines(file, file_name, config, &mut report);
|
||||
format_lines(file, file_name, config, &mut report);
|
||||
|
||||
if let Some(ref mut out) = out {
|
||||
return filemap::write_file(file, file_name, out, config);
|
||||
if let Some(ref mut out) = out {
|
||||
return filemap::write_file(file, file_name, out, config);
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
Ok(false)
|
||||
}) {
|
||||
) {
|
||||
Ok((file_map, has_diff)) => {
|
||||
if report.has_warnings() {
|
||||
summary.add_formatting_error();
|
||||
|
@ -205,10 +205,10 @@ pub fn rewrite_macro(mac: &ast::Mac,
|
||||
context
|
||||
.codemap
|
||||
.span_after(mac.span, original_style.opener()),
|
||||
mac.span.hi - BytePos(1)
|
||||
mac.span.hi - BytePos(1),
|
||||
),
|
||||
context,
|
||||
mac_shape
|
||||
mac_shape,
|
||||
));
|
||||
|
||||
Some(format!("{}{}", macro_name, rewrite))
|
||||
|
Loading…
Reference in New Issue
Block a user