Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple compiletest nits. #32171

Merged
merged 2 commits into from
Mar 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::io::prelude::*;
use std::path::Path;

pub struct ExpectedError {
pub line: usize,
pub line_num: usize,
pub kind: String,
pub msg: String,
}
Expand Down Expand Up @@ -53,15 +53,15 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<ExpectedError> {

rdr.lines()
.enumerate()
.filter_map(|(line_no, ln)| {
.filter_map(|(line_num, line)| {
parse_expected(last_nonfollow_error,
line_no + 1,
&ln.unwrap(),
line_num + 1,
&line.unwrap(),
&tag)
.map(|(which, error)| {
match which {
FollowPrevious(_) => {}
_ => last_nonfollow_error = Some(error.line),
_ => last_nonfollow_error = Some(error.line_num),
}
error
})
Expand Down Expand Up @@ -91,23 +91,21 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
.skip_while(|c| !c.is_whitespace())
.collect::<String>().trim().to_owned();

let (which, line) = if follow {
let (which, line_num) = if follow {
assert!(adjusts == 0, "use either //~| or //~^, not both.");
let line = last_nonfollow_error.unwrap_or_else(|| {
panic!("encountered //~| without preceding //~^ line.")
});
(FollowPrevious(line), line)
let line_num = last_nonfollow_error.expect("encountered //~| without \
preceding //~^ line.");
(FollowPrevious(line_num), line_num)
} else {
let which =
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
let line = line_num - adjusts;
(which, line)
let line_num = line_num - adjusts;
(which, line_num)
};

debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
line_num, tag, which, kind, msg);

Some((which, ExpectedError { line: line,
Some((which, ExpectedError { line_num: line_num,
kind: kind,
msg: msg, }))
}
4 changes: 2 additions & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ fn check_expected_errors(revision: Option<&str>,
}

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