@@ -7,7 +7,8 @@ use rustc_hir::def_id::DefId;
77use rustc_middle:: mir:: interpret:: { ErrorHandled , InvalidMetaKind , ReportedErrorInfo } ;
88use rustc_middle:: query:: TyCtxtAt ;
99use rustc_middle:: ty:: layout:: {
10- self , FnAbiError , FnAbiOfHelpers , FnAbiRequest , LayoutError , LayoutOfHelpers , TyAndLayout ,
10+ self , FnAbiError , FnAbiOfHelpers , FnAbiRequest , LayoutError , LayoutOf , LayoutOfHelpers ,
11+ TyAndLayout ,
1112} ;
1213use rustc_middle:: ty:: { self , GenericArgsRef , Ty , TyCtxt , TypeFoldable , TypingEnv , Variance } ;
1314use rustc_middle:: { mir, span_bug} ;
@@ -91,6 +92,20 @@ impl<'tcx, M: Machine<'tcx>> LayoutOfHelpers<'tcx> for InterpCx<'tcx, M> {
9192 }
9293}
9394
95+ impl < ' tcx , M : Machine < ' tcx > > InterpCx < ' tcx , M > {
96+ /// This inherent method takes priority over the trait method with the same name in LayoutOf,
97+ /// and allows wrapping the actual [LayoutOf::layout_of] with a tracing span.
98+ /// See [LayoutOf::layout_of] for the original documentation.
99+ #[ inline]
100+ pub fn layout_of (
101+ & self ,
102+ ty : Ty < ' tcx > ,
103+ ) -> <InterpCx < ' tcx , M > as LayoutOfHelpers < ' tcx > >:: LayoutOfResult {
104+ let _span = enter_trace_span ! ( M , "InterpCx::layout_of" , "ty = {:?}" , ty. kind( ) ) ;
105+ LayoutOf :: layout_of ( self , ty)
106+ }
107+ }
108+
94109impl < ' tcx , M : Machine < ' tcx > > FnAbiOfHelpers < ' tcx > for InterpCx < ' tcx , M > {
95110 type FnAbiOfResult = Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , InterpErrorKind < ' tcx > > ;
96111
0 commit comments