about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-04-16 08:28:27 +0000
committerbors <bors@rust-lang.org>2015-04-16 08:28:27 +0000
commit8f209d5a3e07b01de3a670689c4929870b40db7d (patch)
tree6061e6a0a484cfac6922edcf5ab5ba3ce6735706 /src/libsyntax/ext
parent798fa2276c31f4661b1c3d96b627337f59e907b4 (diff)
parente4b3faca5167aeb77f49b9cfa9140482cd5ebd11 (diff)
downloadrust-8f209d5a3e07b01de3a670689c4929870b40db7d.tar.gz
rust-8f209d5a3e07b01de3a670689c4929870b40db7d.zip
Auto merge of #24423 - tbelaire:include_bytes, r=alexcrichton
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
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/source_util.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index a4c2d2dc030..d91659bafe4 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -184,6 +184,11 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             return DummyResult::expr(sp);
         }
         Ok(..) => {
+            // Add this input file to the code map to make it available as
+            // dependency information, but don't enter it's contents
+            let filename = format!("{}", file.display());
+            cx.codemap().new_filemap(filename, "".to_string());
+
             base::MacEager::expr(cx.expr_lit(sp, ast::LitBinary(Rc::new(bytes))))
         }
     }