Skip to content

Commit cbafc57

Browse files
committed
save-analsysis: add save-analysis-api CLI flag
1 parent 2c01bb8 commit cbafc57

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/librustc/session/config.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
848848
ls: bool = (false, parse_bool, [UNTRACKED],
849849
"list the symbols defined by a library crate"),
850850
save_analysis: bool = (false, parse_bool, [UNTRACKED],
851-
"write syntax and type analysis (in JSON format) information in addition to normal output"),
851+
"write syntax and type analysis (in JSON format) information, \
852+
addition to normal output"),
852853
save_analysis_csv: bool = (false, parse_bool, [UNTRACKED],
853-
"write syntax and type analysis (in CSV format) information in addition to normal output"),
854+
"write syntax and type analysis (in CSV format) information, in addition to normal output"),
855+
save_analysis_api: bool = (false, parse_bool, [UNTRACKED],
856+
"write syntax and type analysis information for opaque libraries (in JSON format), \
857+
in addition to normal output"),
854858
print_move_fragments: bool = (false, parse_bool, [UNTRACKED],
855859
"print out move-fragment data for every fn"),
856860
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
@@ -2359,6 +2363,8 @@ mod tests {
23592363
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
23602364
opts.debugging_opts.save_analysis_csv = true;
23612365
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2366+
opts.debugging_opts.save_analysis_api = true;
2367+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
23622368
opts.debugging_opts.print_move_fragments = true;
23632369
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
23642370
opts.debugging_opts.flowgraph_print_loans = true;

src/librustc_driver/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,14 +555,17 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
555555

556556
fn save_analysis(sess: &Session) -> bool {
557557
sess.opts.debugging_opts.save_analysis ||
558-
sess.opts.debugging_opts.save_analysis_csv
558+
sess.opts.debugging_opts.save_analysis_csv ||
559+
sess.opts.debugging_opts.save_analysis_api
559560
}
560561

561562
fn save_analysis_format(sess: &Session) -> save::Format {
562563
if sess.opts.debugging_opts.save_analysis {
563564
save::Format::Json
564565
} else if sess.opts.debugging_opts.save_analysis_csv {
565566
save::Format::Csv
567+
} else if sess.opts.debugging_opts.save_analysis_api {
568+
save::Format::JsonApi
566569
} else {
567570
unreachable!();
568571
}

src/librustc_save_analysis/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,13 +727,14 @@ impl Visitor for PathCollector {
727727
pub enum Format {
728728
Csv,
729729
Json,
730+
JsonApi,
730731
}
731732

732733
impl Format {
733734
fn extension(&self) -> &'static str {
734735
match *self {
735736
Format::Csv => ".csv",
736-
Format::Json => ".json",
737+
Format::Json | Format::JsonApi => ".json",
737738
}
738739
}
739740
}
@@ -803,6 +804,7 @@ pub fn process_crate<'l, 'tcx>(tcx: TyCtxt<'l, 'tcx, 'tcx>,
803804
match format {
804805
Format::Csv => dump!(CsvDumper::new(output)),
805806
Format::Json => dump!(JsonDumper::new(output)),
807+
Format::JsonApi => /* TODO */ dump!(JsonDumper::new(output)),
806808
}
807809
}
808810

0 commit comments

Comments
 (0)