detect when variants have the same name as an associated function

This commit is contained in:
Jana Dönszelmann
2025-06-12 10:21:30 +02:00
parent 975741c294
commit 2e7e52e07c
4 changed files with 54 additions and 1 deletions

View File

@@ -1478,6 +1478,9 @@ pub(crate) enum MultipleDeadCodes<'tcx> {
participle: &'tcx str,
name_list: DiagSymbolList,
#[subdiagnostic]
// only on DeadCodes since it's never a problem for tuple struct fields
enum_variants_with_same_name: Vec<EnumVariantSameName<'tcx>>,
#[subdiagnostic]
parent_info: Option<ParentInfo<'tcx>>,
#[subdiagnostic]
ignored_derived_impls: Option<IgnoredDerivedImpls>,
@@ -1498,6 +1501,15 @@ pub(crate) enum MultipleDeadCodes<'tcx> {
},
}
#[derive(Subdiagnostic)]
#[note(passes_enum_variant_same_name)]
pub(crate) struct EnumVariantSameName<'tcx> {
#[primary_span]
pub variant_span: Span,
pub dead_name: Symbol,
pub descr: &'tcx str,
}
#[derive(Subdiagnostic)]
#[label(passes_parent_info)]
pub(crate) struct ParentInfo<'tcx> {