Skip to content

Commit c194cce

Browse files
committed
Rollup merge of rust-lang#32171 - frewsxcv:compiletest, r=alexcrichton
Fix a couple compiletest nits.
2 parents 25d253e + 410333b commit c194cce

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/compiletest/errors.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::io::prelude::*;
1515
use std::path::Path;
1616

1717
pub struct ExpectedError {
18-
pub line: usize,
18+
pub line_num: usize,
1919
pub kind: String,
2020
pub msg: String,
2121
}
@@ -53,15 +53,15 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<ExpectedError> {
5353

5454
rdr.lines()
5555
.enumerate()
56-
.filter_map(|(line_no, ln)| {
56+
.filter_map(|(line_num, line)| {
5757
parse_expected(last_nonfollow_error,
58-
line_no + 1,
59-
&ln.unwrap(),
58+
line_num + 1,
59+
&line.unwrap(),
6060
&tag)
6161
.map(|(which, error)| {
6262
match which {
6363
FollowPrevious(_) => {}
64-
_ => last_nonfollow_error = Some(error.line),
64+
_ => last_nonfollow_error = Some(error.line_num),
6565
}
6666
error
6767
})
@@ -91,23 +91,21 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
9191
.skip_while(|c| !c.is_whitespace())
9292
.collect::<String>().trim().to_owned();
9393

94-
let (which, line) = if follow {
94+
let (which, line_num) = if follow {
9595
assert!(adjusts == 0, "use either //~| or //~^, not both.");
96-
let line = last_nonfollow_error.unwrap_or_else(|| {
97-
panic!("encountered //~| without preceding //~^ line.")
98-
});
99-
(FollowPrevious(line), line)
96+
let line_num = last_nonfollow_error.expect("encountered //~| without \
97+
preceding //~^ line.");
98+
(FollowPrevious(line_num), line_num)
10099
} else {
101100
let which =
102101
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
103-
let line = line_num - adjusts;
104-
(which, line)
102+
let line_num = line_num - adjusts;
103+
(which, line_num)
105104
};
106105

107106
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
108107
line_num, tag, which, kind, msg);
109-
110-
Some((which, ExpectedError { line: line,
108+
Some((which, ExpectedError { line_num: line_num,
111109
kind: kind,
112110
msg: msg, }))
113111
}

src/compiletest/runtest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ fn check_expected_errors(revision: Option<&str>,
10041004
}
10051005

10061006
let prefixes = expected_errors.iter().map(|ee| {
1007-
let expected = format!("{}:{}:", testpaths.file.display(), ee.line);
1007+
let expected = format!("{}:{}:", testpaths.file.display(), ee.line_num);
10081008
// On windows just translate all '\' path separators to '/'
10091009
expected.replace(r"\", "/")
10101010
}).collect::<Vec<String>>();
@@ -1076,7 +1076,7 @@ fn check_expected_errors(revision: Option<&str>,
10761076
if !flag {
10771077
let ee = &expected_errors[i];
10781078
error(revision, &format!("expected {} on line {} not found: {}",
1079-
ee.kind, ee.line, ee.msg));
1079+
ee.kind, ee.line_num, ee.msg));
10801080
not_found += 1;
10811081
}
10821082
}

0 commit comments

Comments
 (0)