Skip to content

Commit 408d402

Browse files
committed
nhwn: use plain u32 in DebugLoc
1 parent f5aa1bc commit 408d402

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::metadata::{file_metadata, UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER};
1+
use super::metadata::file_metadata;
22
use super::utils::DIB;
33
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext};
44
use rustc_codegen_ssa::traits::*;
@@ -102,8 +102,8 @@ fn make_mir_scope(
102102
DIB(cx),
103103
parent_scope.dbg_scope.unwrap(),
104104
file_metadata,
105-
loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
106-
loc.col.map_or(UNKNOWN_COLUMN_NUMBER, |n| n.get()),
105+
loc.line,
106+
loc.col,
107107
)
108108
},
109109
};

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1839,10 +1839,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> {
18391839
.span;
18401840
if !span.is_dummy() {
18411841
let loc = cx.lookup_debug_loc(span.lo());
1842-
return Some(SourceInfo {
1843-
file: file_metadata(cx, &loc.file),
1844-
line: loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
1845-
});
1842+
return Some(SourceInfo { file: file_metadata(cx, &loc.file), line: loc.line });
18461843
}
18471844
}
18481845
_ => {}
@@ -2481,7 +2478,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
24812478
let loc = cx.lookup_debug_loc(span.lo());
24822479
(file_metadata(cx, &loc.file), loc.line)
24832480
} else {
2484-
(unknown_file_metadata(cx), None)
2481+
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
24852482
};
24862483

24872484
let is_local_to_unit = is_node_local_to_unit(cx, def_id);
@@ -2504,7 +2501,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
25042501
linkage_name.as_ptr().cast(),
25052502
linkage_name.len(),
25062503
file_metadata,
2507-
line_number.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
2504+
line_number,
25082505
type_metadata,
25092506
is_local_to_unit,
25102507
global,

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use rustc_target::abi::{LayoutOf, Primitive, Size};
3838
use libc::c_uint;
3939
use smallvec::SmallVec;
4040
use std::cell::RefCell;
41-
use std::num::NonZeroU32;
4241
use tracing::debug;
4342

4443
mod create_scope_map;
@@ -225,9 +224,9 @@ pub struct DebugLoc {
225224
/// Information about the original source file.
226225
pub file: Lrc<SourceFile>,
227226
/// The (1-based) line number.
228-
pub line: Option<NonZeroU32>,
227+
pub line: u32,
229228
/// The (1-based) column number.
230-
pub col: Option<NonZeroU32>,
229+
pub col: u32,
231230
}
232231

233232
impl CodegenCx<'ll, '_> {
@@ -244,16 +243,16 @@ impl CodegenCx<'ll, '_> {
244243
let line = (line + 1) as u32;
245244
let col = (pos - line_pos).to_u32() + 1;
246245

247-
(file, NonZeroU32::new(line), NonZeroU32::new(col))
246+
(file, line, col)
248247
}
249-
Err(file) => (file, None, None),
248+
Err(file) => (file, UNKNOWN_LINE_NUMBER, UNKNOWN_COLUMN_NUMBER),
250249
};
251250

252251
// For MSVC, omit the column number.
253252
// Otherwise, emit it. This mimics clang behaviour.
254253
// See discussion in https://github.com/rust-lang/rust/issues/42921
255254
if self.sess().target.is_like_msvc {
256-
DebugLoc { file, line, col: None }
255+
DebugLoc { file, line, col: UNKNOWN_COLUMN_NUMBER }
257256
} else {
258257
DebugLoc { file, line, col }
259258
}
@@ -359,9 +358,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
359358
linkage_name.as_ptr().cast(),
360359
linkage_name.len(),
361360
file_metadata,
362-
loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
361+
loc.line,
363362
function_type_metadata,
364-
scope_line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
363+
scope_line,
365364
flags,
366365
spflags,
367366
maybe_definition_llfn,
@@ -551,14 +550,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
551550
) -> &'ll DILocation {
552551
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
553552

554-
unsafe {
555-
llvm::LLVMRustDIBuilderCreateDebugLocation(
556-
line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
557-
col.map_or(UNKNOWN_COLUMN_NUMBER, |n| n.get()),
558-
scope,
559-
inlined_at,
560-
)
561-
}
553+
unsafe { llvm::LLVMRustDIBuilderCreateDebugLocation(line, col, scope, inlined_at) }
562554
}
563555

564556
fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value) {
@@ -607,7 +599,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
607599
name.as_ptr().cast(),
608600
name.len(),
609601
file_metadata,
610-
loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
602+
loc.line,
611603
type_metadata,
612604
true,
613605
DIFlags::FlagZero,

0 commit comments

Comments
 (0)