Use a submodule as safety boundary for BoxedResolver
This commit is contained in:
parent
86c2d1a2a7
commit
5e148200d4
1 changed files with 60 additions and 55 deletions
|
@ -86,21 +86,25 @@ fn count_nodes(krate: &ast::Crate) -> usize {
|
|||
counter.count
|
||||
}
|
||||
|
||||
pub struct BoxedResolver(Pin<Box<BoxedResolverInner>>);
|
||||
pub use boxed_resolver::BoxedResolver;
|
||||
mod boxed_resolver {
|
||||
use super::*;
|
||||
|
||||
// Note: Drop order is important to prevent dangling references. Resolver must be dropped first,
|
||||
// then resolver_arenas and finally session.
|
||||
// The drop order is defined to be from top to bottom in RFC1857, so there is no need for
|
||||
// ManuallyDrop for as long as the fields are not reordered.
|
||||
struct BoxedResolverInner {
|
||||
pub struct BoxedResolver(Pin<Box<BoxedResolverInner>>);
|
||||
|
||||
// Note: Drop order is important to prevent dangling references. Resolver must be dropped first,
|
||||
// then resolver_arenas and finally session.
|
||||
// The drop order is defined to be from top to bottom in RFC1857, so there is no need for
|
||||
// ManuallyDrop for as long as the fields are not reordered.
|
||||
struct BoxedResolverInner {
|
||||
resolver: Option<Resolver<'static>>,
|
||||
resolver_arenas: ResolverArenas<'static>,
|
||||
session: Lrc<Session>,
|
||||
_pin: PhantomPinned,
|
||||
}
|
||||
}
|
||||
|
||||
impl BoxedResolver {
|
||||
fn new<F>(session: Lrc<Session>, make_resolver: F) -> Result<(ast::Crate, Self)>
|
||||
impl BoxedResolver {
|
||||
pub(super) fn new<F>(session: Lrc<Session>, make_resolver: F) -> Result<(ast::Crate, Self)>
|
||||
where
|
||||
F: for<'a> FnOnce(
|
||||
&'a Session,
|
||||
|
@ -148,6 +152,7 @@ impl BoxedResolver {
|
|||
Err(resolver) => resolver.borrow_mut().access(|resolver| resolver.clone_outputs()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the "early phases" of the compiler: initial `cfg` processing, loading compiler plugins,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue