Skip to content

Commit aee03c5

Browse files
committed
Derive both Diagnostic and LintDiagnostic on some tys
1 parent 0f0d42d commit aee03c5

File tree

7 files changed

+12
-57
lines changed

7 files changed

+12
-57
lines changed

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,10 @@ fn lint_uncovered_ty_params<'tcx>(
497497
Some(local_type) => tcx.emit_node_lint(
498498
UNCOVERED_PARAM_IN_PROJECTION,
499499
hir_id,
500-
errors::TyParamFirstLocalLint { span, note: (), param: name, local_type },
500+
errors::TyParamFirstLocal { span, note: (), param: name, local_type },
501501
),
502502
None => {
503-
tcx.emit_node_lint(UNCOVERED_PARAM_IN_PROJECTION, hir_id, errors::TyParamSomeLint {
503+
tcx.emit_node_lint(UNCOVERED_PARAM_IN_PROJECTION, hir_id, errors::TyParamSome {
504504
span,
505505
note: (),
506506
param: name,

compiler/rustc_hir_analysis/src/errors.rs

+2-29
Original file line numberDiff line numberDiff line change
@@ -1382,9 +1382,7 @@ pub(crate) struct CrossCrateTraitsDefined {
13821382
pub traits: String,
13831383
}
13841384

1385-
// FIXME(fmease): Deduplicate:
1386-
1387-
#[derive(Diagnostic)]
1385+
#[derive(Diagnostic, LintDiagnostic)]
13881386
#[diag(hir_analysis_ty_param_first_local, code = E0210)]
13891387
#[note]
13901388
pub(crate) struct TyParamFirstLocal<'tcx> {
@@ -1397,20 +1395,7 @@ pub(crate) struct TyParamFirstLocal<'tcx> {
13971395
pub local_type: Ty<'tcx>,
13981396
}
13991397

1400-
#[derive(LintDiagnostic)]
1401-
#[diag(hir_analysis_ty_param_first_local, code = E0210)]
1402-
#[note]
1403-
pub(crate) struct TyParamFirstLocalLint<'tcx> {
1404-
#[primary_span]
1405-
#[label]
1406-
pub span: Span,
1407-
#[note(hir_analysis_case_note)]
1408-
pub note: (),
1409-
pub param: Symbol,
1410-
pub local_type: Ty<'tcx>,
1411-
}
1412-
1413-
#[derive(Diagnostic)]
1398+
#[derive(Diagnostic, LintDiagnostic)]
14141399
#[diag(hir_analysis_ty_param_some, code = E0210)]
14151400
#[note]
14161401
pub(crate) struct TyParamSome {
@@ -1422,18 +1407,6 @@ pub(crate) struct TyParamSome {
14221407
pub param: Symbol,
14231408
}
14241409

1425-
#[derive(LintDiagnostic)]
1426-
#[diag(hir_analysis_ty_param_some, code = E0210)]
1427-
#[note]
1428-
pub(crate) struct TyParamSomeLint {
1429-
#[primary_span]
1430-
#[label]
1431-
pub span: Span,
1432-
#[note(hir_analysis_only_note)]
1433-
pub note: (),
1434-
pub param: Symbol,
1435-
}
1436-
14371410
#[derive(Diagnostic)]
14381411
pub(crate) enum OnlyCurrentTraits {
14391412
#[diag(hir_analysis_only_current_traits_outside, code = E0117)]

compiler/rustc_hir_typeck/src/errors.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ pub(crate) enum SuggestBoxingForReturnImplTrait {
697697
},
698698
}
699699

700-
#[derive(Diagnostic)]
700+
#[derive(Diagnostic, LintDiagnostic)]
701701
#[diag(hir_typeck_self_ctor_from_outer_item, code = E0401)]
702702
pub(crate) struct SelfCtorFromOuterItem {
703703
#[primary_span]
@@ -708,17 +708,6 @@ pub(crate) struct SelfCtorFromOuterItem {
708708
pub sugg: Option<ReplaceWithName>,
709709
}
710710

711-
#[derive(LintDiagnostic)]
712-
#[diag(hir_typeck_self_ctor_from_outer_item)]
713-
pub(crate) struct SelfCtorFromOuterItemLint {
714-
#[primary_span]
715-
pub span: Span,
716-
#[label]
717-
pub impl_span: Span,
718-
#[subdiagnostic]
719-
pub sugg: Option<ReplaceWithName>,
720-
}
721-
722711
#[derive(Subdiagnostic)]
723712
#[suggestion(hir_typeck_suggestion, code = "{name}", applicability = "machine-applicable")]
724713
pub(crate) struct ReplaceWithName {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11511151
self.tcx.emit_node_lint(
11521152
SELF_CONSTRUCTOR_FROM_OUTER_ITEM,
11531153
hir_id,
1154-
errors::SelfCtorFromOuterItemLint {
1154+
errors::SelfCtorFromOuterItem {
11551155
span: path_span,
11561156
impl_span: tcx.def_span(impl_def_id),
11571157
sugg,

compiler/rustc_passes/src/check_attr.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1838,8 +1838,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
18381838
});
18391839
}
18401840
if is_explicit_rust && (int_reprs > 0 || is_c || is_simd) {
1841-
let hint_spans = hint_spans.clone().collect();
1842-
self.dcx().emit_err(errors::ReprConflicting { hint_spans });
1841+
self.dcx().emit_err(errors::ReprConflicting { spans: hint_spans.clone().collect() });
18431842
}
18441843
// Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8)
18451844
if (int_reprs > 1)
@@ -1850,7 +1849,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
18501849
if let ItemLike::Item(item) = item { is_c_like_enum(item) } else { false }
18511850
}))
18521851
{
1853-
self.tcx.emit_node_lint(CONFLICTING_REPR_HINTS, hir_id, errors::ReprConflictingLint {
1852+
self.tcx.emit_node_lint(CONFLICTING_REPR_HINTS, hir_id, errors::ReprConflicting {
18541853
spans: hint_spans.collect(),
18551854
});
18561855
}

compiler/rustc_passes/src/errors.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,9 @@ pub(crate) struct ReprIdent {
621621
pub span: Span,
622622
}
623623

624-
#[derive(Diagnostic)]
624+
#[derive(Diagnostic, LintDiagnostic)]
625625
#[diag(passes_repr_conflicting, code = E0566)]
626626
pub(crate) struct ReprConflicting {
627-
#[primary_span]
628-
pub hint_spans: Vec<Span>,
629-
}
630-
631-
#[derive(LintDiagnostic)]
632-
#[diag(passes_repr_conflicting, code = E0566)]
633-
pub(crate) struct ReprConflictingLint {
634627
#[primary_span]
635628
pub spans: Vec<Span>,
636629
}

tests/ui/self/self-ctor-nongeneric.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: can't reference `Self` constructor from outer item
1+
warning[E0401]: can't reference `Self` constructor from outer item
22
--> $DIR/self-ctor-nongeneric.rs:8:23
33
|
44
LL | impl S0 {
@@ -11,7 +11,7 @@ LL | const C: S0 = Self(0);
1111
= note: for more information, see issue #124186 <https://github.com/rust-lang/rust/issues/124186>
1212
= note: `#[warn(self_constructor_from_outer_item)]` on by default
1313

14-
warning: can't reference `Self` constructor from outer item
14+
warning[E0401]: can't reference `Self` constructor from outer item
1515
--> $DIR/self-ctor-nongeneric.rs:12:13
1616
|
1717
LL | impl S0 {
@@ -25,3 +25,4 @@ LL | Self(0)
2525

2626
warning: 2 warnings emitted
2727

28+
For more information about this error, try `rustc --explain E0401`.

0 commit comments

Comments
 (0)