@@ -181,6 +181,12 @@ impl ForDeref {
181181 for item in & trait_def. items {
182182 match item {
183183 TraitItem :: Const ( item) => {
184+ for attr in item. attrs . iter ( ) {
185+ if attr. path == parse_quote ! { cfg } {
186+ attr. to_tokens ( tokens) ;
187+ }
188+ }
189+
184190 item. const_token . to_tokens ( tokens) ;
185191 item. ident . to_tokens ( tokens) ;
186192 item. colon_token . to_tokens ( tokens) ;
@@ -194,6 +200,12 @@ impl ForDeref {
194200 item. semi_token . to_tokens ( tokens) ;
195201 }
196202 TraitItem :: Method ( item) => {
203+ for attr in item. attrs . iter ( ) {
204+ if attr. path == parse_quote ! { cfg } {
205+ attr. to_tokens ( tokens) ;
206+ }
207+ }
208+
197209 if has_bound_on_self ( & item. sig . generics ) {
198210 // If the method has a bound on Self, we cannot use a dereferencing
199211 // implementation since the definitive type is not guaranteed to match
@@ -242,6 +254,12 @@ impl ForDeref {
242254 } } ) ;
243255 }
244256 TraitItem :: Type ( item) => {
257+ for attr in item. attrs . iter ( ) {
258+ if attr. path == parse_quote ! { cfg } {
259+ attr. to_tokens ( tokens) ;
260+ }
261+ }
262+
245263 if has_bound_on_self ( & item. generics ) {
246264 emit_call_site_error ! (
247265 "cannot autoimpl trait with Deref" ;
0 commit comments