about summary refs log tree commit diff
path: root/src/libsyntax/ext/source_util.rs
diff options
context:
space:
mode:
authorMatthew Russo <matthew@edapp.com>2018-10-30 10:10:42 -0400
committerMatthew Russo <matthew@edapp.com>2018-12-04 17:19:55 -0500
commit6ee4d3cafce0d46b2d76a3f96aa62ca985a3ab6c (patch)
treefb3330595ecb5c3d7991faabe248e60c00a2c60c /src/libsyntax/ext/source_util.rs
parent906deae0790bd18681b937fe9a141a3c26cf1855 (diff)
downloadrust-6ee4d3cafce0d46b2d76a3f96aa62ca985a3ab6c.tar.gz
rust-6ee4d3cafce0d46b2d76a3f96aa62ca985a3ab6c.zip
new_source_file no longer enters duplicate files, expand_include_bytes includes the source if it can convert bytes to string
Diffstat (limited to 'src/libsyntax/ext/source_util.rs')
-rw-r--r--src/libsyntax/ext/source_util.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index e1ba8897a47..654be85862f 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -182,9 +182,12 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Toke
             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
-            cx.source_map().new_source_file(file.into(), String::new());
+            let src = match String::from_utf8(bytes.clone()) {
+                Ok(contents) => contents,
+                Err(..) => "".to_string()
+            };
+
+            cx.source_map().new_source_file(file.into(), src);
 
             base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::new(bytes))))
         }