Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/load-cargo/src/lib.rs')
-rw-r--r--crates/load-cargo/src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/load-cargo/src/lib.rs b/crates/load-cargo/src/lib.rs
index c8a157e88e..dc75abe7ad 100644
--- a/crates/load-cargo/src/lib.rs
+++ b/crates/load-cargo/src/lib.rs
@@ -540,6 +540,20 @@ impl ProcMacroExpander for Expander {
current_dir: String,
) -> Result<tt::TopSubtree, ProcMacroExpansionError> {
let mut cb = |req| match req {
+ SubRequest::LocalFileName { file_id } => {
+ let file = FileId::from_raw(file_id);
+ let source_root_id = db.file_source_root(file).source_root_id(db);
+ let source_root = db.source_root(source_root_id).source_root(db);
+
+ let name = source_root
+ .path_for_file(&file)
+ .and_then(|path| path.clone().into_abs_path())
+ .and_then(|path| {
+ path.as_path().file_name().map(|filename| filename.to_owned())
+ });
+
+ Ok(SubResponse::LocalFileNameResult { name })
+ }
SubRequest::SourceText { file_id, start, end } => {
let file = FileId::from_raw(file_id);
let text = db.file_text(file).text(db);