@@ -9,6 +9,7 @@ use rustc_session::parse::ParseSess;
99use rustc_span:: { sym, Span , DUMMY_SP } ;
1010
1111use std:: ops:: Range ;
12+ use std:: { iter, mem} ;
1213
1314/// A wrapper type to ensure that the parser handles outer attributes correctly.
1415/// When we parse outer attributes, we need to ensure that we capture tokens
@@ -53,7 +54,7 @@ impl AttrWrapper {
5354 // FIXME: require passing an NT to prevent misuse of this method
5455 pub ( crate ) fn prepend_to_nt_inner ( self , attrs : & mut AttrVec ) {
5556 let mut self_attrs = self . attrs ;
56- std :: mem:: swap ( attrs, & mut self_attrs) ;
57+ mem:: swap ( attrs, & mut self_attrs) ;
5758 attrs. extend ( self_attrs) ;
5859 }
5960
@@ -104,13 +105,12 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
104105 // produce an empty `TokenStream` if no calls were made, and omit the
105106 // final token otherwise.
106107 let mut cursor_snapshot = self . cursor_snapshot . clone ( ) ;
107- let tokens =
108- std:: iter:: once ( ( FlatToken :: Token ( self . start_token . 0 . clone ( ) ) , self . start_token . 1 ) )
109- . chain ( std:: iter:: repeat_with ( || {
110- let token = cursor_snapshot. next ( ) ;
111- ( FlatToken :: Token ( token. 0 ) , token. 1 )
112- } ) )
113- . take ( self . num_calls as usize ) ;
108+ let tokens = iter:: once ( ( FlatToken :: Token ( self . start_token . 0 . clone ( ) ) , self . start_token . 1 ) )
109+ . chain ( iter:: repeat_with ( || {
110+ let token = cursor_snapshot. next ( ) ;
111+ ( FlatToken :: Token ( token. 0 ) , token. 1 )
112+ } ) )
113+ . take ( self . num_calls as usize ) ;
114114
115115 if self . replace_ranges . is_empty ( ) {
116116 make_attr_token_stream ( tokens, self . break_last_token )
@@ -158,7 +158,7 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
158158 // This keeps the total length of `tokens` constant throughout the
159159 // replacement process, allowing us to use all of the `ReplaceRanges` entries
160160 // without adjusting indices.
161- let filler = std :: iter:: repeat ( ( FlatToken :: Empty , Spacing :: Alone ) )
161+ let filler = iter:: repeat ( ( FlatToken :: Empty , Spacing :: Alone ) )
162162 . take ( range. len ( ) - new_tokens. len ( ) ) ;
163163
164164 tokens. splice (
@@ -222,8 +222,7 @@ impl<'a> Parser<'a> {
222222 let replace_ranges_start = self . capture_state . replace_ranges . len ( ) ;
223223
224224 let ( mut ret, trailing) = {
225- let prev_capturing =
226- std:: mem:: replace ( & mut self . capture_state . capturing , Capturing :: Yes ) ;
225+ let prev_capturing = mem:: replace ( & mut self . capture_state . capturing , Capturing :: Yes ) ;
227226 let ret_and_trailing = f ( self , attrs. attrs ) ;
228227 self . capture_state . capturing = prev_capturing;
229228 ret_and_trailing?
0 commit comments