mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-22 04:27:33 +00:00
librustc: De-@mut
trait_defs
This commit is contained in:
parent
3f444dca5b
commit
2ead970b21
@ -119,8 +119,13 @@ fn check_impl_of_trait(cx: &mut Context, it: @item, trait_ref: &trait_ref, self_
|
|||||||
let ast_trait_def = cx.tcx.def_map.find(&trait_ref.ref_id)
|
let ast_trait_def = cx.tcx.def_map.find(&trait_ref.ref_id)
|
||||||
.expect("trait ref not in def map!");
|
.expect("trait ref not in def map!");
|
||||||
let trait_def_id = ast_util::def_id_of_def(*ast_trait_def);
|
let trait_def_id = ast_util::def_id_of_def(*ast_trait_def);
|
||||||
let trait_def = cx.tcx.trait_defs.find(&trait_def_id)
|
let trait_def;
|
||||||
.expect("trait def not in trait-defs map!");
|
{
|
||||||
|
let trait_defs = cx.tcx.trait_defs.borrow();
|
||||||
|
trait_def = *trait_defs.get()
|
||||||
|
.find(&trait_def_id)
|
||||||
|
.expect("trait def not in trait-defs map!");
|
||||||
|
}
|
||||||
|
|
||||||
// If this trait has builtin-kind supertraits, meet them.
|
// If this trait has builtin-kind supertraits, meet them.
|
||||||
let self_ty: ty::t = ty::node_id_to_type(cx.tcx, it.id);
|
let self_ty: ty::t = ty::node_id_to_type(cx.tcx, it.id);
|
||||||
|
@ -298,7 +298,7 @@ struct ctxt_ {
|
|||||||
impl_trait_cache: RefCell<HashMap<ast::DefId, Option<@ty::TraitRef>>>,
|
impl_trait_cache: RefCell<HashMap<ast::DefId, Option<@ty::TraitRef>>>,
|
||||||
|
|
||||||
trait_refs: RefCell<HashMap<NodeId, @TraitRef>>,
|
trait_refs: RefCell<HashMap<NodeId, @TraitRef>>,
|
||||||
trait_defs: @mut HashMap<DefId, @TraitDef>,
|
trait_defs: RefCell<HashMap<DefId, @TraitDef>>,
|
||||||
|
|
||||||
/// Despite its name, `items` does not only map NodeId to an item but
|
/// Despite its name, `items` does not only map NodeId to an item but
|
||||||
/// also to expr/stmt/local/arg/etc
|
/// also to expr/stmt/local/arg/etc
|
||||||
@ -987,7 +987,7 @@ pub fn mk_ctxt(s: session::Session,
|
|||||||
node_types: @mut HashMap::new(),
|
node_types: @mut HashMap::new(),
|
||||||
node_type_substs: RefCell::new(HashMap::new()),
|
node_type_substs: RefCell::new(HashMap::new()),
|
||||||
trait_refs: RefCell::new(HashMap::new()),
|
trait_refs: RefCell::new(HashMap::new()),
|
||||||
trait_defs: @mut HashMap::new(),
|
trait_defs: RefCell::new(HashMap::new()),
|
||||||
items: amap,
|
items: amap,
|
||||||
intrinsic_defs: @mut HashMap::new(),
|
intrinsic_defs: @mut HashMap::new(),
|
||||||
freevars: freevars,
|
freevars: freevars,
|
||||||
@ -3963,7 +3963,8 @@ pub fn lookup_impl_vtables(cx: ctxt,
|
|||||||
|
|
||||||
/// Given the did of a trait, returns its canonical trait ref.
|
/// Given the did of a trait, returns its canonical trait ref.
|
||||||
pub fn lookup_trait_def(cx: ctxt, did: ast::DefId) -> @ty::TraitDef {
|
pub fn lookup_trait_def(cx: ctxt, did: ast::DefId) -> @ty::TraitDef {
|
||||||
match cx.trait_defs.find(&did) {
|
let mut trait_defs = cx.trait_defs.borrow_mut();
|
||||||
|
match trait_defs.get().find(&did) {
|
||||||
Some(&trait_def) => {
|
Some(&trait_def) => {
|
||||||
// The item is in this crate. The caller should have added it to the
|
// The item is in this crate. The caller should have added it to the
|
||||||
// type cache already
|
// type cache already
|
||||||
@ -3972,7 +3973,7 @@ pub fn lookup_trait_def(cx: ctxt, did: ast::DefId) -> @ty::TraitDef {
|
|||||||
None => {
|
None => {
|
||||||
assert!(did.crate != ast::LOCAL_CRATE);
|
assert!(did.crate != ast::LOCAL_CRATE);
|
||||||
let trait_def = @csearch::get_trait_def(cx, did);
|
let trait_def = @csearch::get_trait_def(cx, did);
|
||||||
cx.trait_defs.insert(did, trait_def);
|
trait_defs.get().insert(did, trait_def);
|
||||||
return trait_def;
|
return trait_def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -740,10 +740,14 @@ fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> @ty::TraitDef {
|
|||||||
pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::item) -> @ty::TraitDef {
|
pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::item) -> @ty::TraitDef {
|
||||||
let def_id = local_def(it.id);
|
let def_id = local_def(it.id);
|
||||||
let tcx = ccx.tcx;
|
let tcx = ccx.tcx;
|
||||||
match tcx.trait_defs.find(&def_id) {
|
{
|
||||||
Some(&def) => return def,
|
let trait_defs = tcx.trait_defs.borrow();
|
||||||
_ => {}
|
match trait_defs.get().find(&def_id) {
|
||||||
|
Some(&def) => return def,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match it.node {
|
match it.node {
|
||||||
ast::item_trait(ref generics, ref supertraits, _) => {
|
ast::item_trait(ref generics, ref supertraits, _) => {
|
||||||
let self_ty = ty::mk_self(tcx, def_id);
|
let self_ty = ty::mk_self(tcx, def_id);
|
||||||
@ -755,7 +759,8 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::item) -> @ty::TraitDef {
|
|||||||
let trait_def = @ty::TraitDef {generics: ty_generics,
|
let trait_def = @ty::TraitDef {generics: ty_generics,
|
||||||
bounds: bounds,
|
bounds: bounds,
|
||||||
trait_ref: trait_ref};
|
trait_ref: trait_ref};
|
||||||
tcx.trait_defs.insert(def_id, trait_def);
|
let mut trait_defs = tcx.trait_defs.borrow_mut();
|
||||||
|
trait_defs.get().insert(def_id, trait_def);
|
||||||
return trait_def;
|
return trait_def;
|
||||||
}
|
}
|
||||||
ref s => {
|
ref s => {
|
||||||
|
Loading…
Reference in New Issue
Block a user