@@ -16,6 +16,8 @@ use std::str::FromStr;
1616use syn:: { spanned:: Spanned , Meta , MetaList , MetaNameValue } ;
1717use synstructure:: { BindingInfo , Structure , VariantInfo } ;
1818
19+ /// `Applicability` of a suggestion - mirrors `rustc_errors::Applicability` - and used to represent
20+ /// the user's selection of applicability if specified in an attribute.
1921enum Applicability {
2022 MachineApplicable ,
2123 MaybeIncorrect ,
@@ -56,6 +58,7 @@ impl quote::ToTokens for Applicability {
5658 }
5759}
5860
61+ /// Which kind of suggestion is being created?
5962#[ derive( Clone , Copy ) ]
6063enum SubdiagnosticSuggestionKind {
6164 /// `#[suggestion]`
@@ -68,6 +71,7 @@ enum SubdiagnosticSuggestionKind {
6871 Verbose ,
6972}
7073
74+ /// Which kind of subdiagnostic is being created from a variant?
7175#[ derive( Clone , Copy ) ]
7276enum SubdiagnosticKind {
7377 /// `#[label(...)]`
@@ -129,6 +133,7 @@ impl quote::IdentFragment for SubdiagnosticKind {
129133 }
130134}
131135
136+ /// The central struct for constructing the `add_to_diagnostic` method from an annotated struct.
132137pub ( crate ) struct SessionSubdiagnosticDerive < ' a > {
133138 structure : Structure < ' a > ,
134139 diag : syn:: Ident ,
@@ -210,6 +215,10 @@ impl<'a> SessionSubdiagnosticDerive<'a> {
210215 }
211216}
212217
218+ /// Tracks persistent information required for building up the call to add to the diagnostic
219+ /// for the final generated method. This is a separate struct to `SessionSubdiagnosticDerive`
220+ /// only to be able to destructure and split `self.builder` and the `self.structure` up to avoid a
221+ /// double mut borrow later on.
213222struct SessionSubdiagnosticDeriveBuilder < ' a > {
214223 /// The identifier to use for the generated `DiagnosticBuilder` instance.
215224 diag : & ' a syn:: Ident ,
0 commit comments