@@ -84,7 +84,9 @@ fn parse_input(input: &ItemStruct) -> Result<ParsedInput> {
84
84
}
85
85
86
86
let sig = parse_quote ! {
87
- fn #ident( self ) -> :: volatile:: VolatilePtr <' a, #ty, #access>
87
+ fn #ident( self ) -> :: volatile:: VolatilePtr <' a, #ty, A :: Restricted >
88
+ where
89
+ A : :: volatile:: access:: RestrictAccess <#access>
88
90
} ;
89
91
sigs. push ( sig) ;
90
92
}
@@ -112,7 +114,7 @@ fn emit_trait(
112
114
parse_quote ! {
113
115
#( #attrs) *
114
116
#[ allow( non_camel_case_types) ]
115
- #vis trait #trait_ident <' a> {
117
+ #vis trait #trait_ident <' a, A > {
116
118
#(
117
119
#( #method_attrs) *
118
120
#sigs;
@@ -133,9 +135,10 @@ fn emit_impl(
133
135
134
136
parse_quote ! {
135
137
#[ automatically_derived]
136
- impl <' a> #trait_ident<' a> for :: volatile:: VolatilePtr <' a, #struct_ident, :: volatile :: access :: ReadWrite > {
138
+ impl <' a, A > #trait_ident<' a, A > for :: volatile:: VolatilePtr <' a, #struct_ident, A > {
137
139
#(
138
- #sigs {
140
+ #sigs,
141
+ {
139
142
:: volatile:: map_field!( self . #fields) . restrict( )
140
143
}
141
144
) *
@@ -183,24 +186,34 @@ mod tests {
183
186
///
184
187
/// This is a wonderful struct.
185
188
#[ allow( non_camel_case_types) ]
186
- pub trait DeviceConfigVolatileFieldAccess <' a> {
187
- fn feature_select( self ) -> :: volatile:: VolatilePtr <' a, u32 , :: volatile:: access:: ReadWrite >;
189
+ pub trait DeviceConfigVolatileFieldAccess <' a, A > {
190
+ fn feature_select( self ) -> :: volatile:: VolatilePtr <' a, u32 , A :: Restricted >
191
+ where
192
+ A : :: volatile:: access:: RestrictAccess <:: volatile:: access:: ReadWrite >;
188
193
189
194
/// Feature.
190
195
///
191
196
/// This is a good field.
192
- fn feature( self ) -> :: volatile:: VolatilePtr <' a, u32 , ReadOnly >;
197
+ fn feature( self ) -> :: volatile:: VolatilePtr <' a, u32 , A :: Restricted >
198
+ where
199
+ A : :: volatile:: access:: RestrictAccess <ReadOnly >;
193
200
}
194
201
} ;
195
202
196
203
let expected_impl = quote ! {
197
204
#[ automatically_derived]
198
- impl <' a> DeviceConfigVolatileFieldAccess <' a> for :: volatile:: VolatilePtr <' a, DeviceConfig , :: volatile:: access:: ReadWrite > {
199
- fn feature_select( self ) -> :: volatile:: VolatilePtr <' a, u32 , :: volatile:: access:: ReadWrite > {
205
+ impl <' a, A > DeviceConfigVolatileFieldAccess <' a, A > for :: volatile:: VolatilePtr <' a, DeviceConfig , A > {
206
+ fn feature_select( self ) -> :: volatile:: VolatilePtr <' a, u32 , A :: Restricted >
207
+ where
208
+ A : :: volatile:: access:: RestrictAccess <:: volatile:: access:: ReadWrite >,
209
+ {
200
210
:: volatile:: map_field!( self . feature_select) . restrict( )
201
211
}
202
212
203
- fn feature( self ) -> :: volatile:: VolatilePtr <' a, u32 , ReadOnly > {
213
+ fn feature( self ) -> :: volatile:: VolatilePtr <' a, u32 , A :: Restricted >
214
+ where
215
+ A : :: volatile:: access:: RestrictAccess <ReadOnly >,
216
+ {
204
217
:: volatile:: map_field!( self . feature) . restrict( )
205
218
}
206
219
}
@@ -230,12 +243,12 @@ mod tests {
230
243
231
244
let expected_trait = quote ! {
232
245
#[ allow( non_camel_case_types) ]
233
- pub trait DeviceConfigVolatileFieldAccess <' a> { }
246
+ pub trait DeviceConfigVolatileFieldAccess <' a, A > { }
234
247
} ;
235
248
236
249
let expected_impl = quote ! {
237
250
#[ automatically_derived]
238
- impl <' a> DeviceConfigVolatileFieldAccess <' a> for :: volatile:: VolatilePtr <' a, DeviceConfig , :: volatile :: access :: ReadWrite > { }
251
+ impl <' a, A > DeviceConfigVolatileFieldAccess <' a, A > for :: volatile:: VolatilePtr <' a, DeviceConfig , A > { }
239
252
} ;
240
253
241
254
assert_eq ! (
0 commit comments