Skip to content

Commit 410333b

Browse files
committed
Differentiate "line" and "line number" variable names.
1 parent e1048b5 commit 410333b

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/compiletest/errors.rs

+12-13
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,22 +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.expect("encountered //~| without \
97-
preceding //~^ line.");
98-
(FollowPrevious(line), line)
96+
let line_num = last_nonfollow_error.expect("encountered //~| without \
97+
preceding //~^ line.");
98+
(FollowPrevious(line_num), line_num)
9999
} else {
100100
let which =
101101
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
102-
let line = line_num - adjusts;
103-
(which, line)
102+
let line_num = line_num - adjusts;
103+
(which, line_num)
104104
};
105105

106106
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
107107
line_num, tag, which, kind, msg);
108-
109-
Some((which, ExpectedError { line: line,
108+
Some((which, ExpectedError { line_num: line_num,
110109
kind: kind,
111110
msg: msg, }))
112111
}

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)