@@ -415,19 +415,19 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
415
415
416
416
match * ext {
417
417
MultiModifier ( ref mac) => {
418
- let meta = panictry ! ( attr. parse_meta( & self . cx. parse_sess) ) ;
418
+ let meta = panictry ! ( attr. parse_meta( self . cx. parse_sess) ) ;
419
419
let item = mac. expand ( self . cx , attr. span , & meta, item) ;
420
420
kind. expect_from_annotatables ( item)
421
421
}
422
422
MultiDecorator ( ref mac) => {
423
423
let mut items = Vec :: new ( ) ;
424
- let meta = panictry ! ( attr. parse_meta( & self . cx. parse_sess) ) ;
424
+ let meta = panictry ! ( attr. parse_meta( self . cx. parse_sess) ) ;
425
425
mac. expand ( self . cx , attr. span , & meta, & item, & mut |item| items. push ( item) ) ;
426
426
items. push ( item) ;
427
427
kind. expect_from_annotatables ( items)
428
428
}
429
429
SyntaxExtension :: AttrProcMacro ( ref mac) => {
430
- let item_toks = stream_for_item ( & item, & self . cx . parse_sess ) ;
430
+ let item_toks = stream_for_item ( & item, self . cx . parse_sess ) ;
431
431
432
432
let span = Span { ctxt : self . cx . backtrace ( ) , ..attr. span } ;
433
433
let tok_result = mac. expand ( self . cx , attr. span , attr. tokens , item_toks) ;
@@ -439,7 +439,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
439
439
}
440
440
_ => {
441
441
let msg = & format ! ( "macro `{}` may not be used in attributes" , attr. path) ;
442
- self . cx . span_err ( attr. span , & msg) ;
442
+ self . cx . span_err ( attr. span , msg) ;
443
443
kind. dummy ( attr. span )
444
444
}
445
445
}
@@ -454,7 +454,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
454
454
} ;
455
455
let path = & mac. node . path ;
456
456
457
- let ident = ident. unwrap_or ( keywords:: Invalid . ident ( ) ) ;
457
+ let ident = ident. unwrap_or_else ( || keywords:: Invalid . ident ( ) ) ;
458
458
let marked_tts = noop_fold_tts ( mac. node . stream ( ) , & mut Marker ( mark) ) ;
459
459
let opt_expanded = match * ext {
460
460
NormalTT ( ref expandfun, exp_span, allow_internal_unstable) => {
@@ -591,7 +591,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
591
591
}
592
592
_ => {
593
593
let msg = & format ! ( "macro `{}` may not be used for derive attributes" , attr. path) ;
594
- self . cx . span_err ( span, & msg) ;
594
+ self . cx . span_err ( span, msg) ;
595
595
kind. dummy ( span)
596
596
}
597
597
}
@@ -749,19 +749,15 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
749
749
fn check_attributes ( & mut self , attrs : & [ ast:: Attribute ] ) {
750
750
let features = self . cx . ecfg . features . unwrap ( ) ;
751
751
for attr in attrs. iter ( ) {
752
- feature_gate:: check_attribute ( & attr, & self . cx . parse_sess , features) ;
752
+ feature_gate:: check_attribute ( attr, self . cx . parse_sess , features) ;
753
753
}
754
754
}
755
755
}
756
756
757
757
pub fn find_attr_invoc ( attrs : & mut Vec < ast:: Attribute > ) -> Option < ast:: Attribute > {
758
- for i in 0 .. attrs. len ( ) {
759
- if !attr:: is_known ( & attrs[ i] ) && !is_builtin_attr ( & attrs[ i] ) {
760
- return Some ( attrs. remove ( i) ) ;
761
- }
762
- }
763
-
764
- None
758
+ attrs. iter ( )
759
+ . position ( |a| !attr:: is_known ( a) && !is_builtin_attr ( a) )
760
+ . map ( |i| attrs. remove ( i) )
765
761
}
766
762
767
763
// These are pretty nasty. Ideally, we would keep the tokens around, linked from
@@ -923,7 +919,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
923
919
let result = noop_fold_item ( item, self ) ;
924
920
self . cx . current_expansion . module = orig_module;
925
921
self . cx . current_expansion . directory_ownership = orig_directory_ownership;
926
- return result;
922
+ result
927
923
}
928
924
// Ensure that test functions are accessible from the test harness.
929
925
ast:: ItemKind :: Fn ( ..) if self . cx . ecfg . should_test => {
0 commit comments