Some tidying up around include!
This commit is contained in:
parent
ba1d065ffa
commit
177cbe01be
@ -183,13 +183,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
|
// resolve a file-system path to an absolute file-system path (if it
|
||||||
// isn't already)
|
// isn't already)
|
||||||
fn res_rel_file(cx: &mut ExtCtxt, sp: syntax_pos::Span, arg: &Path) -> PathBuf {
|
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() {
|
if !arg.is_absolute() {
|
||||||
let callsite = sp.source_callsite();
|
let callsite = sp.source_callsite();
|
||||||
let mut cu = PathBuf::from(&cx.codemap().span_to_filename(callsite));
|
let mut path = PathBuf::from(&cx.codemap().span_to_filename(callsite));
|
||||||
cu.pop();
|
path.pop();
|
||||||
cu.push(arg);
|
path.push(arg);
|
||||||
cu
|
path
|
||||||
} else {
|
} else {
|
||||||
arg.to_path_buf()
|
arg.to_path_buf()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user