Remove use of RefCell<DefMap> in resolve_lifetime
This commit is contained in:
parent
f5781f143c
commit
1ca1874986
|
@ -23,7 +23,6 @@ use middle::def::{self, DefMap};
|
||||||
use middle::region;
|
use middle::region;
|
||||||
use middle::subst;
|
use middle::subst;
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
@ -55,7 +54,7 @@ struct LifetimeContext<'a> {
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
named_region_map: &'a mut NamedRegionMap,
|
named_region_map: &'a mut NamedRegionMap,
|
||||||
scope: Scope<'a>,
|
scope: Scope<'a>,
|
||||||
def_map: &'a RefCell<DefMap>,
|
def_map: &'a DefMap,
|
||||||
// Deep breath. Our representation for poly trait refs contains a single
|
// Deep breath. Our representation for poly trait refs contains a single
|
||||||
// binder and thus we only allow a single level of quantification. However,
|
// binder and thus we only allow a single level of quantification. However,
|
||||||
// the syntax of Rust permits quantification in two places, e.g., `T: for <'a> Foo<'a>`
|
// the syntax of Rust permits quantification in two places, e.g., `T: for <'a> Foo<'a>`
|
||||||
|
@ -94,7 +93,7 @@ type Scope<'a> = &'a ScopeChain<'a>;
|
||||||
|
|
||||||
static ROOT_SCOPE: ScopeChain<'static> = RootScope;
|
static ROOT_SCOPE: ScopeChain<'static> = RootScope;
|
||||||
|
|
||||||
pub fn krate(sess: &Session, krate: &hir::Crate, def_map: &RefCell<DefMap>) -> NamedRegionMap {
|
pub fn krate(sess: &Session, krate: &hir::Crate, def_map: &DefMap) -> NamedRegionMap {
|
||||||
let mut named_region_map = NodeMap();
|
let mut named_region_map = NodeMap();
|
||||||
visit::walk_crate(&mut LifetimeContext {
|
visit::walk_crate(&mut LifetimeContext {
|
||||||
sess: sess,
|
sess: sess,
|
||||||
|
@ -206,7 +205,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||||
hir::TyPath(None, ref path) => {
|
hir::TyPath(None, ref path) => {
|
||||||
// if this path references a trait, then this will resolve to
|
// if this path references a trait, then this will resolve to
|
||||||
// a trait ref, which introduces a binding scope.
|
// a trait ref, which introduces a binding scope.
|
||||||
match self.def_map.borrow().get(&ty.id).map(|d| (d.base_def, d.depth)) {
|
match self.def_map.get(&ty.id).map(|d| (d.base_def, d.depth)) {
|
||||||
Some((def::DefTrait(..), 0)) => {
|
Some((def::DefTrait(..), 0)) => {
|
||||||
self.with(LateScope(&Vec::new(), self.scope), |_, this| {
|
self.with(LateScope(&Vec::new(), self.scope), |_, this| {
|
||||||
this.visit_path(path, ty.id);
|
this.visit_path(path, ty.id);
|
||||||
|
|
|
@ -700,8 +700,8 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||||
syntax::ext::mtwt::clear_tables();
|
syntax::ext::mtwt::clear_tables();
|
||||||
}
|
}
|
||||||
|
|
||||||
let named_region_map = time(time_passes, "lifetime resolution",
|
let named_region_map = time(time_passes, "lifetime resolution", ||
|
||||||
|| middle::resolve_lifetime::krate(sess, krate, &def_map));
|
middle::resolve_lifetime::krate(sess, krate, &def_map.borrow()));
|
||||||
|
|
||||||
time(time_passes, "looking for entry point",
|
time(time_passes, "looking for entry point",
|
||||||
|| middle::entry::find_entry_point(sess, &ast_map));
|
|| middle::entry::find_entry_point(sess, &ast_map));
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn test_env<F>(source_string: &str,
|
||||||
let lang_items = lang_items::collect_language_items(&sess, &ast_map);
|
let lang_items = lang_items::collect_language_items(&sess, &ast_map);
|
||||||
let resolve::CrateMap { def_map, freevars, .. } =
|
let resolve::CrateMap { def_map, freevars, .. } =
|
||||||
resolve::resolve_crate(&sess, &ast_map, resolve::MakeGlobMap::No);
|
resolve::resolve_crate(&sess, &ast_map, resolve::MakeGlobMap::No);
|
||||||
let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map);
|
let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map.borrow());
|
||||||
let region_map = region::resolve_crate(&sess, krate);
|
let region_map = region::resolve_crate(&sess, krate);
|
||||||
ty::ctxt::create_and_enter(&sess,
|
ty::ctxt::create_and_enter(&sess,
|
||||||
&arenas,
|
&arenas,
|
||||||
|
|
Loading…
Reference in New Issue