Skip to content

Commit 9f481b8

Browse files
committed
include_bytes! now registers the file included
This is a little bit tricky, since with include_str!, we know that we are including utf-8 content, so it's safe to store the source as a String in a FileMap. We don't know that for include_bytes!, but I don't think we actually need to track the contents anyways, so I'm passing "". new_filemap does check for the zero length content, and it should be reasonable, howeven I'm not sure if it would be better to pass None instead of Some(Rc::new("")) as the src component of a FileMap. Fixes bug #24348
1 parent 47551b5 commit 9f481b8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libsyntax/ext/source_util.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
184184
return DummyResult::expr(sp);
185185
}
186186
Ok(..) => {
187+
// Add this input file to the code map to make it available as
188+
// dependency information, but don't enter it's contents
189+
let filename = format!("{}", file.display());
190+
cx.codemap().new_filemap(filename, "".to_string());
191+
187192
base::MacEager::expr(cx.expr_lit(sp, ast::LitBinary(Rc::new(bytes))))
188193
}
189194
}

0 commit comments

Comments
 (0)