@@ -151,20 +151,12 @@ impl<CTX> HashStable<CTX> for LangItem {
151
151
/// Extracts the first `lang = "$name"` out of a list of attributes.
152
152
/// The attributes `#[panic_handler]` and `#[alloc_error_handler]`
153
153
/// are also extracted out when found.
154
- ///
155
- /// About the `check_name` argument: passing in a `Session` would be simpler,
156
- /// because then we could call `Session::check_name` directly. But we want to
157
- /// avoid the need for `rustc_hir` to depend on `rustc_session`, so we
158
- /// use a closure instead.
159
- pub fn extract < ' a , F > ( check_name : F , attrs : & ' a [ ast:: Attribute ] ) -> Option < ( Symbol , Span ) >
160
- where
161
- F : Fn ( & ' a ast:: Attribute , Symbol ) -> bool ,
162
- {
154
+ pub fn extract ( attrs : & [ ast:: Attribute ] ) -> Option < ( Symbol , Span ) > {
163
155
attrs. iter ( ) . find_map ( |attr| {
164
156
Some ( match attr {
165
- _ if check_name ( attr, sym:: lang) => ( attr. value_str ( ) ?, attr. span ) ,
166
- _ if check_name ( attr, sym:: panic_handler) => ( sym:: panic_impl, attr. span ) ,
167
- _ if check_name ( attr, sym:: alloc_error_handler) => ( sym:: oom, attr. span ) ,
157
+ _ if attr. has_name ( sym:: lang) => ( attr. value_str ( ) ?, attr. span ) ,
158
+ _ if attr. has_name ( sym:: panic_handler) => ( sym:: panic_impl, attr. span ) ,
159
+ _ if attr. has_name ( sym:: alloc_error_handler) => ( sym:: oom, attr. span ) ,
168
160
_ => return None ,
169
161
} )
170
162
} )
0 commit comments