File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed
compiler/rustc_resolve/src Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change 1- use std:: cmp:: Reverse ;
1+ use std:: cmp;
22
33use rustc_ast:: expand:: StrippedCfgItem ;
44use rustc_ast:: ptr:: P ;
@@ -3082,20 +3082,21 @@ impl<'tcx> visit::Visitor<'tcx> for UsePlacementFinder {
30823082}
30833083
30843084fn search_for_any_use_in_items ( items : & [ P < ast:: Item > ] ) -> Option < Span > {
3085- for item in items {
3086- if let ItemKind :: Use ( ..) = item. kind
3087- && is_span_suitable_for_use_injection ( item. span )
3088- {
3089- let mut lo = item. span . lo ( ) ;
3090- for attr in & item. attrs {
3091- if attr. span . eq_ctxt ( item. span ) {
3092- lo = std:: cmp:: min ( lo, attr. span . lo ( ) ) ;
3093- }
3094- }
3095- return Some ( Span :: new ( lo, lo, item. span . ctxt ( ) , item. span . parent ( ) ) ) ;
3096- }
3097- }
3098- None
3085+ items
3086+ . iter ( )
3087+ . find ( |item| {
3088+ matches ! ( item. kind, ItemKind :: Use ( ..) ) && is_span_suitable_for_use_injection ( item. span )
3089+ } )
3090+ . map ( |item| {
3091+ let lo = item
3092+ . attrs
3093+ . iter ( )
3094+ . filter ( |attr| attr. span . eq_ctxt ( item. span ) )
3095+ . map ( |attr| attr. span . lo ( ) )
3096+ . fold ( item. span . lo ( ) , cmp:: min) ;
3097+
3098+ Span :: new ( lo, lo, item. span . ctxt ( ) , item. span . parent ( ) )
3099+ } )
30993100}
31003101
31013102fn is_span_suitable_for_use_injection ( s : Span ) -> bool {
You can’t perform that action at this time.
0 commit comments