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.
This commit is contained in:
commit
7ebd81377d
4 changed files with 55 additions and 30 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue