Skip to content

Commit 26e4626

Browse files
committed
Fix include_bytes! not adding a dependency
Fixes rust-lang#24348
1 parent 5245475 commit 26e4626

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libsyntax/ext/source_util.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,17 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
178178
let file = res_rel_file(cx, sp, Path::new(&file));
179179
let mut bytes = Vec::new();
180180
match File::open(&file).and_then(|mut f| f.read_to_end(&mut bytes)) {
181+
Ok(..) => {
182+
let filename = format!("{}", file.display());
183+
cx.codemap().new_filemap(filename, format!("{:?}", bytes));
184+
185+
base::MacEager::expr(cx.expr_lit(sp, ast::LitBinary(Rc::new(bytes))))
186+
}
181187
Err(e) => {
182188
cx.span_err(sp,
183189
&format!("couldn't read {}: {}", file.display(), e));
184190
return DummyResult::expr(sp);
185191
}
186-
Ok(..) => {
187-
base::MacEager::expr(cx.expr_lit(sp, ast::LitBinary(Rc::new(bytes))))
188-
}
189192
}
190193
}
191194

0 commit comments

Comments
 (0)