Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(turbopack-swc-utils): Don't panic if issues aren't emitted, use #[must_use] annotation #74906

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
19 changes: 1 addition & 18 deletions turbopack/crates/turbopack-swc-utils/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use turbopack_core::{
source::Source,
};

#[must_use]
pub struct IssueCollector {
inner: Arc<Mutex<IssueCollectorInner>>,
}
Expand All @@ -22,10 +23,6 @@ impl IssueCollector {
pub async fn emit(self) -> Result<()> {
let issues = {
let mut inner = self.inner.lock();
if inner.emitted {
return Ok(());
}
inner.emitted = true;
take(&mut inner.emitted_issues)
};

Expand All @@ -43,18 +40,6 @@ impl IssueCollector {

struct IssueCollectorInner {
emitted_issues: Vec<Vc<AnalyzeIssue>>,
emitted: bool,
}

impl Drop for IssueCollectorInner {
fn drop(&mut self) {
if !self.emitted {
panic!(
"IssueCollector and IssueEmitter were dropped without calling \
`collector.emit().await?`"
);
}
}
}

pub struct IssueEmitter {
Expand All @@ -72,7 +57,6 @@ impl IssueEmitter {
) -> (Self, IssueCollector) {
let inner = Arc::new(Mutex::new(IssueCollectorInner {
emitted_issues: vec![],
emitted: false,
}));
(
Self {
Expand Down Expand Up @@ -144,7 +128,6 @@ impl Emitter for IssueEmitter {
);

let mut inner = self.inner.lock();
inner.emitted = false;
inner.emitted_issues.push(issue);
}
}
Loading