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