From 95b87d18c0ba2ce019cab6fb75ab52460e6899e7 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 19 Dec 2017 16:43:32 -0600 Subject: [PATCH] add files loaded through doc(include) into dep-info --- src/libsyntax/ext/expand.rs | 4 ++++ src/test/run-make/include_bytes_deps/Makefile | 2 +- src/test/run-make/include_bytes_deps/input.md | 1 + src/test/run-make/include_bytes_deps/main.rs | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/test/run-make/include_bytes_deps/input.md diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 735588d29495..2b648f3d52b3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1120,6 +1120,10 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { match String::from_utf8(buf) { Ok(src) => { + // Add this input file to the code map to make it available as + // dependency information + self.cx.codemap().new_filemap_and_lines(&filename, &src); + let include_info = vec![ dummy_spanned(ast::NestedMetaItemKind::MetaItem( attr::mk_name_value_item_str("file".into(), diff --git a/src/test/run-make/include_bytes_deps/Makefile b/src/test/run-make/include_bytes_deps/Makefile index f7b1d21ace28..1293695b7997 100644 --- a/src/test/run-make/include_bytes_deps/Makefile +++ b/src/test/run-make/include_bytes_deps/Makefile @@ -8,7 +8,7 @@ ifneq ($(shell uname),FreeBSD) ifndef IS_WINDOWS all: $(RUSTC) --emit dep-info main.rs - $(CGREP) "input.txt" "input.bin" < $(TMPDIR)/main.d + $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d else all: diff --git a/src/test/run-make/include_bytes_deps/input.md b/src/test/run-make/include_bytes_deps/input.md new file mode 100644 index 000000000000..2a19b7405f79 --- /dev/null +++ b/src/test/run-make/include_bytes_deps/input.md @@ -0,0 +1 @@ +# Hello, world! diff --git a/src/test/run-make/include_bytes_deps/main.rs b/src/test/run-make/include_bytes_deps/main.rs index 579b2a452a11..27ca1a46a500 100644 --- a/src/test/run-make/include_bytes_deps/main.rs +++ b/src/test/run-make/include_bytes_deps/main.rs @@ -8,6 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(external_doc)] + +#[doc(include="input.md")] +pub struct SomeStruct; + pub fn main() { const INPUT_TXT: &'static str = include_str!("input.txt"); const INPUT_BIN: &'static [u8] = include_bytes!("input.bin");