Check length of break and continue expressions
This commit is contained in:
parent
847bad603e
commit
d98e22c971
@ -137,14 +137,14 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
|
||||
Some(ident) => format!(" {}", ident.node),
|
||||
None => String::new(),
|
||||
};
|
||||
Some(format!("continue{}", id_str))
|
||||
wrap_str(format!("continue{}", id_str), context.config.max_width, width, offset)
|
||||
}
|
||||
ast::ExprKind::Break(ref opt_ident) => {
|
||||
let id_str = match *opt_ident {
|
||||
Some(ident) => format!(" {}", ident.node),
|
||||
None => String::new(),
|
||||
};
|
||||
Some(format!("break{}", id_str))
|
||||
wrap_str(format!("break{}", id_str), context.config.max_width, width, offset)
|
||||
}
|
||||
ast::ExprKind::Closure(capture, ref fn_decl, ref body) => {
|
||||
rewrite_closure(capture, fn_decl, body, self.span, context, width, offset)
|
||||
|
20
tests/source/issue-855.rs
Normal file
20
tests/source/issue-855.rs
Normal file
@ -0,0 +1,20 @@
|
||||
fn main() {
|
||||
'running: loop {
|
||||
for event in event_pump.poll_iter() {
|
||||
match event {
|
||||
Event::Quit {..} | Event::KeyDown { keycode: Some(Keycode::Escape), .. } => break 'running,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main2() {
|
||||
'running: loop {
|
||||
for event in event_pump.poll_iter() {
|
||||
match event {
|
||||
Event::Quit {..} |
|
||||
Event::KeyDownXXXXXXXXXXXXX { keycode: Some(Keycode::Escape), .. } => break 'running,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
tests/target/issue-855.rs
Normal file
23
tests/target/issue-855.rs
Normal file
@ -0,0 +1,23 @@
|
||||
fn main() {
|
||||
'running: loop {
|
||||
for event in event_pump.poll_iter() {
|
||||
match event {
|
||||
Event::Quit { .. } |
|
||||
Event::KeyDown { keycode: Some(Keycode::Escape), .. } => break 'running,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main2() {
|
||||
'running: loop {
|
||||
for event in event_pump.poll_iter() {
|
||||
match event {
|
||||
Event::Quit { .. } |
|
||||
Event::KeyDownXXXXXXXXXXXXX { keycode: Some(Keycode::Escape), .. } => {
|
||||
break 'running
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user