@@ -38,7 +38,6 @@ use rustc_target::abi::{LayoutOf, Primitive, Size};
38
38
use libc:: c_uint;
39
39
use smallvec:: SmallVec ;
40
40
use std:: cell:: RefCell ;
41
- use std:: num:: NonZeroU32 ;
42
41
use tracing:: debug;
43
42
44
43
mod create_scope_map;
@@ -225,9 +224,9 @@ pub struct DebugLoc {
225
224
/// Information about the original source file.
226
225
pub file : Lrc < SourceFile > ,
227
226
/// The (1-based) line number.
228
- pub line : Option < NonZeroU32 > ,
227
+ pub line : u32 ,
229
228
/// The (1-based) column number.
230
- pub col : Option < NonZeroU32 > ,
229
+ pub col : u32 ,
231
230
}
232
231
233
232
impl CodegenCx < ' ll , ' _ > {
@@ -244,16 +243,16 @@ impl CodegenCx<'ll, '_> {
244
243
let line = ( line + 1 ) as u32 ;
245
244
let col = ( pos - line_pos) . to_u32 ( ) + 1 ;
246
245
247
- ( file, NonZeroU32 :: new ( line) , NonZeroU32 :: new ( col) )
246
+ ( file, line, col)
248
247
}
249
- Err ( file) => ( file, None , None ) ,
248
+ Err ( file) => ( file, UNKNOWN_LINE_NUMBER , UNKNOWN_COLUMN_NUMBER ) ,
250
249
} ;
251
250
252
251
// For MSVC, omit the column number.
253
252
// Otherwise, emit it. This mimics clang behaviour.
254
253
// See discussion in https://github.com/rust-lang/rust/issues/42921
255
254
if self . sess ( ) . target . is_like_msvc {
256
- DebugLoc { file, line, col : None }
255
+ DebugLoc { file, line, col : UNKNOWN_COLUMN_NUMBER }
257
256
} else {
258
257
DebugLoc { file, line, col }
259
258
}
@@ -359,9 +358,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
359
358
linkage_name. as_ptr ( ) . cast ( ) ,
360
359
linkage_name. len ( ) ,
361
360
file_metadata,
362
- loc. line . map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
361
+ loc. line ,
363
362
function_type_metadata,
364
- scope_line. map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
363
+ scope_line,
365
364
flags,
366
365
spflags,
367
366
maybe_definition_llfn,
@@ -551,14 +550,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
551
550
) -> & ' ll DILocation {
552
551
let DebugLoc { line, col, .. } = self . lookup_debug_loc ( span. lo ( ) ) ;
553
552
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) }
562
554
}
563
555
564
556
fn create_vtable_metadata ( & self , ty : Ty < ' tcx > , vtable : Self :: Value ) {
@@ -607,7 +599,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
607
599
name. as_ptr ( ) . cast ( ) ,
608
600
name. len ( ) ,
609
601
file_metadata,
610
- loc. line . map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
602
+ loc. line ,
611
603
type_metadata,
612
604
true ,
613
605
DIFlags :: FlagZero ,
0 commit comments