@@ -72,18 +72,22 @@ impl<'a> fmt::Debug for DisplayList<'a> {
72
72
73
73
impl < ' a > Display for DisplayList < ' a > {
74
74
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
75
- let max_lineno = self . body . iter ( ) . fold ( 0 , |max, set| {
75
+ let max_lineno = self . body . iter ( ) . fold ( None , |max, set| {
76
76
set. display_lines . iter ( ) . fold ( max, |max, line| match line {
77
- DisplayLine :: Source { lineno, .. } => cmp:: max ( lineno. unwrap_or ( 0 ) , max) ,
77
+ DisplayLine :: Source { lineno, .. } => match ( max, lineno) {
78
+ ( Some ( max) , Some ( lineno) ) => Some ( cmp:: max ( max, * lineno) ) ,
79
+ ( Some ( max) , None ) => Some ( max) ,
80
+ ( None , Some ( lineno) ) => Some ( * lineno) ,
81
+ ( None , None ) => None ,
82
+ } ,
78
83
_ => max,
79
84
} )
80
85
} ) ;
81
- let lineno_width = if max_lineno == 0 {
82
- 1
83
- } else if self . anonymized_line_numbers {
84
- ANONYMIZED_LINE_NUM . len ( )
85
- } else {
86
- ( ( max_lineno as f64 ) . log10 ( ) . floor ( ) as usize ) + 1
86
+ let lineno_width = match max_lineno {
87
+ None => 0 ,
88
+ Some ( 0 ) => 1 ,
89
+ Some ( _max) if self . anonymized_line_numbers => ANONYMIZED_LINE_NUM . len ( ) ,
90
+ Some ( max) => ( max as f64 ) . log10 ( ) . floor ( ) as usize + 1 ,
87
91
} ;
88
92
89
93
let multiline_depth = self . body . iter ( ) . fold ( 0 , |max, set| {
0 commit comments