From d6023948275b3cef0b8320864595d24ad959c0e3 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 21 Feb 2024 14:51:59 +1100 Subject: Change message type in bug functions. From `impl Into` to `impl Into>`. Because these functions don't produce user-facing output and we don't want their strings to be translated. --- compiler/rustc_errors/src/lib.rs | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'compiler/rustc_errors') diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 0a6d66f52da..0f5757a2e9b 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1076,32 +1076,36 @@ impl DiagCtxt { // Functions beginning with `struct_`/`create_` create a diagnostic. Other // functions create and emit a diagnostic all in one go. impl DiagCtxt { - // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. + // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't + // user-facing. #[track_caller] - pub fn struct_bug(&self, msg: impl Into) -> Diag<'_, BugAbort> { - Diag::new(self, Bug, msg) + pub fn struct_bug(&self, msg: impl Into>) -> Diag<'_, BugAbort> { + Diag::new(self, Bug, msg.into()) } - // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. + // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't + // user-facing. #[track_caller] - pub fn bug(&self, msg: impl Into) -> ! { + pub fn bug(&self, msg: impl Into>) -> ! { self.struct_bug(msg).emit() } - // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. + // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't + // user-facing. #[track_caller] pub fn struct_span_bug( &self, span: impl Into, - msg: impl Into, + msg: impl Into>, ) -> Diag<'_, BugAbort> { self.struct_bug(msg).with_span(span) } - // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. + // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't + // user-facing. #[track_caller] - pub fn span_bug(&self, span: impl Into, msg: impl Into) -> ! { - self.struct_span_bug(span, msg).emit() + pub fn span_bug(&self, span: impl Into, msg: impl Into>) -> ! { + self.struct_span_bug(span, msg.into()).emit() } #[track_caller] @@ -1215,24 +1219,28 @@ impl DiagCtxt { } /// Ensures that an error is printed. See `Level::DelayedBug`. - // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. + // + // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't + // user-facing. #[track_caller] - pub fn delayed_bug(&self, msg: impl Into) -> ErrorGuaranteed { - Diag::::new(self, DelayedBug, msg).emit() + pub fn delayed_bug(&self, msg: impl Into>) -> ErrorGuaranteed { + Diag::::new(self, DelayedBug, msg.into()).emit() } /// Ensures that an error is printed. See `Level::DelayedBug`. /// /// Note: this function used to be called `delay_span_bug`. It was renamed /// to match similar functions like `span_err`, `span_warn`, etc. - // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. + // + // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't + // user-facing. #[track_caller] pub fn span_delayed_bug( &self, sp: impl Into, - msg: impl Into, + msg: impl Into>, ) -> ErrorGuaranteed { - Diag::::new(self, DelayedBug, msg).with_span(sp).emit() + Diag::::new(self, DelayedBug, msg.into()).with_span(sp).emit() } #[rustc_lint_diagnostics] -- cgit 1.4.1-3-g733a5