@@ -168,6 +168,10 @@ impl<'a, 'tcx> SpanEncoder for EncodeContext<'a, 'tcx> {
168168 }
169169
170170 fn encode_span ( & mut self , span : Span ) {
171+ if self . tcx . sess . is_split_rmeta_enabled ( ) {
172+ return ;
173+ }
174+
171175 match self . span_shorthands . entry ( span) {
172176 Entry :: Occupied ( o) => {
173177 // If an offset is smaller than the absolute position, we encode with the offset.
@@ -603,6 +607,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
603607 adapted. encode ( & mut self . opaque )
604608 }
605609
610+ fn dont_encode_source_map (
611+ & mut self ,
612+ ) -> LazyTable < u32 , Option < LazyValue < rustc_span:: SourceFile > > > {
613+ let adapted = TableBuilder :: default ( ) ;
614+ adapted. encode ( & mut self . opaque )
615+ }
616+
606617 fn encode_crate_root ( & mut self ) -> LazyValue < CrateRoot > {
607618 let tcx = self . tcx ;
608619 let mut stats: Vec < ( & ' static str , usize ) > = Vec :: with_capacity ( 32 ) ;
@@ -708,7 +719,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
708719
709720 // Encode source_map. This needs to be done last, because encoding `Span`s tells us which
710721 // `SourceFiles` we actually need to encode.
711- let source_map = stat ! ( "source-map" , || self . encode_source_map( ) ) ;
722+ let source_map = if tcx. sess . is_split_rmeta_enabled ( ) {
723+ stat ! ( "source-map" , || self . dont_encode_source_map( ) )
724+ } else {
725+ stat ! ( "source-map" , || self . encode_source_map( ) )
726+ } ;
712727 let target_modifiers = stat ! ( "target-modifiers" , || self . encode_target_modifiers( ) ) ;
713728
714729 let root = stat ! ( "final" , || {
@@ -733,6 +748,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
733748 attrs,
734749 sym:: default_lib_allocator,
735750 ) ,
751+ has_rmeta_extras: !tcx. sess. is_split_rmeta_enabled( ) ,
736752 proc_macro_data,
737753 debugger_visualizers,
738754 compiler_builtins: ast:: attr:: contains_name( attrs, sym:: compiler_builtins) ,
0 commit comments