提交 8ec68761 编写于 作者: M marmeladema

save_analysis: work on HIR tree instead of AST

上级 f3fadf6a
...@@ -346,12 +346,15 @@ pub fn run_compiler( ...@@ -346,12 +346,15 @@ pub fn run_compiler(
queries.global_ctxt()?; queries.global_ctxt()?;
// Drop AST after creating GlobalCtxt to free memory
let _timer = sess.prof.generic_activity("drop_ast");
mem::drop(queries.expansion()?.take());
if sess.opts.debugging_opts.no_analysis || sess.opts.debugging_opts.ast_json { if sess.opts.debugging_opts.no_analysis || sess.opts.debugging_opts.ast_json {
return early_exit(); return early_exit();
} }
if sess.opts.debugging_opts.save_analysis { if sess.opts.debugging_opts.save_analysis {
let expanded_crate = &queries.expansion()?.peek().0;
let crate_name = queries.crate_name()?.peek().clone(); let crate_name = queries.crate_name()?.peek().clone();
queries.global_ctxt()?.peek_mut().enter(|tcx| { queries.global_ctxt()?.peek_mut().enter(|tcx| {
let result = tcx.analysis(LOCAL_CRATE); let result = tcx.analysis(LOCAL_CRATE);
...@@ -359,7 +362,6 @@ pub fn run_compiler( ...@@ -359,7 +362,6 @@ pub fn run_compiler(
sess.time("save_analysis", || { sess.time("save_analysis", || {
save::process_crate( save::process_crate(
tcx, tcx,
&expanded_crate,
&crate_name, &crate_name,
&compiler.input(), &compiler.input(),
None, None,
...@@ -371,13 +373,7 @@ pub fn run_compiler( ...@@ -371,13 +373,7 @@ pub fn run_compiler(
}); });
result result
// AST will be dropped *after* the `after_analysis` callback
// (needed by the RLS)
})?; })?;
} else {
// Drop AST after creating GlobalCtxt to free memory
let _timer = sess.prof.generic_activity("drop_ast");
mem::drop(queries.expansion()?.take());
} }
queries.global_ctxt()?.peek_mut().enter(|tcx| tcx.analysis(LOCAL_CRATE))?; queries.global_ctxt()?.peek_mut().enter(|tcx| tcx.analysis(LOCAL_CRATE))?;
...@@ -386,10 +382,6 @@ pub fn run_compiler( ...@@ -386,10 +382,6 @@ pub fn run_compiler(
return early_exit(); return early_exit();
} }
if sess.opts.debugging_opts.save_analysis {
mem::drop(queries.expansion()?.take());
}
queries.ongoing_codegen()?; queries.ongoing_codegen()?;
if sess.opts.debugging_opts.print_type_sizes { if sess.opts.debugging_opts.print_type_sizes {
......
...@@ -203,6 +203,30 @@ pub fn visibility_qualified<S: Into<Cow<'static, str>>>(vis: &hir::Visibility<'_ ...@@ -203,6 +203,30 @@ pub fn visibility_qualified<S: Into<Cow<'static, str>>>(vis: &hir::Visibility<'_
}) })
} }
pub fn generic_params_to_string(generic_params: &[GenericParam<'_>]) -> String {
to_string(NO_ANN, |s| s.print_generic_params(generic_params))
}
pub fn bounds_to_string<'b>(bounds: impl IntoIterator<Item = &'b hir::GenericBound<'b>>) -> String {
to_string(NO_ANN, |s| s.print_bounds("", bounds))
}
pub fn param_to_string(arg: &hir::Param<'_>) -> String {
to_string(NO_ANN, |s| s.print_param(arg))
}
pub fn ty_to_string(ty: &hir::Ty<'_>) -> String {
to_string(NO_ANN, |s| s.print_type(ty))
}
pub fn path_segment_to_string(segment: &hir::PathSegment<'_>) -> String {
to_string(NO_ANN, |s| s.print_path_segment(segment))
}
pub fn path_to_string(segment: &hir::Path<'_>) -> String {
to_string(NO_ANN, |s| s.print_path(segment, false))
}
impl<'a> State<'a> { impl<'a> State<'a> {
pub fn cbox(&mut self, u: usize) { pub fn cbox(&mut self, u: usize) {
self.s.cbox(u); self.s.cbox(u);
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册