Handle span error with continue
This should be properly addressed by #184, but requires a change to the rustc parser, so this patch just works around the issue.
This commit is contained in:
parent
ae1eec81af
commit
81f2e449d7
4 changed files with 20 additions and 1 deletions
10
src/expr.rs
10
src/expr.rs
|
@ -105,6 +105,16 @@ impl Rewrite for ast::Expr {
|
||||||
ast::Expr_::ExprPath(ref qself, ref path) => {
|
ast::Expr_::ExprPath(ref qself, ref path) => {
|
||||||
rewrite_path(context, qself.as_ref(), path, width, offset)
|
rewrite_path(context, qself.as_ref(), path, width, offset)
|
||||||
}
|
}
|
||||||
|
// FIXME #184 Note that this formatting is broken due to a bad span
|
||||||
|
// from the parser.
|
||||||
|
// `continue`
|
||||||
|
ast::Expr_::ExprAgain(ref opt_ident) => {
|
||||||
|
let id_str = match *opt_ident {
|
||||||
|
Some(ident) => format!(" {}", ident),
|
||||||
|
None => String::new(),
|
||||||
|
};
|
||||||
|
Some(format!("continue{}", id_str))
|
||||||
|
}
|
||||||
_ => context.codemap.span_to_snippet(self.span).ok(),
|
_ => context.codemap.span_to_snippet(self.span).ok(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(str_escape)]
|
#![feature(str_escape)]
|
||||||
#![feature(str_char)]
|
#![feature(str_char)]
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(unused_attributes)]
|
||||||
|
|
||||||
// TODO we're going to allocate a whole bunch of temp Strings, is it worth
|
// TODO we're going to allocate a whole bunch of temp Strings, is it worth
|
||||||
// keeping some scratch mem for this and running our own StrPool?
|
// keeping some scratch mem for this and running our own StrPool?
|
||||||
|
@ -227,6 +228,8 @@ fn fmt_ast(krate: &ast::Crate, codemap: &CodeMap, config: &Config) -> FileMap {
|
||||||
// Formatting done on a char by char or line by line basis.
|
// Formatting done on a char by char or line by line basis.
|
||||||
// TODO warn on bad license
|
// TODO warn on bad license
|
||||||
// TODO other stuff for parity with make tidy
|
// TODO other stuff for parity with make tidy
|
||||||
|
// FIXME skipping due to `continue`, #184.
|
||||||
|
#[rustfmt_skip]
|
||||||
fn fmt_lines(file_map: &mut FileMap, config: &Config) -> FormatReport {
|
fn fmt_lines(file_map: &mut FileMap, config: &Config) -> FormatReport {
|
||||||
let mut truncate_todo = Vec::new();
|
let mut truncate_todo = Vec::new();
|
||||||
let mut report = FormatReport { file_error_map: HashMap::new() };
|
let mut report = FormatReport { file_error_map: HashMap::new() };
|
||||||
|
|
|
@ -21,5 +21,8 @@ let x = loop { do_forever(); };
|
||||||
while let Some(i) = x.find('s')
|
while let Some(i) = x.find('s')
|
||||||
{
|
{
|
||||||
x.update();
|
x.update();
|
||||||
|
// FIXME #184
|
||||||
|
// continue;
|
||||||
|
// continue 'foo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,5 +25,8 @@ fn main() {
|
||||||
|
|
||||||
while let Some(i) = x.find('s') {
|
while let Some(i) = x.find('s') {
|
||||||
x.update();
|
x.update();
|
||||||
|
// FIXME #184
|
||||||
|
// continue;
|
||||||
|
// continue 'foo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue