File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed
compiler/rustc_resolve/src Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change 1+ use std:: cmp;
2+
13use rustc_ast:: expand:: StrippedCfgItem ;
24use rustc_ast:: ptr:: P ;
35use rustc_ast:: visit:: { self , Visitor } ;
@@ -3074,20 +3076,21 @@ impl<'tcx> visit::Visitor<'tcx> for UsePlacementFinder {
30743076}
30753077
30763078fn search_for_any_use_in_items ( items : & [ P < ast:: Item > ] ) -> Option < Span > {
3077- for item in items {
3078- if let ItemKind :: Use ( ..) = item. kind {
3079- if is_span_suitable_for_use_injection ( item. span ) {
3080- let mut lo = item. span . lo ( ) ;
3081- for attr in & item. attrs {
3082- if attr. span . eq_ctxt ( item. span ) {
3083- lo = std:: cmp:: min ( lo, attr. span . lo ( ) ) ;
3084- }
3085- }
3086- return Some ( Span :: new ( lo, lo, item. span . ctxt ( ) , item. span . parent ( ) ) ) ;
3087- }
3088- }
3089- }
3090- None
3079+ items
3080+ . iter ( )
3081+ . find ( |item| {
3082+ matches ! ( item. kind, ItemKind :: Use ( ..) ) && is_span_suitable_for_use_injection ( item. span )
3083+ } )
3084+ . map ( |item| {
3085+ let lo = item
3086+ . attrs
3087+ . iter ( )
3088+ . filter ( |attr| attr. span . eq_ctxt ( item. span ) )
3089+ . map ( |attr| attr. span . lo ( ) )
3090+ . fold ( item. span . lo ( ) , cmp:: min) ;
3091+
3092+ Span :: new ( lo, lo, item. span . ctxt ( ) , item. span . parent ( ) )
3093+ } )
30913094}
30923095
30933096fn is_span_suitable_for_use_injection ( s : Span ) -> bool {
You can’t perform that action at this time.
0 commit comments