Skip to content

Commit 2bc7197

Browse files
Normalize DebugInfoLevel to standard style
1 parent 442a474 commit 2bc7197

File tree

10 files changed

+38
-40
lines changed

10 files changed

+38
-40
lines changed

src/librustc/session/config.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
//! Contains infrastructure for configuring the compiler, including parsing
1212
//! command line options.
1313
14-
pub use self::DebugInfoLevel::*;
15-
1614
use std::str::FromStr;
1715

1816
use session::{early_error, early_warn, Session};
@@ -110,10 +108,10 @@ impl CrossLangLto {
110108
}
111109

112110
#[derive(Clone, Copy, PartialEq, Hash)]
113-
pub enum DebugInfoLevel {
114-
NoDebugInfo,
115-
LimitedDebugInfo,
116-
FullDebugInfo,
111+
pub enum DebugInfo {
112+
None,
113+
Limited,
114+
Full,
117115
}
118116

119117
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, RustcEncodable, RustcDecodable)]
@@ -378,7 +376,7 @@ top_level_options!(
378376
// Include the debug_assertions flag into dependency tracking, since it
379377
// can influence whether overflow checks are done or not.
380378
debug_assertions: bool [TRACKED],
381-
debuginfo: DebugInfoLevel [TRACKED],
379+
debuginfo: DebugInfo [TRACKED],
382380
lint_opts: Vec<(String, lint::Level)> [TRACKED],
383381
lint_cap: Option<lint::Level> [TRACKED],
384382
describe_lints: bool [UNTRACKED],
@@ -603,7 +601,7 @@ pub fn basic_options() -> Options {
603601
Options {
604602
crate_types: Vec::new(),
605603
optimize: OptLevel::No,
606-
debuginfo: NoDebugInfo,
604+
debuginfo: DebugInfo::None,
607605
lint_opts: Vec::new(),
608606
lint_cap: None,
609607
describe_lints: false,
@@ -2080,12 +2078,12 @@ pub fn build_session_options_and_crate_config(
20802078
if cg.debuginfo.is_some() {
20812079
early_error(error_format, "-g and -C debuginfo both provided");
20822080
}
2083-
FullDebugInfo
2081+
DebugInfo::Full
20842082
} else {
20852083
match cg.debuginfo {
2086-
None | Some(0) => NoDebugInfo,
2087-
Some(1) => LimitedDebugInfo,
2088-
Some(2) => FullDebugInfo,
2084+
None | Some(0) => DebugInfo::None,
2085+
Some(1) => DebugInfo::Limited,
2086+
Some(2) => DebugInfo::Full,
20892087
Some(arg) => {
20902088
early_error(
20912089
error_format,
@@ -2184,7 +2182,7 @@ pub fn build_session_options_and_crate_config(
21842182
Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)),
21852183
};
21862184

2187-
if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
2185+
if !cg.remark.is_empty() && debuginfo == DebugInfo::None {
21882186
early_warn(
21892187
error_format,
21902188
"-C remark will not show source locations without \
@@ -2391,7 +2389,7 @@ mod dep_tracking {
23912389
use std::hash::Hash;
23922390
use std::path::PathBuf;
23932391
use std::collections::hash_map::DefaultHasher;
2394-
use super::{CrateType, DebugInfoLevel, ErrorOutputType, Lto, OptLevel, OutputTypes,
2392+
use super::{CrateType, DebugInfo, ErrorOutputType, Lto, OptLevel, OutputTypes,
23952393
Passes, Sanitizer, CrossLangLto};
23962394
use syntax::feature_gate::UnstableFeatures;
23972395
use rustc_target::spec::{PanicStrategy, RelroLevel, TargetTriple};
@@ -2448,7 +2446,7 @@ mod dep_tracking {
24482446
impl_dep_tracking_hash_via_hash!(Passes);
24492447
impl_dep_tracking_hash_via_hash!(OptLevel);
24502448
impl_dep_tracking_hash_via_hash!(Lto);
2451-
impl_dep_tracking_hash_via_hash!(DebugInfoLevel);
2449+
impl_dep_tracking_hash_via_hash!(DebugInfo);
24522450
impl_dep_tracking_hash_via_hash!(UnstableFeatures);
24532451
impl_dep_tracking_hash_via_hash!(OutputTypes);
24542452
impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind);

src/librustc_codegen_llvm/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use super::command::Command;
1717
use super::rpath::RPathConfig;
1818
use super::rpath;
1919
use metadata::METADATA_FILENAME;
20-
use rustc::session::config::{self, NoDebugInfo, OutputFilenames, OutputType, PrintRequest};
20+
use rustc::session::config::{self, DebugInfo, OutputFilenames, OutputType, PrintRequest};
2121
use rustc::session::config::{RUST_CGU_EXT, Lto};
2222
use rustc::session::filesearch;
2323
use rustc::session::search_paths::PathKind;
@@ -200,7 +200,7 @@ pub(crate) fn link_binary(sess: &Session,
200200
/// split-dwarf like schemes.
201201
fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
202202
// If the objects don't have debuginfo there's nothing to preserve.
203-
if sess.opts.debuginfo == NoDebugInfo {
203+
if sess.opts.debuginfo == DebugInfo::None {
204204
return false
205205
}
206206

@@ -834,7 +834,7 @@ fn link_natively(sess: &Session,
834834
// the symbols. Note, though, that if the object files are being preserved
835835
// for their debug information there's no need for us to run dsymutil.
836836
if sess.target.target.options.is_like_osx &&
837-
sess.opts.debuginfo != NoDebugInfo &&
837+
sess.opts.debuginfo != DebugInfo::None &&
838838
!preserve_objects_for_their_debuginfo(sess)
839839
{
840840
match Command::new("dsymutil").arg(out_filename).output() {

src/librustc_codegen_llvm/back/linker.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use back::symbol_export;
2121
use rustc::hir::def_id::{LOCAL_CRATE, CrateNum};
2222
use rustc::middle::dependency_format::Linkage;
2323
use rustc::session::Session;
24-
use rustc::session::config::{self, CrateType, OptLevel, DebugInfoLevel,
24+
use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
2525
CrossLangLto};
2626
use rustc::ty::TyCtxt;
2727
use rustc_target::spec::{LinkerFlavor, LldFlavor};
@@ -338,7 +338,7 @@ impl<'a> Linker for GccLinker<'a> {
338338

339339
fn debuginfo(&mut self) {
340340
match self.sess.opts.debuginfo {
341-
DebugInfoLevel::NoDebugInfo => {
341+
DebugInfo::None => {
342342
// If we are building without debuginfo enabled and we were called with
343343
// `-Zstrip-debuginfo-if-disabled=yes`, tell the linker to strip any debuginfo
344344
// found when linking to get rid of symbols from libstd.
@@ -826,9 +826,9 @@ impl<'a> Linker for EmLinker<'a> {
826826
fn debuginfo(&mut self) {
827827
// Preserve names or generate source maps depending on debug info
828828
self.cmd.arg(match self.sess.opts.debuginfo {
829-
DebugInfoLevel::NoDebugInfo => "-g0",
830-
DebugInfoLevel::LimitedDebugInfo => "-g3",
831-
DebugInfoLevel::FullDebugInfo => "-g4"
829+
DebugInfo::None => "-g0",
830+
DebugInfo::Limited => "-g3",
831+
DebugInfo::Full => "-g4"
832832
});
833833
}
834834

src/librustc_codegen_llvm/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ pub struct CodegenContext {
344344
pub tm_factory: Arc<dyn Fn() -> Result<&'static mut llvm::TargetMachine, String> + Send + Sync>,
345345
pub msvc_imps_needed: bool,
346346
pub target_pointer_width: String,
347-
debuginfo: config::DebugInfoLevel,
347+
debuginfo: config::DebugInfo,
348348

349349
// Number of cgus excluding the allocator/metadata modules
350350
pub total_cgus: usize,

src/librustc_codegen_llvm/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
4646
use rustc::middle::exported_symbols;
4747
use rustc::util::common::{time, print_time_passes_entry};
4848
use rustc::util::profiling::ProfileCategory;
49-
use rustc::session::config::{self, NoDebugInfo, EntryFnType};
49+
use rustc::session::config::{self, DebugInfo, EntryFnType};
5050
use rustc::session::Session;
5151
use rustc_incremental;
5252
use allocator;
@@ -1249,7 +1249,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12491249
}
12501250

12511251
// Finalize debuginfo
1252-
if cx.sess().opts.debuginfo != NoDebugInfo {
1252+
if cx.sess().opts.debuginfo != DebugInfo::None {
12531253
debuginfo::finalize(&cx);
12541254
}
12551255

src/librustc_codegen_llvm/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use type_of::PointeeInfo;
2626

2727
use rustc_data_structures::base_n;
2828
use rustc::mir::mono::Stats;
29-
use rustc::session::config::{self, NoDebugInfo};
29+
use rustc::session::config::{self, DebugInfo};
3030
use rustc::session::Session;
3131
use rustc::ty::layout::{LayoutError, LayoutOf, Size, TyLayout};
3232
use rustc::ty::{self, Ty, TyCtxt};
@@ -270,7 +270,7 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
270270

271271
let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());
272272

273-
let dbg_cx = if tcx.sess.opts.debuginfo != NoDebugInfo {
273+
let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None {
274274
let dctx = debuginfo::CrateDebugContext::new(llmod);
275275
debuginfo::metadata::compile_unit_metadata(tcx,
276276
&codegen_unit.name().as_str(),
@@ -770,7 +770,7 @@ fn declare_intrinsic(cx: &CodegenCx<'ll, '_>, key: &str) -> Option<&'ll Value> {
770770
ifn!("llvm.assume", fn(i1) -> void);
771771
ifn!("llvm.prefetch", fn(i8p, t_i32, t_i32, t_i32) -> void);
772772

773-
if cx.sess().opts.debuginfo != NoDebugInfo {
773+
if cx.sess().opts.debuginfo != DebugInfo::None {
774774
ifn!("llvm.dbg.declare", fn(Type::metadata(cx), Type::metadata(cx)) -> void);
775775
ifn!("llvm.dbg.value", fn(Type::metadata(cx), t_i64, Type::metadata(cx)) -> void);
776776
}

src/librustc_codegen_llvm/debuginfo/gdb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use llvm;
1515
use common::{C_bytes, CodegenCx, C_i32};
1616
use builder::Builder;
1717
use declare;
18-
use rustc::session::config::NoDebugInfo;
18+
use rustc::session::config::DebugInfo;
1919
use type_::Type;
2020
use value::Value;
2121

@@ -81,6 +81,6 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
8181
"omit_gdb_pretty_printer_section");
8282

8383
!omit_gdb_pretty_printer_section &&
84-
cx.sess().opts.debuginfo != NoDebugInfo &&
84+
cx.sess().opts.debuginfo != DebugInfo::None &&
8585
cx.sess().target.target.options.emit_debug_gdb_scripts
8686
}

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use builder::Builder;
3232
use monomorphize::Instance;
3333
use rustc::ty::{self, ParamEnv, Ty, InstanceDef};
3434
use rustc::mir;
35-
use rustc::session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
35+
use rustc::session::config::{self, DebugInfo};
3636
use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
3737
use value::Value;
3838

@@ -214,7 +214,7 @@ pub fn create_function_debug_context(
214214
llfn: &'ll Value,
215215
mir: &mir::Mir,
216216
) -> FunctionDebugContext<'ll> {
217-
if cx.sess().opts.debuginfo == NoDebugInfo {
217+
if cx.sess().opts.debuginfo == DebugInfo::None {
218218
return FunctionDebugContext::DebugInfoDisabled;
219219
}
220220

@@ -314,7 +314,7 @@ pub fn create_function_debug_context(
314314
cx: &CodegenCx<'ll, 'tcx>,
315315
sig: ty::FnSig<'tcx>,
316316
) -> &'ll DIArray {
317-
if cx.sess().opts.debuginfo == LimitedDebugInfo {
317+
if cx.sess().opts.debuginfo == DebugInfo::Limited {
318318
return create_DIArray(DIB(cx), &[]);
319319
}
320320

@@ -400,7 +400,7 @@ pub fn create_function_debug_context(
400400
name_to_append_suffix_to.push('>');
401401

402402
// Again, only create type information if full debuginfo is enabled
403-
let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo {
403+
let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full {
404404
let names = get_parameter_names(cx, generics);
405405
substs.iter().zip(names).filter_map(|(kind, name)| {
406406
if let UnpackedKind::Type(ty) = kind.unpack() {

src/librustc_codegen_llvm/mir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
1616
use rustc::ty::layout::{LayoutOf, TyLayout};
1717
use rustc::mir::{self, Mir};
1818
use rustc::ty::subst::Substs;
19-
use rustc::session::config::FullDebugInfo;
19+
use rustc::session::config::DebugInfo;
2020
use base;
2121
use builder::Builder;
2222
use common::{CodegenCx, Funclet};
@@ -267,7 +267,7 @@ pub fn codegen_mir(
267267
if let Some(name) = decl.name {
268268
// User variable
269269
let debug_scope = fx.scopes[decl.visibility_scope];
270-
let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo;
270+
let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == DebugInfo::Full;
271271

272272
if !memory_locals.contains(local) && !dbg {
273273
debug!("alloc: {:?} ({}) -> operand", local, name);
@@ -426,7 +426,7 @@ fn arg_local_refs(
426426

427427
// Get the argument scope, if it exists and if we need it.
428428
let arg_scope = scopes[mir::OUTERMOST_SOURCE_SCOPE];
429-
let arg_scope = if bx.sess().opts.debuginfo == FullDebugInfo {
429+
let arg_scope = if bx.sess().opts.debuginfo == DebugInfo::Full {
430430
arg_scope.scope_metadata
431431
} else {
432432
None

src/librustc_mir/transform/simplify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
4242
use rustc::ty::TyCtxt;
4343
use rustc::mir::*;
4444
use rustc::mir::visit::{MutVisitor, Visitor, PlaceContext};
45-
use rustc::session::config::FullDebugInfo;
45+
use rustc::session::config::DebugInfo;
4646
use std::borrow::Cow;
4747
use transform::{MirPass, MirSource};
4848

@@ -294,7 +294,7 @@ impl MirPass for SimplifyLocals {
294294
}
295295

296296
// We may need to keep dead user variables live for debuginfo.
297-
if tcx.sess.opts.debuginfo == FullDebugInfo {
297+
if tcx.sess.opts.debuginfo == DebugInfo::Full {
298298
for local in mir.vars_iter() {
299299
marker.locals.insert(local);
300300
}

0 commit comments

Comments
 (0)