diff options
| author | Jack Moffitt <jack@metajack.im> | 2013-11-27 20:05:12 -0700 |
|---|---|---|
| committer | Jack Moffitt <jack@metajack.im> | 2013-12-10 20:18:17 -0700 |
| commit | 5bd4d2ea7a75b915d70112731e815ed835a683e8 (patch) | |
| tree | 78ad1d01c75c818a587febc3696b4a4dd40333bd /src/libsyntax/ext | |
| parent | ac4dd9efee9248f4c3235460f3c93acc9932eb5a (diff) | |
| download | rust-5bd4d2ea7a75b915d70112731e815ed835a683e8.tar.gz rust-5bd4d2ea7a75b915d70112731e815ed835a683e8.zip | |
Fix missing code map entry for uses of `include_str!`.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index c0c5c6c6c07..2fcf6f1cad0 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -80,6 +80,7 @@ pub fn expand_mod(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) pub fn expand_include(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include!"); + // The file will be added to the code map by the parser let p = parse::new_sub_parser_from_file( cx.parse_sess(), cx.cfg(), &res_rel_file(cx, sp, &Path::new(file)), sp); @@ -99,7 +100,20 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) Ok(bytes) => bytes, }; match str::from_utf8_owned_opt(bytes) { - Some(s) => base::MRExpr(cx.expr_str(sp, s.to_managed())), + Some(s) => { + let s = s.to_managed(); + // Add this input file to the code map to make it available as + // dependency information + cx.parse_sess.cm.files.push(@codemap::FileMap { + name: file.display().to_str().to_managed(), + substr: codemap::FssNone, + src: s, + start_pos: codemap::BytePos(0), + lines: @mut ~[], + multibyte_chars: @mut ~[], + }); + base::MRExpr(cx.expr_str(sp, s)) + } None => { cx.span_fatal(sp, format!("{} wasn't a utf-8 file", file.display())); } |
