@@ -16,7 +16,7 @@ use rustc_data_structures::parallel;
16
16
use rustc_data_structures:: sync:: { Lrc , OnceCell , WorkerLocal } ;
17
17
use rustc_errors:: { ErrorGuaranteed , PResult } ;
18
18
use rustc_expand:: base:: { ExtCtxt , LintStoreExpand , ResolverExpand } ;
19
- use rustc_hir:: def_id:: StableCrateId ;
19
+ use rustc_hir:: def_id:: { StableCrateId , LOCAL_CRATE } ;
20
20
use rustc_lint:: { BufferedEarlyLint , EarlyCheckNode , LintStore } ;
21
21
use rustc_metadata:: creader:: CStore ;
22
22
use rustc_middle:: arena:: Arena ;
@@ -30,7 +30,7 @@ use rustc_plugin_impl as plugin;
30
30
use rustc_query_impl:: { OnDiskCache , Queries as TcxQueries } ;
31
31
use rustc_resolve:: { Resolver , ResolverArenas } ;
32
32
use rustc_session:: config:: { CrateType , Input , OutputFilenames , OutputType } ;
33
- use rustc_session:: cstore:: { MetadataLoader , MetadataLoaderDyn , Untracked } ;
33
+ use rustc_session:: cstore:: { CrateStoreDyn , MetadataLoader , MetadataLoaderDyn , Untracked } ;
34
34
use rustc_session:: output:: filename_for_input;
35
35
use rustc_session:: search_paths:: PathKind ;
36
36
use rustc_session:: { Limit , Session } ;
@@ -47,7 +47,7 @@ use std::marker::PhantomPinned;
47
47
use std:: path:: { Path , PathBuf } ;
48
48
use std:: pin:: Pin ;
49
49
use std:: rc:: Rc ;
50
- use std:: sync:: LazyLock ;
50
+ use std:: sync:: { Arc , LazyLock } ;
51
51
use std:: { env, fs, iter} ;
52
52
53
53
pub fn parse < ' a > ( sess : & ' a Session ) -> PResult < ' a , ast:: Crate > {
@@ -548,7 +548,7 @@ fn escape_dep_env(symbol: Symbol) -> String {
548
548
549
549
fn write_out_deps (
550
550
sess : & Session ,
551
- boxed_resolver : & RefCell < BoxedResolver > ,
551
+ cstore : & CrateStoreDyn ,
552
552
outputs : & OutputFilenames ,
553
553
out_filenames : & [ PathBuf ] ,
554
554
) {
@@ -600,20 +600,19 @@ fn write_out_deps(
600
600
}
601
601
}
602
602
603
- boxed_resolver. borrow_mut ( ) . access ( |resolver| {
604
- for cnum in resolver. cstore ( ) . crates_untracked ( ) {
605
- let source = resolver. cstore ( ) . crate_source_untracked ( cnum) ;
606
- if let Some ( ( path, _) ) = & source. dylib {
607
- files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
608
- }
609
- if let Some ( ( path, _) ) = & source. rlib {
610
- files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
611
- }
612
- if let Some ( ( path, _) ) = & source. rmeta {
613
- files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
614
- }
603
+ let cstore = cstore. as_any ( ) . downcast_ref :: < CStore > ( ) . unwrap ( ) ;
604
+ for cnum in cstore. crates_untracked ( ) {
605
+ let source = cstore. crate_source_untracked ( cnum) ;
606
+ if let Some ( ( path, _) ) = & source. dylib {
607
+ files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
615
608
}
616
- } ) ;
609
+ if let Some ( ( path, _) ) = & source. rlib {
610
+ files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
611
+ }
612
+ if let Some ( ( path, _) ) = & source. rmeta {
613
+ files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
614
+ }
615
+ }
617
616
}
618
617
619
618
let mut file = BufWriter :: new ( fs:: File :: create ( & deps_filename) ?) ;
@@ -661,13 +660,11 @@ fn write_out_deps(
661
660
}
662
661
}
663
662
664
- pub fn prepare_outputs (
665
- sess : & Session ,
666
- krate : & ast:: Crate ,
667
- boxed_resolver : & RefCell < BoxedResolver > ,
668
- crate_name : Symbol ,
669
- ) -> Result < OutputFilenames > {
663
+ fn output_filenames ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> Arc < OutputFilenames > {
664
+ let sess = tcx. sess ;
670
665
let _timer = sess. timer ( "prepare_outputs" ) ;
666
+ let ( _, krate) = & * tcx. resolver_for_lowering ( ( ) ) . borrow ( ) ;
667
+ let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
671
668
672
669
// FIXME: rustdoc passes &[] instead of &krate.attrs here
673
670
let outputs = util:: build_output_filenames ( & krate. attrs , sess) ;
@@ -679,45 +676,41 @@ pub fn prepare_outputs(
679
676
if let Some ( ref input_path) = sess. io . input . opt_path ( ) {
680
677
if sess. opts . will_create_output_file ( ) {
681
678
if output_contains_path ( & output_paths, input_path) {
682
- let reported = sess. emit_err ( InputFileWouldBeOverWritten { path : input_path } ) ;
683
- return Err ( reported) ;
679
+ sess. emit_fatal ( InputFileWouldBeOverWritten { path : input_path } ) ;
684
680
}
685
681
if let Some ( ref dir_path) = output_conflicts_with_dir ( & output_paths) {
686
- let reported =
687
- sess. emit_err ( GeneratedFileConflictsWithDirectory { input_path, dir_path } ) ;
688
- return Err ( reported) ;
682
+ sess. emit_fatal ( GeneratedFileConflictsWithDirectory { input_path, dir_path } ) ;
689
683
}
690
684
}
691
685
}
692
686
693
687
if let Some ( ref dir) = sess. io . temps_dir {
694
688
if fs:: create_dir_all ( dir) . is_err ( ) {
695
- let reported = sess. emit_err ( TempsDirError ) ;
696
- return Err ( reported) ;
689
+ sess. emit_fatal ( TempsDirError ) ;
697
690
}
698
691
}
699
692
700
- write_out_deps ( sess, boxed_resolver , & outputs, & output_paths) ;
693
+ write_out_deps ( sess, tcx . cstore_untracked ( ) , & outputs, & output_paths) ;
701
694
702
695
let only_dep_info = sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
703
696
&& sess. opts . output_types . len ( ) == 1 ;
704
697
705
698
if !only_dep_info {
706
699
if let Some ( ref dir) = sess. io . output_dir {
707
700
if fs:: create_dir_all ( dir) . is_err ( ) {
708
- let reported = sess. emit_err ( OutDirError ) ;
709
- return Err ( reported) ;
701
+ sess. emit_fatal ( OutDirError ) ;
710
702
}
711
703
}
712
704
}
713
705
714
- Ok ( outputs)
706
+ outputs. into ( )
715
707
}
716
708
717
709
pub static DEFAULT_QUERY_PROVIDERS : LazyLock < Providers > = LazyLock :: new ( || {
718
710
let providers = & mut Providers :: default ( ) ;
719
711
providers. analysis = analysis;
720
712
providers. hir_crate = rustc_ast_lowering:: lower_to_hir;
713
+ providers. output_filenames = output_filenames;
721
714
proc_macro_decls:: provide ( providers) ;
722
715
rustc_const_eval:: provide ( providers) ;
723
716
rustc_middle:: hir:: provide ( providers) ;
0 commit comments