@@ -11,7 +11,7 @@ use rustc::lint;
11
11
use rustc:: middle:: { self , reachable, resolve_lifetime, stability} ;
12
12
use rustc:: middle:: cstore:: CrateStore ;
13
13
use rustc:: ty:: { self , AllArenas , Resolutions , TyCtxt , GlobalCtxt } ;
14
- use rustc :: ty :: steal:: Steal ;
14
+ use rustc_data_structures :: steal:: Steal ;
15
15
use rustc:: traits;
16
16
use rustc:: util:: common:: { time, ErrorReported } ;
17
17
use rustc:: session:: Session ;
@@ -38,6 +38,7 @@ use syntax::early_buffered_lints::BufferedEarlyLint;
38
38
use syntax:: ext:: base:: { NamedSyntaxExtension , ExtCtxt } ;
39
39
use syntax:: mut_visit:: MutVisitor ;
40
40
use syntax:: parse:: { self , PResult } ;
41
+ use syntax:: parse:: parser:: InterpUserFn ;
41
42
use syntax:: util:: node_count:: NodeCounter ;
42
43
use syntax:: symbol:: Symbol ;
43
44
use syntax_pos:: FileName ;
@@ -56,16 +57,28 @@ use std::path::PathBuf;
56
57
use std:: cell:: RefCell ;
57
58
use std:: rc:: Rc ;
58
59
59
- pub fn parse < ' a > ( sess : & ' a Session , input : & Input ) -> PResult < ' a , ast:: Crate > {
60
+ pub fn parse < ' a > (
61
+ sess : & ' a Session ,
62
+ input : & Input ,
63
+ interp_user_fn : Option < InterpUserFn > ,
64
+ ) -> PResult < ' a , ast:: Crate > {
60
65
sess. diagnostic ( )
61
66
. set_continue_after_error ( sess. opts . debugging_opts . continue_parse_after_error ) ;
62
67
sess. profiler ( |p| p. start_activity ( "parsing" ) ) ;
63
68
let krate = time ( sess, "parsing" , || match * input {
64
- Input :: File ( ref file) => parse:: parse_crate_from_file ( file, & sess. parse_sess ) ,
69
+ Input :: File ( ref file) => parse:: parse_crate_from_file (
70
+ file,
71
+ & sess. parse_sess ,
72
+ ) ,
65
73
Input :: Str {
66
74
ref input,
67
75
ref name,
68
- } => parse:: parse_crate_from_source_str ( name. clone ( ) , input. clone ( ) , & sess. parse_sess ) ,
76
+ } => parse:: parse_crate_from_source_str (
77
+ name. clone ( ) ,
78
+ input. clone ( ) ,
79
+ & sess. parse_sess ,
80
+ interp_user_fn,
81
+ ) ,
69
82
} ) ?;
70
83
sess. profiler ( |p| p. end_activity ( "parsing" ) ) ;
71
84
@@ -112,7 +125,7 @@ declare_box_region_type!(
112
125
/// harness if one is to be provided, injection of a dependency on the
113
126
/// standard library and prelude, and name resolution.
114
127
///
115
- /// Returns `None` if we're aborting after handling -W help.
128
+ /// Returns `None` if we're aborting after handling ` -W help` .
116
129
pub fn configure_and_expand (
117
130
sess : Lrc < Session > ,
118
131
cstore : Lrc < CStore > ,
@@ -236,7 +249,7 @@ pub fn register_plugins<'a>(
236
249
sess. edition ( ) ,
237
250
& sess. opts . debugging_opts . allow_features ,
238
251
) ;
239
- // these need to be set "early" so that expansion sees `quote` if enabled.
252
+ // These need to be set "early" so that expansion sees `quote` if enabled.
240
253
sess. init_features ( features) ;
241
254
242
255
let crate_types = util:: collect_crate_types ( sess, & krate. attrs ) ;
@@ -354,13 +367,13 @@ fn configure_and_expand_inner<'a>(
354
367
& mut krate, & mut resolver, plugin_info. syntax_exts , sess. edition ( )
355
368
) ;
356
369
357
- // Expand all macros
370
+ // Expand all macros.
358
371
sess. profiler ( |p| p. start_activity ( "macro expansion" ) ) ;
359
372
krate = time ( sess, "expansion" , || {
360
- // Windows dlls do not have rpaths, so they don't know how to find their
373
+ // Windows DLLs do not have rpaths, so they don't know how to find their
361
374
// dependencies. It's up to us to tell the system where to find all the
362
- // dependent dlls . Note that this uses cfg!(windows) as opposed to
363
- // targ_cfg because syntax extensions are always loaded for the host
375
+ // dependent DLLs . Note that this uses ` cfg!(windows)` as opposed to
376
+ // ` targ_cfg` because syntax extensions are always loaded for the host
364
377
// compiler, not for the target.
365
378
//
366
379
// This is somewhat of an inherently racy operation, however, as
@@ -389,7 +402,7 @@ fn configure_and_expand_inner<'a>(
389
402
) ;
390
403
}
391
404
392
- // Create the config for macro expansion
405
+ // Create the config for macro expansion.
393
406
let features = sess. features_untracked ( ) ;
394
407
let cfg = syntax:: ext:: expand:: ExpansionConfig {
395
408
features : Some ( & features) ,
@@ -406,7 +419,7 @@ fn configure_and_expand_inner<'a>(
406
419
ecx. monotonic_expander ( ) . expand_crate ( krate)
407
420
} ) ;
408
421
409
- // The rest is error reporting
422
+ // The rest is error reporting.
410
423
411
424
time ( sess, "check unused macros" , || {
412
425
ecx. check_unused_macros ( ) ;
@@ -447,7 +460,7 @@ fn configure_and_expand_inner<'a>(
447
460
} ) ;
448
461
449
462
// If we're actually rustdoc then there's no need to actually compile
450
- // anything, so switch everything to just looping
463
+ // anything, so switch everything to just looping.
451
464
if sess. opts . actually_rustdoc {
452
465
util:: ReplaceBodyWithLoop :: new ( sess) . visit_crate ( & mut krate) ;
453
466
}
@@ -582,7 +595,7 @@ fn generated_output_paths(
582
595
out_filenames. push ( p) ;
583
596
} ,
584
597
OutputType :: DepInfo if sess. opts . debugging_opts . dep_info_omit_d_target => {
585
- // Don't add the dep-info output when omitting it from dep-info targets
598
+ // Don't add the dep-info output when omitting it from dep-info targets.
586
599
}
587
600
_ => {
588
601
out_filenames. push ( file) ;
@@ -640,15 +653,15 @@ fn escape_dep_filename(filename: &FileName) -> String {
640
653
641
654
fn write_out_deps ( compiler : & Compiler , outputs : & OutputFilenames , out_filenames : & [ PathBuf ] ) {
642
655
let sess = & compiler. sess ;
643
- // Write out dependency rules to the dep-info file if requested
656
+ // Write out dependency rules to the dep-info file if requested.
644
657
if !sess. opts . output_types . contains_key ( & OutputType :: DepInfo ) {
645
658
return ;
646
659
}
647
660
let deps_filename = outputs. path ( OutputType :: DepInfo ) ;
648
661
649
662
let result = ( || -> io:: Result < ( ) > {
650
663
// Build a list of files used to compile the output and
651
- // write Makefile-compatible dependency rules
664
+ // write Makefile-compatible dependency rules.
652
665
let mut files: Vec < String > = sess. source_map ( )
653
666
. files ( )
654
667
. iter ( )
@@ -680,7 +693,7 @@ fn write_out_deps(compiler: &Compiler, outputs: &OutputFilenames, out_filenames:
680
693
681
694
// Emit a fake target for each input file to the compilation. This
682
695
// prevents `make` from spitting out an error if a file is later
683
- // deleted. For more info see #28735
696
+ // deleted. For more info see #28735.
684
697
for path in files {
685
698
writeln ! ( file, "{}:" , path) ?;
686
699
}
@@ -710,7 +723,7 @@ pub fn prepare_outputs(
710
723
krate : & ast:: Crate ,
711
724
crate_name : & str
712
725
) -> Result < OutputFilenames > {
713
- // FIXME: rustdoc passes &[] instead of &krate.attrs here
726
+ // FIXME: rustdoc passes ` &[]` instead of ` &krate.attrs` here.
714
727
let outputs = util:: build_output_filenames (
715
728
& compiler. input ,
716
729
& compiler. output_dir ,
@@ -731,16 +744,15 @@ pub fn prepare_outputs(
731
744
if sess. opts . will_create_output_file ( ) {
732
745
if output_contains_path ( & output_paths, input_path) {
733
746
sess. err ( & format ! (
734
- "the input file \" {}\" would be overwritten by the generated \
735
- executable",
747
+ "the input file \" {}\" would be overwritten by the generated executable" ,
736
748
input_path. display( )
737
749
) ) ;
738
750
return Err ( ErrorReported ) ;
739
751
}
740
752
if let Some ( dir_path) = output_conflicts_with_dir ( & output_paths) {
741
753
sess. err ( & format ! (
742
754
"the generated executable for the input file \" {}\" conflicts with the \
743
- existing directory \" {}\" ",
755
+ existing directory \" {}\" ",
744
756
input_path. display( ) ,
745
757
dir_path. display( )
746
758
) ) ;
@@ -857,14 +869,14 @@ pub fn create_global_ctxt(
857
869
hir_map,
858
870
query_result_on_disk_cache,
859
871
& crate_name,
860
- & outputs
872
+ & outputs,
861
873
) ;
862
874
863
875
global_ctxt = Some ( gcx) ;
864
876
let gcx = global_ctxt. as_ref ( ) . unwrap ( ) ;
865
877
866
878
ty:: tls:: enter_global ( gcx, |tcx| {
867
- // Do some initialization of the DepGraph that can only be done with the
879
+ // Do some initialization of the ` DepGraph` that can only be done with the
868
880
// tcx available.
869
881
time ( tcx. sess , "dep graph tcx init" , || rustc_incremental:: dep_graph_tcx_init ( tcx) ) ;
870
882
} ) ;
@@ -911,7 +923,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
911
923
} ) ;
912
924
} ) ;
913
925
914
- // passes are timed inside typeck
926
+ // Passes are timed inside typeck.
915
927
typeck:: check_crate ( tcx) ?;
916
928
917
929
time ( sess, "misc checking 2" , || {
@@ -925,12 +937,11 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
925
937
} , {
926
938
time( sess, "liveness checking + intrinsic checking" , || {
927
939
par_iter( & tcx. hir( ) . krate( ) . modules) . for_each( |( & module, _) | {
928
- // this must run before MIR dump, because
940
+ // This must run before MIR dump, because
929
941
// "not all control paths return a value" is reported here.
930
942
//
931
- // maybe move the check to a MIR pass?
943
+ // FIXME: maybe move the check to a MIR pass?
932
944
let local_def_id = tcx. hir( ) . local_def_id( module) ;
933
-
934
945
tcx. ensure( ) . check_mod_liveness( local_def_id) ;
935
946
tcx. ensure( ) . check_mod_intrinsics( local_def_id) ;
936
947
} ) ;
@@ -1055,8 +1066,7 @@ fn encode_and_write_metadata(
1055
1066
( metadata, need_metadata_module)
1056
1067
}
1057
1068
1058
- /// Runs the codegen backend, after which the AST and analysis can
1059
- /// be discarded.
1069
+ /// Runs the codegen backend, after which the AST and analysis can be discarded.
1060
1070
pub fn start_codegen < ' tcx > (
1061
1071
codegen_backend : & dyn CodegenBackend ,
1062
1072
tcx : TyCtxt < ' tcx > ,
0 commit comments