Restrict #[non_exaustive] on structs with default field values

Do not allow users to apply `#[non_exaustive]` to a struct when they have also used default field values.
This commit is contained in:
Esteban Küber
2024-12-20 01:07:48 +00:00
parent 9e136a30a9
commit b3cc9b9620
5 changed files with 78 additions and 3 deletions

View File

@@ -119,6 +119,15 @@ pub(crate) struct NonExhaustiveWrongLocation {
pub defn_span: Span,
}
#[derive(Diagnostic)]
#[diag(passes_non_exaustive_with_default_field_values)]
pub(crate) struct NonExhaustiveWithDefaultFieldValues {
#[primary_span]
pub attr_span: Span,
#[label]
pub defn_span: Span,
}
#[derive(Diagnostic)]
#[diag(passes_should_be_applied_to_trait)]
pub(crate) struct AttrShouldBeAppliedToTrait {