@@ -19,7 +19,6 @@ use parse;
1919use parse:: token:: { get_ident_interner} ;
2020use print:: pprust;
2121
22- use std:: cell:: RefCell ;
2322use std:: io;
2423use std:: io:: File ;
2524use std:: str;
@@ -105,20 +104,14 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
105104 Ok ( bytes) => bytes,
106105 } ;
107106 match str:: from_utf8_owned_opt ( bytes) {
108- Some ( s) => {
109- let s = s. to_managed ( ) ;
107+ Some ( src) => {
110108 // Add this input file to the code map to make it available as
111109 // dependency information
112- let mut files = cx. parse_sess . cm . files . borrow_mut ( ) ;
113- files. get ( ) . push ( @codemap:: FileMap {
114- name : file. display ( ) . to_str ( ) . to_managed ( ) ,
115- substr : codemap:: FssNone ,
116- src : s,
117- start_pos : codemap:: BytePos ( 0 ) ,
118- lines : RefCell :: new ( ~[ ] ) ,
119- multibyte_chars : RefCell :: new ( ~[ ] ) ,
120- } ) ;
121- base:: MRExpr ( cx. expr_str ( sp, s) )
110+ let src = src. to_managed ( ) ;
111+ let filename = file. display ( ) . to_str ( ) . to_managed ( ) ;
112+ cx. parse_sess . cm . new_filemap ( filename, src) ;
113+
114+ base:: MRExpr ( cx. expr_str ( sp, src) )
122115 }
123116 None => {
124117 cx. span_fatal ( sp, format ! ( "{} wasn't a utf-8 file" , file. display( ) ) ) ;
0 commit comments