diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 3b2259d535..ef0531c36a 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -3850,7 +3850,7 @@ impl Project { let buffer = this .opened_buffers .get(&buffer_id) - .map(|buffer| buffer.upgrade(cx).unwrap()) + .and_then(|buffer| buffer.upgrade(cx)) .ok_or_else(|| anyhow!("unknown buffer id {}", buffer_id))?; Ok::<_, anyhow::Error>((project_id, buffer)) })?; @@ -3882,7 +3882,7 @@ impl Project { buffers.insert( this.opened_buffers .get(buffer_id) - .map(|buffer| buffer.upgrade(cx).unwrap()) + .and_then(|buffer| buffer.upgrade(cx)) .ok_or_else(|| anyhow!("unknown buffer id {}", buffer_id))?, ); } @@ -3911,7 +3911,7 @@ impl Project { buffers.insert( this.opened_buffers .get(buffer_id) - .map(|buffer| buffer.upgrade(cx).unwrap()) + .and_then(|buffer| buffer.upgrade(cx)) .ok_or_else(|| anyhow!("unknown buffer id {}", buffer_id))?, ); } @@ -3942,7 +3942,7 @@ impl Project { let buffer = this.read_with(&cx, |this, cx| { this.opened_buffers .get(&envelope.payload.buffer_id) - .map(|buffer| buffer.upgrade(cx).unwrap()) + .and_then(|buffer| buffer.upgrade(cx)) .ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id)) })?; buffer @@ -3972,7 +3972,7 @@ impl Project { let buffer = this .opened_buffers .get(&envelope.payload.buffer_id) - .map(|buffer| buffer.upgrade(cx).unwrap()) + .and_then(|buffer| buffer.upgrade(cx)) .ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id))?; let language = buffer.read(cx).language(); let completion = language::proto::deserialize_completion( @@ -4014,7 +4014,7 @@ impl Project { let buffer = this.update(&mut cx, |this, cx| { this.opened_buffers .get(&envelope.payload.buffer_id) - .map(|buffer| buffer.upgrade(cx).unwrap()) + .and_then(|buffer| buffer.upgrade(cx)) .ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id)) })?; buffer @@ -4055,7 +4055,7 @@ impl Project { let buffer = this .opened_buffers .get(&envelope.payload.buffer_id) - .map(|buffer| buffer.upgrade(cx).unwrap()) + .and_then(|buffer| buffer.upgrade(cx)) .ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id))?; Ok::<_, anyhow::Error>(this.apply_code_action(buffer, action, false, cx)) })?;