Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ pub(crate) struct FlycheckHandle {
sender: Sender<StateChange>,
_thread: stdx::thread::JoinHandle,
id: usize,
generation: AtomicUsize,
generation: Arc<AtomicUsize>,
}

impl FlycheckHandle {
pub(crate) fn spawn(
id: usize,
generation: DiagnosticsGeneration,
generation: Arc<AtomicUsize>,
sender: Sender<FlycheckMessage>,
config: FlycheckConfig,
sysroot_root: Option<AbsPathBuf>,
Expand All @@ -163,7 +163,7 @@ impl FlycheckHandle {
) -> FlycheckHandle {
let actor = FlycheckActor::new(
id,
generation,
generation.load(Ordering::Relaxed),
sender,
config,
sysroot_root,
Expand All @@ -176,7 +176,7 @@ impl FlycheckHandle {
stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker, format!("Flycheck{id}"))
.spawn(move || actor.run(receiver))
.expect("failed to spawn thread");
FlycheckHandle { id, generation: generation.into(), sender, _thread: thread }
FlycheckHandle { id, generation, sender, _thread: thread }
}

/// Schedule a re-start of the cargo check worker to do a workspace wide check.
Expand Down
7 changes: 4 additions & 3 deletions crates/rust-analyzer/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! project is currently loading and we don't have a full project model, we
//! still want to respond to various requests.
// FIXME: This is a mess that needs some untangling work
use std::{iter, mem};
use std::{iter, mem, sync::atomic::AtomicUsize};

use hir::{ChangeWithProcMacros, ProcMacrosBuilder, db::DefDatabase};
use ide_db::{
Expand Down Expand Up @@ -866,12 +866,13 @@ impl GlobalState {
let invocation_strategy = config.invocation_strategy();
let next_gen =
self.flycheck.iter().map(FlycheckHandle::generation).max().unwrap_or_default() + 1;
let generation = Arc::new(AtomicUsize::new(next_gen));

self.flycheck = match invocation_strategy {
crate::flycheck::InvocationStrategy::Once => {
vec![FlycheckHandle::spawn(
0,
next_gen,
generation.clone(),
sender.clone(),
config,
None,
Expand Down Expand Up @@ -915,7 +916,7 @@ impl GlobalState {
.map(|(id, (root, manifest_path, target_dir), sysroot_root)| {
FlycheckHandle::spawn(
id,
next_gen,
generation.clone(),
sender.clone(),
config.clone(),
sysroot_root,
Expand Down