diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index e69e6215ba14b..2281aca7a624e 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -11,8 +11,6 @@ //! Contains infrastructure for configuring the compiler, including parsing //! command line options. -pub use self::DebugInfoLevel::*; - use std::str::FromStr; use session::{early_error, early_warn, Session}; @@ -110,10 +108,10 @@ impl CrossLangLto { } #[derive(Clone, Copy, PartialEq, Hash)] -pub enum DebugInfoLevel { - NoDebugInfo, - LimitedDebugInfo, - FullDebugInfo, +pub enum DebugInfo { + None, + Limited, + Full, } #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, RustcEncodable, RustcDecodable)] @@ -378,7 +376,7 @@ top_level_options!( // Include the debug_assertions flag into dependency tracking, since it // can influence whether overflow checks are done or not. debug_assertions: bool [TRACKED], - debuginfo: DebugInfoLevel [TRACKED], + debuginfo: DebugInfo [TRACKED], lint_opts: Vec<(String, lint::Level)> [TRACKED], lint_cap: Option [TRACKED], describe_lints: bool [UNTRACKED], @@ -603,7 +601,7 @@ pub fn basic_options() -> Options { Options { crate_types: Vec::new(), optimize: OptLevel::No, - debuginfo: NoDebugInfo, + debuginfo: DebugInfo::None, lint_opts: Vec::new(), lint_cap: None, describe_lints: false, @@ -2080,12 +2078,12 @@ pub fn build_session_options_and_crate_config( if cg.debuginfo.is_some() { early_error(error_format, "-g and -C debuginfo both provided"); } - FullDebugInfo + DebugInfo::Full } else { match cg.debuginfo { - None | Some(0) => NoDebugInfo, - Some(1) => LimitedDebugInfo, - Some(2) => FullDebugInfo, + None | Some(0) => DebugInfo::None, + Some(1) => DebugInfo::Limited, + Some(2) => DebugInfo::Full, Some(arg) => { early_error( error_format, @@ -2184,7 +2182,7 @@ pub fn build_session_options_and_crate_config( Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)), }; - if !cg.remark.is_empty() && debuginfo == NoDebugInfo { + if !cg.remark.is_empty() && debuginfo == DebugInfo::None { early_warn( error_format, "-C remark will not show source locations without \ @@ -2391,7 +2389,7 @@ mod dep_tracking { use std::hash::Hash; use std::path::PathBuf; use std::collections::hash_map::DefaultHasher; - use super::{CrateType, DebugInfoLevel, ErrorOutputType, Lto, OptLevel, OutputTypes, + use super::{CrateType, DebugInfo, ErrorOutputType, Lto, OptLevel, OutputTypes, Passes, Sanitizer, CrossLangLto}; use syntax::feature_gate::UnstableFeatures; use rustc_target::spec::{PanicStrategy, RelroLevel, TargetTriple}; @@ -2448,7 +2446,7 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(Passes); impl_dep_tracking_hash_via_hash!(OptLevel); impl_dep_tracking_hash_via_hash!(Lto); - impl_dep_tracking_hash_via_hash!(DebugInfoLevel); + impl_dep_tracking_hash_via_hash!(DebugInfo); impl_dep_tracking_hash_via_hash!(UnstableFeatures); impl_dep_tracking_hash_via_hash!(OutputTypes); impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind); diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index 7cd2deabdeb7c..108734b67d3b8 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -17,7 +17,7 @@ use super::command::Command; use super::rpath::RPathConfig; use super::rpath; use metadata::METADATA_FILENAME; -use rustc::session::config::{self, NoDebugInfo, OutputFilenames, OutputType, PrintRequest}; +use rustc::session::config::{self, DebugInfo, OutputFilenames, OutputType, PrintRequest}; use rustc::session::config::{RUST_CGU_EXT, Lto}; use rustc::session::filesearch; use rustc::session::search_paths::PathKind; @@ -200,7 +200,7 @@ pub(crate) fn link_binary(sess: &Session, /// split-dwarf like schemes. fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool { // If the objects don't have debuginfo there's nothing to preserve. - if sess.opts.debuginfo == NoDebugInfo { + if sess.opts.debuginfo == DebugInfo::None { return false } @@ -834,7 +834,7 @@ fn link_natively(sess: &Session, // the symbols. Note, though, that if the object files are being preserved // for their debug information there's no need for us to run dsymutil. if sess.target.target.options.is_like_osx && - sess.opts.debuginfo != NoDebugInfo && + sess.opts.debuginfo != DebugInfo::None && !preserve_objects_for_their_debuginfo(sess) { match Command::new("dsymutil").arg(out_filename).output() { diff --git a/src/librustc_codegen_llvm/back/linker.rs b/src/librustc_codegen_llvm/back/linker.rs index 0383539e7c475..e0a30ef5dbc9a 100644 --- a/src/librustc_codegen_llvm/back/linker.rs +++ b/src/librustc_codegen_llvm/back/linker.rs @@ -21,7 +21,7 @@ use back::symbol_export; use rustc::hir::def_id::{LOCAL_CRATE, CrateNum}; use rustc::middle::dependency_format::Linkage; use rustc::session::Session; -use rustc::session::config::{self, CrateType, OptLevel, DebugInfoLevel, +use rustc::session::config::{self, CrateType, OptLevel, DebugInfo, CrossLangLto}; use rustc::ty::TyCtxt; use rustc_target::spec::{LinkerFlavor, LldFlavor}; @@ -338,7 +338,7 @@ impl<'a> Linker for GccLinker<'a> { fn debuginfo(&mut self) { match self.sess.opts.debuginfo { - DebugInfoLevel::NoDebugInfo => { + DebugInfo::None => { // If we are building without debuginfo enabled and we were called with // `-Zstrip-debuginfo-if-disabled=yes`, tell the linker to strip any debuginfo // found when linking to get rid of symbols from libstd. @@ -826,9 +826,9 @@ impl<'a> Linker for EmLinker<'a> { fn debuginfo(&mut self) { // Preserve names or generate source maps depending on debug info self.cmd.arg(match self.sess.opts.debuginfo { - DebugInfoLevel::NoDebugInfo => "-g0", - DebugInfoLevel::LimitedDebugInfo => "-g3", - DebugInfoLevel::FullDebugInfo => "-g4" + DebugInfo::None => "-g0", + DebugInfo::Limited => "-g3", + DebugInfo::Full => "-g4" }); } diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index aec43be0795b1..a5c6a0d5cd690 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -344,7 +344,7 @@ pub struct CodegenContext { pub tm_factory: Arc Result<&'static mut llvm::TargetMachine, String> + Send + Sync>, pub msvc_imps_needed: bool, pub target_pointer_width: String, - debuginfo: config::DebugInfoLevel, + debuginfo: config::DebugInfo, // Number of cgus excluding the allocator/metadata modules pub total_cgus: usize, diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index d98a8981da724..41336165684f6 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -46,7 +46,7 @@ use rustc::middle::cstore::{self, LinkMeta, LinkagePreference}; use rustc::middle::exported_symbols; use rustc::util::common::{time, print_time_passes_entry}; use rustc::util::profiling::ProfileCategory; -use rustc::session::config::{self, NoDebugInfo, EntryFnType}; +use rustc::session::config::{self, DebugInfo, EntryFnType}; use rustc::session::Session; use rustc_incremental; use allocator; @@ -1249,7 +1249,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } // Finalize debuginfo - if cx.sess().opts.debuginfo != NoDebugInfo { + if cx.sess().opts.debuginfo != DebugInfo::None { debuginfo::finalize(&cx); } diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 2832c114f5158..2f557d0b09998 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -26,7 +26,7 @@ use type_of::PointeeInfo; use rustc_data_structures::base_n; use rustc::mir::mono::Stats; -use rustc::session::config::{self, NoDebugInfo}; +use rustc::session::config::{self, DebugInfo}; use rustc::session::Session; use rustc::ty::layout::{LayoutError, LayoutOf, Size, TyLayout}; use rustc::ty::{self, Ty, TyCtxt}; @@ -270,7 +270,7 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> { let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod()); - let dbg_cx = if tcx.sess.opts.debuginfo != NoDebugInfo { + let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None { let dctx = debuginfo::CrateDebugContext::new(llmod); debuginfo::metadata::compile_unit_metadata(tcx, &codegen_unit.name().as_str(), @@ -770,7 +770,7 @@ fn declare_intrinsic(cx: &CodegenCx<'ll, '_>, key: &str) -> Option<&'ll Value> { ifn!("llvm.assume", fn(i1) -> void); ifn!("llvm.prefetch", fn(i8p, t_i32, t_i32, t_i32) -> void); - if cx.sess().opts.debuginfo != NoDebugInfo { + if cx.sess().opts.debuginfo != DebugInfo::None { ifn!("llvm.dbg.declare", fn(Type::metadata(cx), Type::metadata(cx)) -> void); ifn!("llvm.dbg.value", fn(Type::metadata(cx), t_i64, Type::metadata(cx)) -> void); } diff --git a/src/librustc_codegen_llvm/debuginfo/gdb.rs b/src/librustc_codegen_llvm/debuginfo/gdb.rs index 08128a729b5f0..f6faddb894ffd 100644 --- a/src/librustc_codegen_llvm/debuginfo/gdb.rs +++ b/src/librustc_codegen_llvm/debuginfo/gdb.rs @@ -15,7 +15,7 @@ use llvm; use common::{C_bytes, CodegenCx, C_i32}; use builder::Builder; use declare; -use rustc::session::config::NoDebugInfo; +use rustc::session::config::DebugInfo; use type_::Type; use value::Value; @@ -81,6 +81,6 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool { "omit_gdb_pretty_printer_section"); !omit_gdb_pretty_printer_section && - cx.sess().opts.debuginfo != NoDebugInfo && + cx.sess().opts.debuginfo != DebugInfo::None && cx.sess().target.target.options.emit_debug_gdb_scripts } diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 143b122a5a172..d4fb2549a752c 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -32,7 +32,7 @@ use builder::Builder; use monomorphize::Instance; use rustc::ty::{self, ParamEnv, Ty, InstanceDef}; use rustc::mir; -use rustc::session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; +use rustc::session::config::{self, DebugInfo}; use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet}; use value::Value; @@ -214,7 +214,7 @@ pub fn create_function_debug_context( llfn: &'ll Value, mir: &mir::Mir, ) -> FunctionDebugContext<'ll> { - if cx.sess().opts.debuginfo == NoDebugInfo { + if cx.sess().opts.debuginfo == DebugInfo::None { return FunctionDebugContext::DebugInfoDisabled; } @@ -314,7 +314,7 @@ pub fn create_function_debug_context( cx: &CodegenCx<'ll, 'tcx>, sig: ty::FnSig<'tcx>, ) -> &'ll DIArray { - if cx.sess().opts.debuginfo == LimitedDebugInfo { + if cx.sess().opts.debuginfo == DebugInfo::Limited { return create_DIArray(DIB(cx), &[]); } @@ -400,7 +400,7 @@ pub fn create_function_debug_context( name_to_append_suffix_to.push('>'); // Again, only create type information if full debuginfo is enabled - let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo { + let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full { let names = get_parameter_names(cx, generics); substs.iter().zip(names).filter_map(|(kind, name)| { if let UnpackedKind::Type(ty) = kind.unpack() { diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs index a099cb5c64b21..8fdb67f5930ce 100644 --- a/src/librustc_codegen_llvm/mir/mod.rs +++ b/src/librustc_codegen_llvm/mir/mod.rs @@ -16,7 +16,7 @@ use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts}; use rustc::ty::layout::{LayoutOf, TyLayout}; use rustc::mir::{self, Mir}; use rustc::ty::subst::Substs; -use rustc::session::config::FullDebugInfo; +use rustc::session::config::DebugInfo; use base; use builder::Builder; use common::{CodegenCx, Funclet}; @@ -267,7 +267,7 @@ pub fn codegen_mir( if let Some(name) = decl.name { // User variable let debug_scope = fx.scopes[decl.visibility_scope]; - let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo; + let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == DebugInfo::Full; if !memory_locals.contains(local) && !dbg { debug!("alloc: {:?} ({}) -> operand", local, name); @@ -426,7 +426,7 @@ fn arg_local_refs( // Get the argument scope, if it exists and if we need it. let arg_scope = scopes[mir::OUTERMOST_SOURCE_SCOPE]; - let arg_scope = if bx.sess().opts.debuginfo == FullDebugInfo { + let arg_scope = if bx.sess().opts.debuginfo == DebugInfo::Full { arg_scope.scope_metadata } else { None diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index 6e8471c672934..164790db4b5ec 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -42,7 +42,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::ty::TyCtxt; use rustc::mir::*; use rustc::mir::visit::{MutVisitor, Visitor, PlaceContext}; -use rustc::session::config::FullDebugInfo; +use rustc::session::config::DebugInfo; use std::borrow::Cow; use transform::{MirPass, MirSource}; @@ -294,7 +294,7 @@ impl MirPass for SimplifyLocals { } // We may need to keep dead user variables live for debuginfo. - if tcx.sess.opts.debuginfo == FullDebugInfo { + if tcx.sess.opts.debuginfo == DebugInfo::Full { for local in mir.vars_iter() { marker.locals.insert(local); }