File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -383,13 +383,10 @@ impl Page {
383383
384384 #[ inline]
385385 fn assert_type < T : Slot > ( & self ) -> PageView < ' _ , T > {
386- assert_eq ! (
387- self . slot_type_id,
388- TypeId :: of:: <T >( ) ,
389- "page has slot type `{:?}` but `{:?}` was expected" ,
390- self . slot_type_name,
391- std:: any:: type_name:: <T >( ) ,
392- ) ;
386+ if self . slot_type_id != TypeId :: of :: < T > ( ) {
387+ type_assert_failed :: < T > ( self ) ;
388+ }
389+
393390 PageView ( self , PhantomData )
394391 }
395392
@@ -403,6 +400,17 @@ impl Page {
403400 }
404401}
405402
403+ /// This function is explicitly outlined to avoid debug machinery in the hot-path.
404+ #[ cold]
405+ #[ inline( never) ]
406+ fn type_assert_failed < T : ' static > ( page : & Page ) -> ! {
407+ panic ! (
408+ "page has slot type `{:?}` but `{:?}` was expected" ,
409+ page. slot_type_name,
410+ std:: any:: type_name:: <T >( ) ,
411+ )
412+ }
413+
406414impl Drop for Page {
407415 fn drop ( & mut self ) {
408416 let len = * self . allocated . get_mut ( ) ;
You can’t perform that action at this time.
0 commit comments