@@ -80,6 +80,7 @@ pub fn expand_mod(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
80
80
pub fn expand_include ( cx : @ExtCtxt , sp : Span , tts : & [ ast:: token_tree ] )
81
81
-> base:: MacResult {
82
82
let file = get_single_str_from_tts ( cx, sp, tts, "include!" ) ;
83
+ // The file will be added to the code map by the parser
83
84
let p = parse:: new_sub_parser_from_file (
84
85
cx. parse_sess ( ) , cx. cfg ( ) ,
85
86
& res_rel_file ( cx, sp, & Path :: new ( file) ) , sp) ;
@@ -99,7 +100,20 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
99
100
Ok ( bytes) => bytes,
100
101
} ;
101
102
match str:: from_utf8_owned_opt ( bytes) {
102
- Some ( s) => base:: MRExpr ( cx. expr_str ( sp, s. to_managed ( ) ) ) ,
103
+ Some ( s) => {
104
+ let s = s. to_managed ( ) ;
105
+ // Add this input file to the code map to make it available as
106
+ // dependency information
107
+ cx. parse_sess . cm . files . push ( @codemap:: FileMap {
108
+ name : file. display ( ) . to_str ( ) . to_managed ( ) ,
109
+ substr : codemap:: FssNone ,
110
+ src : s,
111
+ start_pos : codemap:: BytePos ( 0 ) ,
112
+ lines : @mut ~[ ] ,
113
+ multibyte_chars : @mut ~[ ] ,
114
+ } ) ;
115
+ base:: MRExpr ( cx. expr_str ( sp, s) )
116
+ }
103
117
None => {
104
118
cx. span_fatal ( sp, format ! ( "{} wasn't a utf-8 file" , file. display( ) ) ) ;
105
119
}
0 commit comments