diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 80ce203b4fbb6..58936172c5bce 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -102,7 +102,7 @@ fn count_nodes(krate: &ast::Crate) -> usize { declare_box_region_type!( pub BoxedResolver, for(), - (&mut Resolver<'_>) -> (Result, ExpansionResult) + (&mut Resolver<'_>) -> (Result, ResolverOutputs) ); /// Runs the "early phases" of the compiler: initial `cfg` processing, @@ -149,33 +149,16 @@ pub fn configure_and_expand( } }; box_region_allow_access!(for(), (&mut Resolver<'_>), (&mut resolver)); - ExpansionResult::from_resolver_outputs(resolver.into_outputs()) + resolver.into_outputs() }); result.map(|k| (k, resolver)) } -pub struct ExpansionResult { - pub resolver_outputs: Steal, -} - -impl ExpansionResult { - fn from_resolver_outputs(resolver_outputs: ResolverOutputs) -> Self { - ExpansionResult { resolver_outputs: Steal::new(resolver_outputs) } - } -} - impl BoxedResolver { - pub fn to_expansion_result( - resolver: Rc>, - ) -> ExpansionResult { + pub fn to_resolver_outputs(resolver: Rc>) -> ResolverOutputs { match Rc::try_unwrap(resolver) { Ok(resolver) => resolver.into_inner().complete(), - Err(resolver) => { - let resolver = &*resolver; - resolver.borrow_mut().access(|resolver| { - ExpansionResult::from_resolver_outputs(resolver.clone_outputs()) - }) - } + Err(resolver) => resolver.borrow_mut().access(|resolver| resolver.clone_outputs()), } } } diff --git a/src/librustc_interface/queries.rs b/src/librustc_interface/queries.rs index b5c356bf05a1b..ea51e63725ea2 100644 --- a/src/librustc_interface/queries.rs +++ b/src/librustc_interface/queries.rs @@ -1,5 +1,5 @@ use crate::interface::{Compiler, Result}; -use crate::passes::{self, BoxedResolver, ExpansionResult, BoxedGlobalCtxt, PluginInfo}; +use crate::passes::{self, BoxedResolver, BoxedGlobalCtxt, PluginInfo}; use rustc_incremental::DepGraphFuture; use rustc_data_structures::sync::Lrc; @@ -11,6 +11,7 @@ use rustc::session::Session; use rustc::lint::LintStore; use rustc::hir::def_id::LOCAL_CRATE; use rustc::ty::steal::Steal; +use rustc::ty::ResolverOutputs; use rustc::dep_graph::DepGraph; use std::cell::{Ref, RefMut, RefCell}; use std::rc::Rc; @@ -81,7 +82,7 @@ pub(crate) struct Queries { register_plugins: Query<(ast::Crate, PluginInfo, Lrc)>, expansion: Query<(ast::Crate, Steal>>, Lrc)>, dep_graph: Query, - lower_to_hir: Query<(Steal, ExpansionResult)>, + lower_to_hir: Query<(Steal, Steal)>, prepare_outputs: Query, global_ctxt: Query, ongoing_codegen: Query>, @@ -191,7 +192,9 @@ impl Compiler { }) } - pub fn lower_to_hir(&self) -> Result<&Query<(Steal, ExpansionResult)>> { + pub fn lower_to_hir( + &self, + ) -> Result<&Query<(Steal, Steal)>> { self.queries.lower_to_hir.compute(|| { let expansion_result = self.expansion()?; let peeked = expansion_result.peek(); @@ -207,14 +210,14 @@ impl Compiler { &krate ) })?); - Ok((hir, BoxedResolver::to_expansion_result(resolver))) + Ok((hir, Steal::new(BoxedResolver::to_resolver_outputs(resolver)))) }) } pub fn prepare_outputs(&self) -> Result<&Query> { self.queries.prepare_outputs.compute(|| { let expansion_result = self.expansion()?; - let (krate, boxed_resolver) = &*expansion_result.peek(); + let (krate, boxed_resolver, _) = &*expansion_result.peek(); let crate_name = self.crate_name()?; let crate_name = crate_name.peek(); passes::prepare_outputs(self.session(), self, &krate, &boxed_resolver, &crate_name) @@ -228,12 +231,12 @@ impl Compiler { let lint_store = self.expansion()?.peek().2.clone(); let hir = self.lower_to_hir()?; let hir = hir.peek(); - let (ref hir_forest, ref expansion) = *hir; + let (hir_forest, resolver_outputs) = &*hir; Ok(passes::create_global_ctxt( self, lint_store, hir_forest.steal(), - expansion.resolver_outputs.steal(), + resolver_outputs.steal(), outputs, &crate_name)) })