diff options
| author | bors <bors@rust-lang.org> | 2013-12-13 00:32:47 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-13 00:32:47 -0800 |
| commit | 9bbef13702561b955bc1fd71608502d3a10a4acc (patch) | |
| tree | 1ebb348561548fd71107547a85b4738e2ff35e54 /src/libsyntax/ext | |
| parent | 09bb3c0c4bb8d174b783d3bfd3c0cdf06b2fa013 (diff) | |
| parent | b2ccd4c3ec099b57fbcdb7dbc36cdb08c9016b4a (diff) | |
| download | rust-9bbef13702561b955bc1fd71608502d3a10a4acc.tar.gz rust-9bbef13702561b955bc1fd71608502d3a10a4acc.zip | |
auto merge of #10698 : metajack/rust/dep-info, r=alexcrichton
This isn't super useful for libraries yet without #10593. Fixes #7633.
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())); } |
