@@ -265,7 +265,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
265
265
start - min_end
266
266
}
267
267
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
+ ) ;
269
273
position - last_min_end
270
274
}
271
275
} ;
@@ -439,21 +443,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
439
443
IsolatedEncoder :: encode_wasm_custom_sections,
440
444
& wasm_custom_sections) ;
441
445
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
-
451
446
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 ( ) ;
457
447
458
448
// Encode the allocation index
459
449
let interpret_alloc_index = {
@@ -478,9 +468,24 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
478
468
}
479
469
n = new_n;
480
470
}
481
- interpret_alloc_index
471
+ self . lazy_seq ( interpret_alloc_index)
482
472
} ;
483
473
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
+
484
489
let root = self . lazy ( & CrateRoot {
485
490
name : tcx. crate_name ( LOCAL_CRATE ) ,
486
491
extra_filename : tcx. sess . opts . cg . extra_filename . clone ( ) ,
@@ -512,8 +517,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
512
517
impls,
513
518
exported_symbols,
514
519
wasm_custom_sections,
515
- index,
516
520
interpret_alloc_index,
521
+ index,
517
522
} ) ;
518
523
519
524
let total_bytes = self . position ( ) ;
0 commit comments