@@ -20,6 +20,7 @@ use synstructure::{BindingInfo, Structure};
20
20
/// The central struct for constructing the `into_diagnostic` method from an annotated struct.
21
21
pub ( crate ) struct SessionDiagnosticDerive < ' a > {
22
22
structure : Structure < ' a > ,
23
+ sess : syn:: Ident ,
23
24
builder : SessionDiagnosticDeriveBuilder ,
24
25
}
25
26
@@ -28,18 +29,18 @@ impl<'a> SessionDiagnosticDerive<'a> {
28
29
Self {
29
30
builder : SessionDiagnosticDeriveBuilder {
30
31
diag,
31
- sess,
32
32
fields : build_field_mapping ( & structure) ,
33
33
kind : None ,
34
34
code : None ,
35
35
slug : None ,
36
36
} ,
37
+ sess,
37
38
structure,
38
39
}
39
40
}
40
41
41
42
pub ( crate ) fn into_tokens ( self ) -> TokenStream {
42
- let SessionDiagnosticDerive { mut structure, mut builder } = self ;
43
+ let SessionDiagnosticDerive { mut structure, sess , mut builder } = self ;
43
44
44
45
let ast = structure. ast ( ) ;
45
46
let attrs = & ast. attrs ;
@@ -96,7 +97,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
96
97
. each ( |field_binding| builder. generate_field_attrs_code ( field_binding) ) ;
97
98
98
99
let span = ast. span ( ) . unwrap ( ) ;
99
- let ( diag, sess ) = ( & builder. diag , & builder . sess ) ;
100
+ let diag = & builder. diag ;
100
101
let init = match ( builder. kind , builder. slug ) {
101
102
( None , _) => {
102
103
span_err ( span, "diagnostic kind not specified" )
@@ -159,7 +160,6 @@ impl<'a> SessionDiagnosticDerive<'a> {
159
160
}
160
161
} ;
161
162
162
- let sess = & builder. sess ;
163
163
structure. gen_impl ( quote ! {
164
164
gen impl <' __session_diagnostic_sess> rustc_session:: SessionDiagnostic <' __session_diagnostic_sess, #param_ty>
165
165
for @Self
@@ -200,8 +200,6 @@ impl SessionDiagnosticKind {
200
200
/// only to be able to destructure and split `self.builder` and the `self.structure` up to avoid a
201
201
/// double mut borrow later on.
202
202
struct SessionDiagnosticDeriveBuilder {
203
- /// Name of the session parameter that's passed in to the `as_error` method.
204
- sess : syn:: Ident ,
205
203
/// The identifier to use for the generated `DiagnosticBuilder` instance.
206
204
diag : syn:: Ident ,
207
205
0 commit comments