@@ -25,6 +25,7 @@ use rustc::session::{self, config};
25
25
26
26
use syntax:: ast;
27
27
use syntax:: ast:: Name ;
28
+ use syntax:: codemap:: Pos ;
28
29
use syntax:: parse:: token;
29
30
use syntax:: parse:: lexer:: TokenAndSpan ;
30
31
@@ -234,6 +235,13 @@ fn tok_cmp(a: &token::Token, b: &token::Token) -> bool {
234
235
}
235
236
}
236
237
238
+ fn span_cmp ( rust_sp : syntax:: codemap:: Span , antlr_sp : syntax:: codemap:: Span , cm : & syntax:: codemap:: CodeMap ) -> bool {
239
+ println ! ( "{} {}" , cm. bytepos_to_file_charpos( rust_sp. lo) . to_uint( ) , cm. bytepos_to_file_charpos( rust_sp. hi) . to_uint( ) ) ;
240
+ antlr_sp. lo . to_uint ( ) == cm. bytepos_to_file_charpos ( rust_sp. lo ) . to_uint ( ) &&
241
+ antlr_sp. hi . to_uint ( ) == cm. bytepos_to_file_charpos ( rust_sp. hi ) . to_uint ( ) &&
242
+ antlr_sp. expn_id == rust_sp. expn_id
243
+ }
244
+
237
245
fn main ( ) {
238
246
fn next ( r : & mut lexer:: StringReader ) -> TokenAndSpan {
239
247
use syntax:: parse:: lexer:: Reader ;
@@ -259,14 +267,15 @@ fn main() {
259
267
code,
260
268
String :: from_str ( "<n/a>" ) ) ;
261
269
let mut lexer = lexer:: StringReader :: new ( session. diagnostic ( ) , filemap) ;
270
+ let ref cm = lexer. span_diagnostic . cm ;
262
271
263
272
for antlr_tok in antlr_tokens {
264
273
let rustc_tok = next ( & mut lexer) ;
265
274
if rustc_tok. tok == token:: Eof && antlr_tok. tok == token:: Eof {
266
275
continue
267
276
}
268
277
269
- assert ! ( rustc_tok. sp == antlr_tok. sp, "{:?} and {:?} have different spans" , rustc_tok,
278
+ assert ! ( span_cmp ( rustc_tok. sp, antlr_tok. sp, cm ) , "{:?} and {:?} have different spans" , rustc_tok,
270
279
antlr_tok) ;
271
280
272
281
macro_rules! matches {
0 commit comments