Skip to content

Commit cbdab0e

Browse files
committed
internal: document overall approach to reload
1 parent 1182387 commit cbdab0e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

crates/rust-analyzer/src/reload.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
//! Project loading & configuration updates
1+
//! Project loading & configuration updates.
2+
//!
3+
//! This is quite tricky. The main problem is time and changes -- there's no
4+
//! fixed "project" rust-analyzer is working with, "current project" is itself
5+
//! mutable state. For example, when the user edits `Cargo.toml` by adding a new
6+
//! dependency, project model changes. What's more, switching project model is
7+
//! not instantaneous -- it takes time to run `cargo metadata` and (for proc
8+
//! macros) `cargo check`.
9+
//!
10+
//! The main guiding principle here is, as elsewhere in rust-analyzer, is
11+
//! robustness. We try not to assume that the project model exists or is
12+
//! correct. Instead, we try to provide a best-effort service. Even if the
13+
//! project is currently loading and we don't have a full project model, we
14+
//! still want to respond to various requests.
215
use std::{mem, sync::Arc};
316

417
use flycheck::{FlycheckConfig, FlycheckHandle};

0 commit comments

Comments
 (0)