internal: Use Cancellable in favor of Result for clarity

This commit is contained in:
Lukas Wirth
2022-11-07 17:21:37 +01:00
parent 6a06f6f724
commit fa70b0a86e
6 changed files with 44 additions and 43 deletions

View File

@@ -3,11 +3,11 @@
use std::mem;
use cfg::{CfgAtom, CfgExpr};
use ide::{FileId, RunnableKind, TestId};
use ide::{Cancellable, FileId, RunnableKind, TestId};
use project_model::{self, CargoFeatures, ManifestPath, TargetKind};
use vfs::AbsPathBuf;
use crate::{global_state::GlobalStateSnapshot, Result};
use crate::global_state::GlobalStateSnapshot;
/// Abstract representation of Cargo target.
///
@@ -29,7 +29,7 @@ impl CargoTargetSpec {
spec: Option<CargoTargetSpec>,
kind: &RunnableKind,
cfg: &Option<CfgExpr>,
) -> Result<(Vec<String>, Vec<String>)> {
) -> (Vec<String>, Vec<String>) {
let mut args = Vec::new();
let mut extra_args = Vec::new();
@@ -111,13 +111,13 @@ impl CargoTargetSpec {
}
}
}
Ok((args, extra_args))
(args, extra_args)
}
pub(crate) fn for_file(
global_state_snapshot: &GlobalStateSnapshot,
file_id: FileId,
) -> Result<Option<CargoTargetSpec>> {
) -> Cancellable<Option<CargoTargetSpec>> {
let crate_id = match &*global_state_snapshot.analysis.crates_for(file_id)? {
&[crate_id, ..] => crate_id,
_ => return Ok(None),