Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stageleft/src/rewrite_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl VisitMut for RewritePaths {
.chain(path_tail)
.cloned()
.collect();
} else if let Some(module_path) = &self.module_path {
} else {
let mut path_skip_count = 0;
let mut module_skip_end_count = 0;

Expand All @@ -34,6 +34,7 @@ impl VisitMut for RewritePaths {
}

if path_skip_count > 0 {
let module_path = self.module_path.as_ref().unwrap_or(&self.crate_root_path);
let path_tail = path.segments.iter().skip(path_skip_count);
path.segments = module_path
.segments
Expand Down
10 changes: 10 additions & 0 deletions stageleft_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ pub fn crate_paths<'a>(_ctx: BorrowBounds<'a>) -> impl Quoted<'a, bool> {
q!(crate::my_top_level_function())
}

#[stageleft::entry]
pub fn self_path_at_root<'a>(_ctx: BorrowBounds<'a>) -> impl Quoted<'a, bool> {
q!(self::my_top_level_function())
}

#[stageleft::entry]
fn captured_closure<'a>(_ctx: BorrowBounds<'a>) -> impl Quoted<'a, bool> {
let closure = q!(|| true);
Expand Down Expand Up @@ -114,6 +119,11 @@ mod tests {
assert!(crate_paths!());
}

#[test]
fn test_self_path_at_root() {
assert!(self_path_at_root!());
}

#[test]
fn test_local_paths() {
assert!(submodule::self_path!());
Expand Down
Loading