summaryrefslogtreecommitdiff
path: root/compiler/rustc_interface
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2023-02-07 17:34:40 +0400
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2023-02-13 00:10:15 +0400
commitfd73d01c98adb2adb570ab300ee0d5c4dc0eafca (patch)
tree40a6683bc5b00b53a154e41d05dc188ce9fb65ee /compiler/rustc_interface
parent9080b79f2b4d5deccd4e0e6cdbb68780d7d12a58 (diff)
downloadrust-fd73d01c98adb2adb570ab300ee0d5c4dc0eafca.tar.gz
rustc_resolve: Remove `Resolver::clone_output`
And remove `Clone` impls and `Lrc`s that are no longer necessary
Diffstat (limited to 'compiler/rustc_interface')
-rw-r--r--compiler/rustc_interface/src/passes.rs23
-rw-r--r--compiler/rustc_interface/src/queries.rs10
2 files changed, 10 insertions, 23 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs
index 33ebbb411ce..c8d8afae39e 100644
--- a/compiler/rustc_interface/src/passes.rs
+++ b/compiler/rustc_interface/src/passes.rs
@@ -35,13 +35,11 @@ use rustc_target::spec::PanicStrategy;
use rustc_trait_selection::traits;
use std::any::Any;
-use std::cell::RefCell;
use std::ffi::OsString;
use std::io::{self, BufWriter, Write};
use std::marker::PhantomPinned;
use std::path::{Path, PathBuf};
use std::pin::Pin;
-use std::rc::Rc;
use std::sync::{Arc, LazyLock};
use std::{env, fs, iter};
@@ -131,21 +129,12 @@ mod boxed_resolver {
f((&mut *resolver).as_mut().unwrap())
}
- pub fn to_resolver_outputs(resolver: Rc<RefCell<BoxedResolver>>) -> ty::ResolverOutputs {
- match Rc::try_unwrap(resolver) {
- Ok(resolver) => {
- let mut resolver = resolver.into_inner();
- // SAFETY: The resolver doesn't need to be pinned.
- let mut resolver = unsafe {
- resolver
- .0
- .as_mut()
- .map_unchecked_mut(|boxed_resolver| &mut boxed_resolver.resolver)
- };
- resolver.take().unwrap().into_outputs()
- }
- Err(resolver) => resolver.borrow_mut().access(|resolver| resolver.clone_outputs()),
- }
+ pub fn into_outputs(mut self) -> ty::ResolverOutputs {
+ // SAFETY: The resolver doesn't need to be pinned.
+ let mut resolver = unsafe {
+ self.0.as_mut().map_unchecked_mut(|boxed_resolver| &mut boxed_resolver.resolver)
+ };
+ resolver.take().unwrap().into_outputs()
}
}
}
diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs
index 6512695873e..67886b6b989 100644
--- a/compiler/rustc_interface/src/queries.rs
+++ b/compiler/rustc_interface/src/queries.rs
@@ -21,7 +21,6 @@ use rustc_span::symbol::sym;
use rustc_span::Symbol;
use std::any::Any;
use std::cell::{RefCell, RefMut};
-use std::rc::Rc;
use std::sync::Arc;
/// Represent the result of a query.
@@ -88,7 +87,7 @@ pub struct Queries<'tcx> {
parse: Query<ast::Crate>,
crate_name: Query<Symbol>,
register_plugins: Query<(ast::Crate, Lrc<LintStore>)>,
- expansion: Query<(Lrc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>,
+ expansion: Query<(Lrc<ast::Crate>, BoxedResolver, Lrc<LintStore>)>,
dep_graph: Query<DepGraph>,
// This just points to what's in `gcx_cell`.
gcx: Query<&'tcx GlobalCtxt<'tcx>>,
@@ -171,8 +170,7 @@ impl<'tcx> Queries<'tcx> {
pub fn expansion(
&self,
- ) -> Result<QueryResult<'_, (Lrc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>>
- {
+ ) -> Result<QueryResult<'_, (Lrc<ast::Crate>, BoxedResolver, Lrc<LintStore>)>> {
trace!("expansion");
self.expansion.compute(|| {
let crate_name = *self.crate_name()?.borrow();
@@ -188,7 +186,7 @@ impl<'tcx> Queries<'tcx> {
let krate = resolver.access(|resolver| {
passes::configure_and_expand(sess, &lint_store, krate, crate_name, resolver)
})?;
- Ok((Lrc::new(krate), Rc::new(RefCell::new(resolver)), lint_store))
+ Ok((Lrc::new(krate), resolver, lint_store))
})
}
@@ -217,7 +215,7 @@ impl<'tcx> Queries<'tcx> {
untracked,
global_ctxt: untracked_resolutions,
ast_lowering: untracked_resolver_for_lowering,
- } = BoxedResolver::to_resolver_outputs(resolver);
+ } = resolver.into_outputs();
let gcx = passes::create_global_ctxt(
self.compiler,