Skip to content

Commit 2d13145

Browse files
committed
---
yaml --- r: 277305 b: refs/heads/try c: 01d2b4a h: refs/heads/master i: 277303: c9b6aba
1 parent 5bf1712 commit 2d13145

File tree

102 files changed

+6159
-6856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+6159
-6856
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 66ff163081685aa48bc59033eb5280052963a750
4+
refs/heads/try: 01d2b4ab6bdb33e8678c43612b81dbbbad32cc93
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/configure

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ opt llvm-version-check 1 "check if the LLVM version is supported, build anyway"
609609
opt rustbuild 0 "use the rust and cargo based build system"
610610
opt orbit 0 "get MIR where it belongs - everywhere; most importantly, in orbit"
611611
opt codegen-tests 1 "run the src/test/codegen tests"
612-
opt option-checking 1 "complain about unrecognized options in this configure script"
613612

614613
# Optimization and debugging options. These may be overridden by the release channel, etc.
615614
opt_nosave optimize 1 "build optimized rust code"
@@ -675,11 +674,8 @@ then
675674
fi
676675

677676
# Validate Options
678-
if [ -z "$CFG_DISABLE_OPTION_CHECKING" ]
679-
then
680-
step_msg "validating $CFG_SELF args"
681-
validate_opt
682-
fi
677+
step_msg "validating $CFG_SELF args"
678+
validate_opt
683679

684680
# Validate the release channel, and configure options
685681
case "$CFG_RELEASE_CHANNEL" in

branches/try/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
128128
test rustc_lint rustc_const_eval
129129

130130

131-
TOOL_DEPS_compiletest := test getopts log
131+
TOOL_DEPS_compiletest := test getopts log serialize
132132
TOOL_DEPS_rustdoc := rustdoc
133133
TOOL_DEPS_rustc := rustc_driver
134134
TOOL_DEPS_rustbook := std rustdoc

branches/try/src/compiletest/json.rs

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use errors::{Error, ErrorKind};
12+
use rustc_serialize::json;
13+
use std::str::FromStr;
14+
15+
// These structs are a subset of the ones found in
16+
// `syntax::errors::json`.
17+
18+
#[derive(RustcEncodable, RustcDecodable)]
19+
struct Diagnostic {
20+
message: String,
21+
code: Option<DiagnosticCode>,
22+
level: String,
23+
spans: Vec<DiagnosticSpan>,
24+
children: Vec<Diagnostic>,
25+
rendered: Option<String>,
26+
}
27+
28+
#[derive(RustcEncodable, RustcDecodable, Clone)]
29+
struct DiagnosticSpan {
30+
file_name: String,
31+
line_start: usize,
32+
line_end: usize,
33+
column_start: usize,
34+
column_end: usize,
35+
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
36+
}
37+
38+
#[derive(RustcEncodable, RustcDecodable, Clone)]
39+
struct DiagnosticSpanMacroExpansion {
40+
/// span where macro was applied to generate this code
41+
span: DiagnosticSpan,
42+
43+
/// name of macro that was applied (e.g., "foo!" or "#[derive(Eq)]")
44+
macro_decl_name: String,
45+
}
46+
47+
#[derive(RustcEncodable, RustcDecodable, Clone)]
48+
struct DiagnosticCode {
49+
/// The code itself.
50+
code: String,
51+
/// An explanation for the code.
52+
explanation: Option<String>,
53+
}
54+
55+
pub fn parse_output(file_name: &str, output: &str) -> Vec<Error> {
56+
output.lines()
57+
.flat_map(|line| parse_line(file_name, line))
58+
.collect()
59+
}
60+
61+
fn parse_line(file_name: &str, line: &str) -> Vec<Error> {
62+
// The compiler sometimes intermingles non-JSON stuff into the
63+
// output. This hack just skips over such lines. Yuck.
64+
if line.chars().next() == Some('{') {
65+
match json::decode::<Diagnostic>(line) {
66+
Ok(diagnostic) => {
67+
let mut expected_errors = vec![];
68+
push_expected_errors(&mut expected_errors, &diagnostic, file_name);
69+
expected_errors
70+
}
71+
Err(error) => {
72+
println!("failed to decode compiler output as json: `{}`", error);
73+
panic!("failed to decode compiler output as json");
74+
}
75+
}
76+
} else {
77+
vec![]
78+
}
79+
}
80+
81+
fn push_expected_errors(expected_errors: &mut Vec<Error>,
82+
diagnostic: &Diagnostic,
83+
file_name: &str) {
84+
// We only consider messages pertaining to the current file.
85+
let matching_spans =
86+
|| diagnostic.spans.iter().filter(|span| span.file_name == file_name);
87+
let with_code =
88+
|span: &DiagnosticSpan, text: &str| match diagnostic.code {
89+
Some(ref code) =>
90+
// FIXME(#33000) -- it'd be better to use a dedicated
91+
// UI harness than to include the line/col number like
92+
// this, but some current tests rely on it.
93+
//
94+
// Note: Do NOT include the filename. These can easily
95+
// cause false matches where the expected message
96+
// appears in the filename, and hence the message
97+
// changes but the test still passes.
98+
format!("{}:{}: {}:{}: {} [{}]",
99+
span.line_start, span.column_start,
100+
span.line_end, span.column_end,
101+
text, code.code.clone()),
102+
None =>
103+
// FIXME(#33000) -- it'd be better to use a dedicated UI harness
104+
format!("{}:{}: {}:{}: {}",
105+
span.line_start, span.column_start,
106+
span.line_end, span.column_end,
107+
text),
108+
};
109+
110+
// Convert multi-line messages into multiple expected
111+
// errors. We expect to replace these with something
112+
// more structured shortly anyhow.
113+
let mut message_lines = diagnostic.message.lines();
114+
if let Some(first_line) = message_lines.next() {
115+
for span in matching_spans() {
116+
let msg = with_code(span, first_line);
117+
let kind = ErrorKind::from_str(&diagnostic.level).ok();
118+
expected_errors.push(
119+
Error {
120+
line_num: span.line_start,
121+
kind: kind,
122+
msg: msg,
123+
}
124+
);
125+
}
126+
}
127+
for next_line in message_lines {
128+
for span in matching_spans() {
129+
expected_errors.push(
130+
Error {
131+
line_num: span.line_start,
132+
kind: None,
133+
msg: with_code(span, next_line),
134+
}
135+
);
136+
}
137+
}
138+
139+
// If the message has a suggestion, register that.
140+
if let Some(ref rendered) = diagnostic.rendered {
141+
let start_line = matching_spans().map(|s| s.line_start).min().expect("\
142+
every suggestion should have at least one span");
143+
for (index, line) in rendered.lines().enumerate() {
144+
expected_errors.push(
145+
Error {
146+
line_num: start_line + index,
147+
kind: Some(ErrorKind::Suggestion),
148+
msg: line.to_string()
149+
}
150+
);
151+
}
152+
}
153+
154+
// Add notes for the backtrace
155+
for span in matching_spans() {
156+
for frame in &span.expansion {
157+
push_backtrace(expected_errors,
158+
frame,
159+
file_name);
160+
}
161+
}
162+
163+
// Flatten out the children.
164+
for child in &diagnostic.children {
165+
push_expected_errors(expected_errors, child, file_name);
166+
}
167+
}
168+
169+
fn push_backtrace(expected_errors: &mut Vec<Error>,
170+
expansion: &DiagnosticSpanMacroExpansion,
171+
file_name: &str) {
172+
if expansion.span.file_name == file_name {
173+
expected_errors.push(
174+
Error {
175+
line_num: expansion.span.line_start,
176+
kind: Some(ErrorKind::Note),
177+
msg: format!("in this expansion of {}", expansion.macro_decl_name),
178+
}
179+
);
180+
}
181+
182+
for previous_expansion in &expansion.span.expansion {
183+
push_backtrace(expected_errors, previous_expansion, file_name);
184+
}
185+
}

0 commit comments

Comments
 (0)