From 8a9db2545919f945ffbb215e4325917e0bfc5b3a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 Dec 2023 16:26:09 +1100 Subject: Remove more `Session` methods that duplicate `DiagCtxt` methods. --- compiler/rustc_session/src/output.rs | 2 +- compiler/rustc_session/src/session.rs | 24 +++++------------------- 2 files changed, 6 insertions(+), 20 deletions(-) (limited to 'compiler/rustc_session/src') diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index bffebd705ba..db976b30404 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -115,7 +115,7 @@ pub fn validate_crate_name(sess: &Session, s: Symbol, sp: Option) { } if err_count > 0 { - sess.abort_if_errors(); + sess.dcx().abort_if_errors(); } } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index ec6e8684b29..53dd48ea272 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -279,7 +279,7 @@ impl Session { }); // If we should err, make sure we did. - if must_err && self.has_errors().is_none() { + if must_err && self.dcx().has_errors().is_none() { // We have skipped a feature gate, and not run into other errors... reject. self.dcx().emit_err(errors::NotCircumventFeature); } @@ -323,22 +323,7 @@ impl Session { add_feature_diagnostics(&mut err, &self.parse_sess, feature); err } - #[inline] - pub fn err_count(&self) -> usize { - self.dcx().err_count() - } - pub fn has_errors(&self) -> Option { - self.dcx().has_errors() - } - pub fn has_errors_or_span_delayed_bugs(&self) -> Option { - self.dcx().has_errors_or_span_delayed_bugs() - } - pub fn is_compilation_going_to_fail(&self) -> Option { - self.dcx().is_compilation_going_to_fail() - } - pub fn abort_if_errors(&self) { - self.dcx().abort_if_errors(); - } + pub fn compile_status(&self) -> Result<(), ErrorGuaranteed> { if let Some(reported) = self.dcx().has_errors_or_lint_errors() { let _ = self.dcx().emit_stashed_diagnostics(); @@ -347,14 +332,15 @@ impl Session { Ok(()) } } + // FIXME(matthewjasper) Remove this method, it should never be needed. pub fn track_errors(&self, f: F) -> Result where F: FnOnce() -> T, { - let old_count = self.err_count(); + let old_count = self.dcx().err_count(); let result = f(); - if self.err_count() == old_count { + if self.dcx().err_count() == old_count { Ok(result) } else { Err(self.dcx().span_delayed_bug( -- cgit 1.4.1-3-g733a5