@@ -38,6 +38,7 @@ use rustc_target::abi::{LayoutOf, Primitive, Size};
3838use libc:: c_uint;
3939use smallvec:: SmallVec ;
4040use std:: cell:: RefCell ;
41+ use std:: num:: NonZeroU32 ;
4142use tracing:: debug;
4243
4344mod create_scope_map;
@@ -224,9 +225,9 @@ pub struct DebugLoc {
224225 /// Information about the original source file.
225226 pub file : Lrc < SourceFile > ,
226227 /// The (1-based) line number.
227- pub line : Option < u32 > ,
228+ pub line : Option < NonZeroU32 > ,
228229 /// The (1-based) column number.
229- pub col : Option < u32 > ,
230+ pub col : Option < NonZeroU32 > ,
230231}
231232
232233impl CodegenCx < ' ll , ' _ > {
@@ -243,7 +244,7 @@ impl CodegenCx<'ll, '_> {
243244 let line = ( line + 1 ) as u32 ;
244245 let col = ( pos - line_pos) . to_u32 ( ) + 1 ;
245246
246- ( file, Some ( line) , Some ( col) )
247+ ( file, NonZeroU32 :: new ( line) , NonZeroU32 :: new ( col) )
247248 }
248249 Err ( file) => ( file, None , None ) ,
249250 } ;
@@ -358,9 +359,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
358359 linkage_name. as_ptr ( ) . cast ( ) ,
359360 linkage_name. len ( ) ,
360361 file_metadata,
361- loc. line . unwrap_or ( UNKNOWN_LINE_NUMBER ) ,
362+ loc. line . map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
362363 function_type_metadata,
363- scope_line. unwrap_or ( UNKNOWN_LINE_NUMBER ) ,
364+ scope_line. map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
364365 flags,
365366 spflags,
366367 maybe_definition_llfn,
@@ -552,8 +553,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
552553
553554 unsafe {
554555 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 ( ) ) ,
557558 scope,
558559 inlined_at,
559560 )
@@ -606,7 +607,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
606607 name. as_ptr ( ) . cast ( ) ,
607608 name. len ( ) ,
608609 file_metadata,
609- loc. line . unwrap_or ( UNKNOWN_LINE_NUMBER ) ,
610+ loc. line . map_or ( UNKNOWN_LINE_NUMBER , |n| n . get ( ) ) ,
610611 type_metadata,
611612 true ,
612613 DIFlags :: FlagZero ,
0 commit comments