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
|
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,
|
pub struct BoxedResolver(Pin<Box<BoxedResolverInner>>);
|
||||||
// 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
|
// Note: Drop order is important to prevent dangling references. Resolver must be dropped first,
|
||||||
// ManuallyDrop for as long as the fields are not reordered.
|
// then resolver_arenas and finally session.
|
||||||
struct BoxedResolverInner {
|
// 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: Option<Resolver<'static>>,
|
||||||
resolver_arenas: ResolverArenas<'static>,
|
resolver_arenas: ResolverArenas<'static>,
|
||||||
session: Lrc<Session>,
|
session: Lrc<Session>,
|
||||||
_pin: PhantomPinned,
|
_pin: PhantomPinned,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BoxedResolver {
|
impl BoxedResolver {
|
||||||
fn new<F>(session: Lrc<Session>, make_resolver: F) -> Result<(ast::Crate, Self)>
|
pub(super) fn new<F>(session: Lrc<Session>, make_resolver: F) -> Result<(ast::Crate, Self)>
|
||||||
where
|
where
|
||||||
F: for<'a> FnOnce(
|
F: for<'a> FnOnce(
|
||||||
&'a Session,
|
&'a Session,
|
||||||
|
@ -148,6 +152,7 @@ impl BoxedResolver {
|
||||||
Err(resolver) => resolver.borrow_mut().access(|resolver| resolver.clone_outputs()),
|
Err(resolver) => resolver.borrow_mut().access(|resolver| resolver.clone_outputs()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the "early phases" of the compiler: initial `cfg` processing, loading compiler plugins,
|
/// Runs the "early phases" of the compiler: initial `cfg` processing, loading compiler plugins,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue