From 465ac26405d32cc1dd73460fa465c9303f40ea43 Mon Sep 17 00:00:00 2001 From: yukang Date: Fri, 4 Nov 2022 10:02:54 +0800 Subject: [PATCH] deprecate unchecked_claim_error_was_emitted in error_reported --- compiler/rustc_middle/src/ty/visit.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/visit.rs b/compiler/rustc_middle/src/ty/visit.rs index f0e9f990a81..5e366ef703f 100644 --- a/compiler/rustc_middle/src/ty/visit.rs +++ b/compiler/rustc_middle/src/ty/visit.rs @@ -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(()) }