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:
Nick Cameron 2015-08-16 16:43:59 +12:00
parent ae1eec81af
commit 81f2e449d7
4 changed files with 20 additions and 1 deletions

View File

@ -105,6 +105,16 @@ impl Rewrite for ast::Expr {
ast::Expr_::ExprPath(ref qself, ref path) => {
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(),
}
}

View File

@ -11,7 +11,8 @@
#![feature(rustc_private)]
#![feature(str_escape)]
#![feature(str_char)]
#![feature(custom_attribute)]
#![allow(unused_attributes)]
// 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?
@ -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.
// TODO warn on bad license
// 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 {
let mut truncate_todo = Vec::new();
let mut report = FormatReport { file_error_map: HashMap::new() };

View File

@ -21,5 +21,8 @@ let x = loop { do_forever(); };
while let Some(i) = x.find('s')
{
x.update();
// FIXME #184
// continue;
// continue 'foo;
}
}

View File

@ -25,5 +25,8 @@ fn main() {
while let Some(i) = x.find('s') {
x.update();
// FIXME #184
// continue;
// continue 'foo;
}
}