@@ -184,68 +184,66 @@ enum Scope<'a> {
184
184
} ,
185
185
}
186
186
187
- #[ derive( Copy , Clone , Debug ) ]
188
- enum BinderScopeType {
189
- /// Any non-concatenating binder scopes.
190
- Normal ,
191
- /// Within a syntactic trait ref, there may be multiple poly trait refs that
192
- /// are nested (under the `associated_type_bounds` feature). The binders of
193
- /// the inner poly trait refs are extended from the outer poly trait refs
194
- /// and don't increase the late bound depth. If you had
195
- /// `T: for<'a> Foo<Bar: for<'b> Baz<'a, 'b>>`, then the `for<'b>` scope
196
- /// would be `Concatenating`. This also used in trait refs in where clauses
197
- /// where we have two binders `for<> T: for<> Foo` (I've intentionally left
198
- /// out any lifetimes because they aren't needed to show the two scopes).
199
- /// The inner `for<>` has a scope of `Concatenating`.
200
- Concatenating ,
201
- }
202
-
203
- // A helper struct for debugging scopes without printing parent scopes
204
- struct TruncatedScopeDebug < ' a > ( & ' a Scope < ' a > ) ;
205
-
206
- impl < ' a > fmt:: Debug for TruncatedScopeDebug < ' a > {
207
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
208
- match self . 0 {
209
- Scope :: Binder { bound_vars, scope_type, hir_id, where_bound_origin, s : _ } => f
187
+ impl < ' a > Scope < ' a > {
188
+ // A helper for debugging scopes without printing parent scopes
189
+ fn debug_truncated ( & ' a self ) -> impl fmt:: Debug + ' a {
190
+ fmt:: from_fn ( move |f| match self {
191
+ Self :: Binder { bound_vars, scope_type, hir_id, where_bound_origin, s : _ } => f
210
192
. debug_struct ( "Binder" )
211
193
. field ( "bound_vars" , bound_vars)
212
194
. field ( "scope_type" , scope_type)
213
195
. field ( "hir_id" , hir_id)
214
196
. field ( "where_bound_origin" , where_bound_origin)
215
197
. field ( "s" , & ".." )
216
198
. finish ( ) ,
217
- Scope :: Opaque { captures, def_id, s : _ } => f
199
+ Self :: Opaque { captures, def_id, s : _ } => f
218
200
. debug_struct ( "Opaque" )
219
201
. field ( "def_id" , def_id)
220
202
. field ( "captures" , & captures. borrow ( ) )
221
203
. field ( "s" , & ".." )
222
204
. finish ( ) ,
223
- Scope :: Body { id, s : _ } => {
205
+ Self :: Body { id, s : _ } => {
224
206
f. debug_struct ( "Body" ) . field ( "id" , id) . field ( "s" , & ".." ) . finish ( )
225
207
}
226
- Scope :: ObjectLifetimeDefault { lifetime, s : _ } => f
208
+ Self :: ObjectLifetimeDefault { lifetime, s : _ } => f
227
209
. debug_struct ( "ObjectLifetimeDefault" )
228
210
. field ( "lifetime" , lifetime)
229
211
. field ( "s" , & ".." )
230
212
. finish ( ) ,
231
- Scope :: Supertrait { bound_vars, s : _ } => f
213
+ Self :: Supertrait { bound_vars, s : _ } => f
232
214
. debug_struct ( "Supertrait" )
233
215
. field ( "bound_vars" , bound_vars)
234
216
. field ( "s" , & ".." )
235
217
. finish ( ) ,
236
- Scope :: TraitRefBoundary { s : _ } => f. debug_struct ( "TraitRefBoundary" ) . finish ( ) ,
237
- Scope :: LateBoundary { s : _, what, deny_late_regions } => f
218
+ Self :: TraitRefBoundary { s : _ } => f. debug_struct ( "TraitRefBoundary" ) . finish ( ) ,
219
+ Self :: LateBoundary { s : _, what, deny_late_regions } => f
238
220
. debug_struct ( "LateBoundary" )
239
221
. field ( "what" , what)
240
222
. field ( "deny_late_regions" , deny_late_regions)
241
223
. finish ( ) ,
242
- Scope :: Root { opt_parent_item } => {
224
+ Self :: Root { opt_parent_item } => {
243
225
f. debug_struct ( "Root" ) . field ( "opt_parent_item" , & opt_parent_item) . finish ( )
244
226
}
245
- }
227
+ } )
246
228
}
247
229
}
248
230
231
+ #[ derive( Copy , Clone , Debug ) ]
232
+ enum BinderScopeType {
233
+ /// Any non-concatenating binder scopes.
234
+ Normal ,
235
+ /// Within a syntactic trait ref, there may be multiple poly trait refs that
236
+ /// are nested (under the `associated_type_bounds` feature). The binders of
237
+ /// the inner poly trait refs are extended from the outer poly trait refs
238
+ /// and don't increase the late bound depth. If you had
239
+ /// `T: for<'a> Foo<Bar: for<'b> Baz<'a, 'b>>`, then the `for<'b>` scope
240
+ /// would be `Concatenating`. This also used in trait refs in where clauses
241
+ /// where we have two binders `for<> T: for<> Foo` (I've intentionally left
242
+ /// out any lifetimes because they aren't needed to show the two scopes).
243
+ /// The inner `for<>` has a scope of `Concatenating`.
244
+ Concatenating ,
245
+ }
246
+
249
247
type ScopeRef < ' a > = & ' a Scope < ' a > ;
250
248
251
249
pub ( crate ) fn provide ( providers : & mut Providers ) {
@@ -1144,7 +1142,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1144
1142
{
1145
1143
let BoundVarContext { tcx, map, .. } = self ;
1146
1144
let mut this = BoundVarContext { tcx : * tcx, map, scope : & wrap_scope } ;
1147
- let span = debug_span ! ( "scope" , scope = ?TruncatedScopeDebug ( this. scope) ) ;
1145
+ let span = debug_span ! ( "scope" , scope = ?this. scope. debug_truncated ( ) ) ;
1148
1146
{
1149
1147
let _enter = span. enter ( ) ;
1150
1148
f ( & mut this) ;
0 commit comments