UPDATE - rename DiagnosticHandler trait to IntoDiagnostic

This commit is contained in:
Jhonny Bill Mena 2022-09-18 11:45:41 -04:00
parent 5b8152807c
commit 19b348fed4
46 changed files with 659 additions and 584 deletions

View File

@ -1,8 +1,8 @@
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::generic_type_with_parentheses, code = "E0214")]
pub struct GenericTypeWithParentheses {
#[primary_span]
@ -28,7 +28,7 @@ impl AddSubdiagnostic for UseAngleBrackets {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[help]
#[diag(ast_lowering::invalid_abi, code = "E0703")]
pub struct InvalidAbi {
@ -39,7 +39,7 @@ pub struct InvalidAbi {
pub valid_abis: String,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::assoc_ty_parentheses)]
pub struct AssocTyParentheses {
#[primary_span]
@ -71,7 +71,7 @@ impl AddSubdiagnostic for AssocTyParenthesesSub {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(ast_lowering::misplaced_impl_trait, code = "E0562")]
pub struct MisplacedImplTrait<'a> {
#[primary_span]
@ -79,14 +79,14 @@ pub struct MisplacedImplTrait<'a> {
pub position: DiagnosticArgFromDisplay<'a>,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::rustc_box_attribute_error)]
pub struct RustcBoxAttributeError {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::underscore_expr_lhs_assign)]
pub struct UnderscoreExprLhsAssign {
#[primary_span]
@ -94,7 +94,7 @@ pub struct UnderscoreExprLhsAssign {
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::base_expression_double_dot)]
pub struct BaseExpressionDoubleDot {
#[primary_span]
@ -102,7 +102,7 @@ pub struct BaseExpressionDoubleDot {
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::await_only_in_async_fn_and_blocks, code = "E0728")]
pub struct AwaitOnlyInAsyncFnAndBlocks {
#[primary_span]
@ -112,21 +112,21 @@ pub struct AwaitOnlyInAsyncFnAndBlocks {
pub item_span: Option<Span>,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::generator_too_many_parameters, code = "E0628")]
pub struct GeneratorTooManyParameters {
#[primary_span]
pub fn_decl_span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::closure_cannot_be_static, code = "E0697")]
pub struct ClosureCannotBeStatic {
#[primary_span]
pub fn_decl_span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[help]
#[diag(ast_lowering::async_non_move_closure_not_supported, code = "E0708")]
pub struct AsyncNonMoveClosureNotSupported {
@ -134,7 +134,7 @@ pub struct AsyncNonMoveClosureNotSupported {
pub fn_decl_span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::functional_record_update_destructuring_assignment)]
pub struct FunctionalRecordUpdateDestructuringAssignemnt {
#[primary_span]
@ -142,28 +142,28 @@ pub struct FunctionalRecordUpdateDestructuringAssignemnt {
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::async_generators_not_supported, code = "E0727")]
pub struct AsyncGeneratorsNotSupported {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::inline_asm_unsupported_target, code = "E0472")]
pub struct InlineAsmUnsupportedTarget {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::att_syntax_only_x86)]
pub struct AttSyntaxOnlyX86 {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::abi_specified_multiple_times)]
pub struct AbiSpecifiedMultipleTimes {
#[primary_span]
@ -175,14 +175,14 @@ pub struct AbiSpecifiedMultipleTimes {
pub equivalent: Option<()>,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::clobber_abi_not_supported)]
pub struct ClobberAbiNotSupported {
#[primary_span]
pub abi_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[note]
#[diag(ast_lowering::invalid_abi_clobber_abi)]
pub struct InvalidAbiClobberAbi {
@ -191,7 +191,7 @@ pub struct InvalidAbiClobberAbi {
pub supported_abis: String,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::invalid_register)]
pub struct InvalidRegister<'a> {
#[primary_span]
@ -200,7 +200,7 @@ pub struct InvalidRegister<'a> {
pub error: &'a str,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::invalid_register_class)]
pub struct InvalidRegisterClass<'a> {
#[primary_span]
@ -209,7 +209,7 @@ pub struct InvalidRegisterClass<'a> {
pub error: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(ast_lowering::invalid_asm_template_modifier_reg_class)]
pub struct InvalidAsmTemplateModifierRegClass {
#[primary_span]
@ -229,7 +229,7 @@ pub enum InvalidAsmTemplateModifierRegClassSub {
DoesNotSupportModifier { class_name: Symbol },
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::invalid_asm_template_modifier_const)]
pub struct InvalidAsmTemplateModifierConst {
#[primary_span]
@ -239,7 +239,7 @@ pub struct InvalidAsmTemplateModifierConst {
pub op_span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::invalid_asm_template_modifier_sym)]
pub struct InvalidAsmTemplateModifierSym {
#[primary_span]
@ -249,7 +249,7 @@ pub struct InvalidAsmTemplateModifierSym {
pub op_span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::register_class_only_clobber)]
pub struct RegisterClassOnlyClobber {
#[primary_span]
@ -257,7 +257,7 @@ pub struct RegisterClassOnlyClobber {
pub reg_class_name: Symbol,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::register_conflict)]
pub struct RegisterConflict<'a> {
#[primary_span]
@ -271,7 +271,7 @@ pub struct RegisterConflict<'a> {
pub in_out: Option<Span>,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[help]
#[diag(ast_lowering::sub_tuple_binding)]
pub struct SubTupleBinding<'a> {
@ -288,7 +288,7 @@ pub struct SubTupleBinding<'a> {
pub ctx: &'a str,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::extra_double_dot)]
pub struct ExtraDoubleDot<'a> {
#[primary_span]
@ -299,7 +299,7 @@ pub struct ExtraDoubleDot<'a> {
pub ctx: &'a str,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[note]
#[diag(ast_lowering::misplaced_double_dot)]
pub struct MisplacedDoubleDot {
@ -307,28 +307,28 @@ pub struct MisplacedDoubleDot {
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::misplaced_relax_trait_bound)]
pub struct MisplacedRelaxTraitBound {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::not_supported_for_lifetime_binder_async_closure)]
pub struct NotSupportedForLifetimeBinderAsyncClosure {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::arbitrary_expression_in_pattern)]
pub struct ArbitraryExpressionInPattern {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic, Clone, Copy)]
#[derive(DiagnosticHandler, Clone, Copy)]
#[diag(ast_lowering::inclusive_range_with_no_end)]
pub struct InclusiveRangeWithNoEnd {
#[primary_span]

View File

@ -1,12 +1,12 @@
//! Errors emitted by ast_passes.
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic};
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_errors::{fluent, AddToDiagnostic, Applicability, Diagnostic};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};
use crate::ast_validation::ForbiddenLetReason;
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::forbidden_let)]
#[note]
pub struct ForbiddenLet {
@ -16,7 +16,7 @@ pub struct ForbiddenLet {
pub(crate) reason: ForbiddenLetReason,
}
impl AddSubdiagnostic for ForbiddenLetReason {
impl AddToDiagnostic for ForbiddenLetReason {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
match self {
Self::GenericForbidden => {}
@ -30,7 +30,7 @@ impl AddSubdiagnostic for ForbiddenLetReason {
}
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::forbidden_let_stable)]
#[note]
pub struct ForbiddenLetStable {
@ -38,21 +38,21 @@ pub struct ForbiddenLetStable {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::forbidden_assoc_constraint)]
pub struct ForbiddenAssocConstraint {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::keyword_lifetime)]
pub struct KeywordLifetime {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::invalid_label)]
pub struct InvalidLabel {
#[primary_span]
@ -60,7 +60,7 @@ pub struct InvalidLabel {
pub name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::invalid_visibility, code = "E0449")]
pub struct InvalidVisibility {
#[primary_span]
@ -79,7 +79,7 @@ pub enum InvalidVisibilityNote {
IndividualForeignItems,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::trait_fn_const, code = "E0379")]
pub struct TraitFnConst {
#[primary_span]
@ -87,21 +87,21 @@ pub struct TraitFnConst {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::forbidden_lifetime_bound)]
pub struct ForbiddenLifetimeBound {
#[primary_span]
pub spans: Vec<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::forbidden_non_lifetime_param)]
pub struct ForbiddenNonLifetimeParam {
#[primary_span]
pub spans: Vec<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::fn_param_too_many)]
pub struct FnParamTooMany {
#[primary_span]
@ -109,21 +109,21 @@ pub struct FnParamTooMany {
pub max_num_args: usize,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::fn_param_c_var_args_only)]
pub struct FnParamCVarArgsOnly {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::fn_param_c_var_args_not_last)]
pub struct FnParamCVarArgsNotLast {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::fn_param_doc_comment)]
pub struct FnParamDocComment {
#[primary_span]
@ -131,14 +131,14 @@ pub struct FnParamDocComment {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::fn_param_forbidden_attr)]
pub struct FnParamForbiddenAttr {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::fn_param_forbidden_self)]
#[note]
pub struct FnParamForbiddenSelf {
@ -147,7 +147,7 @@ pub struct FnParamForbiddenSelf {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::forbidden_default)]
pub struct ForbiddenDefault {
#[primary_span]
@ -156,7 +156,7 @@ pub struct ForbiddenDefault {
pub def_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::assoc_const_without_body)]
pub struct AssocConstWithoutBody {
#[primary_span]
@ -165,7 +165,7 @@ pub struct AssocConstWithoutBody {
pub replace_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::assoc_fn_without_body)]
pub struct AssocFnWithoutBody {
#[primary_span]
@ -174,7 +174,7 @@ pub struct AssocFnWithoutBody {
pub replace_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::assoc_type_without_body)]
pub struct AssocTypeWithoutBody {
#[primary_span]
@ -183,7 +183,7 @@ pub struct AssocTypeWithoutBody {
pub replace_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::const_without_body)]
pub struct ConstWithoutBody {
#[primary_span]
@ -192,7 +192,7 @@ pub struct ConstWithoutBody {
pub replace_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::static_without_body)]
pub struct StaticWithoutBody {
#[primary_span]
@ -201,7 +201,7 @@ pub struct StaticWithoutBody {
pub replace_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::ty_alias_without_body)]
pub struct TyAliasWithoutBody {
#[primary_span]
@ -210,7 +210,7 @@ pub struct TyAliasWithoutBody {
pub replace_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(ast_passes::fn_without_body)]
pub struct FnWithoutBody {
#[primary_span]
@ -227,7 +227,7 @@ pub struct ExternBlockSuggestion {
pub abi: Option<Symbol>,
}
impl AddSubdiagnostic for ExternBlockSuggestion {
impl AddToDiagnostic for ExternBlockSuggestion {
fn add_to_diagnostic(self, diag: &mut Diagnostic) {
let start_suggestion = if let Some(abi) = self.abi {
format!("extern \"{}\" {{", abi)

View File

@ -1,23 +1,23 @@
use std::num::IntErrorKind;
use rustc_ast as ast;
use rustc_errors::SessionDiagnostic;
use rustc_errors::{
error_code, fluent, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler,
error_code, fluent, Applicability, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed,
Handler,
};
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::{Span, Symbol};
use crate::UnsupportedLiteralReason;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::expected_one_cfg_pattern, code = "E0536")]
pub(crate) struct ExpectedOneCfgPattern {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::invalid_predicate, code = "E0537")]
pub(crate) struct InvalidPredicate {
#[primary_span]
@ -26,7 +26,7 @@ pub(crate) struct InvalidPredicate {
pub predicate: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::multiple_item, code = "E0538")]
pub(crate) struct MultipleItem {
#[primary_span]
@ -35,7 +35,7 @@ pub(crate) struct MultipleItem {
pub item: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::incorrect_meta_item, code = "E0539")]
pub(crate) struct IncorrectMetaItem {
#[primary_span]
@ -50,7 +50,7 @@ pub(crate) struct UnknownMetaItem<'a> {
}
// Manual implementation to be able to format `expected` items correctly.
impl<'a> SessionDiagnostic<'a> for UnknownMetaItem<'_> {
impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let expected = self.expected.iter().map(|name| format!("`{}`", name)).collect::<Vec<_>>();
let mut diag = handler.struct_span_err_with_code(
@ -65,28 +65,28 @@ impl<'a> SessionDiagnostic<'a> for UnknownMetaItem<'_> {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::missing_since, code = "E0542")]
pub(crate) struct MissingSince {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::missing_note, code = "E0543")]
pub(crate) struct MissingNote {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::multiple_stability_levels, code = "E0544")]
pub(crate) struct MultipleStabilityLevels {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::invalid_issue_string, code = "E0545")]
pub(crate) struct InvalidIssueString {
#[primary_span]
@ -144,21 +144,21 @@ impl InvalidIssueStringCause {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::missing_feature, code = "E0546")]
pub(crate) struct MissingFeature {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::non_ident_feature, code = "E0546")]
pub(crate) struct NonIdentFeature {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::missing_issue, code = "E0547")]
pub(crate) struct MissingIssue {
#[primary_span]
@ -167,7 +167,7 @@ pub(crate) struct MissingIssue {
// FIXME: This diagnostic is identical to `IncorrectMetaItem`, barring the error code. Consider
// changing this to `IncorrectMetaItem`. See #51489.
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::incorrect_meta_item, code = "E0551")]
pub(crate) struct IncorrectMetaItem2 {
#[primary_span]
@ -176,14 +176,14 @@ pub(crate) struct IncorrectMetaItem2 {
// FIXME: Why is this the same error code as `InvalidReprHintNoParen` and `InvalidReprHintNoValue`?
// It is more similar to `IncorrectReprFormatGeneric`.
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::incorrect_repr_format_packed_one_or_zero_arg, code = "E0552")]
pub(crate) struct IncorrectReprFormatPackedOneOrZeroArg {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::invalid_repr_hint_no_paren, code = "E0552")]
pub(crate) struct InvalidReprHintNoParen {
#[primary_span]
@ -192,7 +192,7 @@ pub(crate) struct InvalidReprHintNoParen {
pub name: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::invalid_repr_hint_no_value, code = "E0552")]
pub(crate) struct InvalidReprHintNoValue {
#[primary_span]
@ -209,7 +209,7 @@ pub(crate) struct UnsupportedLiteral {
pub start_point_span: Span,
}
impl<'a> SessionDiagnostic<'a> for UnsupportedLiteral {
impl<'a> IntoDiagnostic<'a> for UnsupportedLiteral {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut diag = handler.struct_span_err_with_code(
self.span,
@ -237,7 +237,7 @@ impl<'a> SessionDiagnostic<'a> for UnsupportedLiteral {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::invalid_repr_align_need_arg, code = "E0589")]
pub(crate) struct InvalidReprAlignNeedArg {
#[primary_span]
@ -245,7 +245,7 @@ pub(crate) struct InvalidReprAlignNeedArg {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::invalid_repr_generic, code = "E0589")]
pub(crate) struct InvalidReprGeneric<'a> {
#[primary_span]
@ -255,14 +255,14 @@ pub(crate) struct InvalidReprGeneric<'a> {
pub error_part: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::incorrect_repr_format_align_one_arg, code = "E0693")]
pub(crate) struct IncorrectReprFormatAlignOneArg {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::incorrect_repr_format_generic, code = "E0693")]
pub(crate) struct IncorrectReprFormatGeneric<'a> {
#[primary_span]
@ -317,28 +317,28 @@ impl<'a> IncorrectReprFormatGenericCause<'a> {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::rustc_promotable_pairing, code = "E0717")]
pub(crate) struct RustcPromotablePairing {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::rustc_allowed_unstable_pairing, code = "E0789")]
pub(crate) struct RustcAllowedUnstablePairing {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::cfg_predicate_identifier)]
pub(crate) struct CfgPredicateIdentifier {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::deprecated_item_suggestion)]
pub(crate) struct DeprecatedItemSuggestion {
#[primary_span]
@ -351,21 +351,21 @@ pub(crate) struct DeprecatedItemSuggestion {
pub details: (),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::expected_single_version_literal)]
pub(crate) struct ExpectedSingleVersionLiteral {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::expected_version_literal)]
pub(crate) struct ExpectedVersionLiteral {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::expects_feature_list)]
pub(crate) struct ExpectsFeatureList {
#[primary_span]
@ -374,7 +374,7 @@ pub(crate) struct ExpectsFeatureList {
pub name: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::expects_features)]
pub(crate) struct ExpectsFeatures {
#[primary_span]
@ -383,14 +383,14 @@ pub(crate) struct ExpectsFeatures {
pub name: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::soft_no_args)]
pub(crate) struct SoftNoArgs {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(attr::unknown_version_literal)]
pub(crate) struct UnknownVersionLiteral {
#[primary_span]

View File

@ -1,11 +1,11 @@
use rustc_errors::{IntoDiagnosticArg, MultiSpan};
use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, LintDiagnostic, SessionSubdiagnostic};
use rustc_middle::ty::Ty;
use rustc_span::Span;
use crate::diagnostics::RegionName;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(borrowck::move_unsized, code = "E0161")]
pub(crate) struct MoveUnsized<'tcx> {
pub ty: Ty<'tcx>,
@ -14,7 +14,7 @@ pub(crate) struct MoveUnsized<'tcx> {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(borrowck::higher_ranked_lifetime_error)]
pub(crate) struct HigherRankedLifetimeError {
#[subdiagnostic]
@ -31,14 +31,14 @@ pub(crate) enum HigherRankedErrorCause {
CouldNotNormalize { value: String },
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(borrowck::higher_ranked_subtype_error)]
pub(crate) struct HigherRankedSubtypeError {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(borrowck::generic_does_not_live_long_enough)]
pub(crate) struct GenericDoesNotLiveLongEnough {
pub kind: String,
@ -53,7 +53,7 @@ pub(crate) struct VarNeedNotMut {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(borrowck::const_not_used_in_type_alias)]
pub(crate) struct ConstNotUsedTraitAlias {
pub ct: String,
@ -61,7 +61,7 @@ pub(crate) struct ConstNotUsedTraitAlias {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(borrowck::var_cannot_escape_closure)]
#[note]
#[note(borrowck::cannot_escape)]
@ -110,7 +110,7 @@ pub(crate) enum FnMutReturnTypeErr {
},
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(borrowck::lifetime_constraints_error)]
pub(crate) struct LifetimeOutliveErr {
#[primary_span]

View File

@ -8,7 +8,7 @@ use rustc_ast::tokenstream::TokenStream;
use rustc_attr as attr;
use rustc_errors::PResult;
use rustc_expand::base::{self, *};
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::Span;
pub fn expand_cfg(
@ -35,7 +35,7 @@ pub fn expand_cfg(
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(builtin_macros::requires_cfg_pattern)]
struct RequiresCfgPattern {
#[primary_span]
@ -43,7 +43,7 @@ struct RequiresCfgPattern {
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(builtin_macros::expected_one_cfg_pattern)]
struct OneCfgPattern {
#[primary_span]

View File

@ -1,8 +1,8 @@
use rustc_hir::ConstContext;
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unstable_in_stable)]
pub(crate) struct UnstableInStable {
pub gate: String,
@ -21,14 +21,14 @@ pub(crate) struct UnstableInStable {
pub attr_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::thread_local_access, code = "E0625")]
pub(crate) struct NonConstOpErr {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::static_access, code = "E0013")]
#[help]
pub(crate) struct StaticAccessErr {
@ -40,7 +40,7 @@ pub(crate) struct StaticAccessErr {
pub teach: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::raw_ptr_to_int)]
#[note]
#[note(const_eval::note2)]
@ -49,7 +49,7 @@ pub(crate) struct RawPtrToIntErr {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::raw_ptr_comparison)]
#[note]
pub(crate) struct RawPtrComparisonErr {
@ -57,14 +57,14 @@ pub(crate) struct RawPtrComparisonErr {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::panic_non_str)]
pub(crate) struct PanicNonStrErr {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::mut_deref, code = "E0658")]
pub(crate) struct MutDerefErr {
#[primary_span]
@ -72,7 +72,7 @@ pub(crate) struct MutDerefErr {
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::transient_mut_borrow, code = "E0658")]
pub(crate) struct TransientMutBorrowErr {
#[primary_span]
@ -80,7 +80,7 @@ pub(crate) struct TransientMutBorrowErr {
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::transient_mut_borrow_raw, code = "E0658")]
pub(crate) struct TransientMutBorrowErrRaw {
#[primary_span]
@ -88,7 +88,7 @@ pub(crate) struct TransientMutBorrowErrRaw {
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::max_num_nodes_in_const)]
pub(crate) struct MaxNumNodesInConstErr {
#[primary_span]
@ -96,7 +96,7 @@ pub(crate) struct MaxNumNodesInConstErr {
pub global_const_id: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unallowed_fn_pointer_call)]
pub(crate) struct UnallowedFnPointerCall {
#[primary_span]
@ -104,7 +104,7 @@ pub(crate) struct UnallowedFnPointerCall {
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unstable_const_fn)]
pub(crate) struct UnstableConstFn {
#[primary_span]
@ -112,7 +112,7 @@ pub(crate) struct UnstableConstFn {
pub def_path: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unallowed_mutable_refs, code = "E0764")]
pub(crate) struct UnallowedMutableRefs {
#[primary_span]
@ -122,7 +122,7 @@ pub(crate) struct UnallowedMutableRefs {
pub teach: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unallowed_mutable_refs_raw, code = "E0764")]
pub(crate) struct UnallowedMutableRefsRaw {
#[primary_span]
@ -131,7 +131,7 @@ pub(crate) struct UnallowedMutableRefsRaw {
#[note(const_eval::teach_note)]
pub teach: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::non_const_fmt_macro_call, code = "E0015")]
pub(crate) struct NonConstFmtMacroCall {
#[primary_span]
@ -139,7 +139,7 @@ pub(crate) struct NonConstFmtMacroCall {
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::non_const_fn_call, code = "E0015")]
pub(crate) struct NonConstFnCall {
#[primary_span]
@ -148,7 +148,7 @@ pub(crate) struct NonConstFnCall {
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unallowed_op_in_const_context)]
pub(crate) struct UnallowedOpInConstContext {
#[primary_span]
@ -156,7 +156,7 @@ pub(crate) struct UnallowedOpInConstContext {
pub msg: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unallowed_heap_allocations, code = "E0010")]
pub(crate) struct UnallowedHeapAllocations {
#[primary_span]
@ -167,7 +167,7 @@ pub(crate) struct UnallowedHeapAllocations {
pub teach: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::unallowed_inline_asm, code = "E0015")]
pub(crate) struct UnallowedInlineAsm {
#[primary_span]
@ -175,7 +175,7 @@ pub(crate) struct UnallowedInlineAsm {
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::interior_mutable_data_refer, code = "E0492")]
pub(crate) struct InteriorMutableDataRefer {
#[primary_span]
@ -188,7 +188,7 @@ pub(crate) struct InteriorMutableDataRefer {
pub teach: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(const_eval::interior_mutability_borrow)]
pub(crate) struct InteriorMutabilityBorrow {
#[primary_span]

View File

@ -1,38 +1,38 @@
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(driver::rlink_unable_to_read)]
pub(crate) struct RlinkUnableToRead {
pub err: std::io::Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(driver::rlink_wrong_file_type)]
pub(crate) struct RLinkWrongFileType;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(driver::rlink_empty_version_number)]
pub(crate) struct RLinkEmptyVersionNumber;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(driver::rlink_encoding_version_mismatch)]
pub(crate) struct RLinkEncodingVersionMismatch {
pub version_array: String,
pub rlink_version: u32,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(driver::rlink_rustc_version_mismatch)]
pub(crate) struct RLinkRustcVersionMismatch<'a> {
pub rustc_version: String,
pub current_version: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(driver::rlink_no_a_file)]
pub(crate) struct RlinkNotAFile;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(driver::unpretty_dump_fail)]
pub(crate) struct UnprettyDumpFail {
pub path: String,

View File

@ -51,7 +51,7 @@ lint_non_existant_doc_keyword = found non-existing keyword `{$keyword}` used in
.help = only existing keywords are allowed in core/std
lint_diag_out_of_impl =
diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
lint_untranslatable_diag = diagnostics should be created using translatable messages

View File

@ -35,7 +35,7 @@ pub enum DiagnosticArgValue<'source> {
Number(usize),
}
/// Converts a value of a type into a `DiagnosticArg` (typically a field of a `SessionDiagnostic`
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
/// crates to implement this.

View File

@ -14,9 +14,10 @@ use std::ops::{Deref, DerefMut};
use std::thread::panicking;
/// Trait implemented by error types. This should not be implemented manually. Instead, use
/// `#[derive(SessionDiagnostic)]` -- see [rustc_macros::SessionDiagnostic].
#[rustc_diagnostic_item = "SessionDiagnostic"]
pub trait SessionDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
/// `#[derive(DiagnosticHandler)]` -- see [rustc_macros::DiagnosticHandler].
#[cfg_attr(bootstrap, rustc_diagnostic_item = "SessionDiagnostic")]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "DiagnosticHandler")]
pub trait IntoDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
/// Write out as a diagnostic out of `Handler`.
#[must_use]
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, T>;

View File

@ -60,7 +60,7 @@ mod snippet;
mod styled_buffer;
pub mod translation;
pub use diagnostic_builder::SessionDiagnostic;
pub use diagnostic_builder::IntoDiagnostic;
pub use snippet::Style;
pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorGuaranteed>>;
@ -647,6 +647,8 @@ impl Handler {
/// Construct a builder with the `msg` at the level appropriate for the specific `EmissionGuarantee`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_diagnostic<G: EmissionGuarantee>(
&self,
msg: impl Into<DiagnosticMessage>,
@ -660,6 +662,8 @@ impl Handler {
/// * `can_emit_warnings` is `true`
/// * `is_force_warn` was set in `DiagnosticId::Lint`
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_warn(
&self,
span: impl Into<MultiSpan>,
@ -676,6 +680,8 @@ impl Handler {
/// Attempting to `.emit()` the builder will only emit if either:
/// * `can_emit_warnings` is `true`
/// * `is_force_warn` was set in `DiagnosticId::Lint`
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_warn_with_expectation(
&self,
span: impl Into<MultiSpan>,
@ -689,6 +695,8 @@ impl Handler {
/// Construct a builder at the `Allow` level at the given `span` and with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_allow(
&self,
span: impl Into<MultiSpan>,
@ -702,6 +710,8 @@ impl Handler {
/// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
/// Also include a code.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_warn_with_code(
&self,
span: impl Into<MultiSpan>,
@ -719,6 +729,8 @@ impl Handler {
/// * `can_emit_warnings` is `true`
/// * `is_force_warn` was set in `DiagnosticId::Lint`
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Level::Warning(None), msg)
}
@ -729,6 +741,8 @@ impl Handler {
/// Attempting to `.emit()` the builder will only emit if either:
/// * `can_emit_warnings` is `true`
/// * `is_force_warn` was set in `DiagnosticId::Lint`
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_warn_with_expectation(
&self,
msg: impl Into<DiagnosticMessage>,
@ -739,12 +753,16 @@ impl Handler {
/// Construct a builder at the `Allow` level with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Level::Allow, msg)
}
/// Construct a builder at the `Expect` level with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_expect(
&self,
msg: impl Into<DiagnosticMessage>,
@ -755,6 +773,8 @@ impl Handler {
/// Construct a builder at the `Error` level at the given `span` and with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_err(
&self,
span: impl Into<MultiSpan>,
@ -767,6 +787,8 @@ impl Handler {
/// Construct a builder at the `Error` level at the given `span`, with the `msg`, and `code`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_err_with_code(
&self,
span: impl Into<MultiSpan>,
@ -781,6 +803,8 @@ impl Handler {
/// Construct a builder at the `Error` level with the `msg`.
// FIXME: This method should be removed (every error should have an associated error code).
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_err(
&self,
msg: impl Into<DiagnosticMessage>,
@ -790,12 +814,16 @@ impl Handler {
/// This should only be used by `rustc_middle::lint::struct_lint_level`. Do not use it for hard errors.
#[doc(hidden)]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_err_lint(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Level::Error { lint: true }, msg)
}
/// Construct a builder at the `Error` level with the `msg` and the `code`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_err_with_code(
&self,
msg: impl Into<DiagnosticMessage>,
@ -808,6 +836,8 @@ impl Handler {
/// Construct a builder at the `Warn` level with the `msg` and the `code`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_warn_with_code(
&self,
msg: impl Into<DiagnosticMessage>,
@ -820,6 +850,8 @@ impl Handler {
/// Construct a builder at the `Fatal` level at the given `span` and with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_fatal(
&self,
span: impl Into<MultiSpan>,
@ -832,6 +864,8 @@ impl Handler {
/// Construct a builder at the `Fatal` level at the given `span`, with the `msg`, and `code`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_span_fatal_with_code(
&self,
span: impl Into<MultiSpan>,
@ -845,18 +879,24 @@ impl Handler {
/// Construct a builder at the `Error` level with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
DiagnosticBuilder::new_fatal(self, msg)
}
/// Construct a builder at the `Help` level with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_help(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Level::Help, msg)
}
/// Construct a builder at the `Note` level with the `msg`.
#[rustc_lint_diagnostics]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub fn struct_note_without_error(
&self,
msg: impl Into<DiagnosticMessage>,
@ -1029,6 +1069,39 @@ impl Handler {
self.inner.borrow_mut().emit_diagnostic(diagnostic)
}
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
self.create_err(err).emit()
}
pub fn create_err<'a>(
&'a self,
err: impl IntoDiagnostic<'a>,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
err.into_diagnostic(self)
}
pub fn create_warning<'a>(
&'a self,
warning: impl IntoDiagnostic<'a, ()>,
) -> DiagnosticBuilder<'a, ()> {
warning.into_diagnostic(self)
}
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
self.create_warning(warning).emit()
}
pub fn create_fatal<'a>(
&'a self,
fatal: impl IntoDiagnostic<'a, !>,
) -> DiagnosticBuilder<'a, !> {
fatal.into_diagnostic(self)
}
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
self.create_fatal(fatal).emit()
}
fn emit_diag_at_span(
&self,
mut diag: Diagnostic,

View File

@ -11,7 +11,7 @@ use rustc_attr::{self as attr, Deprecation, Stability};
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::sync::{self, Lrc};
use rustc_errors::{
Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, PResult, SessionDiagnostic,
Applicability, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed, MultiSpan, PResult,
};
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics};
@ -1111,12 +1111,12 @@ impl<'a> ExtCtxt<'a> {
pub fn create_err(
&self,
err: impl SessionDiagnostic<'a>,
err: impl IntoDiagnostic<'a>,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.sess.create_err(err)
}
pub fn emit_err(&self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
pub fn emit_err(&self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
self.sess.emit_err(err)
}

View File

@ -1,29 +1,29 @@
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::symbol::MacroRulesNormalizedIdent;
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(expand::expr_repeat_no_syntax_vars)]
pub(crate) struct NoSyntaxVarsExprRepeat {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(expand::must_repeat_once)]
pub(crate) struct MustRepeatOnce {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(expand::count_repetition_misplaced)]
pub(crate) struct CountRepetitionMisplaced {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(expand::meta_var_expr_unrecognized_var)]
pub(crate) struct MetaVarExprUnrecognizedVar {
#[primary_span]
@ -31,7 +31,7 @@ pub(crate) struct MetaVarExprUnrecognizedVar {
pub key: MacroRulesNormalizedIdent,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(expand::var_still_repeating)]
pub(crate) struct VarStillRepeating {
#[primary_span]
@ -39,7 +39,7 @@ pub(crate) struct VarStillRepeating {
pub ident: MacroRulesNormalizedIdent,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(expand::meta_var_dif_seq_matchers)]
pub(crate) struct MetaVarsDifSeqMatchers {
#[primary_span]

View File

@ -4,7 +4,7 @@ use crate::errors::{
};
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::InferCtxt;
use rustc_errors::SessionDiagnostic;
use rustc_errors::IntoDiagnostic;
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_hir as hir;
use rustc_hir::def::Res;

View File

@ -1,10 +1,10 @@
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::{Span, Symbol};
use std::io;
use std::path::Path;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::ferris_identifier)]
pub struct FerrisIdentifier {
#[primary_span]
@ -13,7 +13,7 @@ pub struct FerrisIdentifier {
pub first_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::emoji_identifier)]
pub struct EmojiIdentifier {
#[primary_span]
@ -21,67 +21,67 @@ pub struct EmojiIdentifier {
pub ident: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::mixed_bin_crate)]
pub struct MixedBinCrate;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::mixed_proc_macro_crate)]
pub struct MixedProcMacroCrate;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::proc_macro_doc_without_arg)]
pub struct ProcMacroDocWithoutArg;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::error_writing_dependencies)]
pub struct ErrorWritingDependencies<'a> {
pub path: &'a Path,
pub error: io::Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::input_file_would_be_overwritten)]
pub struct InputFileWouldBeOverWritten<'a> {
pub path: &'a Path,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::generated_file_conflicts_with_directory)]
pub struct GeneratedFileConflictsWithDirectory<'a> {
pub input_path: &'a Path,
pub dir_path: &'a Path,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::temps_dir_error)]
pub struct TempsDirError;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::out_dir_error)]
pub struct OutDirError;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::cant_emit_mir)]
pub struct CantEmitMIR {
pub error: io::Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::rustc_error_fatal)]
pub struct RustcErrorFatal {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::rustc_error_unexpected_annotation)]
pub struct RustcErrorUnexpectedAnnotation {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(interface::failed_writing_file)]
pub struct FailedWritingFile<'a> {
pub path: &'a Path,

View File

@ -1,9 +1,9 @@
use rustc_errors::{fluent, AddSubdiagnostic, ErrorGuaranteed, Handler, SessionDiagnostic};
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_errors::{fluent, AddSubdiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
use rustc_session::lint::Level;
use rustc_span::{Span, Symbol};
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::overruled_attribute, code = "E0453")]
pub struct OverruledAttribute {
#[primary_span]
@ -42,7 +42,7 @@ impl AddSubdiagnostic for OverruledAttributeSub {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::malformed_attribute, code = "E0452")]
pub struct MalformedAttribute {
#[primary_span]
@ -61,7 +61,7 @@ pub enum MalformedAttributeSub {
ReasonMustComeLast(#[primary_span] Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::unknown_tool_in_scoped_lint, code = "E0710")]
pub struct UnknownToolInScopedLint {
#[primary_span]
@ -72,7 +72,7 @@ pub struct UnknownToolInScopedLint {
pub is_nightly_build: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::builtin_ellipsis_inclusive_range_patterns, code = "E0783")]
pub struct BuiltinEllpisisInclusiveRangePatterns {
#[primary_span]
@ -107,7 +107,7 @@ impl AddSubdiagnostic for RequestedLevel {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::unsupported_group, code = "E0602")]
pub struct UnsupportedGroup {
pub lint_group: String,
@ -119,7 +119,7 @@ pub struct CheckNameUnknown {
pub sub: RequestedLevel,
}
impl SessionDiagnostic<'_> for CheckNameUnknown {
impl IntoDiagnostic<'_> for CheckNameUnknown {
fn into_diagnostic(
self,
handler: &Handler,
@ -136,7 +136,7 @@ impl SessionDiagnostic<'_> for CheckNameUnknown {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::check_name_unknown_tool, code = "E0602")]
pub struct CheckNameUnknownTool {
pub tool_name: Symbol,
@ -144,7 +144,7 @@ pub struct CheckNameUnknownTool {
pub sub: RequestedLevel,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::check_name_warning)]
pub struct CheckNameWarning {
pub msg: String,
@ -152,7 +152,7 @@ pub struct CheckNameWarning {
pub sub: RequestedLevel,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(lint::check_name_deprecated)]
pub struct CheckNameDeprecated {
pub lint_name: String,

View File

@ -372,7 +372,7 @@ declare_tool_lint! {
declare_tool_lint! {
pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL,
Allow,
"prevent creation of diagnostics outside of `SessionDiagnostic`/`AddSubdiagnostic` impls",
"prevent creation of diagnostics outside of `DiagnosticHandler`/`AddSubdiagnostic` impls",
report_in_external_macro: true
}
@ -404,7 +404,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::SessionDiagnostic | sym::AddSubdiagnostic | sym::DecorateLint)
matches!(name, sym::DiagnosticHandler | sym::AddSubdiagnostic | sym::DecorateLint)
{
found_impl = true;
break;

View File

@ -11,27 +11,27 @@ use synstructure::Structure;
/// The central struct for constructing the `into_diagnostic` method from an annotated struct.
pub(crate) struct SessionDiagnosticDerive<'a> {
structure: Structure<'a>,
sess: syn::Ident,
handler: syn::Ident,
builder: DiagnosticDeriveBuilder,
}
impl<'a> SessionDiagnosticDerive<'a> {
pub(crate) fn new(diag: syn::Ident, sess: syn::Ident, structure: Structure<'a>) -> Self {
pub(crate) fn new(diag: syn::Ident, handler: syn::Ident, structure: Structure<'a>) -> Self {
Self {
builder: DiagnosticDeriveBuilder {
diag,
fields: build_field_mapping(&structure),
kind: DiagnosticDeriveKind::SessionDiagnostic,
kind: DiagnosticDeriveKind::DiagnosticHandler,
code: None,
slug: None,
},
sess,
handler,
structure,
}
}
pub(crate) fn into_tokens(self) -> TokenStream {
let SessionDiagnosticDerive { mut structure, sess, mut builder } = self;
let SessionDiagnosticDerive { mut structure, handler, mut builder } = self;
let ast = structure.ast();
let implementation = {
@ -53,7 +53,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
}
Some(slug) => {
quote! {
let mut #diag = #sess.struct_diagnostic(rustc_errors::fluent::#slug);
let mut #diag = #handler.struct_diagnostic(rustc_errors::fluent::#slug);
}
}
};
@ -72,7 +72,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
} else {
span_err(
ast.span().unwrap(),
"`#[derive(SessionDiagnostic)]` can only be used on structs",
"`#[derive(DiagnosticHandler)]` can only be used on structs",
)
.emit();
@ -81,15 +81,15 @@ impl<'a> SessionDiagnosticDerive<'a> {
};
structure.gen_impl(quote! {
gen impl<'__session_diagnostic_sess, G>
rustc_errors::SessionDiagnostic<'__session_diagnostic_sess, G>
gen impl<'__diagnostic_handler_sess, G>
rustc_errors::IntoDiagnostic<'__diagnostic_handler_sess, G>
for @Self
where G: rustc_errors::EmissionGuarantee
{
fn into_diagnostic(
self,
#sess: &'__session_diagnostic_sess rustc_errors::Handler
) -> rustc_errors::DiagnosticBuilder<'__session_diagnostic_sess, G> {
#handler: &'__diagnostic_handler_sess rustc_errors::Handler
) -> rustc_errors::DiagnosticBuilder<'__diagnostic_handler_sess, G> {
use rustc_errors::IntoDiagnosticArg;
#implementation
}

View File

@ -21,12 +21,12 @@ use synstructure::{BindingInfo, Structure};
/// What kind of diagnostic is being derived - a fatal/error/warning or a lint?
#[derive(Copy, Clone, PartialEq, Eq)]
pub(crate) enum DiagnosticDeriveKind {
SessionDiagnostic,
DiagnosticHandler,
LintDiagnostic,
}
/// Tracks persistent information required for building up individual calls to diagnostic methods
/// for generated diagnostic derives - both `SessionDiagnostic` for fatal/errors/warnings and
/// for generated diagnostic derives - both `DiagnosticHandler` for fatal/errors/warnings and
/// `LintDiagnostic` for lints.
pub(crate) struct DiagnosticDeriveBuilder {
/// The identifier to use for the generated `DiagnosticBuilder` instance.
@ -333,7 +333,7 @@ impl DiagnosticDeriveBuilder {
}
"primary_span" => {
match self.kind {
DiagnosticDeriveKind::SessionDiagnostic => {
DiagnosticDeriveKind::DiagnosticHandler => {
report_error_if_not_applied_to_span(attr, &info)?;
Ok(quote! {

View File

@ -12,7 +12,7 @@ use quote::format_ident;
use subdiagnostic::SessionSubdiagnosticDerive;
use synstructure::Structure;
/// Implements `#[derive(SessionDiagnostic)]`, which allows for errors to be specified as a struct,
/// Implements `#[derive(DiagnosticHandler)]`, which allows for errors to be specified as a struct,
/// independent from the actual diagnostics emitting code.
///
/// ```ignore (rust)
@ -22,7 +22,7 @@ use synstructure::Structure;
/// # use rustc_span::{symbol::Ident, Span};
/// # extern crate rust_middle;
/// # use rustc_middle::ty::Ty;
/// #[derive(SessionDiagnostic)]
/// #[derive(DiagnosticHandler)]
/// #[diag(borrowck::move_out_of_borrow, code = "E0505")]
/// pub struct MoveOutOfBorrowError<'tcx> {
/// pub name: Ident,
@ -56,10 +56,10 @@ use synstructure::Structure;
/// });
/// ```
///
/// See rustc dev guide for more examples on using the `#[derive(SessionDiagnostic)]`:
/// See rustc dev guide for more examples on using the `#[derive(DiagnosticHandler)]`:
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream {
SessionDiagnosticDerive::new(format_ident!("diag"), format_ident!("sess"), s).into_tokens()
SessionDiagnosticDerive::new(format_ident!("diag"), format_ident!("handler"), s).into_tokens()
}
/// Implements `#[derive(LintDiagnostic)]`, which allows for lints to be specified as a struct,

View File

@ -127,7 +127,7 @@ decl_derive!([TypeFoldable, attributes(type_foldable)] => type_foldable::type_fo
decl_derive!([TypeVisitable, attributes(type_visitable)] => type_visitable::type_visitable_derive);
decl_derive!([Lift, attributes(lift)] => lift::lift_derive);
decl_derive!(
[SessionDiagnostic, attributes(
[DiagnosticHandler, attributes(
// struct attributes
diag,
help,

View File

@ -3,49 +3,49 @@ use std::{
path::{Path, PathBuf},
};
use rustc_errors::{error_code, ErrorGuaranteed, SessionDiagnostic};
use rustc_macros::SessionDiagnostic;
use rustc_errors::{error_code, IntoDiagnostic, ErrorGuaranteed};
use rustc_macros::DiagnosticHandler;
use rustc_session::config;
use rustc_span::{sym, Span, Symbol};
use rustc_target::spec::{PanicStrategy, TargetTriple};
use crate::locator::CrateFlavor;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::rlib_required)]
pub struct RlibRequired {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::lib_required)]
pub struct LibRequired<'a> {
pub crate_name: Symbol,
pub kind: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::crate_dep_multiple)]
#[help]
pub struct CrateDepMultiple {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::two_panic_runtimes)]
pub struct TwoPanicRuntimes {
pub prev_name: Symbol,
pub cur_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::bad_panic_strategy)]
pub struct BadPanicStrategy {
pub runtime: Symbol,
pub strategy: PanicStrategy,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::required_panic_strategy)]
pub struct RequiredPanicStrategy {
pub crate_name: Symbol,
@ -53,7 +53,7 @@ pub struct RequiredPanicStrategy {
pub desired_strategy: PanicStrategy,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::incompatible_panic_in_drop_strategy)]
pub struct IncompatiblePanicInDropStrategy {
pub crate_name: Symbol,
@ -61,56 +61,56 @@ pub struct IncompatiblePanicInDropStrategy {
pub desired_strategy: PanicStrategy,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_names_in_link)]
pub struct MultipleNamesInLink {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_kinds_in_link)]
pub struct MultipleKindsInLink {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_name_form)]
pub struct LinkNameForm {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_kind_form)]
pub struct LinkKindForm {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_modifiers_form)]
pub struct LinkModifiersForm {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_cfg_form)]
pub struct LinkCfgForm {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::wasm_import_form)]
pub struct WasmImportForm {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::empty_link_name, code = "E0454")]
pub struct EmptyLinkName {
#[primary_span]
@ -118,21 +118,21 @@ pub struct EmptyLinkName {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_framework_apple, code = "E0455")]
pub struct LinkFrameworkApple {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::framework_only_windows, code = "E0455")]
pub struct FrameworkOnlyWindows {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::unknown_link_kind, code = "E0458")]
pub struct UnknownLinkKind<'a> {
#[primary_span]
@ -141,49 +141,49 @@ pub struct UnknownLinkKind<'a> {
pub kind: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_link_modifiers)]
pub struct MultipleLinkModifiers {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_cfgs)]
pub struct MultipleCfgs {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_cfg_single_predicate)]
pub struct LinkCfgSinglePredicate {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_wasm_import)]
pub struct MultipleWasmImport {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::unexpected_link_arg)]
pub struct UnexpectedLinkArg {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::invalid_link_modifier)]
pub struct InvalidLinkModifier {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_modifiers)]
pub struct MultipleModifiers<'a> {
#[primary_span]
@ -191,28 +191,28 @@ pub struct MultipleModifiers<'a> {
pub modifier: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::bundle_needs_static)]
pub struct BundleNeedsStatic {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::whole_archive_needs_static)]
pub struct WholeArchiveNeedsStatic {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::as_needed_compatibility)]
pub struct AsNeededCompatibility {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::unknown_link_modifier)]
pub struct UnknownLinkModifier<'a> {
#[primary_span]
@ -220,14 +220,14 @@ pub struct UnknownLinkModifier<'a> {
pub modifier: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::incompatible_wasm_link)]
pub struct IncompatibleWasmLink {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_requires_name, code = "E0459")]
pub struct LinkRequiresName {
#[primary_span]
@ -235,105 +235,105 @@ pub struct LinkRequiresName {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::raw_dylib_no_nul)]
pub struct RawDylibNoNul {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::link_ordinal_raw_dylib)]
pub struct LinkOrdinalRawDylib {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::lib_framework_apple)]
pub struct LibFrameworkApple;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::empty_renaming_target)]
pub struct EmptyRenamingTarget<'a> {
pub lib_name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::renaming_no_link)]
pub struct RenamingNoLink<'a> {
pub lib_name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_renamings)]
pub struct MultipleRenamings<'a> {
pub lib_name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::no_link_mod_override)]
pub struct NoLinkModOverride {
#[primary_span]
pub span: Option<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::unsupported_abi_i686)]
pub struct UnsupportedAbiI686 {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::unsupported_abi)]
pub struct UnsupportedAbi {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::fail_create_file_encoder)]
pub struct FailCreateFileEncoder {
pub err: Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::fail_seek_file)]
pub struct FailSeekFile {
pub err: Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::fail_write_file)]
pub struct FailWriteFile {
pub err: Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::crate_not_panic_runtime)]
pub struct CrateNotPanicRuntime {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::no_panic_strategy)]
pub struct NoPanicStrategy {
pub crate_name: Symbol,
pub strategy: PanicStrategy,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::profiler_builtins_needs_core)]
pub struct ProfilerBuiltinsNeedsCore;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::not_profiler_runtime)]
pub struct NotProfilerRuntime {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::no_multiple_global_alloc)]
pub struct NoMultipleGlobalAlloc {
#[primary_span]
@ -343,18 +343,18 @@ pub struct NoMultipleGlobalAlloc {
pub span1: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::conflicting_global_alloc)]
pub struct ConflictingGlobalAlloc {
pub crate_name: Symbol,
pub other_crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::global_alloc_required)]
pub struct GlobalAllocRequired;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::no_transitive_needs_dep)]
pub struct NoTransitiveNeedsDep<'a> {
pub crate_name: Symbol,
@ -362,7 +362,7 @@ pub struct NoTransitiveNeedsDep<'a> {
pub deps_crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::failed_write_error)]
pub struct FailedWriteError {
pub filename: PathBuf,
@ -381,20 +381,20 @@ pub struct FailedCreateTempdir {
pub err: Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::failed_create_file)]
pub struct FailedCreateFile<'a> {
pub filename: &'a Path,
pub err: Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::failed_create_encoded_metadata)]
pub struct FailedCreateEncodedMetadata {
pub err: Error,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::non_ascii_name)]
pub struct NonAsciiName {
#[primary_span]
@ -402,7 +402,7 @@ pub struct NonAsciiName {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::extern_location_not_exist)]
pub struct ExternLocationNotExist<'a> {
#[primary_span]
@ -411,7 +411,7 @@ pub struct ExternLocationNotExist<'a> {
pub location: &'a Path,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::extern_location_not_file)]
pub struct ExternLocationNotFile<'a> {
#[primary_span]
@ -427,7 +427,7 @@ pub(crate) struct MultipleCandidates {
pub candidates: Vec<PathBuf>,
}
impl SessionDiagnostic<'_> for MultipleCandidates {
impl IntoDiagnostic<'_> for MultipleCandidates {
fn into_diagnostic(
self,
handler: &'_ rustc_errors::Handler,
@ -444,7 +444,7 @@ impl SessionDiagnostic<'_> for MultipleCandidates {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_matching_crates, code = "E0464")]
#[note]
pub struct MultipleMatchingCrates {
@ -454,7 +454,7 @@ pub struct MultipleMatchingCrates {
pub candidates: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::symbol_conflicts_current, code = "E0519")]
pub struct SymbolConflictsCurrent {
#[primary_span]
@ -462,7 +462,7 @@ pub struct SymbolConflictsCurrent {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::symbol_conflicts_others, code = "E0523")]
pub struct SymbolConflictsOthers {
#[primary_span]
@ -470,7 +470,7 @@ pub struct SymbolConflictsOthers {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::stable_crate_id_collision)]
pub struct StableCrateIdCollision {
#[primary_span]
@ -479,7 +479,7 @@ pub struct StableCrateIdCollision {
pub crate_name1: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::dl_error)]
pub struct DlError {
#[primary_span]
@ -487,7 +487,7 @@ pub struct DlError {
pub err: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::newer_crate_version, code = "E0460")]
#[note]
#[note(metadata::found_crate_versions)]
@ -499,7 +499,7 @@ pub struct NewerCrateVersion {
pub found_crates: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::no_crate_with_triple, code = "E0461")]
#[note(metadata::found_crate_versions)]
pub struct NoCrateWithTriple<'a> {
@ -511,7 +511,7 @@ pub struct NoCrateWithTriple<'a> {
pub found_crates: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::found_staticlib, code = "E0462")]
#[note(metadata::found_crate_versions)]
#[help]
@ -523,7 +523,7 @@ pub struct FoundStaticlib {
pub found_crates: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::incompatible_rustc, code = "E0514")]
#[note(metadata::found_crate_versions)]
#[help]
@ -543,7 +543,7 @@ pub struct InvalidMetadataFiles {
pub crate_rejections: Vec<String>,
}
impl SessionDiagnostic<'_> for InvalidMetadataFiles {
impl IntoDiagnostic<'_> for InvalidMetadataFiles {
fn into_diagnostic(
self,
handler: &'_ rustc_errors::Handler,
@ -571,7 +571,7 @@ pub struct CannotFindCrate {
pub locator_triple: TargetTriple,
}
impl SessionDiagnostic<'_> for CannotFindCrate {
impl IntoDiagnostic<'_> for CannotFindCrate {
fn into_diagnostic(
self,
handler: &'_ rustc_errors::Handler,
@ -617,7 +617,7 @@ impl SessionDiagnostic<'_> for CannotFindCrate {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::no_dylib_plugin, code = "E0457")]
pub struct NoDylibPlugin {
#[primary_span]
@ -625,7 +625,7 @@ pub struct NoDylibPlugin {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::crate_location_unknown_type)]
pub struct CrateLocationUnknownType<'a> {
#[primary_span]
@ -633,7 +633,7 @@ pub struct CrateLocationUnknownType<'a> {
pub path: &'a Path,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::lib_filename_form)]
pub struct LibFilenameForm<'a> {
#[primary_span]
@ -642,28 +642,28 @@ pub struct LibFilenameForm<'a> {
pub dll_suffix: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::multiple_import_name_type)]
pub struct MultipleImportNameType {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::import_name_type_form)]
pub struct ImportNameTypeForm {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::import_name_type_x86)]
pub struct ImportNameTypeX86 {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::unknown_import_name_type)]
pub struct UnknownImportNameType<'a> {
#[primary_span]
@ -671,7 +671,7 @@ pub struct UnknownImportNameType<'a> {
pub import_name_type: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(metadata::import_name_type_raw)]
pub struct ImportNameTypeRaw {
#[primary_span]

View File

@ -1,9 +1,9 @@
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::Span;
use crate::ty::Ty;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(middle::drop_check_overflow, code = "E0320")]
#[note]
pub struct DropCheckOverflow<'tcx> {
@ -13,7 +13,7 @@ pub struct DropCheckOverflow<'tcx> {
pub overflow_ty: Ty<'tcx>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(middle::opaque_hidden_type_mismatch)]
pub struct OpaqueHiddenTypeMismatch<'tcx> {
pub self_ty: Ty<'tcx>,
@ -39,7 +39,7 @@ pub enum TypeMismatchReason {
},
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(middle::limit_invalid)]
pub struct LimitInvalid<'a> {
#[primary_span]

View File

@ -1,21 +1,21 @@
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::{Span, Symbol};
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::path_must_end_in_filename)]
pub(crate) struct PathMustEndInFilename {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::unknown_formatter)]
pub(crate) struct UnknownFormatter {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::duplicate_values_for)]
pub(crate) struct DuplicateValuesFor {
#[primary_span]
@ -23,7 +23,7 @@ pub(crate) struct DuplicateValuesFor {
pub name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::requires_an_argument)]
pub(crate) struct RequiresAnArgument {
#[primary_span]
@ -31,39 +31,39 @@ pub(crate) struct RequiresAnArgument {
pub name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::stop_after_dataflow_ended_compilation)]
pub(crate) struct StopAfterDataFlowEndedCompilation;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::peek_must_be_place_or_ref_place)]
pub(crate) struct PeekMustBePlaceOrRefPlace {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::peek_must_be_not_temporary)]
pub(crate) struct PeekMustBeNotTemporary {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::peek_bit_not_set)]
pub(crate) struct PeekBitNotSet {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::peek_argument_not_a_local)]
pub(crate) struct PeekArgumentNotALocal {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(mir_dataflow::peek_argument_untracked)]
pub(crate) struct PeekArgumentUntracked {
#[primary_span]

View File

@ -1,11 +1,11 @@
use std::path::PathBuf;
use rustc_errors::IntoDiagnostic;
use rustc_errors::ErrorGuaranteed;
use rustc_errors::SessionDiagnostic;
use rustc_macros::{LintDiagnostic, SessionDiagnostic};
use rustc_macros::{DiagnosticHandler, LintDiagnostic};
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(monomorphize::recursion_limit)]
pub struct RecursionLimit {
#[primary_span]
@ -19,7 +19,7 @@ pub struct RecursionLimit {
pub path: PathBuf,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(monomorphize::type_length_limit)]
#[help(monomorphize::consider_type_length_limit)]
pub struct TypeLengthLimit {
@ -32,7 +32,7 @@ pub struct TypeLengthLimit {
pub type_length: usize,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(monomorphize::requires_lang_item)]
pub struct RequiresLangItem {
pub lang_item: String,
@ -44,7 +44,7 @@ pub struct UnusedGenericParams {
pub param_names: Vec<String>,
}
impl SessionDiagnostic<'_> for UnusedGenericParams {
impl IntoDiagnostic<'_> for UnusedGenericParams {
fn into_diagnostic(
self,
handler: &'_ rustc_errors::Handler,
@ -72,11 +72,11 @@ pub struct LargeAssignmentsLint {
pub limit: u64,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(monomorphize::unknown_partition_strategy)]
pub struct UnknownPartitionStrategy;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(monomorphize::symbol_already_defined)]
pub struct SymbolAlreadyDefined {
#[primary_span]

View File

@ -20,7 +20,7 @@ use rustc_errors::{
fluent, Applicability, DiagnosticBuilder, DiagnosticMessage, Handler, MultiSpan, PResult,
};
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed};
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{Span, SpanSnippetError, DUMMY_SP};
@ -242,7 +242,7 @@ impl MultiSugg {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::maybe_report_ambiguous_plus)]
struct AmbiguousPlus {
pub sum_ty: String,
@ -251,7 +251,7 @@ struct AmbiguousPlus {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::maybe_recover_from_bad_type_plus, code = "E0178")]
struct BadTypePlus {
pub ty: String,
@ -285,7 +285,7 @@ pub enum BadTypePlusSub {
},
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::maybe_recover_from_bad_qpath_stage_2)]
struct BadQPathStage2 {
#[primary_span]
@ -294,7 +294,7 @@ struct BadQPathStage2 {
ty: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::incorrect_semicolon)]
struct IncorrectSemicolon<'a> {
#[primary_span]
@ -305,7 +305,7 @@ struct IncorrectSemicolon<'a> {
name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::incorrect_use_of_await)]
struct IncorrectUseOfAwait {
#[primary_span]
@ -313,7 +313,7 @@ struct IncorrectUseOfAwait {
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::incorrect_use_of_await)]
struct IncorrectAwait {
#[primary_span]
@ -324,7 +324,7 @@ struct IncorrectAwait {
question_mark: &'static str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::in_in_typo)]
struct InInTypo {
#[primary_span]
@ -333,7 +333,7 @@ struct InInTypo {
sugg_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_variable_declaration)]
pub struct InvalidVariableDeclaration {
#[primary_span]
@ -362,7 +362,7 @@ pub enum InvalidVariableDeclarationSub {
UseLetNotVar(#[primary_span] Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_comparison_operator)]
pub(crate) struct InvalidComparisonOperator {
#[primary_span]
@ -389,7 +389,7 @@ pub(crate) enum InvalidComparisonOperatorSub {
Spaceship(#[primary_span] Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_logical_operator)]
#[note]
pub(crate) struct InvalidLogicalOperator {
@ -416,7 +416,7 @@ pub(crate) enum InvalidLogicalOperatorSub {
Disjunction(#[primary_span] Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::tilde_is_not_unary_operator)]
pub(crate) struct TildeAsUnaryOperator(
#[primary_span]
@ -424,7 +424,7 @@ pub(crate) struct TildeAsUnaryOperator(
pub Span,
);
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::unexpected_token_after_not)]
pub(crate) struct NotAsNegationOperator {
#[primary_span]
@ -458,7 +458,7 @@ pub enum NotAsNegationOperatorSub {
SuggestNotLogical(#[primary_span] Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::malformed_loop_label)]
pub(crate) struct MalformedLoopLabel {
#[primary_span]
@ -467,7 +467,7 @@ pub(crate) struct MalformedLoopLabel {
pub correct_label: Ident,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::lifetime_in_borrow_expression)]
pub(crate) struct LifetimeInBorrowExpression {
#[primary_span]
@ -477,15 +477,15 @@ pub(crate) struct LifetimeInBorrowExpression {
pub lifetime_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::field_expression_with_generic)]
pub(crate) struct FieldExpressionWithGeneric(#[primary_span] pub Span);
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::macro_invocation_with_qualified_path)]
pub(crate) struct MacroInvocationWithQualifiedPath(#[primary_span] pub Span);
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::unexpected_token_after_label)]
pub(crate) struct UnexpectedTokenAfterLabel(
#[primary_span]
@ -493,7 +493,7 @@ pub(crate) struct UnexpectedTokenAfterLabel(
pub Span,
);
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::require_colon_after_labeled_expression)]
#[note]
pub(crate) struct RequireColonAfterLabeledExpression {
@ -505,7 +505,7 @@ pub(crate) struct RequireColonAfterLabeledExpression {
pub label_end: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::do_catch_syntax_removed)]
#[note]
pub(crate) struct DoCatchSyntaxRemoved {
@ -514,7 +514,7 @@ pub(crate) struct DoCatchSyntaxRemoved {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::float_literal_requires_integer_part)]
pub(crate) struct FloatLiteralRequiresIntegerPart {
#[primary_span]
@ -523,7 +523,7 @@ pub(crate) struct FloatLiteralRequiresIntegerPart {
pub correct: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_int_literal_width)]
#[help]
pub(crate) struct InvalidIntLiteralWidth {
@ -532,7 +532,7 @@ pub(crate) struct InvalidIntLiteralWidth {
pub width: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_num_literal_base_prefix)]
#[note]
pub(crate) struct InvalidNumLiteralBasePrefix {
@ -542,7 +542,7 @@ pub(crate) struct InvalidNumLiteralBasePrefix {
pub fixed: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_num_literal_suffix)]
#[help]
pub(crate) struct InvalidNumLiteralSuffix {
@ -552,7 +552,7 @@ pub(crate) struct InvalidNumLiteralSuffix {
pub suffix: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_float_literal_width)]
#[help]
pub(crate) struct InvalidFloatLiteralWidth {
@ -561,7 +561,7 @@ pub(crate) struct InvalidFloatLiteralWidth {
pub width: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_float_literal_suffix)]
#[help]
pub(crate) struct InvalidFloatLiteralSuffix {
@ -571,14 +571,14 @@ pub(crate) struct InvalidFloatLiteralSuffix {
pub suffix: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::int_literal_too_large)]
pub(crate) struct IntLiteralTooLarge {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::missing_semicolon_before_array)]
pub(crate) struct MissingSemicolonBeforeArray {
#[primary_span]
@ -587,7 +587,7 @@ pub(crate) struct MissingSemicolonBeforeArray {
pub semicolon: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::invalid_block_macro_segment)]
pub(crate) struct InvalidBlockMacroSegment {
#[primary_span]
@ -596,7 +596,7 @@ pub(crate) struct InvalidBlockMacroSegment {
pub context: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::if_expression_missing_then_block)]
pub(crate) struct IfExpressionMissingThenBlock {
#[primary_span]
@ -613,7 +613,7 @@ pub(crate) enum IfExpressionMissingThenBlockSub {
AddThenBlock(#[primary_span] Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::if_expression_missing_condition)]
pub(crate) struct IfExpressionMissingCondition {
#[primary_span]
@ -623,14 +623,14 @@ pub(crate) struct IfExpressionMissingCondition {
pub block_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::expected_expression_found_let)]
pub(crate) struct ExpectedExpressionFoundLet {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::expected_else_block)]
pub(crate) struct ExpectedElseBlock {
#[primary_span]
@ -642,7 +642,7 @@ pub(crate) struct ExpectedElseBlock {
pub condition_start: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::outer_attribute_not_allowed_on_if_else)]
pub(crate) struct OuterAttributeNotAllowedOnIfElse {
#[primary_span]
@ -659,7 +659,7 @@ pub(crate) struct OuterAttributeNotAllowedOnIfElse {
pub attributes: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::missing_in_in_for_loop)]
pub(crate) struct MissingInInForLoop {
#[primary_span]
@ -677,7 +677,7 @@ pub(crate) enum MissingInInForLoopSub {
AddIn(#[primary_span] Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::missing_comma_after_match_arm)]
pub(crate) struct MissingCommaAfterMatchArm {
#[primary_span]
@ -685,7 +685,7 @@ pub(crate) struct MissingCommaAfterMatchArm {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::catch_after_try)]
#[help]
pub(crate) struct CatchAfterTry {
@ -693,7 +693,7 @@ pub(crate) struct CatchAfterTry {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::comma_after_base_struct)]
#[note]
pub(crate) struct CommaAfterBaseStruct {
@ -703,7 +703,7 @@ pub(crate) struct CommaAfterBaseStruct {
pub comma: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::eq_field_init)]
pub(crate) struct EqFieldInit {
#[primary_span]
@ -712,7 +712,7 @@ pub(crate) struct EqFieldInit {
pub eq: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::dotdotdot)]
pub(crate) struct DotDotDot {
#[primary_span]
@ -721,7 +721,7 @@ pub(crate) struct DotDotDot {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::left_arrow_operator)]
pub(crate) struct LeftArrowOperator {
#[primary_span]
@ -729,7 +729,7 @@ pub(crate) struct LeftArrowOperator {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::remove_let)]
pub(crate) struct RemoveLet {
#[primary_span]

View File

@ -36,7 +36,7 @@ use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty
use rustc_ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
use rustc_ast::{ClosureBinder, StmtKind};
use rustc_ast_pretty::pprust;
use rustc_errors::SessionDiagnostic;
use rustc_errors::IntoDiagnostic;
use rustc_errors::{Applicability, Diagnostic, PResult};
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
use rustc_session::lint::BuiltinLintDiagnostics;

View File

@ -1,5 +1,5 @@
use rustc_errors::{Applicability, MultiSpan};
use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, LintDiagnostic, SessionSubdiagnostic};
use rustc_span::{Span, Symbol};
#[derive(LintDiagnostic)]
@ -32,7 +32,7 @@ pub struct IgnoredInlineAttrFnProto;
#[note]
pub struct IgnoredInlineAttrConstants;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::inline_not_fn_or_closure, code = "E0518")]
pub struct InlineNotFnOrClosure {
#[primary_span]
@ -53,7 +53,7 @@ pub struct IgnoredNoCoveragePropagate;
#[diag(passes::no_coverage_fn_defn)]
pub struct IgnoredNoCoverageFnDefn;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::no_coverage_not_coverable, code = "E0788")]
pub struct IgnoredNoCoverageNotCoverable {
#[primary_span]
@ -62,7 +62,7 @@ pub struct IgnoredNoCoverageNotCoverable {
pub defn_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::should_be_applied_to_fn)]
pub struct AttrShouldBeAppliedToFn {
#[primary_span]
@ -71,14 +71,14 @@ pub struct AttrShouldBeAppliedToFn {
pub defn_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::naked_tracked_caller, code = "E0736")]
pub struct NakedTrackedCaller {
#[primary_span]
pub attr_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::should_be_applied_to_fn, code = "E0739")]
pub struct TrackedCallerWrongLocation {
#[primary_span]
@ -87,7 +87,7 @@ pub struct TrackedCallerWrongLocation {
pub defn_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::should_be_applied_to_struct_enum, code = "E0701")]
pub struct NonExhaustiveWrongLocation {
#[primary_span]
@ -96,7 +96,7 @@ pub struct NonExhaustiveWrongLocation {
pub defn_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::should_be_applied_to_trait)]
pub struct AttrShouldBeAppliedToTrait {
#[primary_span]
@ -109,7 +109,7 @@ pub struct AttrShouldBeAppliedToTrait {
#[diag(passes::target_feature_on_statement)]
pub struct TargetFeatureOnStatement;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::should_be_applied_to_static)]
pub struct AttrShouldBeAppliedToStatic {
#[primary_span]
@ -118,7 +118,7 @@ pub struct AttrShouldBeAppliedToStatic {
pub defn_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_expect_str)]
pub struct DocExpectStr<'a> {
#[primary_span]
@ -126,7 +126,7 @@ pub struct DocExpectStr<'a> {
pub attr_name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_alias_empty)]
pub struct DocAliasEmpty<'a> {
#[primary_span]
@ -134,7 +134,7 @@ pub struct DocAliasEmpty<'a> {
pub attr_str: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_alias_bad_char)]
pub struct DocAliasBadChar<'a> {
#[primary_span]
@ -143,7 +143,7 @@ pub struct DocAliasBadChar<'a> {
pub char_: char,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_alias_start_end)]
pub struct DocAliasStartEnd<'a> {
#[primary_span]
@ -151,7 +151,7 @@ pub struct DocAliasStartEnd<'a> {
pub attr_str: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_alias_bad_location)]
pub struct DocAliasBadLocation<'a> {
#[primary_span]
@ -160,7 +160,7 @@ pub struct DocAliasBadLocation<'a> {
pub location: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_alias_not_an_alias)]
pub struct DocAliasNotAnAlias<'a> {
#[primary_span]
@ -175,35 +175,35 @@ pub struct DocAliasDuplicated {
pub first_defn: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_alias_not_string_literal)]
pub struct DocAliasNotStringLiteral {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_alias_malformed)]
pub struct DocAliasMalformed {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_keyword_empty_mod)]
pub struct DocKeywordEmptyMod {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_keyword_not_mod)]
pub struct DocKeywordNotMod {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_keyword_invalid_ident)]
pub struct DocKeywordInvalidIdent {
#[primary_span]
@ -211,21 +211,21 @@ pub struct DocKeywordInvalidIdent {
pub doc_keyword: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_fake_variadic_not_valid)]
pub struct DocFakeVariadicNotValid {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_keyword_only_impl)]
pub struct DocKeywordOnlyImpl {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_inline_conflict)]
#[help]
pub struct DocKeywordConflict {
@ -243,7 +243,7 @@ pub struct DocInlineOnlyUse {
pub item_span: Option<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::doc_attr_not_crate_level)]
pub struct DocAttrNotCrateLevel<'a> {
#[primary_span]
@ -295,7 +295,7 @@ pub struct DocTestUnknownInclude {
#[diag(passes::doc_invalid)]
pub struct DocInvalid;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::pass_by_value)]
pub struct PassByValue {
#[primary_span]
@ -304,7 +304,7 @@ pub struct PassByValue {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::allow_incoherent_impl)]
pub struct AllowIncoherentImpl {
#[primary_span]
@ -313,7 +313,7 @@ pub struct AllowIncoherentImpl {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::has_incoherent_inherent_impl)]
pub struct HasIncoherentInherentImpl {
#[primary_span]
@ -336,7 +336,7 @@ pub struct MustUseNoEffect {
pub target: rustc_hir::Target,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::must_not_suspend)]
pub struct MustNotSuspend {
#[primary_span]
@ -372,7 +372,7 @@ pub struct LinkName<'a> {
pub value: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::no_link)]
pub struct NoLink {
#[primary_span]
@ -381,7 +381,7 @@ pub struct NoLink {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::export_name)]
pub struct ExportName {
#[primary_span]
@ -390,7 +390,7 @@ pub struct ExportName {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_layout_scalar_valid_range_not_struct)]
pub struct RustcLayoutScalarValidRangeNotStruct {
#[primary_span]
@ -399,14 +399,14 @@ pub struct RustcLayoutScalarValidRangeNotStruct {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_layout_scalar_valid_range_arg)]
pub struct RustcLayoutScalarValidRangeArg {
#[primary_span]
pub attr_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_legacy_const_generics_only)]
pub struct RustcLegacyConstGenericsOnly {
#[primary_span]
@ -415,7 +415,7 @@ pub struct RustcLegacyConstGenericsOnly {
pub param_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_legacy_const_generics_index)]
pub struct RustcLegacyConstGenericsIndex {
#[primary_span]
@ -424,7 +424,7 @@ pub struct RustcLegacyConstGenericsIndex {
pub generics_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_legacy_const_generics_index_exceed)]
pub struct RustcLegacyConstGenericsIndexExceed {
#[primary_span]
@ -433,14 +433,14 @@ pub struct RustcLegacyConstGenericsIndexExceed {
pub arg_count: usize,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_legacy_const_generics_index_negative)]
pub struct RustcLegacyConstGenericsIndexNegative {
#[primary_span]
pub invalid_args: Vec<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_dirty_clean)]
pub struct RustcDirtyClean {
#[primary_span]
@ -475,7 +475,7 @@ pub struct NoMangle {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::repr_ident, code = "E0565")]
pub struct ReprIdent {
#[primary_span]
@ -486,21 +486,21 @@ pub struct ReprIdent {
#[diag(passes::repr_conflicting, code = "E0566")]
pub struct ReprConflicting;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::used_static)]
pub struct UsedStatic {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::used_compiler_linker)]
pub struct UsedCompilerLinker {
#[primary_span]
pub spans: Vec<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::allow_internal_unstable)]
pub struct AllowInternalUnstable {
#[primary_span]
@ -509,14 +509,14 @@ pub struct AllowInternalUnstable {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::debug_visualizer_placement)]
pub struct DebugVisualizerPlacement {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::debug_visualizer_invalid)]
#[note(passes::note_1)]
#[note(passes::note_2)]
@ -526,7 +526,7 @@ pub struct DebugVisualizerInvalid {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_allow_const_fn_unstable)]
pub struct RustcAllowConstFnUnstable {
#[primary_span]
@ -535,7 +535,7 @@ pub struct RustcAllowConstFnUnstable {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_std_internal_symbol)]
pub struct RustcStdInternalSymbol {
#[primary_span]
@ -544,21 +544,21 @@ pub struct RustcStdInternalSymbol {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::const_trait)]
pub struct ConstTrait {
#[primary_span]
pub attr_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::link_ordinal)]
pub struct LinkOrdinal {
#[primary_span]
pub attr_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::stability_promotable)]
pub struct StabilityPromotable {
#[primary_span]
@ -602,7 +602,7 @@ pub struct Unused {
pub note: UnusedNote,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::non_exported_macro_invalid_attrs, code = "E0518")]
pub struct NonExportedMacroInvalidAttrs {
#[primary_span]
@ -621,7 +621,7 @@ pub struct UnusedDuplicate {
pub warning: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::unused_multiple)]
pub struct UnusedMultiple {
#[primary_span]
@ -632,7 +632,7 @@ pub struct UnusedMultiple {
pub name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_lint_opt_ty)]
pub struct RustcLintOptTy {
#[primary_span]
@ -641,7 +641,7 @@ pub struct RustcLintOptTy {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(passes::rustc_lint_opt_deny_field_access)]
pub struct RustcLintOptDenyFieldAccess {
#[primary_span]

View File

@ -1,9 +1,9 @@
//! Errors emitted by plugin_impl
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(plugin_impl::load_plugin_error)]
pub struct LoadPluginError {
#[primary_span]
@ -11,7 +11,7 @@ pub struct LoadPluginError {
pub msg: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(plugin_impl::malformed_plugin_attribute, code = "E0498")]
pub struct MalformedPluginAttribute {
#[primary_span]

View File

@ -1,8 +1,8 @@
use rustc_errors::DiagnosticArgFromDisplay;
use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, LintDiagnostic, SessionSubdiagnostic};
use rustc_span::{Span, Symbol};
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(privacy::field_is_private, code = "E0451")]
pub struct FieldIsPrivate {
#[primary_span]
@ -29,7 +29,7 @@ pub enum FieldIsPrivateLabel {
},
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(privacy::item_is_private)]
pub struct ItemIsPrivate<'a> {
#[primary_span]
@ -39,7 +39,7 @@ pub struct ItemIsPrivate<'a> {
pub descr: DiagnosticArgFromDisplay<'a>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(privacy::unnamed_item_is_private)]
pub struct UnnamedItemIsPrivate {
#[primary_span]
@ -48,7 +48,7 @@ pub struct UnnamedItemIsPrivate {
}
// Duplicate of `InPublicInterface` but with a different error code, shares the same slug.
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(privacy::in_public_interface, code = "E0445")]
pub struct InPublicInterfaceTraits<'a> {
#[primary_span]
@ -62,7 +62,7 @@ pub struct InPublicInterfaceTraits<'a> {
}
// Duplicate of `InPublicInterfaceTraits` but with a different error code, shares the same slug.
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(privacy::in_public_interface, code = "E0446")]
pub struct InPublicInterface<'a> {
#[primary_span]
@ -75,7 +75,7 @@ pub struct InPublicInterface<'a> {
pub vis_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(privacy::report_effective_visibility)]
pub struct ReportEffectiveVisibility {
#[primary_span]

View File

@ -1,4 +1,4 @@
use rustc_errors::AddSubdiagnostic;
use rustc_errors::AddToDiagnostic;
use rustc_session::Limit;
use rustc_span::{Span, Symbol};
@ -7,7 +7,7 @@ pub struct CycleStack {
pub desc: String,
}
impl AddSubdiagnostic for CycleStack {
impl AddToDiagnostic for CycleStack {
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
diag.span_note(self.span, &format!("...which requires {}...", self.desc));
}
@ -46,7 +46,7 @@ pub struct CycleUsage {
pub usage: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(query_system::cycle, code = "E0391")]
pub struct Cycle {
#[primary_span]
@ -62,11 +62,11 @@ pub struct Cycle {
pub cycle_usage: Option<CycleUsage>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(query_system::reentrant)]
pub struct Reentrant;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(query_system::increment_compilation)]
#[help]
#[note(query_system::increment_compilation_note1)]
@ -76,7 +76,7 @@ pub struct IncrementCompilation {
pub dep_node: String,
}
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[help]
#[diag(query_system::query_overflow)]
pub struct QueryOverflow {
@ -88,7 +88,7 @@ pub struct QueryOverflow {
pub crate_name: Symbol,
}
#[derive(SessionSubdiagnostic)]
#[derive(Subdiagnostic)]
#[note(query_system::layout_of_depth)]
pub struct LayoutOfDepth {
pub desc: String,

View File

@ -4,7 +4,7 @@ use crate::query::{QueryContext, QueryStackFrame};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{
Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, Level, SessionDiagnostic,
Diagnostic, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed, Handler, Level,
};
use rustc_hir::def::DefKind;
use rustc_session::Session;

View File

@ -1,8 +1,8 @@
use rustc_macros::SessionDiagnostic;
use rustc_macros::DiagnosticHandler;
use std::path::Path;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(save_analysis::could_not_open)]
pub(crate) struct CouldNotOpen<'a> {
pub file_name: &'a Path,

View File

@ -8,7 +8,7 @@ use rustc_span::{Span, Symbol};
use rustc_target::abi::TargetDataLayoutErrors;
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(session::incorrect_cgu_reuse_type)]
pub struct IncorrectCguReuseType<'a> {
#[primary_span]
@ -19,14 +19,14 @@ pub struct IncorrectCguReuseType<'a> {
pub at_least: u8,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(session::cgu_not_recorded)]
pub struct CguNotRecorded<'a> {
pub cgu_user_name: &'a str,
pub cgu_name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(session::feature_gate_error, code = "E0658")]
pub struct FeatureGateError<'a> {
#[primary_span]
@ -46,19 +46,19 @@ pub struct FeatureDiagnosticHelp {
pub feature: Symbol,
}
impl SessionDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
fn into_diagnostic(self, sess: &Handler) -> DiagnosticBuilder<'_, !> {
impl DiagnosticHandler<'_, !> for TargetDataLayoutErrors<'_> {
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
let mut diag;
match self {
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
diag = sess.struct_fatal(fluent::session::target_invalid_address_space);
diag = handler.struct_fatal(fluent::session::target_invalid_address_space);
diag.set_arg("addr_space", addr_space);
diag.set_arg("cause", cause);
diag.set_arg("err", err);
diag
}
TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => {
diag = sess.struct_fatal(fluent::session::target_invalid_bits);
diag = handler.struct_fatal(fluent::session::target_invalid_bits);
diag.set_arg("kind", kind);
diag.set_arg("bit", bit);
diag.set_arg("cause", cause);
@ -66,30 +66,30 @@ impl SessionDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
diag
}
TargetDataLayoutErrors::MissingAlignment { cause } => {
diag = sess.struct_fatal(fluent::session::target_missing_alignment);
diag = handler.struct_fatal(fluent::session::target_missing_alignment);
diag.set_arg("cause", cause);
diag
}
TargetDataLayoutErrors::InvalidAlignment { cause, err } => {
diag = sess.struct_fatal(fluent::session::target_invalid_alignment);
diag = handler.struct_fatal(fluent::session::target_invalid_alignment);
diag.set_arg("cause", cause);
diag.set_arg("err", err);
diag
}
TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => {
diag = sess.struct_fatal(fluent::session::target_inconsistent_architecture);
diag = handler.struct_fatal(fluent::session::target_inconsistent_architecture);
diag.set_arg("dl", dl);
diag.set_arg("target", target);
diag
}
TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => {
diag = sess.struct_fatal(fluent::session::target_inconsistent_pointer_width);
diag = handler.struct_fatal(fluent::session::target_inconsistent_pointer_width);
diag.set_arg("pointer_size", pointer_size);
diag.set_arg("target", target);
diag
}
TargetDataLayoutErrors::InvalidBitsSize { err } => {
diag = sess.struct_fatal(fluent::session::target_invalid_bits_size);
diag = handler.struct_fatal(fluent::session::target_invalid_bits_size);
diag.set_arg("err", err);
diag
}

View File

@ -11,8 +11,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_data_structures::sync::{Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
use rustc_errors::{
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId,
DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, MultiSpan, SessionDiagnostic, StashKey,
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, IntoDiagnostic,
DiagnosticId, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, MultiSpan, StashKey,
};
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
use rustc_span::edition::Edition;
@ -344,34 +344,34 @@ impl ParseSess {
pub fn create_err<'a>(
&'a self,
err: impl SessionDiagnostic<'a>,
err: impl IntoDiagnostic<'a>,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
err.into_diagnostic(&self.span_diagnostic)
}
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
self.create_err(err).emit()
}
pub fn create_warning<'a>(
&'a self,
warning: impl SessionDiagnostic<'a, ()>,
warning: impl IntoDiagnostic<'a, ()>,
) -> DiagnosticBuilder<'a, ()> {
warning.into_diagnostic(&self.span_diagnostic)
}
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
self.create_warning(warning).emit()
}
pub fn create_fatal<'a>(
&'a self,
fatal: impl SessionDiagnostic<'a, !>,
fatal: impl IntoDiagnostic<'a, !>,
) -> DiagnosticBuilder<'a, !> {
fatal.into_diagnostic(&self.span_diagnostic)
}
pub fn emit_fatal<'a>(&'a self, fatal: impl SessionDiagnostic<'a, !>) -> ! {
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
self.create_fatal(fatal).emit()
}

View File

@ -27,8 +27,8 @@ use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
use rustc_errors::json::JsonEmitter;
use rustc_errors::registry::Registry;
use rustc_errors::{
error_code, fallback_fluent_bundle, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
ErrorGuaranteed, FluentBundle, LazyFallbackBundle, MultiSpan, SessionDiagnostic,
error_code, fallback_fluent_bundle, DiagnosticBuilder, IntoDiagnostic, DiagnosticId,
DiagnosticMessage, ErrorGuaranteed, FluentBundle, LazyFallbackBundle, MultiSpan,
};
use rustc_macros::HashStable_Generic;
pub use rustc_span::def_id::StableCrateId;
@ -505,13 +505,13 @@ impl Session {
}
pub fn create_err<'a>(
&'a self,
err: impl SessionDiagnostic<'a>,
err: impl IntoDiagnostic<'a>,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.parse_sess.create_err(err)
}
pub fn create_feature_err<'a>(
&'a self,
err: impl SessionDiagnostic<'a>,
err: impl IntoDiagnostic<'a>,
feature: Symbol,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = self.parse_sess.create_err(err);
@ -521,25 +521,25 @@ impl Session {
add_feature_diagnostics(&mut err, &self.parse_sess, feature);
err
}
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
self.parse_sess.emit_err(err)
}
pub fn create_warning<'a>(
&'a self,
err: impl SessionDiagnostic<'a, ()>,
err: impl IntoDiagnostic<'a, ()>,
) -> DiagnosticBuilder<'a, ()> {
self.parse_sess.create_warning(err)
}
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
self.parse_sess.emit_warning(warning)
}
pub fn create_fatal<'a>(
&'a self,
fatal: impl SessionDiagnostic<'a, !>,
fatal: impl IntoDiagnostic<'a, !>,
) -> DiagnosticBuilder<'a, !> {
self.parse_sess.create_fatal(fatal)
}
pub fn emit_fatal<'a>(&'a self, fatal: impl SessionDiagnostic<'a, !>) -> ! {
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
self.parse_sess.emit_fatal(fatal)
}
#[inline]

View File

@ -177,6 +177,7 @@ symbols! {
DecorateLint,
Default,
Deref,
DiagnosticHandler,
DiagnosticMessage,
DirBuilder,
Display,
@ -277,7 +278,6 @@ symbols! {
RwLockWriteGuard,
Send,
SeqCst,
SessionDiagnostic,
SliceIndex,
Some,
String,

View File

@ -1,10 +1,10 @@
//! Errors emitted by symbol_mangling.
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_macros::SessionDiagnostic;
use rustc_macros::Diagnostic;
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[derive(Diagnostic)]
#[diag(symbol_mangling::test_output)]
pub struct TestOutput {
#[primary_span]

View File

@ -1,10 +1,10 @@
use rustc_errors::{fluent, ErrorGuaranteed, Handler, SessionDiagnostic};
use rustc_macros::SessionDiagnostic;
use rustc_errors::{fluent, IntoDiagnostic, ErrorGuaranteed, Handler};
use rustc_macros::DiagnosticHandler;
use rustc_middle::ty::{PolyTraitRef, Ty, Unevaluated};
use rustc_session::Limit;
use rustc_span::{Span, Symbol};
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(trait_selection::dump_vtable_entries)]
pub struct DumpVTableEntries<'a> {
#[primary_span]
@ -13,7 +13,7 @@ pub struct DumpVTableEntries<'a> {
pub entries: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(trait_selection::unable_to_construct_constant_value)]
pub struct UnableToConstructConstantValue<'a> {
#[primary_span]
@ -21,7 +21,7 @@ pub struct UnableToConstructConstantValue<'a> {
pub unevaluated: Unevaluated<'a>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[help]
#[diag(trait_selection::auto_deref_reached_recursion_limit, code = "E0055")]
pub struct AutoDerefReachedRecursionLimit<'a> {
@ -33,7 +33,7 @@ pub struct AutoDerefReachedRecursionLimit<'a> {
pub crate_name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(trait_selection::empty_on_clause_in_rustc_on_unimplemented, code = "E0232")]
pub struct EmptyOnClauseInOnUnimplemented {
#[primary_span]
@ -41,7 +41,7 @@ pub struct EmptyOnClauseInOnUnimplemented {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(trait_selection::invalid_on_clause_in_rustc_on_unimplemented, code = "E0232")]
pub struct InvalidOnClauseInOnUnimplemented {
#[primary_span]
@ -49,7 +49,7 @@ pub struct InvalidOnClauseInOnUnimplemented {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(trait_selection::no_value_in_rustc_on_unimplemented, code = "E0232")]
#[note]
pub struct NoValueInOnUnimplemented {
@ -66,7 +66,7 @@ pub struct NegativePositiveConflict<'a> {
pub positive_impl_span: Result<Span, Symbol>,
}
impl SessionDiagnostic<'_> for NegativePositiveConflict<'_> {
impl IntoDiagnostic<'_> for NegativePositiveConflict<'_> {
fn into_diagnostic(
self,
handler: &Handler,

View File

@ -1,16 +1,16 @@
//! Errors emitted by ty_utils
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
use rustc_middle::ty::Ty;
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(ty_utils::needs_drop_overflow)]
pub struct NeedsDropOverflow<'tcx> {
pub query_ty: Ty<'tcx>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(ty_utils::generic_constant_too_complex)]
#[help]
pub struct GenericConstantTooComplex {

View File

@ -881,7 +881,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return;
}
// FIXME: Make this use SessionDiagnostic once error codes can be dynamically set.
// FIXME: Make this use DiagnosticHandler once error codes can be dynamically set.
let mut err = self.tcx.sess.struct_span_err_with_code(
op_span,
"invalid left-hand side of assignment",

View File

@ -1,11 +1,11 @@
//! Errors emitted by typeck.
use rustc_errors::SessionDiagnostic;
use rustc_errors::IntoDiagnostic;
use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler};
use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, LintDiagnostic, SessionSubdiagnostic};
use rustc_middle::ty::Ty;
use rustc_span::{symbol::Ident, Span, Symbol};
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::field_multiply_specified_in_initializer, code = "E0062")]
pub struct FieldMultiplySpecifiedInInitializer {
#[primary_span]
@ -16,7 +16,7 @@ pub struct FieldMultiplySpecifiedInInitializer {
pub ident: Ident,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::unrecognized_atomic_operation, code = "E0092")]
pub struct UnrecognizedAtomicOperation<'a> {
#[primary_span]
@ -25,7 +25,7 @@ pub struct UnrecognizedAtomicOperation<'a> {
pub op: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::wrong_number_of_generic_arguments_to_intrinsic, code = "E0094")]
pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
#[primary_span]
@ -36,7 +36,7 @@ pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
pub descr: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::unrecognized_intrinsic_function, code = "E0093")]
pub struct UnrecognizedIntrinsicFunction {
#[primary_span]
@ -45,7 +45,7 @@ pub struct UnrecognizedIntrinsicFunction {
pub name: Symbol,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::lifetimes_or_bounds_mismatch_on_trait, code = "E0195")]
pub struct LifetimesOrBoundsMismatchOnTrait {
#[primary_span]
@ -57,7 +57,7 @@ pub struct LifetimesOrBoundsMismatchOnTrait {
pub ident: Ident,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::drop_impl_on_wrong_item, code = "E0120")]
pub struct DropImplOnWrongItem {
#[primary_span]
@ -65,7 +65,7 @@ pub struct DropImplOnWrongItem {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::field_already_declared, code = "E0124")]
pub struct FieldAlreadyDeclared {
pub field_name: Ident,
@ -76,7 +76,7 @@ pub struct FieldAlreadyDeclared {
pub prev_span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::copy_impl_on_type_with_dtor, code = "E0184")]
pub struct CopyImplOnTypeWithDtor {
#[primary_span]
@ -84,14 +84,14 @@ pub struct CopyImplOnTypeWithDtor {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::multiple_relaxed_default_bounds, code = "E0203")]
pub struct MultipleRelaxedDefaultBounds {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::copy_impl_on_non_adt, code = "E0206")]
pub struct CopyImplOnNonAdt {
#[primary_span]
@ -99,7 +99,7 @@ pub struct CopyImplOnNonAdt {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::trait_object_declared_with_no_traits, code = "E0224")]
pub struct TraitObjectDeclaredWithNoTraits {
#[primary_span]
@ -108,14 +108,14 @@ pub struct TraitObjectDeclaredWithNoTraits {
pub trait_alias_span: Option<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0227")]
pub struct AmbiguousLifetimeBound {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::assoc_type_binding_not_allowed, code = "E0229")]
pub struct AssocTypeBindingNotAllowed {
#[primary_span]
@ -123,14 +123,14 @@ pub struct AssocTypeBindingNotAllowed {
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::functional_record_update_on_non_struct, code = "E0436")]
pub struct FunctionalRecordUpdateOnNonStruct {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::typeof_reserved_keyword_used, code = "E0516")]
pub struct TypeofReservedKeywordUsed<'tcx> {
pub ty: Ty<'tcx>,
@ -141,7 +141,7 @@ pub struct TypeofReservedKeywordUsed<'tcx> {
pub opt_sugg: Option<(Span, Applicability)>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::return_stmt_outside_of_fn_body, code = "E0572")]
pub struct ReturnStmtOutsideOfFnBody {
#[primary_span]
@ -152,14 +152,14 @@ pub struct ReturnStmtOutsideOfFnBody {
pub encl_fn_span: Option<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::yield_expr_outside_of_generator, code = "E0627")]
pub struct YieldExprOutsideOfGenerator {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::struct_expr_non_exhaustive, code = "E0639")]
pub struct StructExprNonExhaustive {
#[primary_span]
@ -167,14 +167,14 @@ pub struct StructExprNonExhaustive {
pub what: &'static str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::method_call_on_unknown_type, code = "E0699")]
pub struct MethodCallOnUnknownType {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::value_of_associated_struct_already_specified, code = "E0719")]
pub struct ValueOfAssociatedStructAlreadySpecified {
#[primary_span]
@ -186,7 +186,7 @@ pub struct ValueOfAssociatedStructAlreadySpecified {
pub def_path: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::address_of_temporary_taken, code = "E0745")]
pub struct AddressOfTemporaryTaken {
#[primary_span]
@ -232,7 +232,7 @@ pub enum ExpectedReturnTypeLabel<'tcx> {
},
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::unconstrained_opaque_type)]
#[note]
pub struct UnconstrainedOpaqueType {
@ -249,8 +249,8 @@ pub struct MissingTypeParams {
pub empty_generic_args: bool,
}
// Manual implementation of `SessionDiagnostic` to be able to call `span_to_snippet`.
impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
// Manual implementation of `DiagnosticHandler` to be able to call `span_to_snippet`.
impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = handler.struct_span_err_with_code(
self.span,
@ -306,7 +306,7 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
}
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::manual_implementation, code = "E0183")]
#[help]
pub struct ManualImplementation {
@ -316,7 +316,7 @@ pub struct ManualImplementation {
pub trait_name: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::substs_on_overridden_impl)]
pub struct SubstsOnOverriddenImpl {
#[primary_span]
@ -339,7 +339,7 @@ pub struct ExternCrateNotIdiomatic {
pub suggestion_code: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::expected_used_symbol)]
pub struct ExpectedUsedSymbol {
#[primary_span]

View File

@ -12,12 +12,13 @@ extern crate rustc_session;
extern crate rustc_span;
use rustc_errors::{
AddSubdiagnostic, SessionDiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, fluent
AddSubdiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, Handler, fluent
};
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, SessionSubdiagnostic};
use rustc_span::Span;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(parser::expect_path)]
struct DeriveSessionDiagnostic {
#[primary_span]
@ -33,7 +34,7 @@ struct Note {
pub struct UntranslatableInSessionDiagnostic;
impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for UntranslatableInSessionDiagnostic {
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInSessionDiagnostic {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
handler.struct_err("untranslatable diagnostic")
//~^ ERROR diagnostics should be created using translatable messages
@ -42,7 +43,7 @@ impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for UntranslatableInSessionDiagn
pub struct TranslatableInSessionDiagnostic;
impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic {
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
handler.struct_err(fluent::parser::expect_path)
}
@ -67,10 +68,10 @@ impl AddSubdiagnostic for TranslatableInAddSubdiagnostic {
pub fn make_diagnostics<'a>(handler: &'a Handler) {
let _diag = handler.struct_err(fluent::parser::expect_path);
//~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
let _diag = handler.struct_err("untranslatable diagnostic");
//~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
//~^^ ERROR diagnostics should be created using translatable messages
}

View File

@ -16,7 +16,7 @@ error: diagnostics should be created using translatable messages
LL | diag.note("untranslatable diagnostic");
| ^^^^
error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
error: diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
--> $DIR/diagnostics.rs:70:25
|
LL | let _diag = handler.struct_err(fluent::parser::expect_path);
@ -28,7 +28,7 @@ note: the lint level is defined here
LL | #![deny(rustc::diagnostic_outside_of_impl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
error: diagnostics should only be created in `IntoDiagnostic`/`AddSubdiagnostic` impls
--> $DIR/diagnostics.rs:73:25
|
LL | let _diag = handler.struct_err("untranslatable diagnostic");

View File

@ -1,10 +1,10 @@
// check-fail
// Tests error conditions for specifying diagnostics using #[derive(SessionDiagnostic)]
// Tests error conditions for specifying diagnostics using #[derive(DiagnosticHandler)]
// normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
// normalize-stderr-test "diagnostic_builder\.rs:[0-9]+:[0-9]+" -> "diagnostic_builder.rs:LL:CC"
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
// changing the output of this test. Since SessionDiagnostic is strictly internal to the compiler
// changing the output of this test. Since DiagnosticHandler is strictly internal to the compiler
// the test is just ignored on stable and beta:
// ignore-beta
// ignore-stable
@ -17,7 +17,7 @@ use rustc_span::symbol::Ident;
use rustc_span::Span;
extern crate rustc_macros;
use rustc_macros::{SessionDiagnostic, LintDiagnostic, SessionSubdiagnostic};
use rustc_macros::{DiagnosticHandler, LintDiagnostic, SessionSubdiagnostic};
extern crate rustc_middle;
use rustc_middle::ty::Ty;
@ -27,70 +27,70 @@ use rustc_errors::{Applicability, MultiSpan};
extern crate rustc_session;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct Hello {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct HelloWarn {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
//~^ ERROR `#[derive(SessionDiagnostic)]` can only be used on structs
enum SessionDiagnosticOnEnum {
//~^ ERROR `#[derive(DiagnosticHandler)]` can only be used on structs
enum DiagnosticHandlerOnEnum {
Foo,
Bar,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
#[diag = "E0123"]
//~^ ERROR `#[diag = ...]` is not a valid attribute
struct WrongStructAttrStyle {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")]
//~^ ERROR `#[nonsense(...)]` is not a valid attribute
//~^^ ERROR diagnostic slug not specified
//~^^^ ERROR cannot find attribute `nonsense` in this scope
struct InvalidStructAttr {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag("E0123")]
//~^ ERROR `#[diag("...")]` is not a valid attribute
//~^^ ERROR diagnostic slug not specified
struct InvalidLitNestedAttr {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(nonsense, code = "E0123")]
//~^ ERROR cannot find value `nonsense` in module `rustc_errors::fluent`
struct InvalidNestedStructAttr {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(nonsense("foo"), code = "E0123", slug = "foo")]
//~^ ERROR `#[diag(nonsense(...))]` is not a valid attribute
//~^^ ERROR diagnostic slug not specified
struct InvalidNestedStructAttr1 {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(nonsense = "...", code = "E0123", slug = "foo")]
//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute
//~^^ ERROR diagnostic slug not specified
struct InvalidNestedStructAttr2 {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(nonsense = 4, code = "E0123", slug = "foo")]
//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute
//~^^ ERROR diagnostic slug not specified
struct InvalidNestedStructAttr3 {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")]
//~^ ERROR `#[diag(slug = ...)]` is not a valid attribute
struct InvalidNestedStructAttr4 {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct WrongPlaceField {
#[suggestion = "bar"]
@ -98,36 +98,36 @@ struct WrongPlaceField {
sp: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0456")]
//~^ ERROR specified multiple times
//~^^ ERROR specified multiple times
struct DiagSpecifiedTwice {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")]
//~^ ERROR specified multiple times
struct CodeSpecifiedTwice {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")]
//~^ ERROR `#[diag(typeck::ambiguous_lifetime_bound)]` is not a valid attribute
struct SlugSpecifiedTwice {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
struct KindNotProvided {} //~ ERROR diagnostic slug not specified
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(code = "E0456")]
//~^ ERROR diagnostic slug not specified
struct SlugNotProvided {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound)]
struct CodeNotProvided {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct MessageWrongType {
#[primary_span]
@ -135,7 +135,7 @@ struct MessageWrongType {
foo: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct InvalidPathFieldAttr {
#[nonsense]
@ -144,7 +144,7 @@ struct InvalidPathFieldAttr {
foo: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithField {
name: String,
@ -152,7 +152,7 @@ struct ErrorWithField {
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithMessageAppliedToField {
#[label(typeck::label)]
@ -160,7 +160,7 @@ struct ErrorWithMessageAppliedToField {
name: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithNonexistentField {
#[suggestion(typeck::suggestion, code = "{name}")]
@ -168,7 +168,7 @@ struct ErrorWithNonexistentField {
suggestion: (Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
//~^ ERROR invalid format string: expected `'}'`
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorMissingClosingBrace {
@ -178,7 +178,7 @@ struct ErrorMissingClosingBrace {
val: usize,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
//~^ ERROR invalid format string: unmatched `}`
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorMissingOpeningBrace {
@ -188,14 +188,14 @@ struct ErrorMissingOpeningBrace {
val: usize,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct LabelOnSpan {
#[label(typeck::label)]
sp: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct LabelOnNonSpan {
#[label(typeck::label)]
@ -203,7 +203,7 @@ struct LabelOnNonSpan {
id: u32,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct Suggest {
#[suggestion(typeck::suggestion, code = "This is the suggested code")]
@ -213,14 +213,14 @@ struct Suggest {
suggestion: (Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithoutCode {
#[suggestion(typeck::suggestion)]
suggestion: (Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithBadKey {
#[suggestion(nonsense = "bar")]
@ -228,7 +228,7 @@ struct SuggestWithBadKey {
suggestion: (Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithShorthandMsg {
#[suggestion(msg = "bar")]
@ -236,21 +236,21 @@ struct SuggestWithShorthandMsg {
suggestion: (Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithoutMsg {
#[suggestion(code = "bar")]
suggestion: (Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithTypesSwapped {
#[suggestion(typeck::suggestion, code = "This is suggested code")]
suggestion: (Applicability, Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithWrongTypeApplicabilityOnly {
#[suggestion(typeck::suggestion, code = "This is suggested code")]
@ -258,14 +258,14 @@ struct SuggestWithWrongTypeApplicabilityOnly {
suggestion: Applicability,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithSpanOnly {
#[suggestion(typeck::suggestion, code = "This is suggested code")]
suggestion: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithDuplicateSpanAndApplicability {
#[suggestion(typeck::suggestion, code = "This is suggested code")]
@ -273,7 +273,7 @@ struct SuggestWithDuplicateSpanAndApplicability {
suggestion: (Span, Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct SuggestWithDuplicateApplicabilityAndSpan {
#[suggestion(typeck::suggestion, code = "This is suggested code")]
@ -281,7 +281,7 @@ struct SuggestWithDuplicateApplicabilityAndSpan {
suggestion: (Applicability, Applicability, Span),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct WrongKindOfAnnotation {
#[label = "bar"]
@ -289,7 +289,7 @@ struct WrongKindOfAnnotation {
z: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct OptionsInErrors {
#[label(typeck::label)]
@ -298,7 +298,7 @@ struct OptionsInErrors {
opt_sugg: Option<(Span, Applicability)>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0456")]
struct MoveOutOfBorrowError<'tcx> {
name: Ident,
@ -312,7 +312,7 @@ struct MoveOutOfBorrowError<'tcx> {
opt_sugg: Option<(Span, Applicability)>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithLifetime<'a> {
#[label(typeck::label)]
@ -320,7 +320,7 @@ struct ErrorWithLifetime<'a> {
name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithDefaultLabelAttr<'a> {
#[label]
@ -328,7 +328,7 @@ struct ErrorWithDefaultLabelAttr<'a> {
name: &'a str,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ArgFieldWithoutSkip {
@ -337,7 +337,7 @@ struct ArgFieldWithoutSkip {
other: Hello,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ArgFieldWithSkip {
#[primary_span]
@ -348,91 +348,91 @@ struct ArgFieldWithSkip {
other: Hello,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithSpannedNote {
#[note]
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithSpannedNoteCustom {
#[note(typeck::note)]
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
#[note]
struct ErrorWithNote {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
#[note(typeck::note)]
struct ErrorWithNoteCustom {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithSpannedHelp {
#[help]
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithSpannedHelpCustom {
#[help(typeck::help)]
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
#[help]
struct ErrorWithHelp {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
#[help(typeck::help)]
struct ErrorWithHelpCustom {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[help]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithHelpWrongOrder {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[help(typeck::help)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithHelpCustomWrongOrder {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[note]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithNoteWrongOrder {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[note(typeck::note)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithNoteCustomWrongOrder {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ApplicabilityInBoth {
#[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")]
@ -440,7 +440,7 @@ struct ApplicabilityInBoth {
suggestion: (Span, Applicability),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct InvalidApplicability {
#[suggestion(typeck::suggestion, code = "...", applicability = "batman")]
@ -448,14 +448,14 @@ struct InvalidApplicability {
suggestion: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ValidApplicability {
#[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")]
suggestion: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct NoApplicability {
#[suggestion(typeck::suggestion, code = "...")]
@ -466,14 +466,14 @@ struct NoApplicability {
#[note(parser::add_paren)]
struct Note;
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound)]
struct Subdiagnostic {
#[subdiagnostic]
note: Note,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct VecField {
#[primary_span]
@ -481,7 +481,7 @@ struct VecField {
spans: Vec<Span>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct UnitField {
#[primary_span]
@ -492,7 +492,7 @@ struct UnitField {
bar: (),
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct OptUnitField {
#[primary_span]
@ -503,7 +503,7 @@ struct OptUnitField {
bar: Option<()>,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct LabelWithTrailingPath {
#[label(typeck::label, foo)]
@ -511,7 +511,7 @@ struct LabelWithTrailingPath {
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct LabelWithTrailingNameValue {
#[label(typeck::label, foo = "...")]
@ -519,7 +519,7 @@ struct LabelWithTrailingNameValue {
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct LabelWithTrailingList {
#[label(typeck::label, foo("..."))]
@ -540,35 +540,35 @@ struct PrimarySpanOnLint {
span: Span,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
struct ErrorWithMultiSpan {
#[primary_span]
span: MultiSpan,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
#[warning]
struct ErrorWithWarn {
val: String,
}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
//~^ ERROR `#[error(...)]` is not a valid attribute
//~| ERROR diagnostic slug not specified
//~| ERROR cannot find attribute `error` in this scope
struct ErrorAttribute {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
//~^ ERROR `#[warn_(...)]` is not a valid attribute
//~| ERROR diagnostic slug not specified
//~| ERROR cannot find attribute `warn_` in this scope
struct WarnAttribute {}
#[derive(SessionDiagnostic)]
#[derive(DiagnosticHandler)]
#[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
//~^ ERROR `#[lint(...)]` is not a valid attribute
//~| ERROR diagnostic slug not specified

View File

@ -1,9 +1,9 @@
error: `#[derive(SessionDiagnostic)]` can only be used on structs
error: `#[derive(DiagnosticHandler)]` can only be used on structs
--> $DIR/diagnostic-derive.rs:39:1
|
LL | / #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
LL | |
LL | | enum SessionDiagnosticOnEnum {
LL | | enum DiagnosticHandlerOnEnum {
LL | | Foo,
LL | | Bar,
LL | | }
@ -214,22 +214,22 @@ LL | #[suggestion(typeck::suggestion, code = "{name}")]
error: invalid format string: expected `'}'` but string was terminated
--> $DIR/diagnostic-derive.rs:171:16
|
LL | #[derive(SessionDiagnostic)]
LL | #[derive(DiagnosticHandler)]
| - ^ expected `'}'` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
= note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `DiagnosticHandler` (in Nightly builds, run with -Z macro-backtrace for more info)
error: invalid format string: unmatched `}` found
--> $DIR/diagnostic-derive.rs:181:15
|
LL | #[derive(SessionDiagnostic)]
LL | #[derive(DiagnosticHandler)]
| ^ unmatched `}` in format string
|
= note: if you intended to print `}`, you can escape it using `}}`
= note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `DiagnosticHandler` (in Nightly builds, run with -Z macro-backtrace for more info)
error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:201:5
@ -448,7 +448,7 @@ LL | #[diag(nonsense, code = "E0123")]
error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied
--> $DIR/diagnostic-derive.rs:331:10
|
LL | #[derive(SessionDiagnostic)]
LL | #[derive(DiagnosticHandler)]
| ^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello`
|
= help: normalized in stderr
@ -457,7 +457,7 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg`
|
LL | arg: impl IntoDiagnosticArg,
| ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg`
= note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `DiagnosticHandler` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 55 previous errors