Skip to content

Commit 73f4321

Browse files
committed
Refactor 'kind' extraction to use str::split_whitespace.
1 parent 985cddf commit 73f4321

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/compiletest/errors.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
121121
(false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())
122122
};
123123
let kind_start = start + tag.len() + adjusts + (follow as usize);
124-
let letters = line[kind_start..].chars();
125-
let kind = letters.skip_while(|c| c.is_whitespace())
126-
.take_while(|c| !c.is_whitespace())
127-
.collect::<String>()
128-
.parse::<ErrorKind>()
129-
.ok();
124+
let kind = line[kind_start..].split_whitespace()
125+
.next()
126+
.expect("Encountered unexpected empty comment")
127+
.parse::<ErrorKind>()
128+
.ok();
130129
let letters = line[kind_start..].chars();
131130
let msg = letters.skip_while(|c| c.is_whitespace())
132131
.skip_while(|c| !c.is_whitespace())

0 commit comments

Comments
 (0)