Skip to content

Commit ab8f152

Browse files
committed
Remove internal mutability from source_locations_enabled
1 parent f1fe925 commit ab8f152

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, Variable
3232
VariableKind, FunctionDebugContextData};
3333

3434
use libc::c_uint;
35-
use std::cell::{Cell, RefCell};
35+
use std::cell::RefCell;
3636
use std::ffi::CString;
3737

3838
use syntax_pos::{self, Span, Pos};
@@ -158,7 +158,7 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
158158
variable_kind: VariableKind,
159159
span: Span,
160160
) {
161-
assert!(!dbg_context.get_ref(span).source_locations_enabled.get());
161+
assert!(!dbg_context.get_ref(span).source_locations_enabled);
162162
let cx = self.cx();
163163

164164
let file = span_start(cx, span).file;
@@ -327,7 +327,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
327327
// Initialize fn debug context (including scope map and namespace map)
328328
let fn_debug_context = FunctionDebugContextData {
329329
fn_metadata,
330-
source_locations_enabled: Cell::new(false),
330+
source_locations_enabled: false,
331331
defining_crate: def_id.krate,
332332
};
333333

src/librustc_codegen_llvm/debuginfo/source_loc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn set_source_location<D>(
3030
FunctionDebugContext::RegularContext(ref data) => data
3131
};
3232

33-
let dbg_loc = if function_debug_context.source_locations_enabled.get() {
33+
let dbg_loc = if function_debug_context.source_locations_enabled {
3434
debug!("set_source_location: {}", bx.sess().source_map().span_to_string(span));
3535
let loc = span_start(bx.cx(), span);
3636
InternalDebugLocation::new(scope.unwrap(), loc.line, loc.col.to_usize())

src/librustc_codegen_ssa/debuginfo.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use syntax_pos::{BytePos, Span};
22
use rustc::hir::def_id::CrateNum;
3-
use std::cell::Cell;
43

54
pub enum FunctionDebugContext<D> {
65
RegularContext(FunctionDebugContextData<D>),
@@ -36,18 +35,18 @@ impl<D> FunctionDebugContext<D> {
3635
/// they are disabled when beginning to codegen a new function. This functions
3736
/// switches source location emitting on and must therefore be called before the
3837
/// first real statement/expression of the function is codegened.
39-
pub fn start_emitting_source_locations<D>(dbg_context: &FunctionDebugContext<D>) {
38+
pub fn start_emitting_source_locations<D>(dbg_context: &mut FunctionDebugContext<D>) {
4039
match *dbg_context {
41-
FunctionDebugContext::RegularContext(ref data) => {
42-
data.source_locations_enabled.set(true)
40+
FunctionDebugContext::RegularContext(ref mut data) => {
41+
data.source_locations_enabled = true;
4342
},
4443
_ => { /* safe to ignore */ }
4544
}
4645
}
4746

4847
pub struct FunctionDebugContextData<D> {
4948
pub fn_metadata: D,
50-
pub source_locations_enabled: Cell<bool>,
49+
pub source_locations_enabled: bool,
5150
pub defining_crate: CrateNum,
5251
}
5352

src/librustc_codegen_ssa/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
334334
// Up until here, IR instructions for this function have explicitly not been annotated with
335335
// source code location, so we don't step into call setup code. From here on, source location
336336
// emitting should be enabled.
337-
debuginfo::start_emitting_source_locations(&fx.debug_context);
337+
debuginfo::start_emitting_source_locations(&mut fx.debug_context);
338338

339339
let rpo = traversal::reverse_postorder(&mir);
340340
let mut visited = BitSet::new_empty(mir.basic_blocks().len());

0 commit comments

Comments
 (0)