@@ -3,19 +3,16 @@ use crate::generics::TypeParamBound;
3
3
use crate :: path:: { Path , PathArguments } ;
4
4
use crate :: punctuated:: Punctuated ;
5
5
use crate :: ty:: { ReturnType , Type } ;
6
- #[ cfg( feature = "full" ) ]
7
6
use proc_macro2:: { Delimiter , TokenStream , TokenTree } ;
8
7
use std:: ops:: ControlFlow ;
9
8
10
- #[ cfg( feature = "full" ) ]
11
9
pub ( crate ) fn requires_semi_to_be_stmt ( expr : & Expr ) -> bool {
12
10
match expr {
13
11
Expr :: Macro ( expr) => !expr. mac . delimiter . is_brace ( ) ,
14
12
_ => requires_comma_to_be_match_arm ( expr) ,
15
13
}
16
14
}
17
15
18
- #[ cfg( feature = "full" ) ]
19
16
pub ( crate ) fn requires_comma_to_be_match_arm ( expr : & Expr ) -> bool {
20
17
match expr {
21
18
Expr :: If ( _)
@@ -60,7 +57,7 @@ pub(crate) fn requires_comma_to_be_match_arm(expr: &Expr) -> bool {
60
57
}
61
58
}
62
59
63
- #[ cfg( all ( feature = "printing" , feature = "full" ) ) ]
60
+ #[ cfg( feature = "printing" ) ]
64
61
pub ( crate ) fn confusable_with_adjacent_block ( mut expr : & Expr ) -> bool {
65
62
let mut stack = Vec :: new ( ) ;
66
63
@@ -146,84 +143,37 @@ pub(crate) fn confusable_with_adjacent_block(mut expr: &Expr) -> bool {
146
143
}
147
144
148
145
#[ cfg( feature = "printing" ) ]
149
- pub ( crate ) fn confusable_with_adjacent_lt ( mut expr : & Expr ) -> bool {
146
+ pub ( crate ) fn trailing_unparameterized_path ( mut ty : & Type ) -> bool {
150
147
loop {
151
- match expr {
152
- Expr :: Binary ( e) => expr = & e. right ,
153
- Expr :: Cast ( e) => return trailing_unparameterized_path ( & e. ty ) ,
154
- Expr :: Reference ( e) => expr = & e. expr ,
155
- Expr :: Unary ( e) => expr = & e. expr ,
156
-
157
- Expr :: Array ( _)
158
- | Expr :: Assign ( _)
159
- | Expr :: Async ( _)
160
- | Expr :: Await ( _)
161
- | Expr :: Block ( _)
162
- | Expr :: Break ( _)
163
- | Expr :: Call ( _)
164
- | Expr :: Closure ( _)
165
- | Expr :: Const ( _)
166
- | Expr :: Continue ( _)
167
- | Expr :: Field ( _)
168
- | Expr :: ForLoop ( _)
169
- | Expr :: Group ( _)
170
- | Expr :: If ( _)
171
- | Expr :: Index ( _)
172
- | Expr :: Infer ( _)
173
- | Expr :: Let ( _)
174
- | Expr :: Lit ( _)
175
- | Expr :: Loop ( _)
176
- | Expr :: Macro ( _)
177
- | Expr :: Match ( _)
178
- | Expr :: MethodCall ( _)
179
- | Expr :: Paren ( _)
180
- | Expr :: Path ( _)
181
- | Expr :: Range ( _)
182
- | Expr :: Repeat ( _)
183
- | Expr :: Return ( _)
184
- | Expr :: Struct ( _)
185
- | Expr :: Try ( _)
186
- | Expr :: TryBlock ( _)
187
- | Expr :: Tuple ( _)
188
- | Expr :: Unsafe ( _)
189
- | Expr :: Verbatim ( _)
190
- | Expr :: While ( _)
191
- | Expr :: Yield ( _) => return false ,
192
- }
193
- }
194
-
195
- fn trailing_unparameterized_path ( mut ty : & Type ) -> bool {
196
- loop {
197
- match ty {
198
- Type :: BareFn ( t) => match & t. output {
199
- ReturnType :: Default => return false ,
200
- ReturnType :: Type ( _, ret) => ty = ret,
201
- } ,
202
- Type :: ImplTrait ( t) => match last_type_in_bounds ( & t. bounds ) {
203
- ControlFlow :: Break ( trailing_path) => return trailing_path,
204
- ControlFlow :: Continue ( t) => ty = t,
205
- } ,
206
- Type :: Path ( t) => match last_type_in_path ( & t. path ) {
207
- ControlFlow :: Break ( trailing_path) => return trailing_path,
208
- ControlFlow :: Continue ( t) => ty = t,
209
- } ,
210
- Type :: Ptr ( t) => ty = & t. elem ,
211
- Type :: Reference ( t) => ty = & t. elem ,
212
- Type :: TraitObject ( t) => match last_type_in_bounds ( & t. bounds ) {
213
- ControlFlow :: Break ( trailing_path) => return trailing_path,
214
- ControlFlow :: Continue ( t) => ty = t,
215
- } ,
148
+ match ty {
149
+ Type :: BareFn ( t) => match & t. output {
150
+ ReturnType :: Default => return false ,
151
+ ReturnType :: Type ( _, ret) => ty = ret,
152
+ } ,
153
+ Type :: ImplTrait ( t) => match last_type_in_bounds ( & t. bounds ) {
154
+ ControlFlow :: Break ( trailing_path) => return trailing_path,
155
+ ControlFlow :: Continue ( t) => ty = t,
156
+ } ,
157
+ Type :: Path ( t) => match last_type_in_path ( & t. path ) {
158
+ ControlFlow :: Break ( trailing_path) => return trailing_path,
159
+ ControlFlow :: Continue ( t) => ty = t,
160
+ } ,
161
+ Type :: Ptr ( t) => ty = & t. elem ,
162
+ Type :: Reference ( t) => ty = & t. elem ,
163
+ Type :: TraitObject ( t) => match last_type_in_bounds ( & t. bounds ) {
164
+ ControlFlow :: Break ( trailing_path) => return trailing_path,
165
+ ControlFlow :: Continue ( t) => ty = t,
166
+ } ,
216
167
217
- Type :: Array ( _)
218
- | Type :: Group ( _)
219
- | Type :: Infer ( _)
220
- | Type :: Macro ( _)
221
- | Type :: Never ( _)
222
- | Type :: Paren ( _)
223
- | Type :: Slice ( _)
224
- | Type :: Tuple ( _)
225
- | Type :: Verbatim ( _) => return false ,
226
- }
168
+ Type :: Array ( _)
169
+ | Type :: Group ( _)
170
+ | Type :: Infer ( _)
171
+ | Type :: Macro ( _)
172
+ | Type :: Never ( _)
173
+ | Type :: Paren ( _)
174
+ | Type :: Slice ( _)
175
+ | Type :: Tuple ( _)
176
+ | Type :: Verbatim ( _) => return false ,
227
177
}
228
178
}
229
179
@@ -249,7 +199,7 @@ pub(crate) fn confusable_with_adjacent_lt(mut expr: &Expr) -> bool {
249
199
}
250
200
251
201
/// Whether the expression's first token is the label of a loop/block.
252
- #[ cfg( all ( feature = "printing" , feature = "full" ) ) ]
202
+ #[ cfg( feature = "printing" ) ]
253
203
pub ( crate ) fn expr_leading_label ( mut expr : & Expr ) -> bool {
254
204
loop {
255
205
match expr {
@@ -302,7 +252,6 @@ pub(crate) fn expr_leading_label(mut expr: &Expr) -> bool {
302
252
}
303
253
304
254
/// Whether the expression's last token is `}`.
305
- #[ cfg( feature = "full" ) ]
306
255
pub ( crate ) fn expr_trailing_brace ( mut expr : & Expr ) -> bool {
307
256
loop {
308
257
match expr {
0 commit comments