@@ -38,6 +38,7 @@ 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 ;
41
42
use tracing:: debug;
42
43
43
44
mod create_scope_map;
@@ -224,9 +225,9 @@ pub struct DebugLoc {
224
225
/// Information about the original source file.
225
226
pub file : Lrc < SourceFile > ,
226
227
/// The (1-based) line number.
227
- pub line : Option < u32 > ,
228
+ pub line : Option < NonZeroU32 > ,
228
229
/// The (1-based) column number.
229
- pub col : Option < u32 > ,
230
+ pub col : Option < NonZeroU32 > ,
230
231
}
231
232
232
233
impl CodegenCx < ' ll , ' _ > {
@@ -243,7 +244,7 @@ impl CodegenCx<'ll, '_> {
243
244
let line = ( line + 1 ) as u32 ;
244
245
let col = ( pos - line_pos) . to_u32 ( ) + 1 ;
245
246
246
- ( file, Some ( line) , Some ( col) )
247
+ ( file, NonZeroU32 :: new ( line) , NonZeroU32 :: new ( col) )
247
248
}
248
249
Err ( file) => ( file, None , None ) ,
249
250
} ;
@@ -358,9 +359,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
358
359
linkage_name. as_ptr ( ) . cast ( ) ,
359
360
linkage_name. len ( ) ,
360
361
file_metadata,
361
- loc. line . unwrap_or ( UNKNOWN_LINE_NUMBER ) ,
362
+ loc. line . map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
362
363
function_type_metadata,
363
- scope_line. unwrap_or ( UNKNOWN_LINE_NUMBER ) ,
364
+ scope_line. map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
364
365
flags,
365
366
spflags,
366
367
maybe_definition_llfn,
@@ -552,8 +553,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
552
553
553
554
unsafe {
554
555
llvm:: LLVMRustDIBuilderCreateDebugLocation (
555
- line. unwrap_or ( UNKNOWN_LINE_NUMBER ) ,
556
- col. unwrap_or ( UNKNOWN_COLUMN_NUMBER ) ,
556
+ line. map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
557
+ col. map_or ( UNKNOWN_COLUMN_NUMBER , |n| n . get ( ) ) ,
557
558
scope,
558
559
inlined_at,
559
560
)
@@ -606,7 +607,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
606
607
name. as_ptr ( ) . cast ( ) ,
607
608
name. len ( ) ,
608
609
file_metadata,
609
- loc. line . unwrap_or ( UNKNOWN_LINE_NUMBER ) ,
610
+ loc. line . map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
610
611
type_metadata,
611
612
true ,
612
613
DIFlags :: FlagZero ,
0 commit comments