@@ -265,7 +265,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
265265 start - min_end
266266 }
267267 LazyState :: Previous ( last_min_end) => {
268- assert ! ( last_min_end <= position) ;
268+ assert ! (
269+ last_min_end <= position,
270+ "make sure that the calls to `lazy*` \
271+ are in the same order as the metadata fields",
272+ ) ;
269273 position - last_min_end
270274 }
271275 } ;
@@ -439,21 +443,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
439443 IsolatedEncoder :: encode_wasm_custom_sections,
440444 & wasm_custom_sections) ;
441445
442- // Encode and index the items.
443- i = self . position ( ) ;
444- let items = self . encode_info_for_items ( ) ;
445- let item_bytes = self . position ( ) - i;
446-
447- i = self . position ( ) ;
448- let index = items. write_index ( & mut self . opaque . cursor ) ;
449- let index_bytes = self . position ( ) - i;
450-
451446 let tcx = self . tcx ;
452- let link_meta = self . link_meta ;
453- let is_proc_macro = tcx. sess . crate_types . borrow ( ) . contains ( & CrateTypeProcMacro ) ;
454- let has_default_lib_allocator =
455- attr:: contains_name ( tcx. hir . krate_attrs ( ) , "default_lib_allocator" ) ;
456- let has_global_allocator = * tcx. sess . has_global_allocator . get ( ) ;
457447
458448 // Encode the allocation index
459449 let interpret_alloc_index = {
@@ -478,9 +468,24 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
478468 }
479469 n = new_n;
480470 }
481- interpret_alloc_index
471+ self . lazy_seq ( interpret_alloc_index)
482472 } ;
483473
474+ // Encode and index the items.
475+ i = self . position ( ) ;
476+ let items = self . encode_info_for_items ( ) ;
477+ let item_bytes = self . position ( ) - i;
478+
479+ i = self . position ( ) ;
480+ let index = items. write_index ( & mut self . opaque . cursor ) ;
481+ let index_bytes = self . position ( ) - i;
482+
483+ let link_meta = self . link_meta ;
484+ let is_proc_macro = tcx. sess . crate_types . borrow ( ) . contains ( & CrateTypeProcMacro ) ;
485+ let has_default_lib_allocator =
486+ attr:: contains_name ( tcx. hir . krate_attrs ( ) , "default_lib_allocator" ) ;
487+ let has_global_allocator = tcx. sess . has_global_allocator . get ( ) ;
488+
484489 let root = self . lazy ( & CrateRoot {
485490 name : tcx. crate_name ( LOCAL_CRATE ) ,
486491 extra_filename : tcx. sess . opts . cg . extra_filename . clone ( ) ,
@@ -512,8 +517,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
512517 impls,
513518 exported_symbols,
514519 wasm_custom_sections,
515- index,
516520 interpret_alloc_index,
521+ index,
517522 } ) ;
518523
519524 let total_bytes = self . position ( ) ;
0 commit comments