diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 18f60d80b35ff..50e2b7927c221 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -497,10 +497,10 @@ fn lint_uncovered_ty_params<'tcx>( Some(local_type) => tcx.emit_node_lint( UNCOVERED_PARAM_IN_PROJECTION, hir_id, - errors::TyParamFirstLocalLint { span, note: (), param: name, local_type }, + errors::TyParamFirstLocal { span, note: (), param: name, local_type }, ), None => { - tcx.emit_node_lint(UNCOVERED_PARAM_IN_PROJECTION, hir_id, errors::TyParamSomeLint { + tcx.emit_node_lint(UNCOVERED_PARAM_IN_PROJECTION, hir_id, errors::TyParamSome { span, note: (), param: name, diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 25362203cb25b..71b357a276346 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -1382,9 +1382,7 @@ pub(crate) struct CrossCrateTraitsDefined { pub traits: String, } -// FIXME(fmease): Deduplicate: - -#[derive(Diagnostic)] +#[derive(Diagnostic, LintDiagnostic)] #[diag(hir_analysis_ty_param_first_local, code = E0210)] #[note] pub(crate) struct TyParamFirstLocal<'tcx> { @@ -1397,20 +1395,7 @@ pub(crate) struct TyParamFirstLocal<'tcx> { pub local_type: Ty<'tcx>, } -#[derive(LintDiagnostic)] -#[diag(hir_analysis_ty_param_first_local, code = E0210)] -#[note] -pub(crate) struct TyParamFirstLocalLint<'tcx> { - #[primary_span] - #[label] - pub span: Span, - #[note(hir_analysis_case_note)] - pub note: (), - pub param: Symbol, - pub local_type: Ty<'tcx>, -} - -#[derive(Diagnostic)] +#[derive(Diagnostic, LintDiagnostic)] #[diag(hir_analysis_ty_param_some, code = E0210)] #[note] pub(crate) struct TyParamSome { @@ -1422,18 +1407,6 @@ pub(crate) struct TyParamSome { pub param: Symbol, } -#[derive(LintDiagnostic)] -#[diag(hir_analysis_ty_param_some, code = E0210)] -#[note] -pub(crate) struct TyParamSomeLint { - #[primary_span] - #[label] - pub span: Span, - #[note(hir_analysis_only_note)] - pub note: (), - pub param: Symbol, -} - #[derive(Diagnostic)] pub(crate) enum OnlyCurrentTraits { #[diag(hir_analysis_only_current_traits_outside, code = E0117)] diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 94a1c5f100952..c5940a9f77dc4 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -697,7 +697,7 @@ pub(crate) enum SuggestBoxingForReturnImplTrait { }, } -#[derive(Diagnostic)] +#[derive(Diagnostic, LintDiagnostic)] #[diag(hir_typeck_self_ctor_from_outer_item, code = E0401)] pub(crate) struct SelfCtorFromOuterItem { #[primary_span] @@ -708,17 +708,6 @@ pub(crate) struct SelfCtorFromOuterItem { pub sugg: Option, } -#[derive(LintDiagnostic)] -#[diag(hir_typeck_self_ctor_from_outer_item)] -pub(crate) struct SelfCtorFromOuterItemLint { - #[primary_span] - pub span: Span, - #[label] - pub impl_span: Span, - #[subdiagnostic] - pub sugg: Option, -} - #[derive(Subdiagnostic)] #[suggestion(hir_typeck_suggestion, code = "{name}", applicability = "machine-applicable")] pub(crate) struct ReplaceWithName { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 3b645fb009140..5defba17b9e64 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1151,7 +1151,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx.emit_node_lint( SELF_CONSTRUCTOR_FROM_OUTER_ITEM, hir_id, - errors::SelfCtorFromOuterItemLint { + errors::SelfCtorFromOuterItem { span: path_span, impl_span: tcx.def_span(impl_def_id), sugg, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index ebd57d4283dfe..6ff663d24a92a 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1838,8 +1838,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { }); } if is_explicit_rust && (int_reprs > 0 || is_c || is_simd) { - let hint_spans = hint_spans.clone().collect(); - self.dcx().emit_err(errors::ReprConflicting { hint_spans }); + self.dcx().emit_err(errors::ReprConflicting { spans: hint_spans.clone().collect() }); } // Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8) if (int_reprs > 1) @@ -1850,7 +1849,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { if let ItemLike::Item(item) = item { is_c_like_enum(item) } else { false } })) { - self.tcx.emit_node_lint(CONFLICTING_REPR_HINTS, hir_id, errors::ReprConflictingLint { + self.tcx.emit_node_lint(CONFLICTING_REPR_HINTS, hir_id, errors::ReprConflicting { spans: hint_spans.collect(), }); } diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 2734af4672d53..0555cf7fa4032 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -621,16 +621,9 @@ pub(crate) struct ReprIdent { pub span: Span, } -#[derive(Diagnostic)] +#[derive(Diagnostic, LintDiagnostic)] #[diag(passes_repr_conflicting, code = E0566)] pub(crate) struct ReprConflicting { - #[primary_span] - pub hint_spans: Vec, -} - -#[derive(LintDiagnostic)] -#[diag(passes_repr_conflicting, code = E0566)] -pub(crate) struct ReprConflictingLint { #[primary_span] pub spans: Vec, } diff --git a/tests/ui/self/self-ctor-nongeneric.stderr b/tests/ui/self/self-ctor-nongeneric.stderr index 6c03c6f3e38a4..308cf6bad8d72 100644 --- a/tests/ui/self/self-ctor-nongeneric.stderr +++ b/tests/ui/self/self-ctor-nongeneric.stderr @@ -1,4 +1,4 @@ -warning: can't reference `Self` constructor from outer item +warning[E0401]: can't reference `Self` constructor from outer item --> $DIR/self-ctor-nongeneric.rs:8:23 | LL | impl S0 { @@ -11,7 +11,7 @@ LL | const C: S0 = Self(0); = note: for more information, see issue #124186 = note: `#[warn(self_constructor_from_outer_item)]` on by default -warning: can't reference `Self` constructor from outer item +warning[E0401]: can't reference `Self` constructor from outer item --> $DIR/self-ctor-nongeneric.rs:12:13 | LL | impl S0 { @@ -25,3 +25,4 @@ LL | Self(0) warning: 2 warnings emitted +For more information about this error, try `rustc --explain E0401`.