File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ impl AnnotationSet {
113113 } )
114114 . collect ( ) ;
115115
116- let must_use = attrs. has_attr_word ( "must_use" ) ;
116+ let must_use = attrs. has_attr_word ( "must_use" ) || attrs . has_attr_namevalue ( "must_use" ) ;
117117 let deprecated = attrs. find_deprecated_note ( ) ;
118118 let mut annotations = HashMap :: new ( ) ;
119119
Original file line number Diff line number Diff line change @@ -149,6 +149,19 @@ pub trait SynAttributeHelpers {
149149 } )
150150 }
151151
152+ /// Searches for attributes like `#[test = "..."]`.
153+ /// Example:
154+ /// - `item.has_attr_namevalue("test")` => `#[test = "..."]`
155+ fn has_attr_namevalue ( & self , name : & str ) -> bool {
156+ self . attrs ( ) . iter ( ) . any ( |attr| {
157+ if let syn:: Meta :: NameValue ( nv) = & attr. meta {
158+ nv. path . is_ident ( name)
159+ } else {
160+ false
161+ }
162+ } )
163+ }
164+
152165 /// Searches for attributes like `#[unsafe(test)]`.
153166 /// Example:
154167 /// - `item.has_unsafe_attr_word("test")` => `#[unsafe(test)]`
You can’t perform that action at this time.
0 commit comments