Skip to content

Commit

Permalink
Derive both Diagnostic and LintDiagnostic on some tys
Browse files Browse the repository at this point in the history
  • Loading branch information
fmease committed May 17, 2024
1 parent c630da4 commit 44d8cb9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 42 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,12 @@ 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 { span, note: (), param: name },
errors::TyParamSome { span, note: (), param: name },
),
};
}
Expand Down
31 changes: 2 additions & 29 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,7 @@ pub struct CrossCrateTraitsDefined {
pub traits: String,
}

// FIXME(fmease): Deduplicate:

#[derive(Diagnostic)]
#[derive(Diagnostic, LintDiagnostic)]
#[diag(hir_analysis_ty_param_first_local, code = E0210)]
#[note]
pub struct TyParamFirstLocal<'tcx> {
Expand All @@ -1373,20 +1371,7 @@ pub struct TyParamFirstLocal<'tcx> {
pub local_type: Ty<'tcx>,
}

#[derive(LintDiagnostic)]
#[diag(hir_analysis_ty_param_first_local, code = E0210)]
#[note]
pub 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 struct TyParamSome {
Expand All @@ -1398,18 +1383,6 @@ pub struct TyParamSome {
pub param: Symbol,
}

#[derive(LintDiagnostic)]
#[diag(hir_analysis_ty_param_some, code = E0210)]
#[note]
pub struct TyParamSomeLint {
#[primary_span]
#[label]
pub span: Span,
#[note(hir_analysis_only_note)]
pub note: (),
pub param: Symbol,
}

#[derive(Diagnostic)]
pub enum OnlyCurrentTraits {
#[diag(hir_analysis_only_current_traits_outside, code = E0117)]
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1907,8 +1907,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)
Expand All @@ -1925,7 +1924,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
self.tcx.emit_node_lint(
CONFLICTING_REPR_HINTS,
hir_id,
errors::ReprConflictingLint { spans: hint_spans.collect() },
errors::ReprConflicting { spans: hint_spans.collect() },
);
}
}
Expand Down
9 changes: 1 addition & 8 deletions compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,16 +609,9 @@ pub struct ReprIdent {
pub span: Span,
}

#[derive(Diagnostic)]
#[derive(Diagnostic, LintDiagnostic)]
#[diag(passes_repr_conflicting, code = E0566)]
pub struct ReprConflicting {
#[primary_span]
pub hint_spans: Vec<Span>,
}

#[derive(LintDiagnostic)]
#[diag(passes_repr_conflicting, code = E0566)]
pub struct ReprConflictingLint {
#[primary_span]
pub spans: Vec<Span>,
}
Expand Down

0 comments on commit 44d8cb9

Please sign in to comment.