-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(turbo-tasks): Move OutputContent from memory backend into tu…
…rbo-tasks, represent Empty as None (#69473) This is preparation for local tasks/cells in #69126. - Moves this into the `turbo-tasks` crate so that it can be used with local cells/outputs in #69126. - Remove the `Empty` state from the enum because the implementation in #69126 does not currently need that. This can still be represented using `None`.
- Loading branch information
Showing
4 changed files
with
56 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::{ | ||
borrow::Cow, | ||
fmt::{self, Display}, | ||
}; | ||
|
||
use anyhow::anyhow; | ||
|
||
use crate::{util::SharedError, RawVc}; | ||
|
||
/// A helper type representing the output of a resolved task. | ||
#[derive(Clone, Debug)] | ||
pub enum OutputContent { | ||
Link(RawVc), | ||
Error(SharedError), | ||
Panic(Option<Box<Cow<'static, str>>>), | ||
} | ||
|
||
impl OutputContent { | ||
pub fn as_read_result(&self) -> anyhow::Result<RawVc> { | ||
match &self { | ||
Self::Error(err) => Err(anyhow::Error::new(err.clone())), | ||
Self::Link(raw_vc) => Ok(*raw_vc), | ||
Self::Panic(Some(message)) => Err(anyhow!("A task panicked: {message}")), | ||
Self::Panic(None) => Err(anyhow!("A task panicked")), | ||
} | ||
} | ||
} | ||
|
||
impl Display for OutputContent { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Self::Link(raw_vc) => write!(f, "link {:?}", raw_vc), | ||
Self::Error(err) => write!(f, "error {}", err), | ||
Self::Panic(Some(message)) => write!(f, "panic {}", message), | ||
Self::Panic(None) => write!(f, "panic"), | ||
} | ||
} | ||
} |