diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index fbc1b9981f5..88d8b5ed640 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -6,6 +6,7 @@ import syntax::ast::{int_ty, uint_ty, float_ty}; import syntax::parse::parse_sess; import util::filesearch; import back::target_strs; +import back::link; import middle::lint; enum os { os_win32, os_macos, os_linux, os_freebsd, } @@ -113,6 +114,34 @@ impl session for session { } } +#[doc = "Some reasonable defaults"] +fn basic_options() -> @options { + @{ + crate_type: session::lib_crate, + static: false, + optimize: 0u, + debuginfo: false, + extra_debuginfo: false, + verify: false, + lint_opts: [], + save_temps: false, + stats: false, + time_passes: false, + count_llvm_insns: false, + time_llvm_passes: false, + output_type: link::output_type_exe, + addl_lib_search_paths: [], + maybe_sysroot: none, + target_triple: driver::host_triple(), + cfg: [], + test: false, + parse_only: false, + no_trans: false, + no_asm_comments: false, + debug_rustc: false, + } +} + // Seems out of place, but it uses session, so I'm putting it here fn expect(sess: session, opt: option, msg: fn() -> str) -> T { alt opt { diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index 71716ea059e..1d3ead93f9a 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -123,34 +123,8 @@ fn build_ctxt(sess: session::session, ast: @ast::crate, } } -// FIXME: this whole structure should not be duplicated here. makes it -// painful to add or remove options. fn build_session() -> (session::session, @mut bool) { - let sopts: @session::options = @{ - crate_type: session::lib_crate, - static: false, - optimize: 0u, - debuginfo: false, - extra_debuginfo: false, - verify: false, - lint_opts: [], - save_temps: false, - stats: false, - time_passes: false, - count_llvm_insns: false, - time_llvm_passes: false, - output_type: link::output_type_exe, - addl_lib_search_paths: [], - maybe_sysroot: none, - target_triple: driver::host_triple(), - cfg: [], - test: false, - parse_only: false, - no_trans: false, - no_asm_comments: false, - debug_rustc: false, - }; - + let sopts: @session::options = session::basic_options(); let codemap = codemap::new_codemap(); let error_handlers = build_error_handlers(codemap); let {emitter, span_handler, ignore_errors} = error_handlers;