@@ -3,6 +3,7 @@ const COMMENT: &str = "//@";
3
3
/// A header line, like `//@name: value` consists of the prefix `//@` and the directive
4
4
/// `name: value`. It is also possibly revisioned, e.g. `//@[revision] name: value`.
5
5
pub ( crate ) struct HeaderLine < ' ln > {
6
+ pub ( crate ) line_number : usize ,
6
7
pub ( crate ) revision : Option < & ' ln str > ,
7
8
pub ( crate ) directive : & ' ln str ,
8
9
}
@@ -11,7 +12,7 @@ pub(crate) struct HeaderLine<'ln> {
11
12
///
12
13
/// Adjusted from compiletest/src/header.rs.
13
14
pub ( crate ) fn iter_header < ' ln > ( contents : & ' ln str , it : & mut dyn FnMut ( HeaderLine < ' ln > ) ) {
14
- for ln in contents. lines ( ) {
15
+ for ( line_number , ln ) in ( 1 .. ) . zip ( contents. lines ( ) ) {
15
16
let ln = ln. trim ( ) ;
16
17
17
18
// We're left with potentially `[rev]name: value`.
@@ -24,9 +25,9 @@ pub(crate) fn iter_header<'ln>(contents: &'ln str, it: &mut dyn FnMut(HeaderLine
24
25
panic ! ( "malformed revision directive: expected `//@[rev]`, found `{ln}`" ) ;
25
26
} ;
26
27
// We trimmed off the `[rev]` portion, left with `name: value`.
27
- it ( HeaderLine { revision : Some ( revision) , directive : remainder. trim ( ) } ) ;
28
+ it ( HeaderLine { line_number , revision : Some ( revision) , directive : remainder. trim ( ) } ) ;
28
29
} else {
29
- it ( HeaderLine { revision : None , directive : remainder. trim ( ) } ) ;
30
+ it ( HeaderLine { line_number , revision : None , directive : remainder. trim ( ) } ) ;
30
31
}
31
32
}
32
33
}
0 commit comments