mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Auto merge of #122132 - nnethercote:diag-renaming3, r=nnethercote
Diagnostic renaming 3 A sequel to https://github.com/rust-lang/rust/pull/121780. r? `@davidtwco`
This commit is contained in:
commit
cd81f5b27e
@ -1,10 +1,10 @@
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp,
|
||||
codes::*, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{symbol::Ident, Span, Symbol};
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
|
||||
pub struct GenericTypeWithParentheses {
|
||||
#[primary_span]
|
||||
@ -14,7 +14,7 @@ pub struct GenericTypeWithParentheses {
|
||||
pub sub: Option<UseAngleBrackets>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Subdiagnostic)]
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")]
|
||||
pub struct UseAngleBrackets {
|
||||
#[suggestion_part(code = "<")]
|
||||
@ -40,8 +40,8 @@ pub struct InvalidAbi {
|
||||
|
||||
pub struct InvalidAbiReason(pub &'static str);
|
||||
|
||||
impl AddToDiagnostic for InvalidAbiReason {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for InvalidAbiReason {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
@ -63,7 +63,7 @@ pub struct InvalidAbiSuggestion {
|
||||
pub suggestion: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_assoc_ty_parentheses)]
|
||||
pub struct AssocTyParentheses {
|
||||
#[primary_span]
|
||||
@ -72,7 +72,7 @@ pub struct AssocTyParentheses {
|
||||
pub sub: AssocTyParenthesesSub,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Subdiagnostic)]
|
||||
#[derive(Subdiagnostic)]
|
||||
pub enum AssocTyParenthesesSub {
|
||||
#[multipart_suggestion(ast_lowering_remove_parentheses)]
|
||||
Empty {
|
||||
@ -106,7 +106,7 @@ pub struct MisplacedAssocTyBinding {
|
||||
pub suggestion: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_underscore_expr_lhs_assign)]
|
||||
pub struct UnderscoreExprLhsAssign {
|
||||
#[primary_span]
|
||||
@ -114,7 +114,7 @@ pub struct UnderscoreExprLhsAssign {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_base_expression_double_dot, code = E0797)]
|
||||
pub struct BaseExpressionDoubleDot {
|
||||
#[primary_span]
|
||||
@ -122,7 +122,7 @@ pub struct BaseExpressionDoubleDot {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = E0728)]
|
||||
pub struct AwaitOnlyInAsyncFnAndBlocks {
|
||||
#[primary_span]
|
||||
@ -132,21 +132,21 @@ pub struct AwaitOnlyInAsyncFnAndBlocks {
|
||||
pub item_span: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_coroutine_too_many_parameters, code = E0628)]
|
||||
pub struct CoroutineTooManyParameters {
|
||||
#[primary_span]
|
||||
pub fn_decl_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_closure_cannot_be_static, code = E0697)]
|
||||
pub struct ClosureCannotBeStatic {
|
||||
#[primary_span]
|
||||
pub fn_decl_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
|
||||
pub struct FunctionalRecordUpdateDestructuringAssignment {
|
||||
#[primary_span]
|
||||
@ -154,28 +154,28 @@ pub struct FunctionalRecordUpdateDestructuringAssignment {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_async_coroutines_not_supported, code = E0727)]
|
||||
pub struct AsyncCoroutinesNotSupported {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_inline_asm_unsupported_target, code = E0472)]
|
||||
pub struct InlineAsmUnsupportedTarget {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_att_syntax_only_x86)]
|
||||
pub struct AttSyntaxOnlyX86 {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_abi_specified_multiple_times)]
|
||||
pub struct AbiSpecifiedMultipleTimes {
|
||||
#[primary_span]
|
||||
@ -187,7 +187,7 @@ pub struct AbiSpecifiedMultipleTimes {
|
||||
pub equivalent: Option<()>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_clobber_abi_not_supported)]
|
||||
pub struct ClobberAbiNotSupported {
|
||||
#[primary_span]
|
||||
@ -203,7 +203,7 @@ pub struct InvalidAbiClobberAbi {
|
||||
pub supported_abis: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_invalid_register)]
|
||||
pub struct InvalidRegister<'a> {
|
||||
#[primary_span]
|
||||
@ -212,7 +212,7 @@ pub struct InvalidRegister<'a> {
|
||||
pub error: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_invalid_register_class)]
|
||||
pub struct InvalidRegisterClass<'a> {
|
||||
#[primary_span]
|
||||
@ -241,7 +241,7 @@ pub enum InvalidAsmTemplateModifierRegClassSub {
|
||||
DoesNotSupportModifier { class_name: Symbol },
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_invalid_asm_template_modifier_const)]
|
||||
pub struct InvalidAsmTemplateModifierConst {
|
||||
#[primary_span]
|
||||
@ -251,7 +251,7 @@ pub struct InvalidAsmTemplateModifierConst {
|
||||
pub op_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_invalid_asm_template_modifier_sym)]
|
||||
pub struct InvalidAsmTemplateModifierSym {
|
||||
#[primary_span]
|
||||
@ -261,7 +261,7 @@ pub struct InvalidAsmTemplateModifierSym {
|
||||
pub op_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_invalid_asm_template_modifier_label)]
|
||||
pub struct InvalidAsmTemplateModifierLabel {
|
||||
#[primary_span]
|
||||
@ -271,7 +271,7 @@ pub struct InvalidAsmTemplateModifierLabel {
|
||||
pub op_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_register_class_only_clobber)]
|
||||
pub struct RegisterClassOnlyClobber {
|
||||
#[primary_span]
|
||||
@ -279,7 +279,7 @@ pub struct RegisterClassOnlyClobber {
|
||||
pub reg_class_name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_register_conflict)]
|
||||
pub struct RegisterConflict<'a> {
|
||||
#[primary_span]
|
||||
@ -293,7 +293,7 @@ pub struct RegisterConflict<'a> {
|
||||
pub in_out: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[help]
|
||||
#[diag(ast_lowering_sub_tuple_binding)]
|
||||
pub struct SubTupleBinding<'a> {
|
||||
@ -311,7 +311,7 @@ pub struct SubTupleBinding<'a> {
|
||||
pub ctx: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_extra_double_dot)]
|
||||
pub struct ExtraDoubleDot<'a> {
|
||||
#[primary_span]
|
||||
@ -322,7 +322,7 @@ pub struct ExtraDoubleDot<'a> {
|
||||
pub ctx: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[note]
|
||||
#[diag(ast_lowering_misplaced_double_dot)]
|
||||
pub struct MisplacedDoubleDot {
|
||||
@ -330,7 +330,7 @@ pub struct MisplacedDoubleDot {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_misplaced_relax_trait_bound)]
|
||||
pub struct MisplacedRelaxTraitBound {
|
||||
#[primary_span]
|
||||
@ -363,14 +363,14 @@ pub struct NeverPatternWithGuard {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_arbitrary_expression_in_pattern)]
|
||||
pub struct ArbitraryExpressionInPattern {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic, Clone, Copy)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_lowering_inclusive_range_with_no_end)]
|
||||
pub struct InclusiveRangeWithNoEnd {
|
||||
#[primary_span]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use rustc_ast::ParamKindOrd;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{symbol::Ident, Span, Symbol};
|
||||
@ -373,8 +373,8 @@ pub struct ArgsBeforeConstraint {
|
||||
pub struct EmptyLabelManySpans(pub Vec<Span>);
|
||||
|
||||
// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
|
||||
impl AddToDiagnostic for EmptyLabelManySpans {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for EmptyLabelManySpans {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
@ -742,8 +742,8 @@ pub struct StableFeature {
|
||||
pub since: Symbol,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for StableFeature {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for StableFeature {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -1,9 +1,7 @@
|
||||
use std::num::IntErrorKind;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_errors::{
|
||||
codes::*, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level,
|
||||
};
|
||||
use rustc_errors::{codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
||||
@ -50,8 +48,8 @@ pub(crate) struct UnknownMetaItem<'a> {
|
||||
}
|
||||
|
||||
// Manual implementation to be able to format `expected` items correctly.
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnknownMetaItem<'_> {
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnknownMetaItem<'_> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
||||
Diag::new(dcx, level, fluent::attr_unknown_meta_item)
|
||||
.with_span(self.span)
|
||||
@ -203,8 +201,8 @@ pub(crate) struct UnsupportedLiteral {
|
||||
pub start_point_span: Span,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnsupportedLiteral {
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
let mut diag = Diag::new(
|
||||
dcx,
|
||||
level,
|
||||
|
@ -191,9 +191,9 @@ impl Display for RegionName {
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for RegionName {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl rustc_errors::IntoDiagArg for RegionName {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level, MultiSpan,
|
||||
SingleLabelManySpans, SubdiagMessageOp,
|
||||
codes::*, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
||||
SingleLabelManySpans, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{symbol::Ident, Span, Symbol};
|
||||
@ -425,9 +425,9 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
|
||||
}
|
||||
|
||||
// Hand-written implementation to support custom user messages.
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefinedWithUserMessage {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for EnvNotDefinedWithUserMessage {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
#[expect(
|
||||
rustc::untranslatable_diagnostic,
|
||||
reason = "cannot translate user-provided messages"
|
||||
@ -589,8 +589,8 @@ pub(crate) struct FormatUnusedArg {
|
||||
|
||||
// Allow the singular form to be a subdiagnostic of the multiple-unused
|
||||
// form of diagnostic.
|
||||
impl AddToDiagnostic for FormatUnusedArg {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for FormatUnusedArg {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -785,8 +785,8 @@ pub(crate) struct AsmClobberNoReg {
|
||||
pub(crate) clobbers: Vec<Span>,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
// eager translation as `span_labels` takes `AsRef<str>`
|
||||
let lbl1 = dcx.eagerly_translate_to_string(
|
||||
crate::fluent_generated::builtin_macros_asm_clobber_abi,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
|
||||
use rustc_errors::{Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::Span;
|
||||
|
||||
@ -89,8 +89,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
|
||||
#[help(codegen_gcc_missing_features)]
|
||||
pub(crate) struct MissingFeatures;
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::codegen_gcc_target_feature_disable_or_enable);
|
||||
if let Some(span) = self.span {
|
||||
diag.span(span);
|
||||
|
@ -4,7 +4,7 @@ use std::path::Path;
|
||||
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
|
||||
use rustc_errors::{Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::Span;
|
||||
|
||||
@ -99,9 +99,9 @@ pub(crate) struct DynamicLinkingWithLTO;
|
||||
|
||||
pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ParseTargetMachineConfig<'_> {
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let diag: Diag<'_, G> = self.0.into_diagnostic(dcx, level);
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let diag: Diag<'_, G> = self.0.into_diag(dcx, level);
|
||||
let (message, _) = diag.messages.first().expect("`LlvmError` with no message");
|
||||
let message = dcx.eagerly_translate_to_string(message.clone(), diag.args.iter());
|
||||
Diag::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config)
|
||||
@ -119,8 +119,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
|
||||
#[help(codegen_llvm_missing_features)]
|
||||
pub(crate) struct MissingFeatures;
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::codegen_llvm_target_feature_disable_or_enable);
|
||||
if let Some(span) = self.span {
|
||||
diag.span(span);
|
||||
@ -179,8 +179,8 @@ pub enum LlvmError<'a> {
|
||||
|
||||
pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String);
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
use LlvmError::*;
|
||||
let msg_with_llvm_err = match &self.0 {
|
||||
WriteOutput { .. } => fluent::codegen_llvm_write_output_with_llvm_err,
|
||||
@ -198,7 +198,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
|
||||
ParseBitcode => fluent::codegen_llvm_parse_bitcode_with_llvm_err,
|
||||
};
|
||||
self.0
|
||||
.into_diagnostic(dcx, level)
|
||||
.into_diag(dcx, level)
|
||||
.with_primary_message(msg_with_llvm_err)
|
||||
.with_arg("llvm_err", self.1)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use crate::errors;
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_data_structures::unord::UnordSet;
|
||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@ -205,8 +205,8 @@ impl fmt::Display for CguReuse {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for CguReuse {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for CguReuse {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ use crate::assert_module_sources::CguReuse;
|
||||
use crate::back::command::Command;
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg,
|
||||
Level,
|
||||
codes::*, Diag, DiagArgValue, DiagCtxt, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
|
||||
};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_middle::ty::layout::LayoutError;
|
||||
@ -152,8 +151,8 @@ impl<'a> CopyPath<'a> {
|
||||
|
||||
struct DebugArgPath<'a>(pub &'a Path);
|
||||
|
||||
impl IntoDiagnosticArg for DebugArgPath<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for DebugArgPath<'_> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
|
||||
}
|
||||
}
|
||||
@ -215,8 +214,8 @@ pub enum LinkRlibError {
|
||||
|
||||
pub struct ThorinErrorWrapper(pub thorin::Error);
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
|
||||
fn into_diag(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let build = |msg| Diag::new(dcx, level, msg);
|
||||
match self.0 {
|
||||
thorin::Error::ReadInput(_) => build(fluent::codegen_ssa_thorin_read_input_failure),
|
||||
@ -348,8 +347,8 @@ pub struct LinkingFailed<'a> {
|
||||
pub escaped_output: String,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for LinkingFailed<'_> {
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
|
||||
fn into_diag(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::codegen_ssa_linking_failed);
|
||||
diag.arg("linker_path", format!("{}", self.linker_path.display()));
|
||||
diag.arg("exit_status", format!("{}", self.exit_status));
|
||||
@ -974,8 +973,8 @@ pub enum ExpectedPointerMutability {
|
||||
Not,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ExpectedPointerMutability {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for ExpectedPointerMutability {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
match self {
|
||||
ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")),
|
||||
ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")),
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::mem;
|
||||
|
||||
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, IntoDiagnostic, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, Diagnostic, IntoDiagArg};
|
||||
use rustc_hir::CRATE_HIR_ID;
|
||||
use rustc_middle::mir::AssertKind;
|
||||
use rustc_middle::query::TyCtxtAt;
|
||||
@ -40,10 +40,10 @@ impl MachineStopType for ConstEvalErrKind {
|
||||
RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {}
|
||||
AssertFailure(kind) => kind.add_args(adder),
|
||||
Panic { msg, line, col, file } => {
|
||||
adder("msg".into(), msg.into_diagnostic_arg());
|
||||
adder("file".into(), file.into_diagnostic_arg());
|
||||
adder("line".into(), line.into_diagnostic_arg());
|
||||
adder("col".into(), col.into_diagnostic_arg());
|
||||
adder("msg".into(), msg.into_diag_arg());
|
||||
adder("file".into(), file.into_diag_arg());
|
||||
adder("line".into(), line.into_diag_arg());
|
||||
adder("col".into(), col.into_diag_arg());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,7 @@ pub(super) fn report<'tcx, C, F, E>(
|
||||
where
|
||||
C: FnOnce() -> (Span, Vec<FrameNote>),
|
||||
F: FnOnce(Span, Vec<FrameNote>) -> E,
|
||||
E: IntoDiagnostic<'tcx>,
|
||||
E: Diagnostic<'tcx>,
|
||||
{
|
||||
// Special handling for certain errors
|
||||
match error {
|
||||
@ -168,7 +168,7 @@ pub(super) fn lint<'tcx, 'mir, L>(
|
||||
lint: &'static rustc_session::lint::Lint,
|
||||
decorator: impl FnOnce(Vec<errors::FrameNote>) -> L,
|
||||
) where
|
||||
L: for<'a> rustc_errors::DecorateLint<'a, ()>,
|
||||
L: for<'a> rustc_errors::LintDiagnostic<'a, ()>,
|
||||
{
|
||||
let (span, frames) = get_span_and_frames(tcx, machine);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use rustc_errors::{
|
||||
codes::*, Diag, DiagArgValue, DiagCtxt, DiagMessage, EmissionGuarantee, IntoDiagnostic, Level,
|
||||
codes::*, Diag, DiagArgValue, DiagCtxt, DiagMessage, Diagnostic, EmissionGuarantee, Level,
|
||||
};
|
||||
use rustc_hir::ConstContext;
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
@ -239,7 +239,7 @@ pub(crate) struct NonConstImplNote {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic, PartialEq, Eq, Clone)]
|
||||
#[derive(Subdiagnostic, Clone)]
|
||||
#[note(const_eval_frame_note)]
|
||||
pub struct FrameNote {
|
||||
#[primary_span]
|
||||
@ -858,8 +858,7 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
|
||||
InvalidProgramInfo::Layout(e) => {
|
||||
// The level doesn't matter, `dummy_diag` is consumed without it being used.
|
||||
let dummy_level = Level::Bug;
|
||||
let dummy_diag: Diag<'_, ()> =
|
||||
e.into_diagnostic().into_diagnostic(diag.dcx, dummy_level);
|
||||
let dummy_diag: Diag<'_, ()> = e.into_diagnostic().into_diag(diag.dcx, dummy_level);
|
||||
for (name, val) in dummy_diag.args.iter() {
|
||||
diag.arg(name.clone(), val.clone());
|
||||
}
|
||||
@ -887,8 +886,8 @@ impl ReportErrorExt for ResourceExhaustionInfo {
|
||||
fn add_args<G: EmissionGuarantee>(self, _: &mut Diag<'_, G>) {}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for InternKind {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl rustc_errors::IntoDiagArg for InternKind {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Borrowed(match self {
|
||||
InternKind::Static(Mutability::Not) => "static",
|
||||
InternKind::Static(Mutability::Mut) => "static_mut",
|
||||
|
@ -38,7 +38,7 @@ pub enum DiagArgValue {
|
||||
Str(Cow<'static, str>),
|
||||
// This gets converted to a `FluentNumber`, which is an `f64`. An `i32`
|
||||
// safely fits in an `f64`. Any integers bigger than that will be converted
|
||||
// to strings in `into_diagnostic_arg` and stored using the `Str` variant.
|
||||
// to strings in `into_diag_arg` and stored using the `Str` variant.
|
||||
Number(i32),
|
||||
StrListSepByAnd(Vec<Cow<'static, str>>),
|
||||
}
|
||||
@ -112,48 +112,48 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
||||
/// When implemented manually, it should be generic over the emission
|
||||
/// guarantee, i.e.:
|
||||
/// ```ignore (fragment)
|
||||
/// impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for Foo { ... }
|
||||
/// impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for Foo { ... }
|
||||
/// ```
|
||||
/// rather than being specific:
|
||||
/// ```ignore (fragment)
|
||||
/// impl<'a> IntoDiagnostic<'a> for Bar { ... } // the default type param is `ErrorGuaranteed`
|
||||
/// impl<'a> IntoDiagnostic<'a, ()> for Baz { ... }
|
||||
/// impl<'a> Diagnostic<'a> for Bar { ... } // the default type param is `ErrorGuaranteed`
|
||||
/// impl<'a> Diagnostic<'a, ()> for Baz { ... }
|
||||
/// ```
|
||||
/// There are two reasons for this.
|
||||
/// - A diagnostic like `Foo` *could* be emitted at any level -- `level` is
|
||||
/// passed in to `into_diagnostic` from outside. Even if in practice it is
|
||||
/// passed in to `into_diag` from outside. Even if in practice it is
|
||||
/// always emitted at a single level, we let the diagnostic creation/emission
|
||||
/// site determine the level (by using `create_err`, `emit_warn`, etc.)
|
||||
/// rather than the `IntoDiagnostic` impl.
|
||||
/// rather than the `Diagnostic` impl.
|
||||
/// - Derived impls are always generic, and it's good for the hand-written
|
||||
/// impls to be consistent with them.
|
||||
#[rustc_diagnostic_item = "IntoDiagnostic"]
|
||||
pub trait IntoDiagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> {
|
||||
#[rustc_diagnostic_item = "Diagnostic"]
|
||||
pub trait Diagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> {
|
||||
/// Write out as a diagnostic out of `DiagCtxt`.
|
||||
#[must_use]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G>;
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G>;
|
||||
}
|
||||
|
||||
impl<'a, T, G> IntoDiagnostic<'a, G> for Spanned<T>
|
||||
impl<'a, T, G> Diagnostic<'a, G> for Spanned<T>
|
||||
where
|
||||
T: IntoDiagnostic<'a, G>,
|
||||
T: Diagnostic<'a, G>,
|
||||
G: EmissionGuarantee,
|
||||
{
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
self.node.into_diagnostic(dcx, level).with_span(self.span)
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
self.node.into_diag(dcx, level).with_span(self.span)
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts a value of a type into a `DiagArg` (typically a field of an `IntoDiagnostic` struct).
|
||||
/// Converts a value of a type into a `DiagArg` (typically a field of an `Diag` struct).
|
||||
/// Implemented as a custom trait rather than `From` so that it is implemented on the type being
|
||||
/// converted rather than on `DiagArgValue`, which enables types from other `rustc_*` crates to
|
||||
/// implement this.
|
||||
pub trait IntoDiagnosticArg {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue;
|
||||
pub trait IntoDiagArg {
|
||||
fn into_diag_arg(self) -> DiagArgValue;
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for DiagArgValue {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for DiagArgValue {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self
|
||||
}
|
||||
}
|
||||
@ -170,19 +170,19 @@ impl Into<FluentValue<'static>> for DiagArgValue {
|
||||
|
||||
/// Trait implemented by error types. This should not be implemented manually. Instead, use
|
||||
/// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
|
||||
#[rustc_diagnostic_item = "AddToDiagnostic"]
|
||||
pub trait AddToDiagnostic
|
||||
#[rustc_diagnostic_item = "Subdiagnostic"]
|
||||
pub trait Subdiagnostic
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
/// Add a subdiagnostic to an existing diagnostic.
|
||||
fn add_to_diagnostic<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
self.add_to_diagnostic_with(diag, |_, m| m);
|
||||
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
self.add_to_diag_with(diag, |_, m| m);
|
||||
}
|
||||
|
||||
/// Add a subdiagnostic to an existing diagnostic where `f` is invoked on every message used
|
||||
/// (to optionally perform eager translation).
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -193,8 +193,8 @@ pub trait SubdiagMessageOp<G> = Fn(&mut Diag<'_, G>, SubdiagMessage) -> SubdiagM
|
||||
|
||||
/// Trait implemented by lint types. This should not be implemented manually. Instead, use
|
||||
/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
|
||||
#[rustc_diagnostic_item = "DecorateLint"]
|
||||
pub trait DecorateLint<'a, G: EmissionGuarantee> {
|
||||
#[rustc_diagnostic_item = "LintDiagnostic"]
|
||||
pub trait LintDiagnostic<'a, G: EmissionGuarantee> {
|
||||
/// Decorate and emit a lint.
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>);
|
||||
|
||||
@ -419,8 +419,8 @@ impl DiagInner {
|
||||
self.children.push(sub);
|
||||
}
|
||||
|
||||
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagnosticArg) {
|
||||
self.args.insert(name.into(), arg.into_diagnostic_arg());
|
||||
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg) {
|
||||
self.args.insert(name.into(), arg.into_diag_arg());
|
||||
}
|
||||
|
||||
/// Fields used for Hash, and PartialEq trait.
|
||||
@ -482,7 +482,7 @@ pub struct Subdiag {
|
||||
/// - The `EmissionGuarantee`, which determines the type returned from `emit`.
|
||||
///
|
||||
/// Each constructed `Diag` must be consumed by a function such as `emit`,
|
||||
/// `cancel`, `delay_as_bug`, or `into_diagnostic`. A panic occurrs if a `Diag`
|
||||
/// `cancel`, `delay_as_bug`, or `into_diag`. A panic occurrs if a `Diag`
|
||||
/// is dropped without being consumed by one of these functions.
|
||||
///
|
||||
/// If there is some state in a downstream crate you would like to access in
|
||||
@ -1194,9 +1194,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn subdiagnostic(
|
||||
&mut self,
|
||||
dcx: &crate::DiagCtxt,
|
||||
subdiagnostic: impl AddToDiagnostic,
|
||||
subdiagnostic: impl Subdiagnostic,
|
||||
) -> &mut Self {
|
||||
subdiagnostic.add_to_diagnostic_with(self, |diag, msg| {
|
||||
subdiagnostic.add_to_diag_with(self, |diag, msg| {
|
||||
let args = diag.args.iter();
|
||||
let msg = diag.subdiagnostic_message_to_diagnostic_message(msg);
|
||||
dcx.eagerly_translate(msg, args)
|
||||
@ -1243,7 +1243,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn arg(
|
||||
&mut self,
|
||||
name: impl Into<DiagArgName>,
|
||||
arg: impl IntoDiagnosticArg,
|
||||
arg: impl IntoDiagArg,
|
||||
) -> &mut Self {
|
||||
self.deref_mut().arg(name, arg);
|
||||
self
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::diagnostic::DiagLocation;
|
||||
use crate::{fluent_generated as fluent, AddToDiagnostic};
|
||||
use crate::{fluent_generated as fluent, Subdiagnostic};
|
||||
use crate::{
|
||||
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, ErrCode, IntoDiagnostic, IntoDiagnosticArg,
|
||||
Level, SubdiagMessageOp,
|
||||
Diag, DiagArgValue, DiagCtxt, Diagnostic, EmissionGuarantee, ErrCode, IntoDiagArg, Level,
|
||||
SubdiagMessageOp,
|
||||
};
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast_pretty::pprust;
|
||||
@ -22,9 +22,9 @@ use std::process::ExitStatus;
|
||||
|
||||
pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display);
|
||||
|
||||
impl IntoDiagnosticArg for DiagArgFromDisplay<'_> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.0.to_string().into_diagnostic_arg()
|
||||
impl IntoDiagArg for DiagArgFromDisplay<'_> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.0.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,34 +40,34 @@ impl<'a, T: fmt::Display> From<&'a T> for DiagArgFromDisplay<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.clone().into_diagnostic_arg()
|
||||
impl<'a, T: Clone + IntoDiagArg> IntoDiagArg for &'a T {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.clone().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! into_diagnostic_arg_using_display {
|
||||
macro_rules! into_diag_arg_using_display {
|
||||
($( $ty:ty ),+ $(,)?) => {
|
||||
$(
|
||||
impl IntoDiagnosticArg for $ty {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl IntoDiagArg for $ty {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! into_diagnostic_arg_for_number {
|
||||
macro_rules! into_diag_arg_for_number {
|
||||
($( $ty:ty ),+ $(,)?) => {
|
||||
$(
|
||||
impl IntoDiagnosticArg for $ty {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for $ty {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
// Convert to a string if it won't fit into `Number`.
|
||||
if let Ok(n) = TryInto::<i32>::try_into(self) {
|
||||
DiagArgValue::Number(n)
|
||||
} else {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ macro_rules! into_diagnostic_arg_for_number {
|
||||
}
|
||||
}
|
||||
|
||||
into_diagnostic_arg_using_display!(
|
||||
into_diag_arg_using_display!(
|
||||
ast::ParamKindOrd,
|
||||
std::io::Error,
|
||||
Box<dyn std::error::Error>,
|
||||
@ -92,10 +92,10 @@ into_diagnostic_arg_using_display!(
|
||||
ErrCode,
|
||||
);
|
||||
|
||||
into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
|
||||
into_diag_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
|
||||
|
||||
impl IntoDiagnosticArg for bool {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for bool {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
if self {
|
||||
DiagArgValue::Str(Cow::Borrowed("true"))
|
||||
} else {
|
||||
@ -104,64 +104,64 @@ impl IntoDiagnosticArg for bool {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for char {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for char {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for Vec<char> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for Vec<char> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::StrListSepByAnd(
|
||||
self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for Symbol {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_ident_string().into_diagnostic_arg()
|
||||
impl IntoDiagArg for Symbol {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_ident_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnosticArg for &'a str {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'a> IntoDiagArg for &'a str {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for String {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for String {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnosticArg for Cow<'a, str> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl<'a> IntoDiagArg for Cow<'a, str> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self.into_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnosticArg for &'a Path {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl<'a> IntoDiagArg for &'a Path {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for PathBuf {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for PathBuf {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for PanicStrategy {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for PanicStrategy {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self.desc().to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for hir::ConstContext {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for hir::ConstContext {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Borrowed(match self {
|
||||
hir::ConstContext::ConstFn => "const_fn",
|
||||
hir::ConstContext::Static(_) => "static",
|
||||
@ -170,58 +170,58 @@ impl IntoDiagnosticArg for hir::ConstContext {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::Expr {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for ast::Expr {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::Path {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for ast::Path {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::token::Token {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for ast::token::Token {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(pprust::token_to_string(&self))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::token::TokenKind {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for ast::token::TokenKind {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(pprust::token_kind_to_string(&self))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for type_ir::FloatTy {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for type_ir::FloatTy {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Borrowed(self.name_str()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for std::ffi::CString {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for std::ffi::CString {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for rustc_data_structures::small_c_str::SmallCStr {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ast::Visibility {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for ast::Visibility {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
let s = pprust::vis_to_string(&self);
|
||||
let s = s.trim_end().to_string();
|
||||
DiagArgValue::Str(Cow::Owned(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for rustc_lint_defs::Level {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for rustc_lint_defs::Level {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
|
||||
}
|
||||
}
|
||||
@ -235,22 +235,22 @@ impl From<Vec<Symbol>> for DiagSymbolList {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for DiagSymbolList {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for DiagSymbolList {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::StrListSepByAnd(
|
||||
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl<Id> IntoDiagArg for hir::def::Res<Id> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Borrowed(self.descr()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetDataLayoutErrors<'_> {
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetDataLayoutErrors<'_> {
|
||||
fn into_diag(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
match self {
|
||||
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
||||
Diag::new(dcx, level, fluent::errors_target_invalid_address_space)
|
||||
@ -297,8 +297,8 @@ pub struct SingleLabelManySpans {
|
||||
pub spans: Vec<Span>,
|
||||
pub label: &'static str,
|
||||
}
|
||||
impl AddToDiagnostic for SingleLabelManySpans {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for SingleLabelManySpans {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
@ -315,20 +315,20 @@ pub struct ExpectedLifetimeParameter {
|
||||
pub count: usize,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for DiagLocation {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for DiagLocation {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::from(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for Backtrace {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for Backtrace {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::from(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for Level {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for Level {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::from(self.to_string()))
|
||||
}
|
||||
}
|
||||
@ -342,8 +342,8 @@ pub struct IndicateAnonymousLifetime {
|
||||
pub suggestion: String,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for type_ir::ClosureKind {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for type_ir::ClosureKind {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(self.as_str().into())
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ extern crate self as rustc_errors;
|
||||
|
||||
pub use codes::*;
|
||||
pub use diagnostic::{
|
||||
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue,
|
||||
DiagInner, DiagStyledString, EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg,
|
||||
StringPart, Subdiag, SubdiagMessageOp,
|
||||
BugAbort, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, DiagStyledString,
|
||||
Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, LintDiagnostic, StringPart, Subdiag,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
pub use diagnostic_impls::{
|
||||
DiagArgFromDisplay, DiagSymbolList, ExpectedLifetimeParameter, IndicateAnonymousLifetime,
|
||||
@ -1134,12 +1134,12 @@ impl DiagCtxt {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, BugAbort>) -> Diag<'a, BugAbort> {
|
||||
bug.into_diagnostic(self, Bug)
|
||||
pub fn create_bug<'a>(&'a self, bug: impl Diagnostic<'a, BugAbort>) -> Diag<'a, BugAbort> {
|
||||
bug.into_diag(self, Bug)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, BugAbort>) -> ! {
|
||||
pub fn emit_bug<'a>(&'a self, bug: impl Diagnostic<'a, BugAbort>) -> ! {
|
||||
self.create_bug(bug).emit()
|
||||
}
|
||||
|
||||
@ -1174,29 +1174,26 @@ impl DiagCtxt {
|
||||
#[track_caller]
|
||||
pub fn create_fatal<'a>(
|
||||
&'a self,
|
||||
fatal: impl IntoDiagnostic<'a, FatalAbort>,
|
||||
fatal: impl Diagnostic<'a, FatalAbort>,
|
||||
) -> Diag<'a, FatalAbort> {
|
||||
fatal.into_diagnostic(self, Fatal)
|
||||
fatal.into_diag(self, Fatal)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, FatalAbort>) -> ! {
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl Diagnostic<'a, FatalAbort>) -> ! {
|
||||
self.create_fatal(fatal).emit()
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_almost_fatal<'a>(
|
||||
&'a self,
|
||||
fatal: impl IntoDiagnostic<'a, FatalError>,
|
||||
fatal: impl Diagnostic<'a, FatalError>,
|
||||
) -> Diag<'a, FatalError> {
|
||||
fatal.into_diagnostic(self, Fatal)
|
||||
fatal.into_diag(self, Fatal)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_almost_fatal<'a>(
|
||||
&'a self,
|
||||
fatal: impl IntoDiagnostic<'a, FatalError>,
|
||||
) -> FatalError {
|
||||
pub fn emit_almost_fatal<'a>(&'a self, fatal: impl Diagnostic<'a, FatalError>) -> FatalError {
|
||||
self.create_almost_fatal(fatal).emit()
|
||||
}
|
||||
|
||||
@ -1234,12 +1231,12 @@ impl DiagCtxt {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> Diag<'a> {
|
||||
err.into_diagnostic(self, Error)
|
||||
pub fn create_err<'a>(&'a self, err: impl Diagnostic<'a>) -> Diag<'a> {
|
||||
err.into_diag(self, Error)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
|
||||
pub fn emit_err<'a>(&'a self, err: impl Diagnostic<'a>) -> ErrorGuaranteed {
|
||||
self.create_err(err).emit()
|
||||
}
|
||||
|
||||
@ -1297,12 +1294,12 @@ impl DiagCtxt {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) -> Diag<'a, ()> {
|
||||
warning.into_diagnostic(self, Warning)
|
||||
pub fn create_warn<'a>(&'a self, warning: impl Diagnostic<'a, ()>) -> Diag<'a, ()> {
|
||||
warning.into_diag(self, Warning)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
||||
pub fn emit_warn<'a>(&'a self, warning: impl Diagnostic<'a, ()>) {
|
||||
self.create_warn(warning).emit()
|
||||
}
|
||||
|
||||
@ -1335,12 +1332,12 @@ impl DiagCtxt {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>) -> Diag<'a, ()> {
|
||||
note.into_diagnostic(self, Note)
|
||||
pub fn create_note<'a>(&'a self, note: impl Diagnostic<'a, ()>) -> Diag<'a, ()> {
|
||||
note.into_diag(self, Note)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>) {
|
||||
pub fn emit_note<'a>(&'a self, note: impl Diagnostic<'a, ()>) {
|
||||
self.create_note(note).emit()
|
||||
}
|
||||
|
||||
|
@ -1510,7 +1510,7 @@ impl fmt::Display for ConstContext {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: `IntoDiagnosticArg` impl for `ConstContext` lives in `rustc_errors`
|
||||
// NOTE: `IntoDiagArg` impl for `ConstContext` lives in `rustc_errors`
|
||||
// due to a cyclical dependency between hir that crate.
|
||||
|
||||
/// A literal.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level, MultiSpan,
|
||||
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::Ty;
|
||||
@ -355,10 +355,10 @@ pub struct MissingTypeParams {
|
||||
pub empty_generic_args: bool,
|
||||
}
|
||||
|
||||
// Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`.
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for MissingTypeParams {
|
||||
// Manual implementation of `Diagnostic` to be able to call `span_to_snippet`.
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MissingTypeParams {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
let mut err = Diag::new(dcx, level, fluent::hir_analysis_missing_type_params);
|
||||
err.span(self.span);
|
||||
err.code(E0393);
|
||||
|
@ -3,8 +3,8 @@ use std::borrow::Cow;
|
||||
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee,
|
||||
IntoDiagnosticArg, MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagArgValue, EmissionGuarantee, IntoDiagArg, MultiSpan,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::Ty;
|
||||
@ -42,8 +42,8 @@ pub enum ReturnLikeStatementKind {
|
||||
Become,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ReturnLikeStatementKind {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for ReturnLikeStatementKind {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
let kind = match self {
|
||||
Self::Return => "return",
|
||||
Self::Become => "become",
|
||||
@ -194,8 +194,8 @@ pub struct TypeMismatchFruTypo {
|
||||
pub expr: Option<String>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for TypeMismatchFruTypo {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for TypeMismatchFruTypo {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -373,8 +373,8 @@ pub struct RemoveSemiForCoerce {
|
||||
pub semi: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for RemoveSemiForCoerce {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for RemoveSemiForCoerce {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -549,8 +549,8 @@ pub enum CastUnknownPointerSub {
|
||||
From(Span),
|
||||
}
|
||||
|
||||
impl rustc_errors::AddToDiagnostic for CastUnknownPointerSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl rustc_errors::Subdiagnostic for CastUnknownPointerSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
|
@ -26,8 +26,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_errors::{
|
||||
codes::*, pluralize, struct_span_code_err, AddToDiagnostic, Applicability, Diag,
|
||||
ErrorGuaranteed, StashKey,
|
||||
codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, StashKey,
|
||||
Subdiagnostic,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
@ -2600,7 +2600,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// We know by construction that `<expr>.await` is either on Rust 2015
|
||||
// or results in `ExprKind::Await`. Suggest switching the edition to 2018.
|
||||
err.note("to `.await` a `Future`, switch to Rust 2018 or later");
|
||||
HelpUseLatestEdition::new().add_to_diagnostic(&mut err);
|
||||
HelpUseLatestEdition::new().add_to_diag(&mut err);
|
||||
}
|
||||
|
||||
err.emit()
|
||||
|
@ -1,7 +1,7 @@
|
||||
use hir::GenericParamKind;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
|
||||
EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagMessage, DiagStyledString, EmissionGuarantee, IntoDiagArg,
|
||||
MultiSpan, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::FnRetTy;
|
||||
@ -224,8 +224,8 @@ pub enum RegionOriginNote<'a> {
|
||||
},
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for RegionOriginNote<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for RegionOriginNote<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -289,8 +289,8 @@ pub enum LifetimeMismatchLabels {
|
||||
},
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for LifetimeMismatchLabels {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for LifetimeMismatchLabels {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -337,8 +337,8 @@ pub struct AddLifetimeParamsSuggestion<'a> {
|
||||
pub add_note: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -439,8 +439,8 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
|
||||
pub binding_span: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
mut self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -537,11 +537,11 @@ pub enum TyOrSig<'tcx> {
|
||||
ClosureSig(Highlighted<'tcx, Binder<'tcx, FnSig<'tcx>>>),
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for TyOrSig<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for TyOrSig<'_> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
match self {
|
||||
TyOrSig::Ty(ty) => ty.into_diagnostic_arg(),
|
||||
TyOrSig::ClosureSig(sig) => sig.into_diagnostic_arg(),
|
||||
TyOrSig::Ty(ty) => ty.into_diag_arg(),
|
||||
TyOrSig::ClosureSig(sig) => sig.into_diag_arg(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -758,8 +758,8 @@ pub struct ConsiderBorrowingParamHelp {
|
||||
pub spans: Vec<Span>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for ConsiderBorrowingParamHelp {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for ConsiderBorrowingParamHelp {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -803,8 +803,8 @@ pub struct DynTraitConstraintSuggestion {
|
||||
pub ident: Ident,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for DynTraitConstraintSuggestion {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for DynTraitConstraintSuggestion {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -850,8 +850,8 @@ pub struct ReqIntroducedLocations {
|
||||
pub add_label: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for ReqIntroducedLocations {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for ReqIntroducedLocations {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
mut self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -873,8 +873,8 @@ pub struct MoreTargeted {
|
||||
pub ident: Symbol,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for MoreTargeted {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for MoreTargeted {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -1296,8 +1296,8 @@ pub struct SuggestTuplePatternMany {
|
||||
pub compatible_variants: Vec<String>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for SuggestTuplePatternMany {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for SuggestTuplePatternMany {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use crate::infer::error_reporting::nice_region_error::find_anon_type;
|
||||
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagnosticArg, SubdiagMessageOp};
|
||||
use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp, Subdiagnostic};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::{symbol::kw, Span};
|
||||
|
||||
@ -107,8 +107,8 @@ pub enum SuffixKind {
|
||||
ReqByBinding,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for PrefixKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for PrefixKind {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
let kind = match self {
|
||||
Self::Empty => "empty",
|
||||
Self::RefValidFor => "ref_valid_for",
|
||||
@ -129,8 +129,8 @@ impl IntoDiagnosticArg for PrefixKind {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for SuffixKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for SuffixKind {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
let kind = match self {
|
||||
Self::Empty => "empty",
|
||||
Self::Continues => "continues",
|
||||
@ -159,8 +159,8 @@ impl RegionExplanation<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for RegionExplanation<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for RegionExplanation<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
|
@ -61,7 +61,7 @@ use crate::traits::{
|
||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_errors::{
|
||||
codes::*, pluralize, struct_span_code_err, Applicability, Diag, DiagCtxt, DiagStyledString,
|
||||
ErrorGuaranteed, IntoDiagnosticArg,
|
||||
ErrorGuaranteed, IntoDiagArg,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
@ -2895,11 +2895,11 @@ impl<'tcx> ObligationCause<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Newtype to allow implementing IntoDiagnosticArg
|
||||
/// Newtype to allow implementing IntoDiagArg
|
||||
pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>);
|
||||
|
||||
impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for ObligationCauseAsDiagArg<'_> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
use crate::traits::ObligationCauseCode::*;
|
||||
let kind = match self.0.code() {
|
||||
CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat",
|
||||
|
@ -5,7 +5,7 @@ use crate::errors::{
|
||||
use crate::infer::error_reporting::TypeErrCtxt;
|
||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use crate::infer::InferCtxt;
|
||||
use rustc_errors::{codes::*, Diag, IntoDiagnosticArg};
|
||||
use rustc_errors::{codes::*, Diag, IntoDiagArg};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Namespace};
|
||||
@ -133,8 +133,8 @@ impl InferenceDiagnosticsParentData {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for UnderspecifiedArgKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for UnderspecifiedArgKind {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
let kind = match self {
|
||||
Self::Type { .. } => "type",
|
||||
Self::Const { is_parameter: true } => "const_with_param",
|
||||
|
@ -11,7 +11,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::SubregionOrigin;
|
||||
use crate::infer::TyCtxt;
|
||||
|
||||
use rustc_errors::AddToDiagnostic;
|
||||
use rustc_errors::Subdiagnostic;
|
||||
use rustc_errors::{Diag, ErrorGuaranteed};
|
||||
use rustc_hir::Ty;
|
||||
use rustc_middle::ty::Region;
|
||||
@ -145,5 +145,5 @@ pub fn suggest_adding_lifetime_params<'tcx>(
|
||||
err: &mut Diag<'_>,
|
||||
) {
|
||||
let suggestion = AddLifetimeParamsSuggestion { tcx, sub, ty_sup, ty_sub, add_note: false };
|
||||
suggestion.add_to_diagnostic(err);
|
||||
suggestion.add_to_diag(err);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use crate::infer::ValuePairs;
|
||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||
use crate::traits::{ObligationCause, ObligationCauseCode};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::{Diag, IntoDiagnosticArg};
|
||||
use rustc_errors::{Diag, IntoDiagArg};
|
||||
use rustc_hir::def::Namespace;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::error::ExpectedFound;
|
||||
@ -26,11 +26,11 @@ pub struct Highlighted<'tcx, T> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
impl<'tcx, T> IntoDiagnosticArg for Highlighted<'tcx, T>
|
||||
impl<'tcx, T> IntoDiagArg for Highlighted<'tcx, T>
|
||||
where
|
||||
T: for<'a> Print<'tcx, FmtPrinter<'a, 'tcx>>,
|
||||
{
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
rustc_errors::DiagArgValue::Str(self.to_string().into())
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::{AddToDiagnostic, Applicability, Diag, ErrorGuaranteed, MultiSpan};
|
||||
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, Subdiagnostic};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{walk_ty, Visitor};
|
||||
use rustc_hir::{
|
||||
@ -234,7 +234,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
if let (Some(ident), true) = (override_error_code, fn_returns.is_empty()) {
|
||||
// Provide a more targeted error code and description.
|
||||
let retarget_subdiag = MoreTargeted { ident };
|
||||
retarget_subdiag.add_to_diagnostic(&mut err);
|
||||
retarget_subdiag.add_to_diag(&mut err);
|
||||
}
|
||||
|
||||
let arg = match param.param.pat.simple_ident() {
|
||||
@ -532,7 +532,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
hir_v.visit_ty(self_ty);
|
||||
for &span in &traits {
|
||||
let subdiag = DynTraitConstraintSuggestion { span, ident };
|
||||
subdiag.add_to_diagnostic(err);
|
||||
subdiag.add_to_diag(err);
|
||||
suggested = true;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use crate::errors::{
|
||||
use crate::fluent_generated as fluent;
|
||||
use crate::infer::error_reporting::{note_and_explain_region, TypeErrCtxt};
|
||||
use crate::infer::{self, SubregionOrigin};
|
||||
use rustc_errors::{AddToDiagnostic, Diag};
|
||||
use rustc_errors::{Diag, Subdiagnostic};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::traits::ObligationCauseCode;
|
||||
use rustc_middle::ty::error::TypeError;
|
||||
@ -22,13 +22,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
requirement: ObligationCauseAsDiagArg(trace.cause.clone()),
|
||||
expected_found: self.values_str(trace.values).map(|(e, f, _)| (e, f)),
|
||||
}
|
||||
.add_to_diagnostic(err),
|
||||
.add_to_diag(err),
|
||||
infer::Reborrow(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_reborrow }.add_to_diagnostic(err)
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_reborrow }.add_to_diag(err)
|
||||
}
|
||||
infer::RelateObjectBound(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_object_bound }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::ReferenceOutlivesReferent(ty, span) => {
|
||||
RegionOriginNote::WithName {
|
||||
@ -37,7 +37,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
name: &self.ty_to_string(ty),
|
||||
continues: false,
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::RelateParamBound(span, ty, opt_span) => {
|
||||
RegionOriginNote::WithName {
|
||||
@ -46,19 +46,19 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
name: &self.ty_to_string(ty),
|
||||
continues: opt_span.is_some(),
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
if let Some(span) = opt_span {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_param_bound_2 }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
}
|
||||
infer::RelateRegionParamBound(span) => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_relate_region_param_bound }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::CompareImplItemObligation { span, .. } => {
|
||||
RegionOriginNote::Plain { span, msg: fluent::infer_compare_impl_item_obligation }
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
infer::CheckAssociatedTypeBounds { ref parent, .. } => {
|
||||
self.note_region_origin(err, parent);
|
||||
@ -68,7 +68,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
span,
|
||||
msg: fluent::infer_ascribe_user_type_prove_predicate,
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
.add_to_diag(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ lint_deprecated_lint_name =
|
||||
.help = change it to {$replace}
|
||||
|
||||
lint_diag_out_of_impl =
|
||||
diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
|
||||
diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
|
||||
lint_drop_glue =
|
||||
types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped
|
||||
|
@ -44,7 +44,7 @@ use rustc_ast::tokenstream::{TokenStream, TokenTree};
|
||||
use rustc_ast::visit::{FnCtxt, FnKind};
|
||||
use rustc_ast::{self as ast, *};
|
||||
use rustc_ast_pretty::pprust::{self, expr_to_string};
|
||||
use rustc_errors::{Applicability, DecorateLint, MultiSpan};
|
||||
use rustc_errors::{Applicability, LintDiagnostic, MultiSpan};
|
||||
use rustc_feature::{deprecated_attributes, AttributeGate, BuiltinAttribute, GateIssue, Stability};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
@ -327,7 +327,7 @@ impl UnsafeCode {
|
||||
&self,
|
||||
cx: &EarlyContext<'_>,
|
||||
span: Span,
|
||||
decorate: impl for<'a> DecorateLint<'a, ()>,
|
||||
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
||||
) {
|
||||
// This comes from a macro that has `#[allow_internal_unsafe]`.
|
||||
if span.allows_unsafe() {
|
||||
|
@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::sync;
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan};
|
||||
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
|
||||
use rustc_feature::Features;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
@ -563,13 +563,13 @@ pub trait LintContext {
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||
);
|
||||
|
||||
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
|
||||
/// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`,
|
||||
/// typically generated by `#[derive(LintDiagnostic)]`).
|
||||
fn emit_span_lint<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
span: S,
|
||||
decorator: impl for<'a> DecorateLint<'a, ()>,
|
||||
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
||||
) {
|
||||
self.opt_span_lint(lint, Some(span), decorator.msg(), |diag| {
|
||||
decorator.decorate_lint(diag);
|
||||
@ -590,9 +590,9 @@ pub trait LintContext {
|
||||
self.opt_span_lint(lint, Some(span), msg, decorate);
|
||||
}
|
||||
|
||||
/// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
|
||||
/// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically
|
||||
/// generated by `#[derive(LintDiagnostic)]`).
|
||||
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) {
|
||||
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> LintDiagnostic<'a, ()>) {
|
||||
self.opt_span_lint(lint, None as Option<Span>, decorator.msg(), |diag| {
|
||||
decorator.decorate_lint(diag);
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{codes::*, AddToDiagnostic, Diag, EmissionGuarantee, SubdiagMessageOp};
|
||||
use rustc_errors::{codes::*, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_session::lint::Level;
|
||||
use rustc_span::{Span, Symbol};
|
||||
@ -23,8 +23,8 @@ pub enum OverruledAttributeSub {
|
||||
CommandLineSource,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for OverruledAttributeSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for OverruledAttributeSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -351,15 +351,14 @@ declare_tool_lint! {
|
||||
|
||||
declare_tool_lint! {
|
||||
/// The `diagnostic_outside_of_impl` lint detects calls to functions annotated with
|
||||
/// `#[rustc_lint_diagnostics]` that are outside an `IntoDiagnostic`, `AddToDiagnostic`, or
|
||||
/// `DecorateLint` impl, or a `#[derive(Diagnostic)]`, `#[derive(Subdiagnostic)]`,
|
||||
/// `#[derive(DecorateLint)]` expansion.
|
||||
/// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `Subdiagnostic`, or
|
||||
/// `LintDiagnostic` impl (either hand-written or derived).
|
||||
///
|
||||
/// More details on diagnostics implementations can be found
|
||||
/// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html).
|
||||
pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL,
|
||||
Deny,
|
||||
"prevent creation of diagnostics outside of `IntoDiagnostic`/`AddToDiagnostic` impls",
|
||||
"prevent diagnostic creation outside of `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
@ -455,7 +454,7 @@ impl LateLintPass<'_> for Diagnostics {
|
||||
}
|
||||
|
||||
// Calls to `#[rustc_lint_diagnostics]`-marked functions should only occur:
|
||||
// - inside an impl of `IntoDiagnostic`, `AddToDiagnostic`, or `DecorateLint`, or
|
||||
// - inside an impl of `Diagnostic`, `Subdiagnostic`, or `LintDiagnostic`, or
|
||||
// - inside a parent function that is itself marked with `#[rustc_lint_diagnostics]`.
|
||||
//
|
||||
// Otherwise, emit a `DIAGNOSTIC_OUTSIDE_OF_IMPL` lint.
|
||||
@ -467,10 +466,7 @@ impl LateLintPass<'_> for Diagnostics {
|
||||
&& let Impl { of_trait: Some(of_trait), .. } = impl_
|
||||
&& let Some(def_id) = of_trait.trait_def_id()
|
||||
&& let Some(name) = cx.tcx.get_diagnostic_name(def_id)
|
||||
&& matches!(
|
||||
name,
|
||||
sym::IntoDiagnostic | sym::AddToDiagnostic | sym::DecorateLint
|
||||
)
|
||||
&& matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::LintDiagnostic)
|
||||
{
|
||||
is_inside_appropriate_impl = true;
|
||||
break;
|
||||
|
@ -16,7 +16,7 @@ use crate::{
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan};
|
||||
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
|
||||
use rustc_feature::{Features, GateIssue};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
@ -1119,7 +1119,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
span: MultiSpan,
|
||||
decorate: impl for<'a> DecorateLint<'a, ()>,
|
||||
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
||||
) {
|
||||
let (level, src) = self.lint_level(lint);
|
||||
lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| {
|
||||
@ -1128,7 +1128,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) {
|
||||
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) {
|
||||
let (level, src) = self.lint_level(lint);
|
||||
lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
|
||||
decorate.decorate_lint(lint);
|
||||
|
@ -5,8 +5,8 @@ use std::num::NonZero;
|
||||
use crate::errors::RequestedLevel;
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, DecorateLint, Diag, DiagMessage, DiagStyledString,
|
||||
EmissionGuarantee, SubdiagMessageOp, SuggestionStyle,
|
||||
codes::*, Applicability, Diag, DiagMessage, DiagStyledString, EmissionGuarantee,
|
||||
LintDiagnostic, SubdiagMessageOp, Subdiagnostic, SuggestionStyle,
|
||||
};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||
@ -136,7 +136,7 @@ pub struct BuiltinMissingDebugImpl<'a> {
|
||||
}
|
||||
|
||||
// Needed for def_path_str
|
||||
impl<'a> DecorateLint<'a, ()> for BuiltinMissingDebugImpl<'_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
||||
diag.arg("debug", self.tcx.def_path_str(self.def_id));
|
||||
}
|
||||
@ -241,7 +241,7 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
|
||||
pub session: &'a Session,
|
||||
}
|
||||
|
||||
impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.span_label(self.label, fluent::lint_label);
|
||||
rustc_session::parse::add_feature_diagnostics(
|
||||
@ -270,8 +270,8 @@ pub struct SuggestChangingAssocTypes<'a, 'b> {
|
||||
pub ty: &'a rustc_hir::Ty<'b>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> AddToDiagnostic for SuggestChangingAssocTypes<'a, 'b> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'a, 'b> Subdiagnostic for SuggestChangingAssocTypes<'a, 'b> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -326,8 +326,8 @@ pub struct BuiltinTypeAliasGenericBoundsSuggestion {
|
||||
pub suggestions: Vec<(Span, String)>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for BuiltinTypeAliasGenericBoundsSuggestion {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for BuiltinTypeAliasGenericBoundsSuggestion {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -423,7 +423,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> {
|
||||
pub tcx: TyCtxt<'a>,
|
||||
}
|
||||
|
||||
impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.arg("ty", self.ty);
|
||||
diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label);
|
||||
@ -434,7 +434,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
||||
fluent::lint_builtin_unpermitted_type_init_label_suggestion,
|
||||
);
|
||||
}
|
||||
self.sub.add_to_diagnostic(diag);
|
||||
self.sub.add_to_diag(diag);
|
||||
}
|
||||
|
||||
fn msg(&self) -> DiagMessage {
|
||||
@ -447,8 +447,8 @@ pub struct BuiltinUnpermittedTypeInitSub {
|
||||
pub err: InitError,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for BuiltinUnpermittedTypeInitSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for BuiltinUnpermittedTypeInitSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -502,8 +502,8 @@ pub struct BuiltinClashingExternSub<'a> {
|
||||
pub found: Ty<'a>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for BuiltinClashingExternSub<'_> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for BuiltinClashingExternSub<'_> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -784,8 +784,8 @@ pub struct HiddenUnicodeCodepointsDiagLabels {
|
||||
pub spans: Vec<(char, Span)>,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagLabels {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -802,8 +802,8 @@ pub enum HiddenUnicodeCodepointsDiagSub {
|
||||
}
|
||||
|
||||
// Used because of multiple multipart_suggestion and note
|
||||
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -950,8 +950,8 @@ pub struct NonBindingLetSub {
|
||||
pub is_assign_desugar: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for NonBindingLetSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for NonBindingLetSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -1159,7 +1159,7 @@ pub struct NonFmtPanicUnused {
|
||||
}
|
||||
|
||||
// Used because of two suggestions based on one Option<Span>
|
||||
impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
|
||||
impl<'a> LintDiagnostic<'a, ()> for NonFmtPanicUnused {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.arg("count", self.count);
|
||||
diag.note(fluent::lint_note);
|
||||
@ -1236,8 +1236,8 @@ pub enum NonSnakeCaseDiagSub {
|
||||
SuggestionAndNote { span: Span },
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for NonSnakeCaseDiagSub {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for NonSnakeCaseDiagSub {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -1397,7 +1397,7 @@ pub struct DropTraitConstraintsDiag<'a> {
|
||||
}
|
||||
|
||||
// Needed for def_path_str
|
||||
impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.arg("predicate", self.predicate);
|
||||
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
||||
@ -1414,7 +1414,7 @@ pub struct DropGlue<'a> {
|
||||
}
|
||||
|
||||
// Needed for def_path_str
|
||||
impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
||||
}
|
||||
@ -1478,8 +1478,8 @@ pub enum OverflowingBinHexSign {
|
||||
Negative,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for OverflowingBinHexSign {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for OverflowingBinHexSign {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -1689,7 +1689,7 @@ pub struct ImproperCTypes<'a> {
|
||||
}
|
||||
|
||||
// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
|
||||
impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.arg("ty", self.ty);
|
||||
diag.arg("desc", self.desc);
|
||||
@ -1832,7 +1832,7 @@ pub enum UnusedDefSuggestion {
|
||||
}
|
||||
|
||||
// Needed because of def_path_str
|
||||
impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for UnusedDef<'_, '_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.arg("pre", self.pre);
|
||||
diag.arg("post", self.post);
|
||||
@ -1915,7 +1915,7 @@ pub struct AsyncFnInTraitDiag {
|
||||
pub sugg: Option<Vec<(Span, String)>>,
|
||||
}
|
||||
|
||||
impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag {
|
||||
impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.note(fluent::lint_note);
|
||||
if let Some(sugg) = self.sugg {
|
||||
|
@ -10,7 +10,7 @@ use quote::quote;
|
||||
use syn::spanned::Spanned;
|
||||
use synstructure::Structure;
|
||||
|
||||
/// The central struct for constructing the `into_diagnostic` method from an annotated struct.
|
||||
/// The central struct for constructing the `into_diag` method from an annotated struct.
|
||||
pub(crate) struct DiagnosticDerive<'a> {
|
||||
structure: Structure<'a>,
|
||||
}
|
||||
@ -72,14 +72,11 @@ impl<'a> DiagnosticDerive<'a> {
|
||||
|
||||
// A lifetime of `'a` causes conflicts, but `_sess` is fine.
|
||||
let mut imp = structure.gen_impl(quote! {
|
||||
gen impl<'_sess, G>
|
||||
rustc_errors::IntoDiagnostic<'_sess, G>
|
||||
for @Self
|
||||
gen impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for @Self
|
||||
where G: rustc_errors::EmissionGuarantee
|
||||
{
|
||||
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
fn into_diag(
|
||||
self,
|
||||
dcx: &'_sess rustc_errors::DiagCtxt,
|
||||
level: rustc_errors::Level
|
||||
@ -156,7 +153,7 @@ impl<'a> LintDiagnosticDerive<'a> {
|
||||
});
|
||||
|
||||
let mut imp = structure.gen_impl(quote! {
|
||||
gen impl<'__a> rustc_errors::DecorateLint<'__a, ()> for @Self {
|
||||
gen impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for @Self {
|
||||
#[track_caller]
|
||||
fn decorate_lint<'__b>(
|
||||
self,
|
||||
|
@ -6,7 +6,7 @@ mod utils;
|
||||
|
||||
use diagnostic::{DiagnosticDerive, LintDiagnosticDerive};
|
||||
use proc_macro2::TokenStream;
|
||||
use subdiagnostic::SubdiagnosticDeriveBuilder;
|
||||
use subdiagnostic::SubdiagnosticDerive;
|
||||
use synstructure::Structure;
|
||||
|
||||
/// Implements `#[derive(Diagnostic)]`, which allows for errors to be specified as a struct,
|
||||
@ -55,7 +55,7 @@ use synstructure::Structure;
|
||||
///
|
||||
/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
|
||||
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
|
||||
pub fn session_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||
pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||
s.underscore_const(true);
|
||||
DiagnosticDerive::new(s).into_tokens()
|
||||
}
|
||||
@ -153,7 +153,7 @@ pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||
///
|
||||
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
|
||||
/// ```
|
||||
pub fn session_subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||
pub fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||
s.underscore_const(true);
|
||||
SubdiagnosticDeriveBuilder::new().into_tokens(s)
|
||||
SubdiagnosticDerive::new().into_tokens(s)
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ use synstructure::{BindingInfo, Structure, VariantInfo};
|
||||
|
||||
use super::utils::SubdiagnosticVariant;
|
||||
|
||||
/// The central struct for constructing the `add_to_diagnostic` method from an annotated struct.
|
||||
pub(crate) struct SubdiagnosticDeriveBuilder {
|
||||
/// The central struct for constructing the `add_to_diag` method from an annotated struct.
|
||||
pub(crate) struct SubdiagnosticDerive {
|
||||
diag: syn::Ident,
|
||||
f: syn::Ident,
|
||||
}
|
||||
|
||||
impl SubdiagnosticDeriveBuilder {
|
||||
impl SubdiagnosticDerive {
|
||||
pub(crate) fn new() -> Self {
|
||||
let diag = format_ident!("diag");
|
||||
let f = format_ident!("f");
|
||||
@ -86,8 +86,8 @@ impl SubdiagnosticDeriveBuilder {
|
||||
let diag = &self.diag;
|
||||
let f = &self.f;
|
||||
let ret = structure.gen_impl(quote! {
|
||||
gen impl rustc_errors::AddToDiagnostic for @Self {
|
||||
fn add_to_diagnostic_with<__G, __F>(
|
||||
gen impl rustc_errors::Subdiagnostic for @Self {
|
||||
fn add_to_diag_with<__G, __F>(
|
||||
self,
|
||||
#diag: &mut rustc_errors::Diag<'_, __G>,
|
||||
#f: __F
|
||||
@ -109,7 +109,7 @@ impl SubdiagnosticDeriveBuilder {
|
||||
/// double mut borrow later on.
|
||||
struct SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
||||
/// The identifier to use for the generated `Diag` instance.
|
||||
parent: &'parent SubdiagnosticDeriveBuilder,
|
||||
parent: &'parent SubdiagnosticDerive,
|
||||
|
||||
/// Info for the current variant (or the type if not an enum).
|
||||
variant: &'a VariantInfo<'a>,
|
||||
|
@ -118,7 +118,7 @@ decl_derive!(
|
||||
suggestion,
|
||||
suggestion_short,
|
||||
suggestion_hidden,
|
||||
suggestion_verbose)] => diagnostics::session_diagnostic_derive
|
||||
suggestion_verbose)] => diagnostics::diagnostic_derive
|
||||
);
|
||||
decl_derive!(
|
||||
[LintDiagnostic, attributes(
|
||||
@ -156,5 +156,5 @@ decl_derive!(
|
||||
skip_arg,
|
||||
primary_span,
|
||||
suggestion_part,
|
||||
applicability)] => diagnostics::session_subdiagnostic_derive
|
||||
applicability)] => diagnostics::subdiagnostic_derive
|
||||
);
|
||||
|
@ -3,7 +3,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use rustc_errors::{codes::*, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
|
||||
use rustc_errors::{codes::*, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_session::config;
|
||||
use rustc_span::{sym, Span, Symbol};
|
||||
@ -495,8 +495,8 @@ pub(crate) struct MultipleCandidates {
|
||||
pub candidates: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for MultipleCandidates {
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for MultipleCandidates {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::metadata_multiple_candidates);
|
||||
diag.arg("crate_name", self.crate_name);
|
||||
diag.arg("flavor", self.flavor);
|
||||
@ -593,9 +593,9 @@ pub struct InvalidMetadataFiles {
|
||||
pub crate_rejections: Vec<String>,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for InvalidMetadataFiles {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidMetadataFiles {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::metadata_invalid_meta_files);
|
||||
diag.arg("crate_name", self.crate_name);
|
||||
diag.arg("add_info", self.add_info);
|
||||
@ -622,9 +622,9 @@ pub struct CannotFindCrate {
|
||||
pub is_ui_testing: bool,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for CannotFindCrate {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::metadata_cannot_find_crate);
|
||||
diag.arg("crate_name", self.crate_name);
|
||||
diag.arg("current_crate", self.current_crate);
|
||||
|
@ -220,7 +220,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
use rustc_data_structures::owned_slice::slice_owned;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_fs_util::try_canonicalize;
|
||||
use rustc_session::config;
|
||||
use rustc_session::cstore::CrateSource;
|
||||
@ -290,8 +290,8 @@ impl fmt::Display for CrateFlavor {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for CrateFlavor {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for CrateFlavor {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
match self {
|
||||
CrateFlavor::Rlib => DiagArgValue::Str(Cow::Borrowed("rlib")),
|
||||
CrateFlavor::Rmeta => DiagArgValue::Str(Cow::Borrowed("rmeta")),
|
||||
|
@ -6,7 +6,7 @@ use crate::ty::{layout, tls, Ty, TyCtxt, ValTree};
|
||||
|
||||
use rustc_ast_ir::Mutability;
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_session::CtfeBacktrace;
|
||||
use rustc_span::{def_id::DefId, Span, DUMMY_SP};
|
||||
@ -234,8 +234,8 @@ pub enum InvalidMetaKind {
|
||||
TooBig,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for InvalidMetaKind {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for InvalidMetaKind {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Borrowed(match self {
|
||||
InvalidMetaKind::SliceTooBig => "slice_too_big",
|
||||
InvalidMetaKind::TooBig => "too_big",
|
||||
@ -266,10 +266,10 @@ pub struct Misalignment {
|
||||
pub required: Align,
|
||||
}
|
||||
|
||||
macro_rules! impl_into_diagnostic_arg_through_debug {
|
||||
macro_rules! impl_into_diag_arg_through_debug {
|
||||
($($ty:ty),*$(,)?) => {$(
|
||||
impl IntoDiagnosticArg for $ty {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for $ty {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
|
||||
}
|
||||
}
|
||||
@ -277,7 +277,7 @@ macro_rules! impl_into_diagnostic_arg_through_debug {
|
||||
}
|
||||
|
||||
// These types have nice `Debug` output so we can just use them in diagnostics.
|
||||
impl_into_diagnostic_arg_through_debug! {
|
||||
impl_into_diag_arg_through_debug! {
|
||||
AllocId,
|
||||
Pointer<AllocId>,
|
||||
AllocRange,
|
||||
@ -370,8 +370,8 @@ pub enum PointerKind {
|
||||
Box,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for PointerKind {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for PointerKind {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(
|
||||
match self {
|
||||
Self::Ref(_) => "ref",
|
||||
|
@ -100,7 +100,7 @@ macro_rules! err_ub_custom {
|
||||
msg: || $msg,
|
||||
add_args: Box::new(move |mut set_arg| {
|
||||
$($(
|
||||
set_arg(stringify!($name).into(), rustc_errors::IntoDiagnosticArg::into_diagnostic_arg($name));
|
||||
set_arg(stringify!($name).into(), rustc_errors::IntoDiagArg::into_diag_arg($name));
|
||||
)*)?
|
||||
})
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use crate::ty::{AdtDef, InstanceDef, UserTypeAnnotationIndex};
|
||||
use crate::ty::{GenericArg, GenericArgsRef};
|
||||
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
|
||||
use rustc_hir::def::{CtorKind, Namespace};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
||||
use rustc_hir::{self, CoroutineDesugaring, CoroutineKind, ImplicitSelfKind};
|
||||
|
@ -311,7 +311,7 @@ impl<O> AssertKind<O> {
|
||||
|
||||
macro_rules! add {
|
||||
($name: expr, $value: expr) => {
|
||||
adder($name.into(), $value.into_diagnostic_arg());
|
||||
adder($name.into(), $value.into_diag_arg());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html
|
||||
|
||||
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::RangeEnd;
|
||||
@ -676,9 +676,9 @@ impl<'tcx> Pat<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for Pat<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
format!("{self}").into_diagnostic_arg()
|
||||
impl<'tcx> IntoDiagArg for Pat<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
format!("{self}").into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
use rustc_apfloat::Float;
|
||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
use rustc_target::abi::Size;
|
||||
use std::fmt;
|
||||
@ -114,10 +114,10 @@ impl std::fmt::Debug for ConstInt {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ConstInt {
|
||||
impl IntoDiagArg for ConstInt {
|
||||
// FIXME this simply uses the Debug impl, but we could probably do better by converting both
|
||||
// to an inherent method that returns `Cow`.
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(format!("{self:?}").into())
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ pub struct UnevaluatedConst<'tcx> {
|
||||
pub args: GenericArgsRef<'tcx>,
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
format!("{self:?}").into_diagnostic_arg()
|
||||
impl rustc_errors::IntoDiagArg for UnevaluatedConst<'_> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
format!("{self:?}").into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, WorkerLocal}
|
||||
#[cfg(parallel_compiler)]
|
||||
use rustc_data_structures::sync::{DynSend, DynSync};
|
||||
use rustc_data_structures::unord::UnordSet;
|
||||
use rustc_errors::{DecorateLint, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, MultiSpan};
|
||||
use rustc_errors::{Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, LintDiagnostic, MultiSpan};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
@ -2129,7 +2129,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
T::collect_and_apply(iter, |xs| self.mk_bound_variable_kinds(xs))
|
||||
}
|
||||
|
||||
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
|
||||
/// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`,
|
||||
/// typically generated by `#[derive(LintDiagnostic)]`).
|
||||
#[track_caller]
|
||||
pub fn emit_node_span_lint(
|
||||
@ -2137,7 +2137,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
lint: &'static Lint,
|
||||
hir_id: HirId,
|
||||
span: impl Into<MultiSpan>,
|
||||
decorator: impl for<'a> DecorateLint<'a, ()>,
|
||||
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
||||
) {
|
||||
let msg = decorator.msg();
|
||||
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
||||
@ -2163,14 +2163,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate);
|
||||
}
|
||||
|
||||
/// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
|
||||
/// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically
|
||||
/// generated by `#[derive(LintDiagnostic)]`).
|
||||
#[track_caller]
|
||||
pub fn emit_node_lint(
|
||||
self,
|
||||
lint: &'static Lint,
|
||||
id: HirId,
|
||||
decorator: impl for<'a> DecorateLint<'a, ()>,
|
||||
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
||||
) {
|
||||
self.node_lint(lint, id, decorator.msg(), |diag| {
|
||||
decorator.decorate_lint(diag);
|
||||
|
@ -11,7 +11,7 @@ use crate::ty::{
|
||||
};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagnosticArg};
|
||||
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagArg};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -19,9 +19,9 @@ use rustc_hir::{PredicateOrigin, WherePredicate};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_type_ir::TyKind::*;
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> IntoDiagArg for Ty<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
|
||||
use rustc_ast_ir::visit::VisitorResult;
|
||||
use rustc_ast_ir::walk_visitable_list;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_serialize::{Decodable, Encodable};
|
||||
@ -57,9 +57,9 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where
|
||||
{
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> IntoDiagArg for GenericArg<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
|
||||
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_error_messages::DiagMessage;
|
||||
use rustc_errors::{
|
||||
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
|
||||
Diag, DiagArgValue, DiagCtxt, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -254,9 +254,9 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> IntoDiagArg for LayoutError<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1267,14 +1267,14 @@ pub enum FnAbiError<'tcx> {
|
||||
AdjustForForeignAbi(call::AdjustForForeignAbiError),
|
||||
}
|
||||
|
||||
impl<'a, 'b, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FnAbiError<'b> {
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
impl<'a, 'b, G: EmissionGuarantee> Diagnostic<'a, G> for FnAbiError<'b> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
match self {
|
||||
Self::Layout(e) => e.into_diagnostic().into_diagnostic(dcx, level),
|
||||
Self::Layout(e) => e.into_diagnostic().into_diag(dcx, level),
|
||||
Self::AdjustForForeignAbi(call::AdjustForForeignAbiError::Unsupported {
|
||||
arch,
|
||||
abi,
|
||||
}) => UnsupportedFnAbi { arch, abi: abi.name() }.into_diagnostic(dcx, level),
|
||||
}) => UnsupportedFnAbi { arch, abi: abi.name() }.into_diag(dcx, level),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_span::Span;
|
||||
@ -120,14 +120,14 @@ impl<'tcx> Predicate<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl rustc_errors::IntoDiagArg for Predicate<'_> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl rustc_errors::IntoDiagArg for Clause<'_> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||
}
|
||||
}
|
||||
@ -407,9 +407,9 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> IntoDiagArg for TraitRef<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,9 +453,9 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> IntoDiagArg for ExistentialTraitRef<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2722,9 +2722,9 @@ where
|
||||
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
|
||||
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
|
||||
|
||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> rustc_errors::IntoDiagArg for TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
@ -2739,9 +2739,9 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
|
||||
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
|
||||
pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>);
|
||||
|
||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> rustc_errors::IntoDiagArg for TraitRefPrintSugared<'tcx> {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
|
||||
use crate::ty::{List, ParamEnv};
|
||||
use hir::def::DefKind;
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_errors::{DiagArgValue, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan};
|
||||
use rustc_errors::{DiagArgValue, ErrorGuaranteed, IntoDiagArg, MultiSpan};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::LangItem;
|
||||
@ -1094,12 +1094,12 @@ impl<'tcx, T: IntoIterator> Binder<'tcx, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
|
||||
impl<'tcx, T> IntoDiagArg for Binder<'tcx, T>
|
||||
where
|
||||
T: IntoDiagnosticArg,
|
||||
T: IntoDiagArg,
|
||||
{
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.value.into_diagnostic_arg()
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.value.into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1307,9 +1307,9 @@ impl<'tcx> FnSig<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl<'tcx> IntoDiagArg for FnSig<'tcx> {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::DiagArgValue;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic,
|
||||
Level, MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
@ -419,8 +419,8 @@ pub struct UnsafeNotInheritedLintNote {
|
||||
pub body_span: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for UnsafeNotInheritedLintNote {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for UnsafeNotInheritedLintNote {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
@ -461,10 +461,8 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
|
||||
pub ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G>
|
||||
for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_>
|
||||
{
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag =
|
||||
Diag::new(dcx, level, fluent::mir_build_non_exhaustive_patterns_type_not_empty);
|
||||
diag.span(self.span);
|
||||
@ -867,8 +865,8 @@ pub struct Variant {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl<'tcx> AddToDiagnostic for AdtDefinedHere<'tcx> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'tcx> Subdiagnostic for AdtDefinedHere<'tcx> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use rustc_errors::{
|
||||
codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagMessage,
|
||||
EmissionGuarantee, IntoDiagnostic, Level,
|
||||
codes::*, Applicability, Diag, DiagArgValue, DiagCtxt, DiagMessage, Diagnostic,
|
||||
EmissionGuarantee, Level, LintDiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails};
|
||||
@ -62,9 +62,9 @@ pub(crate) struct RequiresUnsafe {
|
||||
// so we need to eagerly translate the label here, which isn't supported by the derive API
|
||||
// We could also exhaustively list out the primary messages for all unsafe violations,
|
||||
// but this would result in a lot of duplication.
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for RequiresUnsafe {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for RequiresUnsafe {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::mir_transform_requires_unsafe);
|
||||
diag.code(E0133);
|
||||
diag.span(self.span);
|
||||
@ -181,7 +181,7 @@ pub(crate) struct UnsafeOpInUnsafeFn {
|
||||
pub suggest_unsafe_block: Option<(Span, Span, Span)>,
|
||||
}
|
||||
|
||||
impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn {
|
||||
impl<'a> LintDiagnostic<'a, ()> for UnsafeOpInUnsafeFn {
|
||||
#[track_caller]
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
let desc = diag.dcx.eagerly_translate_to_string(self.details.label(), [].into_iter());
|
||||
@ -215,7 +215,7 @@ pub(crate) enum AssertLintKind {
|
||||
UnconditionalPanic,
|
||||
}
|
||||
|
||||
impl<'a, P: std::fmt::Debug> DecorateLint<'a, ()> for AssertLint<P> {
|
||||
impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint<P> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
let message = self.assert_kind.diagnostic_message();
|
||||
self.assert_kind.add_args(&mut |name, value| {
|
||||
@ -269,7 +269,7 @@ pub(crate) struct MustNotSupend<'tcx, 'a> {
|
||||
}
|
||||
|
||||
// Needed for def_path_str
|
||||
impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> {
|
||||
impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
||||
diag.span_label(self.yield_sp, fluent::_subdiag::label);
|
||||
if let Some(reason) = self.reason {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
|
||||
use rustc_errors::{Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic};
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
||||
@ -46,9 +46,9 @@ pub struct UnusedGenericParamsHint {
|
||||
pub param_names: Vec<String>,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for UnusedGenericParamsHint {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for UnusedGenericParamsHint {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::monomorphize_unused_generic_params);
|
||||
diag.span(self.span);
|
||||
for (span, name) in self.param_spans.into_iter().zip(self.param_names) {
|
||||
|
@ -3,8 +3,8 @@ use std::borrow::Cow;
|
||||
use rustc_ast::token::Token;
|
||||
use rustc_ast::{Path, Visibility};
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic,
|
||||
Level, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_session::errors::ExprParenthesesNeeded;
|
||||
@ -1065,9 +1065,9 @@ pub(crate) struct ExpectedIdentifier {
|
||||
pub help_cannot_start_number: Option<HelpIdentifierStartsWithNumber>,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedIdentifier {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
let token_descr = TokenDescription::from_token(&self.token);
|
||||
|
||||
let mut diag = Diag::new(
|
||||
@ -1093,17 +1093,17 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
|
||||
diag.arg("token", self.token);
|
||||
|
||||
if let Some(sugg) = self.suggest_raw {
|
||||
sugg.add_to_diagnostic(&mut diag);
|
||||
sugg.add_to_diag(&mut diag);
|
||||
}
|
||||
|
||||
ExpectedIdentifierFound::new(token_descr, self.span).add_to_diagnostic(&mut diag);
|
||||
ExpectedIdentifierFound::new(token_descr, self.span).add_to_diag(&mut diag);
|
||||
|
||||
if let Some(sugg) = self.suggest_remove_comma {
|
||||
sugg.add_to_diagnostic(&mut diag);
|
||||
sugg.add_to_diag(&mut diag);
|
||||
}
|
||||
|
||||
if let Some(help) = self.help_cannot_start_number {
|
||||
help.add_to_diagnostic(&mut diag);
|
||||
help.add_to_diag(&mut diag);
|
||||
}
|
||||
|
||||
diag
|
||||
@ -1125,9 +1125,9 @@ pub(crate) struct ExpectedSemi {
|
||||
pub sugg: ExpectedSemiSugg,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedSemi {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
let token_descr = TokenDescription::from_token(&self.token);
|
||||
|
||||
let mut diag = Diag::new(
|
||||
@ -1154,7 +1154,7 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi {
|
||||
diag.span_label(unexpected_token_label, fluent::parse_label_unexpected_token);
|
||||
}
|
||||
|
||||
self.sugg.add_to_diagnostic(&mut diag);
|
||||
self.sugg.add_to_diag(&mut diag);
|
||||
|
||||
diag
|
||||
}
|
||||
@ -1466,8 +1466,8 @@ pub(crate) struct FnTraitMissingParen {
|
||||
pub machine_applicable: bool,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for FnTraitMissingParen {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for FnTraitMissingParen {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -36,8 +36,8 @@ use rustc_ast::{
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{
|
||||
pluralize, AddToDiagnostic, Applicability, Diag, DiagCtxt, ErrorGuaranteed, FatalError, PErr,
|
||||
PResult,
|
||||
pluralize, Applicability, Diag, DiagCtxt, ErrorGuaranteed, FatalError, PErr, PResult,
|
||||
Subdiagnostic,
|
||||
};
|
||||
use rustc_session::errors::ExprParenthesesNeeded;
|
||||
use rustc_span::source_map::Spanned;
|
||||
@ -298,7 +298,7 @@ impl<'a> Parser<'a> {
|
||||
{
|
||||
recovered_ident = Some((ident, IdentIsRaw::Yes));
|
||||
|
||||
// `Symbol::to_string()` is different from `Symbol::into_diagnostic_arg()`,
|
||||
// `Symbol::to_string()` is different from `Symbol::into_diag_arg()`,
|
||||
// which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#`
|
||||
let ident_name = ident.name.to_string();
|
||||
|
||||
@ -1271,7 +1271,7 @@ impl<'a> Parser<'a> {
|
||||
Ok(_) => {
|
||||
if self.token == token::Eq {
|
||||
let sugg = SuggAddMissingLetStmt { span: prev_span };
|
||||
sugg.add_to_diagnostic(err);
|
||||
sugg.add_to_diag(err);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
@ -27,7 +27,7 @@ use rustc_ast::{Arm, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLim
|
||||
use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{AddToDiagnostic, Applicability, Diag, PResult, StashKey};
|
||||
use rustc_errors::{Applicability, Diag, PResult, StashKey, Subdiagnostic};
|
||||
use rustc_lexer::unescape::unescape_char;
|
||||
use rustc_macros::Subdiagnostic;
|
||||
use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded};
|
||||
@ -3451,8 +3451,8 @@ impl<'a> Parser<'a> {
|
||||
let in_if_guard = self.restrictions.contains(Restrictions::IN_IF_GUARD);
|
||||
|
||||
let async_block_err = |e: &mut Diag<'_>, span: Span| {
|
||||
errors::AsyncBlockIn2015 { span }.add_to_diagnostic(e);
|
||||
errors::HelpUseLatestEdition::new().add_to_diagnostic(e);
|
||||
errors::AsyncBlockIn2015 { span }.add_to_diag(e);
|
||||
errors::HelpUseLatestEdition::new().add_to_diag(e);
|
||||
};
|
||||
|
||||
while self.token != token::CloseDelim(close_delim) {
|
||||
|
@ -9,7 +9,7 @@ use rustc_ast::{ast, AttrKind, AttrStyle, Attribute, LitKind};
|
||||
use rustc_ast::{MetaItemKind, MetaItemLit, NestedMetaItem};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::StashKey;
|
||||
use rustc_errors::{Applicability, DiagCtxt, IntoDiagnosticArg, MultiSpan};
|
||||
use rustc_errors::{Applicability, DiagCtxt, IntoDiagArg, MultiSpan};
|
||||
use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LocalModDefId;
|
||||
@ -79,14 +79,14 @@ pub(crate) enum ProcMacroKind {
|
||||
Attribute,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for ProcMacroKind {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
impl IntoDiagArg for ProcMacroKind {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
match self {
|
||||
ProcMacroKind::Attribute => "attribute proc macro",
|
||||
ProcMacroKind::Derive => "derive proc macro",
|
||||
ProcMacroKind::FunctionLike => "function-like proc macro",
|
||||
}
|
||||
.into_diagnostic_arg()
|
||||
.into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@ use std::{
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_ast::Label;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, DiagSymbolList, EmissionGuarantee,
|
||||
IntoDiagnostic, Level, MultiSpan, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
|
||||
MultiSpan, SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_hir::{self as hir, ExprKind, Target};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
@ -862,9 +862,9 @@ pub struct ItemFollowingInnerAttr {
|
||||
pub kind: &'static str,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for InvalidAttrAtCrateLevel {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidAttrAtCrateLevel {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::passes_invalid_attr_at_crate_level);
|
||||
diag.span(self.span);
|
||||
diag.arg("name", self.name);
|
||||
@ -1012,9 +1012,9 @@ pub struct BreakNonLoop<'a> {
|
||||
pub break_expr_span: Span,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'_, G> for BreakNonLoop<'a> {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::passes_break_non_loop);
|
||||
diag.span(self.span);
|
||||
diag.code(E0571);
|
||||
@ -1156,9 +1156,9 @@ pub struct NakedFunctionsAsmBlock {
|
||||
pub non_asms: Vec<Span>,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for NakedFunctionsAsmBlock {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for NakedFunctionsAsmBlock {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::passes_naked_functions_asm_block);
|
||||
diag.span(self.span);
|
||||
diag.code(E0787);
|
||||
@ -1267,9 +1267,9 @@ pub struct NoMainErr {
|
||||
pub add_teach_note: bool,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for NoMainErr {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NoMainErr {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::passes_no_main_function);
|
||||
diag.span(DUMMY_SP);
|
||||
diag.code(E0601);
|
||||
@ -1325,9 +1325,9 @@ pub struct DuplicateLangItem {
|
||||
pub(crate) duplicate: Duplicate,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for DuplicateLangItem {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for DuplicateLangItem {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(
|
||||
dcx,
|
||||
level,
|
||||
@ -1751,8 +1751,8 @@ pub struct UnusedVariableStringInterp {
|
||||
pub hi: Span,
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for UnusedVariableStringInterp {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for UnusedVariableStringInterp {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, SubdiagMessageOp};
|
||||
use rustc_errors::{Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
|
||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::thir::Pat;
|
||||
use rustc_middle::ty::Ty;
|
||||
@ -61,8 +61,8 @@ pub struct Overlap<'tcx> {
|
||||
pub range: Pat<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> AddToDiagnostic for Overlap<'tcx> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'tcx> Subdiagnostic for Overlap<'tcx> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
@ -109,8 +109,8 @@ pub struct GappedRange<'tcx> {
|
||||
pub first_range: Pat<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> AddToDiagnostic for GappedRange<'tcx> {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl<'tcx> Subdiagnostic for GappedRange<'tcx> {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_: F,
|
||||
|
@ -97,7 +97,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'p, 'tcx>(
|
||||
lint_name: "non_exhaustive_omitted_patterns",
|
||||
};
|
||||
|
||||
use rustc_errors::DecorateLint;
|
||||
use rustc_errors::LintDiagnostic;
|
||||
let mut err = rcx.tcx.dcx().struct_span_warn(arm.pat.data().unwrap().span, "");
|
||||
err.primary_message(decorator.msg());
|
||||
decorator.decorate_lint(&mut err);
|
||||
|
@ -521,7 +521,7 @@ pub(crate) struct ToolModuleImported {
|
||||
#[diag(resolve_module_only)]
|
||||
pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span);
|
||||
|
||||
#[derive(Diagnostic, Default)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_macro_expected_found)]
|
||||
pub(crate) struct MacroExpectedFound<'a> {
|
||||
#[primary_span]
|
||||
|
@ -17,7 +17,7 @@ use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}
|
||||
use rustc_ast::*;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_errors::{
|
||||
codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagnosticArg, StashKey,
|
||||
codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagArg, StashKey,
|
||||
};
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
|
||||
@ -89,8 +89,8 @@ impl PatternSource {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for PatternSource {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
impl IntoDiagArg for PatternSource {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
DiagArgValue::Str(Cow::Borrowed(self.descr()))
|
||||
}
|
||||
}
|
||||
|
@ -562,7 +562,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
expected,
|
||||
found: res.descr(),
|
||||
macro_path: &path_str,
|
||||
..Default::default() // Subdiagnostics default to None
|
||||
remove_surrounding_derive: None,
|
||||
add_as_non_derive: None,
|
||||
};
|
||||
|
||||
// Suggest moving the macro out of the derive() if the macro isn't Derive
|
||||
|
@ -13,7 +13,7 @@ use crate::{EarlyDiagCtxt, Session};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
|
||||
use rustc_errors::emitter::HumanReadableErrorType;
|
||||
use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagnosticArg};
|
||||
use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagArg};
|
||||
use rustc_feature::UnstableFeatures;
|
||||
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
|
||||
use rustc_span::source_map::FilePathMapping;
|
||||
@ -3098,9 +3098,9 @@ impl fmt::Display for CrateType {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for CrateType {
|
||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl IntoDiagArg for CrateType {
|
||||
fn into_diag_arg(self) -> DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@ use std::num::NonZero;
|
||||
use rustc_ast::token;
|
||||
use rustc_ast::util::literal::LitError;
|
||||
use rustc_errors::{
|
||||
codes::*, Diag, DiagCtxt, DiagMessage, EmissionGuarantee, ErrorGuaranteed, IntoDiagnostic,
|
||||
Level, MultiSpan,
|
||||
codes::*, Diag, DiagCtxt, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level,
|
||||
MultiSpan,
|
||||
};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_span::{Span, Symbol};
|
||||
@ -17,9 +17,9 @@ pub struct FeatureGateError {
|
||||
pub explain: DiagMessage,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FeatureGateError {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for FeatureGateError {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter, HumanR
|
||||
use rustc_errors::json::JsonEmitter;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::{
|
||||
codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, FatalAbort,
|
||||
FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl,
|
||||
codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagMessage, Diagnostic, ErrorGuaranteed,
|
||||
FatalAbort, FluentBundle, LazyFallbackBundle, TerminalUrl,
|
||||
};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
pub use rustc_span::def_id::StableCrateId;
|
||||
@ -111,9 +111,9 @@ impl Mul<usize> for Limit {
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Limit {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diagnostic_arg()
|
||||
impl rustc_errors::IntoDiagArg for Limit {
|
||||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||
self.to_string().into_diag_arg()
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,11 +305,7 @@ impl Session {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_feature_err<'a>(
|
||||
&'a self,
|
||||
err: impl IntoDiagnostic<'a>,
|
||||
feature: Symbol,
|
||||
) -> Diag<'a> {
|
||||
pub fn create_feature_err<'a>(&'a self, err: impl Diagnostic<'a>, feature: Symbol) -> Diag<'a> {
|
||||
let mut err = self.dcx().create_err(err);
|
||||
if err.code.is_none() {
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
|
@ -129,7 +129,6 @@ symbols! {
|
||||
Abi,
|
||||
AcqRel,
|
||||
Acquire,
|
||||
AddToDiagnostic,
|
||||
Any,
|
||||
Arc,
|
||||
ArcWeak,
|
||||
@ -184,10 +183,10 @@ symbols! {
|
||||
DebugStruct,
|
||||
Decodable,
|
||||
Decoder,
|
||||
DecorateLint,
|
||||
Default,
|
||||
Deref,
|
||||
DiagMessage,
|
||||
Diagnostic,
|
||||
DirBuilder,
|
||||
Display,
|
||||
DoubleEndedIterator,
|
||||
@ -223,7 +222,6 @@ symbols! {
|
||||
Input,
|
||||
Instant,
|
||||
Into,
|
||||
IntoDiagnostic,
|
||||
IntoFuture,
|
||||
IntoIterator,
|
||||
IoLines,
|
||||
@ -243,6 +241,7 @@ symbols! {
|
||||
Layout,
|
||||
Left,
|
||||
LinkedList,
|
||||
LintDiagnostic,
|
||||
LintPass,
|
||||
LocalKey,
|
||||
Mutex,
|
||||
@ -305,6 +304,7 @@ symbols! {
|
||||
String,
|
||||
StructuralPartialEq,
|
||||
SubdiagMessage,
|
||||
Subdiagnostic,
|
||||
Sync,
|
||||
T,
|
||||
Target,
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Errors emitted by symbol_mangling.
|
||||
|
||||
use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
|
||||
use rustc_errors::{Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
|
||||
use rustc_span::Span;
|
||||
use std::fmt;
|
||||
|
||||
@ -13,8 +13,8 @@ pub struct TestOutput {
|
||||
// This diagnostic doesn't need translation because (a) it doesn't contain any
|
||||
// natural language, and (b) it's only used in tests. So we construct it
|
||||
// manually and avoid the fluent machinery.
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TestOutput {
|
||||
fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TestOutput {
|
||||
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let TestOutput { span, kind, content } = self;
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic,
|
||||
Level, SubdiagMessageOp,
|
||||
codes::*, Applicability, Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_middle::ty::{self, ClosureKind, PolyTraitRef, Ty};
|
||||
@ -57,9 +57,9 @@ pub struct NegativePositiveConflict<'tcx> {
|
||||
pub positive_impl_span: Result<Span, Symbol>,
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for NegativePositiveConflict<'_> {
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for NegativePositiveConflict<'_> {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
fn into_diag(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::trait_selection_negative_positive_conflict);
|
||||
diag.arg("trait_desc", self.trait_desc.print_only_trait_path().to_string());
|
||||
diag.arg("self_desc", self.self_ty.map_or_else(|| "none".to_string(), |ty| ty.to_string()));
|
||||
@ -100,8 +100,8 @@ pub enum AdjustSignatureBorrow {
|
||||
RemoveBorrow { remove_borrow: Vec<(Span, String)> },
|
||||
}
|
||||
|
||||
impl AddToDiagnostic for AdjustSignatureBorrow {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for AdjustSignatureBorrow {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
|
@ -14,8 +14,8 @@ extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
||||
use rustc_errors::{
|
||||
AddToDiagnostic, DecorateLint, Diag, DiagCtxt, DiagInner, DiagMessage, EmissionGuarantee,
|
||||
IntoDiagnostic, Level, SubdiagMessageOp,
|
||||
Diag, DiagCtxt, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level, LintDiagnostic,
|
||||
SubdiagMessageOp, Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::Span;
|
||||
@ -36,27 +36,27 @@ struct Note {
|
||||
span: Span,
|
||||
}
|
||||
|
||||
pub struct UntranslatableInIntoDiagnostic;
|
||||
pub struct UntranslatableInDiagnostic;
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UntranslatableInIntoDiagnostic {
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UntranslatableInDiagnostic {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
Diag::new(dcx, level, "untranslatable diagnostic")
|
||||
//~^ ERROR diagnostics should be created using translatable messages
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TranslatableInIntoDiagnostic;
|
||||
pub struct TranslatableInDiagnostic;
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for TranslatableInIntoDiagnostic {
|
||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for TranslatableInDiagnostic {
|
||||
fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
|
||||
Diag::new(dcx, level, crate::fluent_generated::no_crate_example)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UntranslatableInAddToDiagnostic;
|
||||
pub struct UntranslatableInAddtoDiag;
|
||||
|
||||
impl AddToDiagnostic for UntranslatableInAddToDiagnostic {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for UntranslatableInAddtoDiag {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -66,10 +66,10 @@ impl AddToDiagnostic for UntranslatableInAddToDiagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TranslatableInAddToDiagnostic;
|
||||
pub struct TranslatableInAddtoDiag;
|
||||
|
||||
impl AddToDiagnostic for TranslatableInAddToDiagnostic {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
impl Subdiagnostic for TranslatableInAddtoDiag {
|
||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
f: F,
|
||||
@ -78,9 +78,9 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UntranslatableInDecorateLint;
|
||||
pub struct UntranslatableInLintDiagnostic;
|
||||
|
||||
impl<'a> DecorateLint<'a, ()> for UntranslatableInDecorateLint {
|
||||
impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic {
|
||||
fn decorate_lint<'b, >(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.note("untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should be created using translatable messages
|
||||
@ -91,9 +91,9 @@ impl<'a> DecorateLint<'a, ()> for UntranslatableInDecorateLint {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TranslatableInDecorateLint;
|
||||
pub struct TranslatableInLintDiagnostic;
|
||||
|
||||
impl<'a> DecorateLint<'a, ()> for TranslatableInDecorateLint {
|
||||
impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.note(crate::fluent_generated::no_crate_note);
|
||||
}
|
||||
@ -105,10 +105,10 @@ impl<'a> DecorateLint<'a, ()> for TranslatableInDecorateLint {
|
||||
|
||||
pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) {
|
||||
let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
||||
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
|
||||
let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
//~^^ ERROR diagnostics should be created using translatable messages
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ error: diagnostics should be created using translatable messages
|
||||
LL | diag.note("untranslatable diagnostic");
|
||||
| ^^^^
|
||||
|
||||
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
|
||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
--> $DIR/diagnostics.rs:107:21
|
||||
|
|
||||
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
||||
@ -34,7 +34,7 @@ note: the lint level is defined here
|
||||
LL | #![deny(rustc::diagnostic_outside_of_impl)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
|
||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
--> $DIR/diagnostics.rs:110:21
|
||||
|
|
||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@ check-fail
|
||||
// Tests that a doc comment will not preclude a field from being considered a diagnostic argument
|
||||
//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
||||
//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
||||
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
|
||||
|
||||
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
||||
@ -25,7 +25,7 @@ use rustc_span::Span;
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
|
||||
|
||||
struct NotIntoDiagnosticArg;
|
||||
struct NotIntoDiagArg;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(no_crate_example)]
|
||||
@ -33,8 +33,8 @@ struct Test {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
/// A doc comment
|
||||
arg: NotIntoDiagnosticArg,
|
||||
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
||||
arg: NotIntoDiagArg,
|
||||
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
@ -43,6 +43,6 @@ struct SubTest {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
/// A doc comment
|
||||
arg: NotIntoDiagnosticArg,
|
||||
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
||||
arg: NotIntoDiagArg,
|
||||
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
||||
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||
--> $DIR/diagnostic-derive-doc-comment-field.rs:36:10
|
||||
|
|
||||
LL | #[derive(Diagnostic)]
|
||||
| ---------- required by a bound introduced by this call
|
||||
...
|
||||
LL | arg: NotIntoDiagnosticArg,
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
|
||||
LL | arg: NotIntoDiagArg,
|
||||
| ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
|
||||
|
|
||||
= help: normalized in stderr
|
||||
note: required by a bound in `Diag::<'a, G>::arg`
|
||||
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
|
||||
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
||||
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||
--> $DIR/diagnostic-derive-doc-comment-field.rs:46:10
|
||||
|
|
||||
LL | #[derive(Subdiagnostic)]
|
||||
| ------------- required by a bound introduced by this call
|
||||
...
|
||||
LL | arg: NotIntoDiagnosticArg,
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
|
||||
LL | arg: NotIntoDiagArg,
|
||||
| ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
|
||||
|
|
||||
= help: normalized in stderr
|
||||
note: required by a bound in `Diag::<'a, G>::arg`
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@ check-fail
|
||||
// Tests error conditions for specifying diagnostics using #[derive(Diagnostic)]
|
||||
//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
||||
//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
||||
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
|
||||
|
||||
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
||||
@ -347,7 +347,7 @@ struct ArgFieldWithoutSkip {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
other: Hello,
|
||||
//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied
|
||||
//~^ ERROR the trait bound `Hello: IntoDiagArg` is not satisfied
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -355,7 +355,7 @@ struct ArgFieldWithoutSkip {
|
||||
struct ArgFieldWithSkip {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
// `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if
|
||||
// `Hello` does not implement `IntoDiagArg` so this would result in an error if
|
||||
// not for `#[skip_arg]`.
|
||||
#[skip_arg]
|
||||
other: Hello,
|
||||
|
@ -618,14 +618,14 @@ LL | #[derive(Diagnostic)]
|
||||
|
|
||||
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied
|
||||
error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied
|
||||
--> $DIR/diagnostic-derive.rs:349:12
|
||||
|
|
||||
LL | #[derive(Diagnostic)]
|
||||
| ---------- required by a bound introduced by this call
|
||||
...
|
||||
LL | other: Hello,
|
||||
| ^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello`
|
||||
| ^^^^^ the trait `IntoDiagArg` is not implemented for `Hello`
|
||||
|
|
||||
= help: normalized in stderr
|
||||
note: required by a bound in `Diag::<'a, G>::arg`
|
||||
|
Loading…
Reference in New Issue
Block a user