@@ -184,68 +184,66 @@ enum Scope<'a> {
184184 } ,
185185}
186186
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
210192 . debug_struct ( "Binder" )
211193 . field ( "bound_vars" , bound_vars)
212194 . field ( "scope_type" , scope_type)
213195 . field ( "hir_id" , hir_id)
214196 . field ( "where_bound_origin" , where_bound_origin)
215197 . field ( "s" , & ".." )
216198 . finish ( ) ,
217- Scope :: Opaque { captures, def_id, s : _ } => f
199+ Self :: Opaque { captures, def_id, s : _ } => f
218200 . debug_struct ( "Opaque" )
219201 . field ( "def_id" , def_id)
220202 . field ( "captures" , & captures. borrow ( ) )
221203 . field ( "s" , & ".." )
222204 . finish ( ) ,
223- Scope :: Body { id, s : _ } => {
205+ Self :: Body { id, s : _ } => {
224206 f. debug_struct ( "Body" ) . field ( "id" , id) . field ( "s" , & ".." ) . finish ( )
225207 }
226- Scope :: ObjectLifetimeDefault { lifetime, s : _ } => f
208+ Self :: ObjectLifetimeDefault { lifetime, s : _ } => f
227209 . debug_struct ( "ObjectLifetimeDefault" )
228210 . field ( "lifetime" , lifetime)
229211 . field ( "s" , & ".." )
230212 . finish ( ) ,
231- Scope :: Supertrait { bound_vars, s : _ } => f
213+ Self :: Supertrait { bound_vars, s : _ } => f
232214 . debug_struct ( "Supertrait" )
233215 . field ( "bound_vars" , bound_vars)
234216 . field ( "s" , & ".." )
235217 . 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
238220 . debug_struct ( "LateBoundary" )
239221 . field ( "what" , what)
240222 . field ( "deny_late_regions" , deny_late_regions)
241223 . finish ( ) ,
242- Scope :: Root { opt_parent_item } => {
224+ Self :: Root { opt_parent_item } => {
243225 f. debug_struct ( "Root" ) . field ( "opt_parent_item" , & opt_parent_item) . finish ( )
244226 }
245- }
227+ } )
246228 }
247229}
248230
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+
249247type ScopeRef < ' a > = & ' a Scope < ' a > ;
250248
251249pub ( crate ) fn provide ( providers : & mut Providers ) {
@@ -1144,7 +1142,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
11441142 {
11451143 let BoundVarContext { tcx, map, .. } = self ;
11461144 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 ( ) ) ;
11481146 {
11491147 let _enter = span. enter ( ) ;
11501148 f ( & mut this) ;
0 commit comments