Skip to content

Commit 11234e2

Browse files
committed
UPDATE - rename DiagnosticHandler trait to IntoDiagnostic
1 parent 5ea97aa commit 11234e2

File tree

20 files changed

+55
-55
lines changed

20 files changed

+55
-55
lines changed

compiler/rustc_attr/src/session_diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::num::IntErrorKind;
22

33
use rustc_ast as ast;
44
use rustc_errors::{
5-
error_code, fluent, Applicability, DiagnosticBuilder, DiagnosticHandler, ErrorGuaranteed,
5+
error_code, fluent, Applicability, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed,
66
Handler,
77
};
88
use rustc_macros::DiagnosticHandler;
@@ -50,7 +50,7 @@ pub(crate) struct UnknownMetaItem<'a> {
5050
}
5151

5252
// Manual implementation to be able to format `expected` items correctly.
53-
impl<'a> DiagnosticHandler<'a> for UnknownMetaItem<'_> {
53+
impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> {
5454
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
5555
let expected = self.expected.iter().map(|name| format!("`{}`", name)).collect::<Vec<_>>();
5656
let mut diag = handler.struct_span_err_with_code(
@@ -209,7 +209,7 @@ pub(crate) struct UnsupportedLiteral {
209209
pub start_point_span: Span,
210210
}
211211

212-
impl<'a> DiagnosticHandler<'a> for UnsupportedLiteral {
212+
impl<'a> IntoDiagnostic<'a> for UnsupportedLiteral {
213213
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
214214
let mut diag = handler.struct_span_err_with_code(
215215
self.span,

compiler/rustc_error_messages/locales/en-US/lint.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ lint_non_existant_doc_keyword = found non-existing keyword `{$keyword}` used in
5151
.help = only existing keywords are allowed in core/std
5252
5353
lint_diag_out_of_impl =
54-
diagnostics should only be created in `DiagnosticHandler`/`AddSubdiagnostic` impls
54+
diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
5555
5656
lint_untranslatable_diag = diagnostics should be created using translatable messages
5757

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub enum DiagnosticArgValue<'source> {
3535
Number(usize),
3636
}
3737

38-
/// Converts a value of a type into a `DiagnosticArg` (typically a field of a `DiagnosticHandler`
38+
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
3939
/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type
4040
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
4141
/// crates to implement this.

compiler/rustc_errors/src/diagnostic_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::thread::panicking;
1717
/// `#[derive(DiagnosticHandler)]` -- see [rustc_macros::DiagnosticHandler].
1818
#[cfg_attr(bootstrap, rustc_diagnostic_item = "SessionDiagnostic")]
1919
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "DiagnosticHandler")]
20-
pub trait DiagnosticHandler<'a, T: EmissionGuarantee = ErrorGuaranteed> {
20+
pub trait IntoDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
2121
/// Write out as a diagnostic out of `Handler`.
2222
#[must_use]
2323
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, T>;

compiler/rustc_errors/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ mod snippet;
6161
mod styled_buffer;
6262
pub mod translation;
6363

64-
pub use diagnostic_builder::DiagnosticHandler;
64+
pub use diagnostic_builder::IntoDiagnostic;
6565
pub use snippet::Style;
6666

6767
pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorGuaranteed>>;
@@ -1067,36 +1067,36 @@ impl Handler {
10671067
self.inner.borrow_mut().emit_diagnostic(diagnostic)
10681068
}
10691069

1070-
pub fn emit_err<'a>(&'a self, err: impl DiagnosticHandler<'a>) -> ErrorGuaranteed {
1070+
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
10711071
self.create_err(err).emit()
10721072
}
10731073

10741074
pub fn create_err<'a>(
10751075
&'a self,
1076-
err: impl DiagnosticHandler<'a>,
1076+
err: impl IntoDiagnostic<'a>,
10771077
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
10781078
err.into_diagnostic(self)
10791079
}
10801080

10811081
pub fn create_warning<'a>(
10821082
&'a self,
1083-
warning: impl DiagnosticHandler<'a, ()>,
1083+
warning: impl IntoDiagnostic<'a, ()>,
10841084
) -> DiagnosticBuilder<'a, ()> {
10851085
warning.into_diagnostic(self)
10861086
}
10871087

1088-
pub fn emit_warning<'a>(&'a self, warning: impl DiagnosticHandler<'a, ()>) {
1088+
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
10891089
self.create_warning(warning).emit()
10901090
}
10911091

10921092
pub fn create_fatal<'a>(
10931093
&'a self,
1094-
fatal: impl DiagnosticHandler<'a, !>,
1094+
fatal: impl IntoDiagnostic<'a, !>,
10951095
) -> DiagnosticBuilder<'a, !> {
10961096
fatal.into_diagnostic(self)
10971097
}
10981098

1099-
pub fn emit_fatal<'a>(&'a self, fatal: impl DiagnosticHandler<'a, !>) -> ! {
1099+
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
11001100
self.create_fatal(fatal).emit()
11011101
}
11021102

compiler/rustc_expand/src/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_attr::{self as attr, Deprecation, Stability};
1111
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
1212
use rustc_data_structures::sync::{self, Lrc};
1313
use rustc_errors::{
14-
Applicability, DiagnosticBuilder, DiagnosticHandler, ErrorGuaranteed, MultiSpan, PResult,
14+
Applicability, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed, MultiSpan, PResult,
1515
};
1616
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
1717
use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics};
@@ -1104,12 +1104,12 @@ impl<'a> ExtCtxt<'a> {
11041104

11051105
pub fn create_err(
11061106
&self,
1107-
err: impl DiagnosticHandler<'a>,
1107+
err: impl IntoDiagnostic<'a>,
11081108
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
11091109
self.sess.create_err(err)
11101110
}
11111111

1112-
pub fn emit_err(&self, err: impl DiagnosticHandler<'a>) -> ErrorGuaranteed {
1112+
pub fn emit_err(&self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
11131113
self.sess.emit_err(err)
11141114
}
11151115

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::errors::{
44
};
55
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
66
use crate::infer::InferCtxt;
7-
use rustc_errors::DiagnosticHandler;
7+
use rustc_errors::IntoDiagnostic;
88
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, IntoDiagnosticArg};
99
use rustc_hir as hir;
1010
use rustc_hir::def::Res;

compiler/rustc_lint/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{fluent, AddSubdiagnostic, DiagnosticHandler, ErrorGuaranteed, Handler};
1+
use rustc_errors::{fluent, AddSubdiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
22
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
33
use rustc_session::lint::Level;
44
use rustc_span::{Span, Symbol};
@@ -119,7 +119,7 @@ pub struct CheckNameUnknown {
119119
pub sub: RequestedLevel,
120120
}
121121

122-
impl DiagnosticHandler<'_> for CheckNameUnknown {
122+
impl IntoDiagnostic<'_> for CheckNameUnknown {
123123
fn into_diagnostic(
124124
self,
125125
handler: &Handler,

compiler/rustc_macros/src/diagnostics/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
8282

8383
structure.gen_impl(quote! {
8484
gen impl<'__diagnostic_handler_sess, G>
85-
rustc_errors::DiagnosticHandler<'__diagnostic_handler_sess, G>
85+
rustc_errors::IntoDiagnostic<'__diagnostic_handler_sess, G>
8686
for @Self
8787
where G: rustc_errors::EmissionGuarantee
8888
{

compiler/rustc_metadata/src/errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
path::{Path, PathBuf},
44
};
55

6-
use rustc_errors::{error_code, DiagnosticHandler, ErrorGuaranteed};
6+
use rustc_errors::{error_code, IntoDiagnostic, ErrorGuaranteed};
77
use rustc_macros::DiagnosticHandler;
88
use rustc_session::config;
99
use rustc_span::{sym, Span, Symbol};
@@ -421,7 +421,7 @@ pub(crate) struct MultipleCandidates {
421421
pub candidates: Vec<PathBuf>,
422422
}
423423

424-
impl DiagnosticHandler<'_> for MultipleCandidates {
424+
impl IntoDiagnostic<'_> for MultipleCandidates {
425425
fn into_diagnostic(
426426
self,
427427
handler: &'_ rustc_errors::Handler,
@@ -537,7 +537,7 @@ pub struct InvalidMetadataFiles {
537537
pub crate_rejections: Vec<String>,
538538
}
539539

540-
impl DiagnosticHandler<'_> for InvalidMetadataFiles {
540+
impl IntoDiagnostic<'_> for InvalidMetadataFiles {
541541
fn into_diagnostic(
542542
self,
543543
handler: &'_ rustc_errors::Handler,
@@ -565,7 +565,7 @@ pub struct CannotFindCrate {
565565
pub locator_triple: TargetTriple,
566566
}
567567

568-
impl DiagnosticHandler<'_> for CannotFindCrate {
568+
impl IntoDiagnostic<'_> for CannotFindCrate {
569569
fn into_diagnostic(
570570
self,
571571
handler: &'_ rustc_errors::Handler,

0 commit comments

Comments
 (0)