@@ -1766,108 +1766,111 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1766
1766
}
1767
1767
} ;
1768
1768
1769
- self . cdata . source_map_import_info . get_or_init ( || {
1770
- let external_source_map = self . root . source_map . decode ( self ) ;
1771
-
1772
- external_source_map
1773
- . map ( |source_file_to_import| {
1774
- // We can't reuse an existing SourceFile, so allocate a new one
1775
- // containing the information we need.
1776
- let rustc_span:: SourceFile {
1777
- mut name,
1778
- src_hash,
1779
- start_pos,
1780
- end_pos,
1781
- mut lines,
1782
- mut multibyte_chars,
1783
- mut non_narrow_chars,
1784
- mut normalized_pos,
1785
- name_hash,
1786
- ..
1787
- } = source_file_to_import;
1788
-
1789
- // If this file is under $sysroot/lib/rustlib/src/ but has not been remapped
1790
- // during rust bootstrapping by `remap-debuginfo = true`, and the user
1791
- // wish to simulate that behaviour by -Z simulate-remapped-rust-src-base,
1792
- // then we change `name` to a similar state as if the rust was bootstrapped
1793
- // with `remap-debuginfo = true`.
1794
- // This is useful for testing so that tests about the effects of
1795
- // `try_to_translate_virtual_to_real` don't have to worry about how the
1796
- // compiler is bootstrapped.
1797
- if let Some ( virtual_dir) =
1798
- & sess. opts . debugging_opts . simulate_remapped_rust_src_base
1799
- {
1800
- if let Some ( real_dir) = & sess. opts . real_rust_source_base_dir {
1801
- if let rustc_span:: FileName :: Real ( ref mut old_name) = name {
1802
- if let rustc_span:: RealFileName :: LocalPath ( local) = old_name {
1803
- if let Ok ( rest) = local. strip_prefix ( real_dir) {
1804
- * old_name = rustc_span:: RealFileName :: Remapped {
1805
- local_path : None ,
1806
- virtual_name : virtual_dir. join ( rest) ,
1807
- } ;
1769
+ self . cdata . source_map_import_info . get_or_init (
1770
+ #[ inline( never) ]
1771
+ || {
1772
+ let external_source_map = self . root . source_map . decode ( self ) ;
1773
+
1774
+ external_source_map
1775
+ . map ( |source_file_to_import| {
1776
+ // We can't reuse an existing SourceFile, so allocate a new one
1777
+ // containing the information we need.
1778
+ let rustc_span:: SourceFile {
1779
+ mut name,
1780
+ src_hash,
1781
+ start_pos,
1782
+ end_pos,
1783
+ mut lines,
1784
+ mut multibyte_chars,
1785
+ mut non_narrow_chars,
1786
+ mut normalized_pos,
1787
+ name_hash,
1788
+ ..
1789
+ } = source_file_to_import;
1790
+
1791
+ // If this file is under $sysroot/lib/rustlib/src/ but has not been remapped
1792
+ // during rust bootstrapping by `remap-debuginfo = true`, and the user
1793
+ // wish to simulate that behaviour by -Z simulate-remapped-rust-src-base,
1794
+ // then we change `name` to a similar state as if the rust was bootstrapped
1795
+ // with `remap-debuginfo = true`.
1796
+ // This is useful for testing so that tests about the effects of
1797
+ // `try_to_translate_virtual_to_real` don't have to worry about how the
1798
+ // compiler is bootstrapped.
1799
+ if let Some ( virtual_dir) =
1800
+ & sess. opts . debugging_opts . simulate_remapped_rust_src_base
1801
+ {
1802
+ if let Some ( real_dir) = & sess. opts . real_rust_source_base_dir {
1803
+ if let rustc_span:: FileName :: Real ( ref mut old_name) = name {
1804
+ if let rustc_span:: RealFileName :: LocalPath ( local) = old_name {
1805
+ if let Ok ( rest) = local. strip_prefix ( real_dir) {
1806
+ * old_name = rustc_span:: RealFileName :: Remapped {
1807
+ local_path : None ,
1808
+ virtual_name : virtual_dir. join ( rest) ,
1809
+ } ;
1810
+ }
1808
1811
}
1809
1812
}
1810
1813
}
1811
1814
}
1812
- }
1813
1815
1814
- // If this file's path has been remapped to `/rustc/$hash`,
1815
- // we might be able to reverse that (also see comments above,
1816
- // on `try_to_translate_virtual_to_real`).
1817
- try_to_translate_virtual_to_real ( & mut name) ;
1816
+ // If this file's path has been remapped to `/rustc/$hash`,
1817
+ // we might be able to reverse that (also see comments above,
1818
+ // on `try_to_translate_virtual_to_real`).
1819
+ try_to_translate_virtual_to_real ( & mut name) ;
1818
1820
1819
- let source_length = ( end_pos - start_pos) . to_usize ( ) ;
1821
+ let source_length = ( end_pos - start_pos) . to_usize ( ) ;
1820
1822
1821
- // Translate line-start positions and multibyte character
1822
- // position into frame of reference local to file.
1823
- // `SourceMap::new_imported_source_file()` will then translate those
1824
- // coordinates to their new global frame of reference when the
1825
- // offset of the SourceFile is known.
1826
- for pos in & mut lines {
1827
- * pos = * pos - start_pos;
1828
- }
1829
- for mbc in & mut multibyte_chars {
1830
- mbc. pos = mbc. pos - start_pos;
1831
- }
1832
- for swc in & mut non_narrow_chars {
1833
- * swc = * swc - start_pos;
1834
- }
1835
- for np in & mut normalized_pos {
1836
- np. pos = np. pos - start_pos;
1837
- }
1823
+ // Translate line-start positions and multibyte character
1824
+ // position into frame of reference local to file.
1825
+ // `SourceMap::new_imported_source_file()` will then translate those
1826
+ // coordinates to their new global frame of reference when the
1827
+ // offset of the SourceFile is known.
1828
+ for pos in & mut lines {
1829
+ * pos = * pos - start_pos;
1830
+ }
1831
+ for mbc in & mut multibyte_chars {
1832
+ mbc. pos = mbc. pos - start_pos;
1833
+ }
1834
+ for swc in & mut non_narrow_chars {
1835
+ * swc = * swc - start_pos;
1836
+ }
1837
+ for np in & mut normalized_pos {
1838
+ np. pos = np. pos - start_pos;
1839
+ }
1838
1840
1839
- let local_version = sess. source_map ( ) . new_imported_source_file (
1840
- name,
1841
- src_hash,
1842
- name_hash,
1843
- source_length,
1844
- self . cnum ,
1845
- lines,
1846
- multibyte_chars,
1847
- non_narrow_chars,
1848
- normalized_pos,
1849
- start_pos,
1850
- end_pos,
1851
- ) ;
1852
- debug ! (
1853
- "CrateMetaData::imported_source_files alloc \
1841
+ let local_version = sess. source_map ( ) . new_imported_source_file (
1842
+ name,
1843
+ src_hash,
1844
+ name_hash,
1845
+ source_length,
1846
+ self . cnum ,
1847
+ lines,
1848
+ multibyte_chars,
1849
+ non_narrow_chars,
1850
+ normalized_pos,
1851
+ start_pos,
1852
+ end_pos,
1853
+ ) ;
1854
+ debug ! (
1855
+ "CrateMetaData::imported_source_files alloc \
1854
1856
source_file {:?} original (start_pos {:?} end_pos {:?}) \
1855
1857
translated (start_pos {:?} end_pos {:?})",
1856
- local_version. name,
1857
- start_pos,
1858
- end_pos,
1859
- local_version. start_pos,
1860
- local_version. end_pos
1861
- ) ;
1862
-
1863
- ImportedSourceFile {
1864
- original_start_pos : start_pos,
1865
- original_end_pos : end_pos,
1866
- translated_source_file : local_version,
1867
- }
1868
- } )
1869
- . collect ( )
1870
- } )
1858
+ local_version. name,
1859
+ start_pos,
1860
+ end_pos,
1861
+ local_version. start_pos,
1862
+ local_version. end_pos
1863
+ ) ;
1864
+
1865
+ ImportedSourceFile {
1866
+ original_start_pos : start_pos,
1867
+ original_end_pos : end_pos,
1868
+ translated_source_file : local_version,
1869
+ }
1870
+ } )
1871
+ . collect ( )
1872
+ } ,
1873
+ )
1871
1874
}
1872
1875
}
1873
1876
0 commit comments