librustpkg: Fix diagnostic invocation syntax in librustdoc, librusti, and librustpkg.

This commit is contained in:
Patrick Walton 2013-08-30 10:55:24 -07:00
parent 6ecbd75843
commit d126be068b
4 changed files with 51 additions and 23 deletions

View File

@ -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")));

View File

@ -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(

View File

@ -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);

View File

@ -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.