Skip to content

Commit ac0c2fb

Browse files
committed
Merge pull request #20808 from Manishearth/span_fix
Fix checking of command line expansion spans Reviewed-by: alexcrichton
2 parents c0ca57a + 4a7b710 commit ac0c2fb

File tree

4 files changed

+8
-24
lines changed

4 files changed

+8
-24
lines changed

src/compiletest/header.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ pub struct TestProps {
4242
pub pretty_compare_only: bool,
4343
// Patterns which must not appear in the output of a cfail test.
4444
pub forbid_output: Vec<String>,
45-
// Ignore errors which originate from a command line span
46-
pub ignore_command_line: bool,
4745
}
4846

4947
// Load any test directives embedded in the file
@@ -62,8 +60,6 @@ pub fn load_props(testfile: &Path) -> TestProps {
6260
let mut pretty_mode = None;
6361
let mut pretty_compare_only = false;
6462
let mut forbid_output = Vec::new();
65-
let mut ignore_command_line = false;
66-
6763
iter_header(testfile, |ln| {
6864
match parse_error_pattern(ln) {
6965
Some(ep) => error_patterns.push(ep),
@@ -106,10 +102,6 @@ pub fn load_props(testfile: &Path) -> TestProps {
106102
pretty_compare_only = parse_pretty_compare_only(ln);
107103
}
108104

109-
if !ignore_command_line {
110-
ignore_command_line = parse_ignore_command_line(ln);
111-
}
112-
113105
match parse_aux_build(ln) {
114106
Some(ab) => { aux_builds.push(ab); }
115107
None => {}
@@ -148,7 +140,6 @@ pub fn load_props(testfile: &Path) -> TestProps {
148140
pretty_mode: pretty_mode.unwrap_or("normal".to_string()),
149141
pretty_compare_only: pretty_compare_only,
150142
forbid_output: forbid_output,
151-
ignore_command_line: ignore_command_line,
152143
}
153144
}
154145

@@ -300,10 +291,6 @@ fn parse_pretty_compare_only(line: &str) -> bool {
300291
parse_name_directive(line, "pretty-compare-only")
301292
}
302293

303-
fn parse_ignore_command_line(line: &str) -> bool {
304-
parse_name_directive(line, "ignore-command-line")
305-
}
306-
307294
fn parse_exec_env(line: &str) -> Option<(String, String)> {
308295
parse_name_value_directive(line, "exec-env").map(|nv| {
309296
// nv is either FOO or FOO=BAR

src/compiletest/runtest.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
104104
if !props.error_patterns.is_empty() {
105105
fatal("both error pattern and expected errors specified");
106106
}
107-
check_expected_errors(props, expected_errors, testfile, &proc_res);
107+
check_expected_errors(expected_errors, testfile, &proc_res);
108108
} else {
109109
check_error_patterns(props, testfile, output_to_check.as_slice(), &proc_res);
110110
}
@@ -941,8 +941,7 @@ fn check_forbid_output(props: &TestProps,
941941
}
942942
}
943943

944-
fn check_expected_errors(props: &TestProps,
945-
expected_errors: Vec<errors::ExpectedError> ,
944+
fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
946945
testfile: &Path,
947946
proc_res: &ProcRes) {
948947

@@ -997,11 +996,6 @@ fn check_expected_errors(props: &TestProps,
997996
was_expected = true;
998997
}
999998

1000-
if line.starts_with("<command line option>") &&
1001-
props.ignore_command_line {
1002-
was_expected = true;
1003-
}
1004-
1005999
if !was_expected && is_compiler_error_or_warning(line) {
10061000
fatal_proc_rec(format!("unexpected compiler error or warning: '{}'",
10071001
line).as_slice(),

src/libsyntax/diagnostic.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub use self::RenderSpan::*;
1313
pub use self::ColorConfig::*;
1414
use self::Destination::*;
1515

16-
use codemap::{COMMAND_LINE_SP, Pos, Span};
16+
use codemap::{COMMAND_LINE_SP, COMMAND_LINE_EXPN, Pos, Span};
1717
use codemap;
1818
use diagnostics;
1919

@@ -393,7 +393,10 @@ impl Emitter for EmitterWriter {
393393
fn emit(dst: &mut EmitterWriter, cm: &codemap::CodeMap, rsp: RenderSpan,
394394
msg: &str, code: Option<&str>, lvl: Level, custom: bool) -> io::IoResult<()> {
395395
let sp = rsp.span();
396-
let ss = if sp == COMMAND_LINE_SP {
396+
397+
// We cannot check equality directly with COMMAND_LINE_SP
398+
// since PartialEq is manually implemented to ignore the ExpnId
399+
let ss = if sp.expn_id == COMMAND_LINE_EXPN {
397400
"<command line option>".to_string()
398401
} else {
399402
cm.span_to_string(sp)

src/test/compile-fail/recursion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-command-line: See https://github.com/rust-lang/rust/issues/20747
11+
//~^^^^^^^^^^ ERROR overflow
1212
//
1313
// We also get a second error message at the top of file (dummy
1414
// span). This is not helpful, but also kind of annoying to prevent,

0 commit comments

Comments
 (0)