Skip to content

Commit d8571e0

Browse files
committed
Simplify
1 parent 733ef31 commit d8571e0

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

crates/ra_db/src/input.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,11 @@ impl Env {
337337
}
338338

339339
impl ExternSource {
340-
pub fn extern_path(&self, path: impl AsRef<Path>) -> Option<(ExternSourceId, RelativePathBuf)> {
341-
let path = path.as_ref();
340+
pub fn extern_path(&self, path: &Path) -> Option<(ExternSourceId, RelativePathBuf)> {
342341
self.extern_paths.iter().find_map(|(root_path, id)| {
343-
if let Ok(rel_path) = path.strip_prefix(root_path) {
344-
let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
345-
Some((*id, rel_path))
346-
} else {
347-
None
348-
}
342+
let rel_path = path.strip_prefix(root_path).ok()?;
343+
let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
344+
Some((*id, rel_path))
349345
})
350346
}
351347

crates/ra_db/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
158158
if std::path::Path::new(path).is_absolute() {
159159
let krate = *self.relevant_crates(anchor).get(0)?;
160160
let (extern_source_id, relative_file) =
161-
self.0.crate_graph()[krate].extern_source.extern_path(path)?;
161+
self.0.crate_graph()[krate].extern_source.extern_path(path.as_ref())?;
162162

163163
let source_root = self.0.source_root(SourceRootId(extern_source_id.0));
164164
source_root.file_by_relative_path(&relative_file)

0 commit comments

Comments
 (0)