]> git.lizzy.rs Git - rust.git/commitdiff
Refactor 'kind' extraction to use `str::split_whitespace`.
authorCorey Farwell <coreyf@rwell.org>
Tue, 22 Mar 2016 01:16:07 +0000 (21:16 -0400)
committerCorey Farwell <coreyf@rwell.org>
Tue, 22 Mar 2016 01:16:07 +0000 (21:16 -0400)
src/compiletest/errors.rs

index 0a7784ccc007f7005ea091db605d5ee3826df614..7ad0cd2a95d4bedd8b7966b4f0af52c5cd5bcff8 100644 (file)
@@ -121,12 +121,11 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
         (false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())
     };
     let kind_start = start + tag.len() + adjusts + (follow as usize);
-    let letters = line[kind_start..].chars();
-    let kind = letters.skip_while(|c| c.is_whitespace())
-                      .take_while(|c| !c.is_whitespace())
-                      .collect::<String>()
-                      .parse::<ErrorKind>()
-                      .ok();
+    let kind = line[kind_start..].split_whitespace()
+                                 .next()
+                                 .expect("Encountered unexpected empty comment")
+                                 .parse::<ErrorKind>()
+                                 .ok();
     let letters = line[kind_start..].chars();
     let msg = letters.skip_while(|c| c.is_whitespace())
                      .skip_while(|c| !c.is_whitespace())