summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-06 16:25:41 +0800
committerkennytm <kennytm@gmail.com>2018-03-06 20:52:32 +0800
commitb691c521bb079dda26b9d37d00662fafeb87f783 (patch)
tree5c297b7f1da341d4169d92835b6c548a7c304083
parent7dc3f17ef999940a4337a5ea5823acb5c3da65e4 (diff)
parent2e7e68b76223b9f14b54852584a5334f33a8798d (diff)
downloadrust-b691c521bb079dda26b9d37d00662fafeb87f783.tar.gz
Rollup merge of #48754 - leodasvacas:while-let-all-the-things, r=rkruppe
while let all the things
-rw-r--r--src/librustc/hir/print.rs9
-rw-r--r--src/librustc/middle/reachable.rs6
-rw-r--r--src/librustc_data_structures/obligation_forest/mod.rs8
-rw-r--r--src/libstd/sys_common/wtf8.rs23
-rw-r--r--src/libsyntax_ext/format.rs17
-rw-r--r--src/libsyntax_pos/lib.rs7
6 files changed, 20 insertions, 50 deletions
diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs
index ed8cea3eb65..d91aa3a3851 100644
--- a/src/librustc/hir/print.rs
+++ b/src/librustc/hir/print.rs
@@ -2208,13 +2208,8 @@ impl<'a> State<'a> {
if self.next_comment().is_none() {
self.s.hardbreak()?;
}
- loop {
- match self.next_comment() {
- Some(ref cmnt) => {
- self.print_comment(cmnt)?;
- }
- _ => break,
- }
+ while let Some(ref cmnt) = self.next_comment() {
+ self.print_comment(cmnt)?
}
Ok(())
}
diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs
index 749685182a8..5658b5b6832 100644
--- a/src/librustc/middle/reachable.rs
+++ b/src/librustc/middle/reachable.rs
@@ -206,11 +206,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// Step 2: Mark all symbols that the symbols on the worklist touch.
fn propagate(&mut self) {
let mut scanned = FxHashSet();
- loop {
- let search_item = match self.worklist.pop() {
- Some(item) => item,
- None => break,
- };
+ while let Some(search_item) = self.worklist.pop() {
if !scanned.insert(search_item) {
continue
}
diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs
index 02cae52166a..42a17d33fa6 100644
--- a/src/librustc_data_structures/obligation_forest/mod.rs
+++ b/src/librustc_data_structures/obligation_forest/mod.rs
@@ -415,13 +415,7 @@ impl<O: ForestObligation> ObligationForest<O> {
}
}
- loop {
- // non-standard `while let` to bypass #6393
- let i = match error_stack.pop() {
- Some(i) => i,
- None => break
- };
-
+ while let Some(i) = error_stack.pop() {
let node = &self.nodes[i];
match node.state.get() {
diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs
index 46d554d6411..9fff8b91f96 100644
--- a/src/libstd/sys_common/wtf8.rs
+++ b/src/libstd/sys_common/wtf8.rs
@@ -428,20 +428,15 @@ impl fmt::Debug for Wtf8 {
formatter.write_str("\"")?;
let mut pos = 0;
- loop {
- match self.next_surrogate(pos) {
- None => break,
- Some((surrogate_pos, surrogate)) => {
- write_str_escaped(
- formatter,
- unsafe { str::from_utf8_unchecked(
- &self.bytes[pos .. surrogate_pos]
- )},
- )?;
- write!(formatter, "\\u{{{:x}}}", surrogate)?;
- pos = surrogate_pos + 3;
- }
- }
+ while let Some((surrogate_pos, surrogate)) = self.next_surrogate(pos) {
+ write_str_escaped(
+ formatter,
+ unsafe { str::from_utf8_unchecked(
+ &self.bytes[pos .. surrogate_pos]
+ )},
+ )?;
+ write!(formatter, "\\u{{{:x}}}", surrogate)?;
+ pos = surrogate_pos + 3;
}
write_str_escaped(
formatter,
diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs
index a7822414c69..8fd95aa1ca8 100644
--- a/src/libsyntax_ext/format.rs
+++ b/src/libsyntax_ext/format.rs
@@ -732,18 +732,13 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
let mut parser = parse::Parser::new(fmt_str);
let mut pieces = vec![];
- loop {
- match parser.next() {
- Some(mut piece) => {
- if !parser.errors.is_empty() {
- break;
- }
- cx.verify_piece(&piece);
- cx.resolve_name_inplace(&mut piece);
- pieces.push(piece);
- }
- None => break,
+ while let Some(mut piece) = parser.next() {
+ if !parser.errors.is_empty() {
+ break;
}
+ cx.verify_piece(&piece);
+ cx.resolve_name_inplace(&mut piece);
+ pieces.push(piece);
}
let numbered_position_args = pieces.iter().any(|arg: &parse::Piece| {
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index 9f746adbe65..ed9eb5d5c92 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -322,12 +322,7 @@ impl Span {
pub fn macro_backtrace(mut self) -> Vec<MacroBacktrace> {
let mut prev_span = DUMMY_SP;
let mut result = vec![];
- loop {
- let info = match self.ctxt().outer().expn_info() {
- Some(info) => info,
- None => break,
- };
-
+ while let Some(info) = self.ctxt().outer().expn_info() {
let (pre, post) = match info.callee.format {
ExpnFormat::MacroAttribute(..) => ("#[", "]"),
ExpnFormat::MacroBang(..) => ("", "!"),