@@ -3,6 +3,7 @@ const COMMENT: &str = "//@";
33/// A header line, like `//@name: value` consists of the prefix `//@` and the directive
44/// `name: value`. It is also possibly revisioned, e.g. `//@[revision] name: value`.
55pub ( crate ) struct HeaderLine < ' ln > {
6+ pub ( crate ) line_number : usize ,
67 pub ( crate ) revision : Option < & ' ln str > ,
78 pub ( crate ) directive : & ' ln str ,
89}
@@ -11,7 +12,7 @@ pub(crate) struct HeaderLine<'ln> {
1112///
1213/// Adjusted from compiletest/src/header.rs.
1314pub ( 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 ( ) ) {
1516 let ln = ln. trim ( ) ;
1617
1718 // 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
2425 panic ! ( "malformed revision directive: expected `//@[rev]`, found `{ln}`" ) ;
2526 } ;
2627 // 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 ( ) } ) ;
2829 } else {
29- it ( HeaderLine { revision : None , directive : remainder. trim ( ) } ) ;
30+ it ( HeaderLine { line_number , revision : None , directive : remainder. trim ( ) } ) ;
3031 }
3132 }
3233}
0 commit comments