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.rs18
1 files changed, 4 insertions, 14 deletions
diff --git a/crates/load-cargo/src/lib.rs b/crates/load-cargo/src/lib.rs
index 023253f23f..4ffc8383b6 100644
--- a/crates/load-cargo/src/lib.rs
+++ b/crates/load-cargo/src/lib.rs
@@ -563,20 +563,10 @@ impl ProcMacroExpander for Expander {
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 path = source_root.path_for_file(&file);
-
- let name = path
- .and_then(|p| p.as_path())
- .and_then(|p| p.file_name())
- .map(|n| n.to_owned())
- .or_else(|| {
- path.and_then(|p| {
- p.name_and_extension().map(|(name, ext)| match ext {
- Some(ext) => format!("{name}.{ext}"),
- None => name.into(),
- })
- })
- })
+ let name = source_root
+ .path_for_file(&file)
+ .and_then(|path| path.as_path())
+ .and_then(|path| path.file_name().map(|filename| filename.to_owned()))
.unwrap_or_default();
Ok(SubResponse::FileNameResult { name })