Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs12
-rw-r--r--crates/rust-analyzer/src/global_state.rs8
-rw-r--r--crates/rust-analyzer/src/handlers/request.rs4
-rw-r--r--crates/vfs/src/lib.rs4
4 files changed, 14 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 186b65692e..b500db77d9 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -1075,12 +1075,12 @@ fn location_csv_pat(db: &RootDatabase, vfs: &Vfs, sm: &BodySourceMap, pat_id: Pa
format!("{path},{}:{},{}:{}", start.line + 1, start.col, end.line + 1, end.col)
}
-fn expr_syntax_range(
+fn expr_syntax_range<'a>(
db: &RootDatabase,
- vfs: &Vfs,
+ vfs: &'a Vfs,
sm: &BodySourceMap,
expr_id: ExprId,
-) -> Option<(VfsPath, LineCol, LineCol)> {
+) -> Option<(&'a VfsPath, LineCol, LineCol)> {
let src = sm.expr_syntax(expr_id);
if let Ok(src) = src {
let root = db.parse_or_expand(src.file_id);
@@ -1096,12 +1096,12 @@ fn expr_syntax_range(
None
}
}
-fn pat_syntax_range(
+fn pat_syntax_range<'a>(
db: &RootDatabase,
- vfs: &Vfs,
+ vfs: &'a Vfs,
sm: &BodySourceMap,
pat_id: PatId,
-) -> Option<(VfsPath, LineCol, LineCol)> {
+) -> Option<(&'a VfsPath, LineCol, LineCol)> {
let src = sm.pat_syntax(pat_id);
if let Ok(src) = src {
let root = db.parse_or_expand(src.file_id);
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index b2d507491b..9bcee6465a 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -297,7 +297,7 @@ impl GlobalState {
let mut bytes = vec![];
let mut modified_rust_files = vec![];
for file in changed_files {
- let vfs_path = &vfs.file_path(file.file_id);
+ let vfs_path = vfs.file_path(file.file_id);
if let Some(path) = vfs_path.as_path() {
let path = path.to_path_buf();
if reload::should_refresh_for_change(&path, file.kind()) {
@@ -481,7 +481,7 @@ impl GlobalStateSnapshot {
}
pub(crate) fn anchored_path(&self, path: &AnchoredPathBuf) -> Url {
- let mut base = self.vfs_read().file_path(path.anchor);
+ let mut base = self.vfs_read().file_path(path.anchor).clone();
base.pop();
let path = base.join(&path.path).unwrap();
let path = path.as_path().unwrap();
@@ -489,7 +489,7 @@ impl GlobalStateSnapshot {
}
pub(crate) fn file_id_to_file_path(&self, file_id: FileId) -> vfs::VfsPath {
- self.vfs_read().file_path(file_id)
+ self.vfs_read().file_path(file_id).clone()
}
pub(crate) fn cargo_target_for_crate_root(
@@ -497,7 +497,7 @@ impl GlobalStateSnapshot {
crate_id: CrateId,
) -> Option<(&CargoWorkspace, Target)> {
let file_id = self.analysis.crate_root(crate_id).ok()?;
- let path = self.vfs_read().file_path(file_id);
+ let path = self.vfs_read().file_path(file_id).clone();
let path = path.as_path()?;
self.workspaces.iter().find_map(|ws| match ws {
ProjectWorkspace::Cargo { cargo, .. } => {
diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs
index 04a0439542..0e005975fb 100644
--- a/crates/rust-analyzer/src/handlers/request.rs
+++ b/crates/rust-analyzer/src/handlers/request.rs
@@ -2097,7 +2097,7 @@ pub(crate) fn fetch_dependency_list(
.into_iter()
.filter_map(|it| {
let root_file_path = state.file_id_to_file_path(it.root_file_id);
- crate_path(root_file_path).and_then(to_url).map(|path| CrateInfoResult {
+ crate_path(&root_file_path).and_then(to_url).map(|path| CrateInfoResult {
name: it.name,
version: it.version,
path,
@@ -2118,7 +2118,7 @@ pub(crate) fn fetch_dependency_list(
/// An `Option` value representing the path to the directory of the crate with the given
/// name, if such a crate is found. If no crate with the given name is found, this function
/// returns `None`.
-fn crate_path(root_file_path: VfsPath) -> Option<VfsPath> {
+fn crate_path(root_file_path: &VfsPath) -> Option<VfsPath> {
let mut current_dir = root_file_path.parent();
while let Some(path) = current_dir {
let cargo_toml_path = path.join("../Cargo.toml")?;
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs
index 34a85818eb..824ce39870 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -163,8 +163,8 @@ impl Vfs {
/// # Panics
///
/// Panics if the id is not present in the `Vfs`.
- pub fn file_path(&self, file_id: FileId) -> VfsPath {
- self.interner.lookup(file_id).clone()
+ pub fn file_path(&self, file_id: FileId) -> &VfsPath {
+ self.interner.lookup(file_id)
}
/// Returns an iterator over the stored ids and their corresponding paths.