deprecate unchecked_claim_error_was_emitted in error_reported

This commit is contained in:
yukang 2022-11-04 10:02:54 +08:00
parent 1f21b96dce
commit 465ac26405

View File

@ -97,7 +97,11 @@ fn references_error(&self) -> bool {
}
fn error_reported(&self) -> Result<(), ErrorGuaranteed> {
if self.references_error() {
Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
if let Some(reported) = ty::tls::with(|tcx| tcx.sess.has_errors()) {
Err(reported)
} else {
bug!("expect tcx.sess.has_errors return true");
}
} else {
Ok(())
}