@@ -366,9 +366,11 @@ Session::handle_option (
366
366
Compile::Mangler::set_mangling (flag_rust_mangling);
367
367
break ;
368
368
369
- case OPT_frust_cfg_:
370
- ret = handle_cfg_option (std::string (arg));
371
- break ;
369
+ case OPT_frust_cfg_: {
370
+ auto string_arg = std::string (arg);
371
+ ret = handle_cfg_option (string_arg);
372
+ break ;
373
+ }
372
374
373
375
default :
374
376
break ;
@@ -378,7 +380,7 @@ Session::handle_option (
378
380
}
379
381
380
382
bool
381
- Session::handle_cfg_option (const std::string &input)
383
+ Session::handle_cfg_option (std::string &input)
382
384
{
383
385
std::string key;
384
386
std::string value;
@@ -402,8 +404,8 @@ Session::handle_cfg_option (const std::string &input)
402
404
return true ;
403
405
}
404
406
405
- /* Enables a certain dump depending on the name passed in. Returns true if name
406
- * is valid, false otherwise. */
407
+ /* Enables a certain dump depending on the name passed in. Returns true if
408
+ * name is valid, false otherwise. */
407
409
bool
408
410
Session::enable_dump (std::string arg)
409
411
{
@@ -532,8 +534,8 @@ Session::parse_file (const char *filename)
532
534
* line into crate root)
533
535
* - injection (some lint checks or dummy, register builtin macros, crate
534
536
* injection)
535
- * - expansion (expands all macros, maybe build test harness, AST validation,
536
- * maybe macro crate)
537
+ * - expansion (expands all macros, maybe build test harness, AST
538
+ * validation, maybe macro crate)
537
539
* - resolution (name resolution, type resolution, maybe feature checking,
538
540
* maybe buffered lints)
539
541
* TODO not done */
@@ -603,8 +605,8 @@ Session::parse_file (const char *filename)
603
605
if (saw_errors ())
604
606
return ;
605
607
606
- // scan unused has to be done after type resolution since methods are resolved
607
- // at that point
608
+ // scan unused has to be done after type resolution since methods are
609
+ // resolved at that point
608
610
Resolver::ScanUnused::Scan ();
609
611
610
612
if (saw_errors ())
@@ -638,11 +640,11 @@ Session::debug_dump_load_crates (Parser<Lexer> &parser)
638
640
639
641
/* TODO: search through inner attrs and see whether any of those attr paths
640
642
* contain "no_core", "no_std", "compiler_builtins". If so/not, save certain
641
- * crate names. In these names, insert items at beginning of crate items. This
642
- * is crate injection. Also, inject prelude use decl at beginning (first name
643
- * is assumed to be prelude - prelude is a use decl automatically generated to
644
- * enable using Option and Copy without qualifying it or importing it via
645
- * 'use' manually) */
643
+ * crate names. In these names, insert items at beginning of crate items.
644
+ * This is crate injection. Also, inject prelude use decl at beginning
645
+ * (first name is assumed to be prelude - prelude is a use decl
646
+ * automatically generated to enable using Option and Copy without
647
+ * qualifying it or importing it via 'use' manually) */
646
648
647
649
std::vector<std::string> crate_names;
648
650
for (const auto &item : crate.items )
@@ -695,8 +697,8 @@ Session::injection (AST::Crate &crate)
695
697
696
698
// register builtin macros
697
699
/* In rustc, builtin macros are divided into 3 categories depending on use -
698
- * "bang" macros, "attr" macros, and "derive" macros. I think the meanings of
699
- * these categories should be fairly obvious to anyone who has used rust.
700
+ * "bang" macros, "attr" macros, and "derive" macros. I think the meanings
701
+ * of these categories should be fairly obvious to anyone who has used rust.
700
702
* Builtin macro list by category: Bang
701
703
* - asm
702
704
* - assert
@@ -739,8 +741,8 @@ Session::injection (AST::Crate &crate)
739
741
* rustc also has a "quote" macro that is defined differently and is
740
742
* supposedly not stable so eh. */
741
743
/* TODO: actually implement injection of these macros. In particular, derive
742
- * macros, cfg, and test should be prioritised since they seem to be used the
743
- * most. */
744
+ * macros, cfg, and test should be prioritised since they seem to be used
745
+ * the most. */
744
746
745
747
// crate injection
746
748
std::vector<std::string> names;
@@ -804,11 +806,11 @@ Session::injection (AST::Crate &crate)
804
806
crate.items .insert (crate.items .begin (), std::move (use_decl));
805
807
806
808
/* TODO: potentially add checking attribute crate type? I can't figure out
807
- * what this does currently comment says "Unconditionally collect crate types
808
- * from attributes to make them used", which presumably refers to checking the
809
- * linkage info by "crate_type". It also seems to ensure that an invalid crate
810
- * type is not specified, so maybe just do that. Valid crate types: bin lib
811
- * dylib staticlib cdylib rlib proc-macro */
809
+ * what this does currently comment says "Unconditionally collect crate
810
+ * types from attributes to make them used", which presumably refers to
811
+ * checking the linkage info by "crate_type". It also seems to ensure that
812
+ * an invalid crate type is not specified, so maybe just do that. Valid
813
+ * crate types: bin lib dylib staticlib cdylib rlib proc-macro */
812
814
813
815
rust_debug (" finished injection" );
814
816
}
@@ -818,8 +820,8 @@ Session::expansion (AST::Crate &crate)
818
820
{
819
821
rust_debug (" started expansion" );
820
822
821
- /* rustc has a modification to windows PATH temporarily here, which may end up
822
- * being required */
823
+ /* rustc has a modification to windows PATH temporarily here, which may end
824
+ * up being required */
823
825
824
826
// create macro expansion config?
825
827
// if not, would at least have to configure recursion_limit
@@ -1036,10 +1038,10 @@ TargetOptions::enable_implicit_feature_reqs (std::string feature)
1036
1038
* [types/values] or absolute paths)
1037
1039
* - HIR lower (convert modified AST to simpler HIR [both expressions and
1038
1040
* module tree])
1039
- * - resolve type aliases (replace any usages of type aliases with actual type
1040
- * [except associated types])
1041
- * - resolve bind (iterate HIR tree and set binding annotations on all concrete
1042
- * types [avoids path lookups later])
1041
+ * - resolve type aliases (replace any usages of type aliases with actual
1042
+ * type [except associated types])
1043
+ * - resolve bind (iterate HIR tree and set binding annotations on all
1044
+ * concrete types [avoids path lookups later])
1043
1045
* - resolve HIR markings (generate "markings" [e.g. for Copy/Send/Sync/...]
1044
1046
* for all types
1045
1047
* - sort impls (small pass - sort impls into groups)
@@ -1059,8 +1061,8 @@ TargetOptions::enable_implicit_feature_reqs (std::string feature)
1059
1061
* function calls)
1060
1062
* - expand HIR reborrows (apply reborrow rules [taking '&mut *v' instead of
1061
1063
* 'v'])
1062
- * - expand HIR erasedtype (replace all erased types 'impl Trait' with the true
1063
- * type)
1064
+ * - expand HIR erasedtype (replace all erased types 'impl Trait' with the
1065
+ * true type)
1064
1066
* - typecheck expressions (validate - double check that previous passes
1065
1067
* haven't broke type system rules)
1066
1068
* - lower MIR (convert HIR exprs into a control-flow graph [MIR])
@@ -1071,24 +1073,25 @@ TargetOptions::enable_implicit_feature_reqs (std::string feature)
1071
1073
* - MIR optimise (perform various simple optimisations on the MIR - constant
1072
1074
* propagation, dead code elimination, borrow elimination, some inlining)
1073
1075
* - MIR validate PO (re-validate the MIR)
1074
- * - MIR validate full (optionally: perform expensive state-tracking validation
1075
- * on MIR)
1076
- * - trans enumerate (enumerate all items needed for code generation, primarily
1077
- * types used for generics)
1078
- * - trans auto impls (create magic trait impls as enumerated in previous pass)
1076
+ * - MIR validate full (optionally: perform expensive state-tracking
1077
+ * validation on MIR)
1078
+ * - trans enumerate (enumerate all items needed for code generation,
1079
+ * primarily types used for generics)
1080
+ * - trans auto impls (create magic trait impls as enumerated in previous
1081
+ * pass)
1079
1082
* - trans monomorph (generate monomorphised copies of all functions [with
1080
1083
* generics replaced with real types])
1081
- * - MIR optimise inline (run optimisation again, this time with full type info
1082
- * [primarily for inlining])
1084
+ * - MIR optimise inline (run optimisation again, this time with full type
1085
+ * info [primarily for inlining])
1083
1086
* - HIR serialise (write out HIR dump [module tree and generic/inline MIR])
1084
1087
* - trans codegen (generate final output file: emit C source file and call C
1085
1088
* compiler) */
1086
1089
1087
1090
/* rustc compile pipeline (basic, in way less detail):
1088
1091
* - parse input (parse .rs to AST)
1089
1092
* - name resolution, macro expansion, and configuration (process AST
1090
- * recursively, resolving paths, expanding macros, processing #[cfg] nodes [i.e.
1091
- * maybe stripping stuff from AST])
1093
+ * recursively, resolving paths, expanding macros, processing #[cfg] nodes
1094
+ * [i.e. maybe stripping stuff from AST])
1092
1095
* - lower to HIR
1093
1096
* - type check and other analyses (e.g. privacy checking)
1094
1097
* - lower to MIR and post-processing (and do stuff like borrow checking)
@@ -1100,14 +1103,14 @@ TargetOptions::enable_implicit_feature_reqs (std::string feature)
1100
1103
* - register plugins (attributes injection, set various options, register
1101
1104
* lints, load plugins)
1102
1105
* - expansion/configure and expand (initial 'cfg' processing, 'loading
1103
- * compiler plugins', syntax expansion, secondary 'cfg' expansion, synthesis of
1104
- * a test harness if required, injection of any std lib dependency and prelude,
1105
- * and name resolution) - actually documented inline
1106
+ * compiler plugins', syntax expansion, secondary 'cfg' expansion, synthesis
1107
+ * of a test harness if required, injection of any std lib dependency and
1108
+ * prelude, and name resolution) - actually documented inline
1106
1109
* - seeming pierced-together order: pre-AST expansion lint checks,
1107
1110
* registering builtin macros, crate injection, then expand all macros, then
1108
- * maybe build test harness, AST validation, maybe create a macro crate (if not
1109
- * rustdoc), name resolution, complete gated feature checking, add all buffered
1110
- * lints
1111
+ * maybe build test harness, AST validation, maybe create a macro crate (if
1112
+ * not rustdoc), name resolution, complete gated feature checking, add all
1113
+ * buffered lints
1111
1114
* - create global context (lower to HIR)
1112
1115
* - analysis on global context (HIR optimisations? create MIR?)
1113
1116
* - code generation
0 commit comments