Skip to content

Commit 7ddc610

Browse files
author
Jakub Wieczorek
committed
---
yaml --- r: 123510 b: refs/heads/auto c: 9b9cce2 h: refs/heads/master v: v3
1 parent 735b740 commit 7ddc610

Some content is hidden

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

41 files changed

+537
-265
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: a672456c40d28f051ecbdb2caf5bf6733371d494
16+
refs/heads/auto: 9b9cce2316119a2ffdc9556d410e464b7542d64d
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/compiletest/procsrv.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::os;
1112
use std::str;
1213
use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
1314
use std::dynamic_lib::DynamicLibrary;
1415

15-
fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
16+
fn target_env(lib_path: &str, aux_path: Option<&str>) -> Vec<(String, String)> {
1617
// Need to be sure to put both the lib_path and the aux path in the dylib
1718
// search path for the child.
1819
let mut path = DynamicLibrary::search_path();
@@ -22,11 +23,19 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
2223
}
2324
path.insert(0, Path::new(lib_path));
2425

25-
// Add the new dylib search path var
26+
// Remove the previous dylib search path var
2627
let var = DynamicLibrary::envvar();
28+
let mut env: Vec<(String,String)> = os::env();
29+
match env.iter().position(|&(ref k, _)| k.as_slice() == var) {
30+
Some(i) => { env.remove(i); }
31+
None => {}
32+
}
33+
34+
// Add the new dylib search path var
2735
let newpath = DynamicLibrary::create_path(path.as_slice());
2836
let newpath = str::from_utf8(newpath.as_slice()).unwrap().to_string();
29-
cmd.env(var.to_string(), newpath);
37+
env.push((var.to_string(), newpath));
38+
return env;
3039
}
3140

3241
pub struct Result {pub status: ProcessExit, pub out: String, pub err: String}
@@ -38,14 +47,8 @@ pub fn run(lib_path: &str,
3847
env: Vec<(String, String)> ,
3948
input: Option<String>) -> Option<Result> {
4049

41-
let mut cmd = Command::new(prog);
42-
cmd.args(args);
43-
add_target_env(&mut cmd, lib_path, aux_path);
44-
for (key, val) in env.move_iter() {
45-
cmd.env(key, val);
46-
}
47-
48-
match cmd.spawn() {
50+
let env = env.clone().append(target_env(lib_path, aux_path).as_slice());
51+
match Command::new(prog).args(args).env(env.as_slice()).spawn() {
4952
Ok(mut process) => {
5053
for input in input.iter() {
5154
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
@@ -70,14 +73,8 @@ pub fn run_background(lib_path: &str,
7073
env: Vec<(String, String)> ,
7174
input: Option<String>) -> Option<Process> {
7275

73-
let mut cmd = Command::new(prog);
74-
cmd.args(args);
75-
add_target_env(&mut cmd, lib_path, aux_path);
76-
for (key, val) in env.move_iter() {
77-
cmd.env(key, val);
78-
}
79-
80-
match cmd.spawn() {
76+
let env = env.clone().append(target_env(lib_path, aux_path).as_slice());
77+
match Command::new(prog).args(args).env(env.as_slice()).spawn() {
8178
Ok(mut process) => {
8279
for input in input.iter() {
8380
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();

branches/auto/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
574574
cmd.arg("./src/etc/lldb_batchmode.py")
575575
.arg(test_executable)
576576
.arg(debugger_script)
577-
.env_set_all([("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]);
577+
.env([("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]);
578578

579579
let (status, out, err) = match cmd.spawn() {
580580
Ok(process) => {

branches/auto/src/libcore/num/f32.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
//! Operations and constants for 32-bits floats (`f32` type)
1212
1313
#![doc(primitive = "f32")]
14-
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
15-
#![allow(type_overflow)]
1614

1715
use intrinsics;
1816
use mem;

branches/auto/src/libcore/num/f64.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
//! Operations and constants for 64-bits floats (`f64` type)
1212
1313
#![doc(primitive = "f64")]
14-
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
15-
#![allow(type_overflow)]
1614

1715
use intrinsics;
1816
use mem;

branches/auto/src/libnative/io/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ fn with_argv<T>(prog: &CString, args: &[CString],
729729
}
730730

731731
#[cfg(unix)]
732-
fn with_envp<T>(env: Option<&[(&CString, &CString)]>,
732+
fn with_envp<T>(env: Option<&[(CString, CString)]>,
733733
cb: proc(*const c_void) -> T) -> T {
734734
// On posixy systems we can pass a char** for envp, which is a
735735
// null-terminated array of "k=v\0" strings. Since we must create
@@ -762,7 +762,7 @@ fn with_envp<T>(env: Option<&[(&CString, &CString)]>,
762762
}
763763

764764
#[cfg(windows)]
765-
fn with_envp<T>(env: Option<&[(&CString, &CString)]>, cb: |*mut c_void| -> T) -> T {
765+
fn with_envp<T>(env: Option<&[(CString, CString)]>, cb: |*mut c_void| -> T) -> T {
766766
// On win32 we pass an "environment block" which is not a char**, but
767767
// rather a concatenation of null-terminated k=v\0 sequences, with a final
768768
// \0 to terminate.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014 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+
register_diagnostic!(E0001, r##"
12+
This error suggests that the expression arm corresponding to the noted pattern
13+
will never be reached as for all possible values of the expression being matched,
14+
one of the preceeding patterns will match.
15+
16+
This means that perhaps some of the preceeding patterns are too general, this
17+
one is too specific or the ordering is incorrect.
18+
"##)

branches/auto/src/librustc/driver/config.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
532532
optopt("", "opt-level", "Optimize with possible levels 0-3", "LEVEL"),
533533
optopt( "", "out-dir", "Write output to compiler-chosen filename in <dir>", "DIR"),
534534
optflag("", "parse-only", "Parse only; do not compile, assemble, or link"),
535+
optopt("", "explain", "Provide a detailed explanation of an error message", "OPT"),
535536
optflagopt("", "pretty",
536537
"Pretty-print the input instead of compiling;
537538
valid types are: `normal` (un-annotated source),
@@ -807,6 +808,7 @@ mod test {
807808
use getopts::getopts;
808809
use syntax::attr;
809810
use syntax::attr::AttrMetaMethods;
811+
use syntax::diagnostics;
810812

811813
// When the user supplies --test we should implicitly supply --cfg test
812814
#[test]
@@ -816,8 +818,9 @@ mod test {
816818
Ok(m) => m,
817819
Err(f) => fail!("test_switch_implies_cfg_test: {}", f)
818820
};
821+
let registry = diagnostics::registry::Registry::new([]);
819822
let sessopts = build_session_options(matches);
820-
let sess = build_session(sessopts, None);
823+
let sess = build_session(sessopts, None, registry);
821824
let cfg = build_configuration(&sess);
822825
assert!((attr::contains_name(cfg.as_slice(), "test")));
823826
}
@@ -834,8 +837,9 @@ mod test {
834837
fail!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
835838
}
836839
};
840+
let registry = diagnostics::registry::Registry::new([]);
837841
let sessopts = build_session_options(matches);
838-
let sess = build_session(sessopts, None);
842+
let sess = build_session(sessopts, None, registry);
839843
let cfg = build_configuration(&sess);
840844
let mut test_items = cfg.iter().filter(|m| m.name().equiv(&("test")));
841845
assert!(test_items.next().is_some());

branches/auto/src/librustc/driver/driver.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use driver::{PpmFlowGraph, PpmExpanded, PpmExpandedIdentified, PpmTyped};
1616
use driver::{PpmIdentified};
1717
use front;
1818
use lib::llvm::{ContextRef, ModuleRef};
19+
use lint;
1920
use metadata::common::LinkMeta;
2021
use metadata::creader;
2122
use middle::cfg;
@@ -26,7 +27,7 @@ use middle;
2627
use plugin::load::Plugins;
2728
use plugin::registry::Registry;
2829
use plugin;
29-
use lint;
30+
3031
use util::common::time;
3132
use util::ppaux;
3233
use util::nodemap::{NodeSet};
@@ -41,6 +42,7 @@ use std::io::MemReader;
4142
use syntax::ast;
4243
use syntax::attr;
4344
use syntax::attr::{AttrMetaMethods};
45+
use syntax::diagnostics;
4446
use syntax::parse;
4547
use syntax::parse::token;
4648
use syntax::print::{pp, pprust};
@@ -213,6 +215,15 @@ pub fn phase_2_configure_and_expand(sess: &Session,
213215
let mut registry = Registry::new(&krate);
214216

215217
time(time_passes, "plugin registration", (), |_| {
218+
if sess.features.rustc_diagnostic_macros.get() {
219+
registry.register_macro("__diagnostic_used",
220+
diagnostics::plugin::expand_diagnostic_used);
221+
registry.register_macro("__register_diagnostic",
222+
diagnostics::plugin::expand_register_diagnostic);
223+
registry.register_macro("__build_diagnostic_array",
224+
diagnostics::plugin::expand_build_diagnostic_array);
225+
}
226+
216227
for &registrar in registrars.iter() {
217228
registrar(&mut registry);
218229
}

branches/auto/src/librustc/driver/mod.rs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use std::task::TaskBuilder;
2626
use syntax::ast;
2727
use syntax::parse;
2828
use syntax::diagnostic::Emitter;
29+
use syntax::diagnostics;
2930

3031
use getopts;
3132

@@ -49,8 +50,24 @@ fn run_compiler(args: &[String]) {
4950
Some(matches) => matches,
5051
None => return
5152
};
52-
let sopts = config::build_session_options(&matches);
5353

54+
let descriptions = diagnostics::registry::Registry::new(super::DIAGNOSTICS);
55+
match matches.opt_str("explain") {
56+
Some(ref code) => {
57+
match descriptions.find_description(code.as_slice()) {
58+
Some(ref description) => {
59+
println!("{}", description);
60+
}
61+
None => {
62+
early_error(format!("no extended information for {}", code).as_slice());
63+
}
64+
}
65+
return;
66+
},
67+
None => ()
68+
}
69+
70+
let sopts = config::build_session_options(&matches);
5471
let (input, input_file_path) = match matches.free.len() {
5572
0u => {
5673
if sopts.describe_lints {
@@ -75,7 +92,7 @@ fn run_compiler(args: &[String]) {
7592
_ => early_error("multiple input filenames provided")
7693
};
7794

78-
let sess = build_session(sopts, input_file_path);
95+
let sess = build_session(sopts, input_file_path, descriptions);
7996
let cfg = config::build_configuration(&sess);
8097
let odir = matches.opt_str("out-dir").map(|o| Path::new(o));
8198
let ofile = matches.opt_str("o").map(|o| Path::new(o));
@@ -383,14 +400,14 @@ fn parse_crate_attrs(sess: &Session, input: &Input) ->
383400
}
384401

385402
pub fn early_error(msg: &str) -> ! {
386-
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto);
387-
emitter.emit(None, msg, diagnostic::Fatal);
403+
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
404+
emitter.emit(None, msg, None, diagnostic::Fatal);
388405
fail!(diagnostic::FatalError);
389406
}
390407

391408
pub fn early_warn(msg: &str) {
392-
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto);
393-
emitter.emit(None, msg, diagnostic::Warning);
409+
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
410+
emitter.emit(None, msg, None, diagnostic::Warning);
394411
}
395412

396413
pub fn list_metadata(sess: &Session, path: &Path,
@@ -429,14 +446,15 @@ fn monitor(f: proc():Send) {
429446
Err(value) => {
430447
// Task failed without emitting a fatal diagnostic
431448
if !value.is::<diagnostic::FatalError>() {
432-
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto);
449+
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
433450

434451
// a .span_bug or .bug call has already printed what
435452
// it wants to print.
436453
if !value.is::<diagnostic::ExplicitBug>() {
437454
emitter.emit(
438455
None,
439456
"unexpected failure",
457+
None,
440458
diagnostic::Bug);
441459
}
442460

@@ -447,7 +465,7 @@ fn monitor(f: proc():Send) {
447465
"run with `RUST_BACKTRACE=1` for a backtrace".to_string(),
448466
];
449467
for note in xs.iter() {
450-
emitter.emit(None, note.as_slice(), diagnostic::Note)
468+
emitter.emit(None, note.as_slice(), None, diagnostic::Note)
451469
}
452470

453471
match r.read_to_string() {
@@ -457,6 +475,7 @@ fn monitor(f: proc():Send) {
457475
format!("failed to read internal \
458476
stderr: {}",
459477
e).as_slice(),
478+
None,
460479
diagnostic::Error)
461480
}
462481
}

branches/auto/src/librustc/driver/session.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use util::nodemap::NodeMap;
2020
use syntax::ast::NodeId;
2121
use syntax::codemap::Span;
2222
use syntax::diagnostic;
23+
use syntax::diagnostics;
2324
use syntax::parse;
2425
use syntax::parse::token;
2526
use syntax::parse::ParseSess;
@@ -65,6 +66,9 @@ impl Session {
6566
pub fn span_err(&self, sp: Span, msg: &str) {
6667
self.diagnostic().span_err(sp, msg)
6768
}
69+
pub fn span_err_with_code(&self, sp: Span, msg: &str, code: &str) {
70+
self.diagnostic().span_err_with_code(sp, msg, code)
71+
}
6872
pub fn err(&self, msg: &str) {
6973
self.diagnostic().handler().err(msg)
7074
}
@@ -197,11 +201,12 @@ impl Session {
197201
}
198202

199203
pub fn build_session(sopts: config::Options,
200-
local_crate_source_file: Option<Path>)
204+
local_crate_source_file: Option<Path>,
205+
registry: diagnostics::registry::Registry)
201206
-> Session {
202207
let codemap = codemap::CodeMap::new();
203208
let diagnostic_handler =
204-
diagnostic::default_handler(sopts.color);
209+
diagnostic::default_handler(sopts.color, Some(registry));
205210
let span_diagnostic_handler =
206211
diagnostic::mk_span_handler(diagnostic_handler, codemap);
207212

branches/auto/src/librustc/front/feature_gate.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
6666

6767
("quad_precision_float", Removed),
6868

69+
("rustc_diagnostic_macros", Active),
70+
6971
// A temporary feature gate used to enable parser extensions needed
7072
// to bootstrap fix for #5723.
7173
("issue_5723_bootstrap", Active),
@@ -93,6 +95,7 @@ pub struct Features {
9395
pub default_type_params: Cell<bool>,
9496
pub issue_5723_bootstrap: Cell<bool>,
9597
pub overloaded_calls: Cell<bool>,
98+
pub rustc_diagnostic_macros: Cell<bool>
9699
}
97100

98101
impl Features {
@@ -101,6 +104,7 @@ impl Features {
101104
default_type_params: Cell::new(false),
102105
issue_5723_bootstrap: Cell::new(false),
103106
overloaded_calls: Cell::new(false),
107+
rustc_diagnostic_macros: Cell::new(false)
104108
}
105109
}
106110
}
@@ -425,4 +429,5 @@ pub fn check_crate(sess: &Session, krate: &ast::Crate) {
425429
sess.features.default_type_params.set(cx.has_feature("default_type_params"));
426430
sess.features.issue_5723_bootstrap.set(cx.has_feature("issue_5723_bootstrap"));
427431
sess.features.overloaded_calls.set(cx.has_feature("overloaded_calls"));
432+
sess.features.rustc_diagnostic_macros.set(cx.has_feature("rustc_diagnostic_macros"));
428433
}

0 commit comments

Comments
 (0)