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,

compiler/rustc_monomorphize/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::path::PathBuf;
22

3-
use rustc_errors::DiagnosticHandler;
3+
use rustc_errors::IntoDiagnostic;
44
use rustc_errors::ErrorGuaranteed;
55
use rustc_macros::{DiagnosticHandler, LintDiagnostic};
66
use rustc_span::Span;
@@ -44,7 +44,7 @@ pub struct UnusedGenericParams {
4444
pub param_names: Vec<String>,
4545
}
4646

47-
impl DiagnosticHandler<'_> for UnusedGenericParams {
47+
impl IntoDiagnostic<'_> for UnusedGenericParams {
4848
fn into_diagnostic(
4949
self,
5050
handler: &'_ rustc_errors::Handler,

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty
3535
use rustc_ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
3636
use rustc_ast::{ClosureBinder, StmtKind};
3737
use rustc_ast_pretty::pprust;
38-
use rustc_errors::DiagnosticHandler;
38+
use rustc_errors::IntoDiagnostic;
3939
use rustc_errors::{Applicability, Diagnostic, PResult};
4040
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
4141
use rustc_session::lint::BuiltinLintDiagnostics;

compiler/rustc_query_system/src/query/job.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::query::{QueryContext, QueryStackFrame};
44

55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_errors::{
7-
Diagnostic, DiagnosticBuilder, DiagnosticHandler, ErrorGuaranteed, Handler, Level,
7+
Diagnostic, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed, Handler, Level,
88
};
99
use rustc_hir::def::DefKind;
1010
use rustc_session::Session;

compiler/rustc_session/src/parse.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
1111
use rustc_data_structures::sync::{Lock, Lrc};
1212
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
1313
use rustc_errors::{
14-
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticHandler,
14+
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, IntoDiagnostic,
1515
DiagnosticId, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, MultiSpan, StashKey,
1616
};
1717
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
@@ -340,34 +340,34 @@ impl ParseSess {
340340

341341
pub fn create_err<'a>(
342342
&'a self,
343-
err: impl DiagnosticHandler<'a>,
343+
err: impl IntoDiagnostic<'a>,
344344
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
345345
err.into_diagnostic(&self.span_diagnostic)
346346
}
347347

348-
pub fn emit_err<'a>(&'a self, err: impl DiagnosticHandler<'a>) -> ErrorGuaranteed {
348+
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
349349
self.create_err(err).emit()
350350
}
351351

352352
pub fn create_warning<'a>(
353353
&'a self,
354-
warning: impl DiagnosticHandler<'a, ()>,
354+
warning: impl IntoDiagnostic<'a, ()>,
355355
) -> DiagnosticBuilder<'a, ()> {
356356
warning.into_diagnostic(&self.span_diagnostic)
357357
}
358358

359-
pub fn emit_warning<'a>(&'a self, warning: impl DiagnosticHandler<'a, ()>) {
359+
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
360360
self.create_warning(warning).emit()
361361
}
362362

363363
pub fn create_fatal<'a>(
364364
&'a self,
365-
fatal: impl DiagnosticHandler<'a, !>,
365+
fatal: impl IntoDiagnostic<'a, !>,
366366
) -> DiagnosticBuilder<'a, !> {
367367
fatal.into_diagnostic(&self.span_diagnostic)
368368
}
369369

370-
pub fn emit_fatal<'a>(&'a self, fatal: impl DiagnosticHandler<'a, !>) -> ! {
370+
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
371371
self.create_fatal(fatal).emit()
372372
}
373373

compiler/rustc_session/src/session.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
2727
use rustc_errors::json::JsonEmitter;
2828
use rustc_errors::registry::Registry;
2929
use rustc_errors::{
30-
error_code, fallback_fluent_bundle, DiagnosticBuilder, DiagnosticHandler, DiagnosticId,
30+
error_code, fallback_fluent_bundle, DiagnosticBuilder, IntoDiagnostic, DiagnosticId,
3131
DiagnosticMessage, ErrorGuaranteed, FluentBundle, LazyFallbackBundle, MultiSpan,
3232
};
3333
use rustc_macros::HashStable_Generic;
@@ -461,13 +461,13 @@ impl Session {
461461
}
462462
pub fn create_err<'a>(
463463
&'a self,
464-
err: impl DiagnosticHandler<'a>,
464+
err: impl IntoDiagnostic<'a>,
465465
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
466466
self.parse_sess.create_err(err)
467467
}
468468
pub fn create_feature_err<'a>(
469469
&'a self,
470-
err: impl DiagnosticHandler<'a>,
470+
err: impl IntoDiagnostic<'a>,
471471
feature: Symbol,
472472
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
473473
let mut err = self.parse_sess.create_err(err);
@@ -477,25 +477,25 @@ impl Session {
477477
add_feature_diagnostics(&mut err, &self.parse_sess, feature);
478478
err
479479
}
480-
pub fn emit_err<'a>(&'a self, err: impl DiagnosticHandler<'a>) -> ErrorGuaranteed {
480+
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
481481
self.parse_sess.emit_err(err)
482482
}
483483
pub fn create_warning<'a>(
484484
&'a self,
485-
err: impl DiagnosticHandler<'a, ()>,
485+
err: impl IntoDiagnostic<'a, ()>,
486486
) -> DiagnosticBuilder<'a, ()> {
487487
self.parse_sess.create_warning(err)
488488
}
489-
pub fn emit_warning<'a>(&'a self, warning: impl DiagnosticHandler<'a, ()>) {
489+
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
490490
self.parse_sess.emit_warning(warning)
491491
}
492492
pub fn create_fatal<'a>(
493493
&'a self,
494-
fatal: impl DiagnosticHandler<'a, !>,
494+
fatal: impl IntoDiagnostic<'a, !>,
495495
) -> DiagnosticBuilder<'a, !> {
496496
self.parse_sess.create_fatal(fatal)
497497
}
498-
pub fn emit_fatal<'a>(&'a self, fatal: impl DiagnosticHandler<'a, !>) -> ! {
498+
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
499499
self.parse_sess.emit_fatal(fatal)
500500
}
501501
#[inline]

compiler/rustc_trait_selection/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, DiagnosticHandler, ErrorGuaranteed, Handler};
1+
use rustc_errors::{fluent, IntoDiagnostic, ErrorGuaranteed, Handler};
22
use rustc_macros::DiagnosticHandler;
33
use rustc_middle::ty::{PolyTraitRef, Ty, Unevaluated};
44
use rustc_session::Limit;
@@ -66,7 +66,7 @@ pub struct NegativePositiveConflict<'a> {
6666
pub positive_impl_span: Result<Span, Symbol>,
6767
}
6868

69-
impl DiagnosticHandler<'_> for NegativePositiveConflict<'_> {
69+
impl IntoDiagnostic<'_> for NegativePositiveConflict<'_> {
7070
fn into_diagnostic(
7171
self,
7272
handler: &Handler,

compiler/rustc_typeck/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Errors emitted by typeck.
2-
use rustc_errors::DiagnosticHandler;
2+
use rustc_errors::IntoDiagnostic;
33
use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler};
44
use rustc_macros::{DiagnosticHandler, LintDiagnostic, SessionSubdiagnostic};
55
use rustc_middle::ty::Ty;
@@ -250,7 +250,7 @@ pub struct MissingTypeParams {
250250
}
251251

252252
// Manual implementation of `DiagnosticHandler` to be able to call `span_to_snippet`.
253-
impl<'a> DiagnosticHandler<'a> for MissingTypeParams {
253+
impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
254254
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
255255
let mut err = handler.struct_span_err_with_code(
256256
self.span,

0 commit comments

Comments
 (0)