@@ -68,17 +68,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
68
68
// i32, which is the type of y but with the anonymous region replaced
69
69
// with 'a, the corresponding bound region and is_first which is true if
70
70
// the hir::Arg is the first argument in the function declaration.
71
- pub ( super ) fn find_arg_with_region ( & self ,
72
- anon_region : Region < ' tcx > ,
73
- replace_region : Region < ' tcx > )
74
- -> Option < AnonymousArgInfo > {
75
-
71
+ pub ( super ) fn find_arg_with_region (
72
+ & self ,
73
+ anon_region : Region < ' tcx > ,
74
+ replace_region : Region < ' tcx > ,
75
+ ) -> Option < AnonymousArgInfo > {
76
76
let ( id, bound_region) = match * anon_region {
77
77
ty:: ReFree ( ref free_region) => ( free_region. scope , free_region. bound_region ) ,
78
- ty:: ReEarlyBound ( ref ebr) => {
79
- ( self . tcx . parent_def_id ( ebr. def_id ) . unwrap ( ) ,
80
- ty:: BoundRegion :: BrNamed ( ebr. def_id , ebr. name ) )
81
- }
78
+ ty:: ReEarlyBound ( ref ebr) => (
79
+ self . tcx . parent_def_id ( ebr. def_id ) . unwrap ( ) ,
80
+ ty:: BoundRegion :: BrNamed ( ebr. def_id , ebr. name ) ,
81
+ ) ,
82
82
_ => return None , // not a free region
83
83
} ;
84
84
@@ -94,21 +94,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
94
94
// May return None; sometimes the tables are not yet populated.
95
95
let ty = tables. borrow ( ) . node_id_to_type_opt ( arg. hir_id ) ?;
96
96
let mut found_anon_region = false ;
97
- let new_arg_ty = self . tcx
98
- . fold_regions ( & ty , & mut false , |r , _| if * r == * anon_region {
97
+ let new_arg_ty = self . tcx . fold_regions ( & ty , & mut false , |r , _| {
98
+ if * r == * anon_region {
99
99
found_anon_region = true ;
100
100
replace_region
101
101
} else {
102
102
r
103
- } ) ;
103
+ }
104
+ } ) ;
104
105
if found_anon_region {
105
106
let is_first = index == 0 ;
106
107
Some ( AnonymousArgInfo {
107
- arg : arg,
108
- arg_ty : new_arg_ty,
109
- bound_region : bound_region,
110
- is_first : is_first,
111
- } )
108
+ arg : arg,
109
+ arg_ty : new_arg_ty,
110
+ bound_region : bound_region,
111
+ is_first : is_first,
112
+ } )
112
113
} else {
113
114
None
114
115
}
@@ -127,13 +128,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
127
128
128
129
// This method returns the DefId and the BoundRegion corresponding to the given region.
129
130
pub ( super ) fn is_suitable_region ( & self , region : Region < ' tcx > ) -> Option < FreeRegionInfo > {
130
-
131
131
let ( suitable_region_binding_scope, bound_region) = match * region {
132
132
ty:: ReFree ( ref free_region) => ( free_region. scope , free_region. bound_region ) ,
133
- ty:: ReEarlyBound ( ref ebr) => {
134
- ( self . tcx . parent_def_id ( ebr. def_id ) . unwrap ( ) ,
135
- ty:: BoundRegion :: BrNamed ( ebr. def_id , ebr. name ) )
136
- }
133
+ ty:: ReEarlyBound ( ref ebr) => (
134
+ self . tcx . parent_def_id ( ebr. def_id ) . unwrap ( ) ,
135
+ ty:: BoundRegion :: BrNamed ( ebr. def_id , ebr. name ) ,
136
+ ) ,
137
137
_ => return None , // not a free region
138
138
} ;
139
139
@@ -142,31 +142,29 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
142
142
. as_local_node_id ( suitable_region_binding_scope)
143
143
. unwrap ( ) ;
144
144
let is_impl_item = match self . tcx . hir . find ( node_id) {
145
-
146
- Some ( hir_map:: NodeItem ( ..) ) |
147
- Some ( hir_map:: NodeTraitItem ( ..) ) => false ,
145
+ Some ( hir_map:: NodeItem ( ..) ) | Some ( hir_map:: NodeTraitItem ( ..) ) => false ,
148
146
Some ( hir_map:: NodeImplItem ( ..) ) => {
149
147
self . is_bound_region_in_impl_item ( suitable_region_binding_scope)
150
148
}
151
149
_ => return None ,
152
150
} ;
153
151
154
152
return Some ( FreeRegionInfo {
155
- def_id : suitable_region_binding_scope,
156
- boundregion : bound_region,
157
- is_impl_item : is_impl_item,
158
- } ) ;
159
-
153
+ def_id : suitable_region_binding_scope,
154
+ boundregion : bound_region,
155
+ is_impl_item : is_impl_item,
156
+ } ) ;
160
157
}
161
158
162
159
// Here, we check for the case where the anonymous region
163
160
// is in the return type.
164
161
// FIXME(#42703) - Need to handle certain cases here.
165
- pub ( super ) fn is_return_type_anon ( & self ,
166
- scope_def_id : DefId ,
167
- br : ty:: BoundRegion ,
168
- decl : & hir:: FnDecl )
169
- -> Option < Span > {
162
+ pub ( super ) fn is_return_type_anon (
163
+ & self ,
164
+ scope_def_id : DefId ,
165
+ br : ty:: BoundRegion ,
166
+ decl : & hir:: FnDecl ,
167
+ ) -> Option < Span > {
170
168
let ret_ty = self . tcx . type_of ( scope_def_id) ;
171
169
match ret_ty. sty {
172
170
ty:: TyFnDef ( _, _) => {
@@ -186,14 +184,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
186
184
// FIXME(#42700) - Need to format self properly to
187
185
// enable E0621 for it.
188
186
pub ( super ) fn is_self_anon ( & self , is_first : bool , scope_def_id : DefId ) -> bool {
189
- is_first &&
190
- self . tcx
191
- . opt_associated_item ( scope_def_id)
192
- . map ( |i| i. method_has_self_argument ) == Some ( true )
187
+ is_first
188
+ && self . tcx
189
+ . opt_associated_item ( scope_def_id)
190
+ . map ( |i| i. method_has_self_argument ) == Some ( true )
193
191
}
194
192
195
193
// Here we check if the bound region is in Impl Item.
196
- pub ( super ) fn is_bound_region_in_impl_item ( & self , suitable_region_binding_scope : DefId ) -> bool {
194
+ pub ( super ) fn is_bound_region_in_impl_item (
195
+ & self ,
196
+ suitable_region_binding_scope : DefId ,
197
+ ) -> bool {
197
198
let container_id = self . tcx
198
199
. associated_item ( suitable_region_binding_scope)
199
200
. container
@@ -213,12 +214,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
213
214
// This method returns whether the given Region is Named
214
215
pub ( super ) fn is_named_region ( & self , region : Region < ' tcx > ) -> bool {
215
216
match * region {
216
- ty:: ReFree ( ref free_region) => {
217
- match free_region. bound_region {
218
- ty:: BrNamed ( ..) => true ,
219
- _ => false ,
220
- }
221
- }
217
+ ty:: ReFree ( ref free_region) => match free_region. bound_region {
218
+ ty:: BrNamed ( ..) => true ,
219
+ _ => false ,
220
+ } ,
222
221
ty:: ReEarlyBound ( _) => true ,
223
222
_ => false ,
224
223
}
0 commit comments