diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-08-30 10:55:24 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-09-23 18:23:20 -0700 |
| commit | d126be068b0daab3b5abd9b1f365a4c98f2121b7 (patch) | |
| tree | cac9e30553300c5b867e5864e8c289e09e0f0f24 | |
| parent | 6ecbd75843a2187027d09649c9046189d1d4a446 (diff) | |
| download | rust-d126be068b0daab3b5abd9b1f365a4c98f2121b7.tar.gz rust-d126be068b0daab3b5abd9b1f365a4c98f2121b7.zip | |
librustpkg: Fix diagnostic invocation syntax in librustdoc, librusti, and librustpkg.
| -rw-r--r-- | src/librustdoc/core.rs | 13 | ||||
| -rw-r--r-- | src/librusti/rusti.rs | 48 | ||||
| -rw-r--r-- | src/librustpkg/rustpkg.rs | 4 | ||||
| -rw-r--r-- | src/librustpkg/util.rs | 9 |
4 files changed, 51 insertions, 23 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 9fb5e8c04c1..8a7bb1f9346 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -11,9 +11,10 @@ use rustc; use rustc::{driver, middle}; -use syntax; -use syntax::parse; use syntax::ast; +use syntax::diagnostic; +use syntax::parse; +use syntax; use std::os; use std::local_data; @@ -48,9 +49,11 @@ fn get_ast_and_resolve(cpath: &Path, libs: ~[Path]) -> DocContext { let span_diagnostic_handler = syntax::diagnostic::mk_span_handler(diagnostic_handler, parsesess.cm); - let sess = driver::driver::build_session_(sessopts, parsesess.cm, - syntax::diagnostic::emit, - span_diagnostic_handler); + let sess = driver::driver::build_session_(sessopts, + parsesess.cm, + @diagnostic::DefaultEmitter as + @diagnostic::Emitter, + span_diagnostic_handler); let mut cfg = build_configuration(sess); cfg.push(@dummy_spanned(ast::MetaWord(@"stage2"))); diff --git a/src/librusti/rusti.rs b/src/librusti/rusti.rs index 368596b3f44..0d024812c21 100644 --- a/src/librusti/rusti.rs +++ b/src/librusti/rusti.rs @@ -76,8 +76,9 @@ use extra::rl; use rustc::driver::{driver, session}; use rustc::back::link::jit; -use syntax::{ast, diagnostic}; +use syntax::{ast, codemap, diagnostic}; use syntax::ast_util::*; +use syntax::diagnostic::Emitter; use syntax::parse::token; use syntax::print::pprust; @@ -107,6 +108,28 @@ enum CmdAction { action_run_line(~str), } +struct EncodableWarningEmitter; + +impl diagnostic::Emitter for EncodableWarningEmitter { + fn emit(&self, + cm: Option<(@codemap::CodeMap, codemap::Span)>, + msg: &str, + lvl: diagnostic::level) { + diagnostic::DefaultEmitter.emit(cm, msg, lvl); + if msg.contains("failed to find an implementation of trait") && + msg.contains("extra::serialize::Encodable") { + diagnostic::DefaultEmitter.emit(cm, + "Currrently rusti serializes \ + bound locals between different \ + lines of input. This means that \ + all values of local variables \ + need to be encodable, and this \ + type isn't encodable", + diagnostic::note); + } + } +} + /// Run an input string in a Repl, returning the new Repl. fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str], input: ~str) -> (~Program, Option<~jit::Engine>) @@ -124,18 +147,9 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str], // extra helpful information if the error crops up. Otherwise people are // bound to be very confused when they find out code is running that they // never typed in... - let sess = driver::build_session(options, |cm, msg, lvl| { - diagnostic::emit(cm, msg, lvl); - if msg.contains("failed to find an implementation of trait") && - msg.contains("extra::serialize::Encodable") { - diagnostic::emit(cm, - "Currrently rusti serializes bound locals between \ - different lines of input. This means that all \ - values of local variables need to be encodable, \ - and this type isn't encodable", - diagnostic::note); - } - }); + let sess = driver::build_session(options, + @EncodableWarningEmitter as + @diagnostic::Emitter); let intr = token::get_ident_interner(); // @@ -243,7 +257,9 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str], let input = driver::str_input(code.to_managed()); let cfg = driver::build_configuration(sess); let outputs = driver::build_output_filenames(&input, &None, &None, [], sess); - let sess = driver::build_session(options, diagnostic::emit); + let sess = driver::build_session(options, + @diagnostic::DefaultEmitter as + @diagnostic::Emitter); let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input); let expanded_crate = driver::phase_2_configure_and_expand(sess, cfg, crate); @@ -305,7 +321,9 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> { .. (*session::basic_options()).clone() }; let input = driver::file_input(src_path.clone()); - let sess = driver::build_session(options, diagnostic::emit); + let sess = driver::build_session(options, + @diagnostic::DefaultEmitter as + @diagnostic::Emitter); *sess.building_library = true; let cfg = driver::build_configuration(sess); let outputs = driver::build_output_filenames( diff --git a/src/librustpkg/rustpkg.rs b/src/librustpkg/rustpkg.rs index 077d1cf02f8..25d0802b9ad 100644 --- a/src/librustpkg/rustpkg.rs +++ b/src/librustpkg/rustpkg.rs @@ -110,7 +110,9 @@ impl<'self> PkgScript<'self> { .. (*session::basic_options()).clone() }; let input = driver::file_input(script.clone()); - let sess = driver::build_session(options, diagnostic::emit); + let sess = driver::build_session(options, + @diagnostic::DefaultEmitter as + @diagnostic::Emitter); let cfg = driver::build_configuration(sess); let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input); let crate = driver::phase_2_configure_and_expand(sess, cfg.clone(), crate); diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 02524b65020..8c6268e7d23 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -232,7 +232,10 @@ pub fn compile_input(context: &BuildContext, maybe_sysroot: Some(sysroot_to_use), addl_lib_search_paths: @mut (~[]), output_type: output_type, - .. (*driver::build_session_options(binary, &matches, diagnostic::emit)).clone() + .. (*driver::build_session_options(binary, + &matches, + @diagnostic::DefaultEmitter as + @diagnostic::Emitter)).clone() }; let addl_lib_search_paths = @mut options.addl_lib_search_paths; @@ -247,7 +250,9 @@ pub fn compile_input(context: &BuildContext, } } - let sess = driver::build_session(options, diagnostic::emit); + let sess = driver::build_session(options, + @diagnostic::DefaultEmitter as + @diagnostic::Emitter); // Infer dependencies that rustpkg needs to build, by scanning for // `extern mod` directives. |
