diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-08-13 11:03:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-13 11:03:09 +0200 |
| commit | 7ebd81377db0e24f57be9c4f7aa84d2556931f1a (patch) | |
| tree | 20f8c61828289792c264a66dbfc9fdaf7c0cf2ba /src/libsyntax/ext | |
| parent | adbce60d6f131e5b3789f01417dedb05e4489898 (diff) | |
| parent | 6d736df76bb37e019728cea50a4902c23fb09e1b (diff) | |
| download | rust-7ebd81377db0e24f57be9c4f7aa84d2556931f1a.tar.gz rust-7ebd81377db0e24f57be9c4f7aa84d2556931f1a.zip | |
Rollup merge of #43782 - nrc:include, r=GuillaumeGomez
Fix include! in doc tests By making the path relative to the current file. Fixes #43153 [breaking-change] - if you use `include!` inside a doc test, you'll need to change the path to be relative to the current file rather than relative to the working directory.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index b293aa8de38..95fe41be122 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -193,13 +193,14 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Toke // resolve a file-system path to an absolute file-system path (if it // isn't already) fn res_rel_file(cx: &mut ExtCtxt, sp: syntax_pos::Span, arg: &Path) -> PathBuf { - // NB: relative paths are resolved relative to the compilation unit + // Relative paths are resolved relative to the file in which they are found + // after macro expansion (that is, they are unhygienic). if !arg.is_absolute() { let callsite = sp.source_callsite(); - let mut cu = PathBuf::from(&cx.codemap().span_to_filename(callsite)); - cu.pop(); - cu.push(arg); - cu + let mut path = PathBuf::from(&cx.codemap().span_to_filename(callsite)); + path.pop(); + path.push(arg); + path } else { arg.to_path_buf() } |
