@@ -21,7 +21,7 @@ use rustc_errors::json::JsonEmitter;
2121use  rustc_errors:: registry:: Registry ; 
2222use  rustc_errors:: { Applicability ,  DiagnosticBuilder ,  DiagnosticId ,  ErrorReported } ; 
2323use  rustc_span:: edition:: Edition ; 
24- use  rustc_span:: source_map:: { self ,   FileLoader ,  MultiSpan ,  RealFileLoader ,  SourceMap ,  Span } ; 
24+ use  rustc_span:: source_map:: { FileLoader ,  MultiSpan ,  RealFileLoader ,  SourceMap ,  Span } ; 
2525use  rustc_span:: { SourceFileHashAlgorithm ,  Symbol } ; 
2626use  rustc_target:: asm:: InlineAsmArch ; 
2727use  rustc_target:: spec:: { CodeModel ,  PanicStrategy ,  RelocModel ,  RelroLevel } ; 
@@ -523,7 +523,7 @@ impl Session {
523523    } 
524524
525525    #[ inline]  
526-     pub  fn  source_map ( & self )  -> & source_map :: SourceMap  { 
526+     pub  fn  source_map ( & self )  -> & SourceMap  { 
527527        self . parse_sess . source_map ( ) 
528528    } 
529529    pub  fn  verbose ( & self )  -> bool  { 
@@ -1026,26 +1026,10 @@ impl Session {
10261026    } 
10271027} 
10281028
1029- pub  fn  build_session ( 
1030-     sopts :  config:: Options , 
1031-     local_crate_source_file :  Option < PathBuf > , 
1032-     registry :  rustc_errors:: registry:: Registry , 
1033- )  -> Session  { 
1034-     build_session_with_source_map ( 
1035-         sopts, 
1036-         local_crate_source_file, 
1037-         registry, 
1038-         DiagnosticOutput :: Default , 
1039-         Default :: default ( ) , 
1040-         None , 
1041-     ) 
1042-     . 0 
1043- } 
1044- 
10451029fn  default_emitter ( 
10461030    sopts :  & config:: Options , 
10471031    registry :  rustc_errors:: registry:: Registry , 
1048-     source_map :  & Lrc < source_map :: SourceMap > , 
1032+     source_map :  Lrc < SourceMap > , 
10491033    emitter_dest :  Option < Box < dyn  Write  + Send > > , 
10501034)  -> Box < dyn  Emitter  + sync:: Send >  { 
10511035    let  macro_backtrace = sopts. debugging_opts . macro_backtrace ; 
@@ -1054,25 +1038,22 @@ fn default_emitter(
10541038            let  ( short,  color_config)  = kind. unzip ( ) ; 
10551039
10561040            if  let  HumanReadableErrorType :: AnnotateSnippet ( _)  = kind { 
1057-                 let  emitter = AnnotateSnippetEmitterWriter :: new ( 
1058-                     Some ( source_map. clone ( ) ) , 
1059-                     short, 
1060-                     macro_backtrace, 
1061-                 ) ; 
1041+                 let  emitter =
1042+                     AnnotateSnippetEmitterWriter :: new ( Some ( source_map) ,  short,  macro_backtrace) ; 
10621043                Box :: new ( emitter. ui_testing ( sopts. debugging_opts . ui_testing ) ) 
10631044            }  else  { 
10641045                let  emitter = match  dst { 
10651046                    None  => EmitterWriter :: stderr ( 
10661047                        color_config, 
1067-                         Some ( source_map. clone ( ) ) , 
1048+                         Some ( source_map) , 
10681049                        short, 
10691050                        sopts. debugging_opts . teach , 
10701051                        sopts. debugging_opts . terminal_width , 
10711052                        macro_backtrace, 
10721053                    ) , 
10731054                    Some ( dst)  => EmitterWriter :: new ( 
10741055                        dst, 
1075-                         Some ( source_map. clone ( ) ) , 
1056+                         Some ( source_map) , 
10761057                        short, 
10771058                        false ,  // no teach messages when writing to a buffer 
10781059                        false ,  // no colors when writing to a buffer 
@@ -1084,20 +1065,14 @@ fn default_emitter(
10841065            } 
10851066        } 
10861067        ( config:: ErrorOutputType :: Json  {  pretty,  json_rendered } ,  None )  => Box :: new ( 
1087-             JsonEmitter :: stderr ( 
1088-                 Some ( registry) , 
1089-                 source_map. clone ( ) , 
1090-                 pretty, 
1091-                 json_rendered, 
1092-                 macro_backtrace, 
1093-             ) 
1094-             . ui_testing ( sopts. debugging_opts . ui_testing ) , 
1068+             JsonEmitter :: stderr ( Some ( registry) ,  source_map,  pretty,  json_rendered,  macro_backtrace) 
1069+                 . ui_testing ( sopts. debugging_opts . ui_testing ) , 
10951070        ) , 
10961071        ( config:: ErrorOutputType :: Json  {  pretty,  json_rendered } ,  Some ( dst) )  => Box :: new ( 
10971072            JsonEmitter :: new ( 
10981073                dst, 
10991074                Some ( registry) , 
1100-                 source_map. clone ( ) , 
1075+                 source_map, 
11011076                pretty, 
11021077                json_rendered, 
11031078                macro_backtrace, 
@@ -1112,14 +1087,14 @@ pub enum DiagnosticOutput {
11121087    Raw ( Box < dyn  Write  + Send > ) , 
11131088} 
11141089
1115- pub  fn  build_session_with_source_map ( 
1090+ pub  fn  build_session ( 
11161091    sopts :  config:: Options , 
11171092    local_crate_source_file :  Option < PathBuf > , 
11181093    registry :  rustc_errors:: registry:: Registry , 
11191094    diagnostics_output :  DiagnosticOutput , 
11201095    driver_lint_caps :  FxHashMap < lint:: LintId ,  lint:: Level > , 
11211096    file_loader :  Option < Box < dyn  FileLoader  + Send  + Sync  + ' static > > , 
1122- )  -> ( Session ,   Lrc < SourceMap > )  { 
1097+ )  -> Session  { 
11231098    // FIXME: This is not general enough to make the warning lint completely override 
11241099    // normal diagnostic warnings, since the warning lint can also be denied and changed 
11251100    // later via the source code. 
@@ -1157,7 +1132,7 @@ pub fn build_session_with_source_map(
11571132        sopts. file_path_mapping ( ) , 
11581133        hash_kind, 
11591134    ) ) ; 
1160-     let  emitter = default_emitter ( & sopts,  registry,  & source_map,  write_dest) ; 
1135+     let  emitter = default_emitter ( & sopts,  registry,  source_map. clone ( ) ,  write_dest) ; 
11611136
11621137    let  span_diagnostic = rustc_errors:: Handler :: with_emitter_and_flags ( 
11631138        emitter, 
@@ -1185,7 +1160,7 @@ pub fn build_session_with_source_map(
11851160        None 
11861161    } ; 
11871162
1188-     let  parse_sess = ParseSess :: with_span_handler ( span_diagnostic,  source_map. clone ( ) ) ; 
1163+     let  parse_sess = ParseSess :: with_span_handler ( span_diagnostic,  source_map) ; 
11891164    let  sysroot = match  & sopts. maybe_sysroot  { 
11901165        Some ( sysroot)  => sysroot. clone ( ) , 
11911166        None  => filesearch:: get_or_default_sysroot ( ) , 
@@ -1308,7 +1283,7 @@ pub fn build_session_with_source_map(
13081283
13091284    validate_commandline_args_with_session_available ( & sess) ; 
13101285
1311-     ( sess,  source_map ) 
1286+     sess
13121287} 
13131288
13141289// If it is useful to have a Session available already for validating a 
0 commit comments