Skip to content

Commit cdc18b9

Browse files
committed
Remove Rc's borrow method to avoid conflicts with RefCell's borrow in Rc<RefCell<T>>.
1 parent 12b2607 commit cdc18b9

File tree

28 files changed

+59
-76
lines changed

28 files changed

+59
-76
lines changed

src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ let x = Rc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
16871687
let y = x.clone(); // a new owner
16881688
let z = x; // this moves `x` into `z`, rather than creating a new owner
16891689

1690-
assert!(*z.borrow() == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1690+
assert!(*z == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
16911691

16921692
// the variable is mutable, but not the contents of the box
16931693
let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]);

src/libarena/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ struct Chunk {
5151
}
5252
impl Chunk {
5353
fn capacity(&self) -> uint {
54-
self.data.borrow().borrow().get().capacity()
54+
self.data.deref().borrow().get().capacity()
5555
}
5656

5757
unsafe fn as_ptr(&self) -> *u8 {
58-
self.data.borrow().borrow().get().as_ptr()
58+
self.data.deref().borrow().get().as_ptr()
5959
}
6060
}
6161

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10811081
ebml_w.tag(c::tag_table_capture_map, |ebml_w| {
10821082
ebml_w.id(id);
10831083
ebml_w.tag(c::tag_table_val, |ebml_w| {
1084-
ebml_w.emit_from_vec(cap_vars.borrow().as_slice(),
1084+
ebml_w.emit_from_vec(cap_vars.deref().as_slice(),
10851085
|ebml_w, cap_var| {
10861086
cap_var.encode(ebml_w);
10871087
})

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl<'a> CheckLoanCtxt<'a> {
716716
span: Span) {
717717
let capture_map = self.bccx.capture_map.borrow();
718718
let cap_vars = capture_map.get().get(&closure_id);
719-
for cap_var in cap_vars.borrow().iter() {
719+
for cap_var in cap_vars.deref().iter() {
720720
let var_id = ast_util::def_id_of_def(cap_var.def).node;
721721
let var_path = @LpVar(var_id);
722722
self.check_if_path_is_moved(closure_id, span,

src/librustc/middle/borrowck/gather_loans/gather_moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn gather_captures(bccx: &BorrowckCtxt,
4949
closure_expr: &ast::Expr) {
5050
let capture_map = bccx.capture_map.borrow();
5151
let captured_vars = capture_map.get().get(&closure_expr.id);
52-
for captured_var in captured_vars.borrow().iter() {
52+
for captured_var in captured_vars.deref().iter() {
5353
match captured_var.mode {
5454
moves::CapMove => {
5555
let cmt = bccx.cat_captured_var(closure_expr.id,

src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl<'a> GatherLoanCtxt<'a> {
406406
closure_expr: &ast::Expr) {
407407
let capture_map = self.bccx.capture_map.borrow();
408408
let captured_vars = capture_map.get().get(&closure_expr.id);
409-
for captured_var in captured_vars.borrow().iter() {
409+
for captured_var in captured_vars.deref().iter() {
410410
match captured_var.mode {
411411
moves::CapCopy | moves::CapMove => { continue; }
412412
moves::CapRef => { }

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub fn lit_to_const(lit: &Lit) -> const_val {
512512
match lit.node {
513513
LitStr(ref s, _) => const_str((*s).clone()),
514514
LitBinary(ref data) => {
515-
const_binary(Rc::new(data.borrow().iter().map(|x| *x).collect()))
515+
const_binary(Rc::new(data.deref().iter().map(|x| *x).collect()))
516516
}
517517
LitChar(n) => const_uint(n as u64),
518518
LitInt(n, _) => const_int(n),

src/librustc/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
298298
}
299299
}
300300
};
301-
let type_param_defs = type_param_defs.borrow();
301+
let type_param_defs = type_param_defs.deref();
302302
if ts.len() != type_param_defs.len() {
303303
// Fail earlier to make debugging easier
304304
fail!("internal error: in kind::check_expr, length \

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ fn visit_expr(v: &mut LivenessVisitor, expr: &Expr, this: @IrMaps) {
505505
let capture_map = this.capture_map.borrow();
506506
let cvs = capture_map.get().get(&expr.id);
507507
let mut call_caps = Vec::new();
508-
for cv in cvs.borrow().iter() {
508+
for cv in cvs.deref().iter() {
509509
match moves::moved_variable_node_id_from_def(cv.def) {
510510
Some(rv) => {
511511
let cv_ln = this.add_live_node(FreeVarNode(cv.span));

src/librustc/middle/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<T:Subst> Subst for Rc<T> {
142142
fn subst_spanned(&self, tcx: ty::ctxt,
143143
substs: &ty::substs,
144144
span: Option<Span>) -> Rc<T> {
145-
Rc::new(self.borrow().subst_spanned(tcx, substs, span))
145+
Rc::new(self.deref().subst_spanned(tcx, substs, span))
146146
}
147147
}
148148

0 commit comments

Comments
 (0)