Skip to content

Commit 41e0209

Browse files
committed
---
yaml --- r: 94618 b: refs/heads/try c: 984b567 h: refs/heads/master v: v3
1 parent 9724a33 commit 41e0209

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 7ffba5c3e16291b8bcadbe9485de8faad1766aa8
5+
refs/heads/try: 984b567f9e5bb7153634bbdbc9661e8b8a6c8c63
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/typeck/infer/mod.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use middle::typeck::infer::lub::Lub;
3535
use middle::typeck::infer::to_str::InferStr;
3636
use middle::typeck::infer::unify::{ValsAndBindings, Root};
3737
use middle::typeck::infer::error_reporting::ErrorReporting;
38+
use std::cell::Cell;
3839
use std::hashmap::HashMap;
3940
use std::result;
4041
use std::vec;
@@ -43,8 +44,8 @@ use syntax::ast;
4344
use syntax::codemap;
4445
use syntax::codemap::Span;
4546
use util::common::indent;
46-
use util::ppaux::{bound_region_to_str, ty_to_str, trait_ref_to_str, Repr,
47-
UserString};
47+
use util::ppaux::{bound_region_to_str, ty_to_str, trait_ref_to_str, Repr};
48+
use util::ppaux::{UserString};
4849

4950
pub mod doc;
5051
pub mod macros;
@@ -80,15 +81,15 @@ pub struct InferCtxt {
8081
// types that might instantiate a general type variable have an
8182
// order, represented by its upper and lower bounds.
8283
ty_var_bindings: ValsAndBindings<ty::TyVid, Bounds<ty::t>>,
83-
ty_var_counter: uint,
84+
ty_var_counter: Cell<uint>,
8485

8586
// Map from integral variable to the kind of integer it represents
8687
int_var_bindings: ValsAndBindings<ty::IntVid, Option<IntVarValue>>,
87-
int_var_counter: uint,
88+
int_var_counter: Cell<uint>,
8889

8990
// Map from floating variable to the kind of float it represents
9091
float_var_bindings: ValsAndBindings<ty::FloatVid, Option<ast::float_ty>>,
91-
float_var_counter: uint,
92+
float_var_counter: Cell<uint>,
9293

9394
// For region variables.
9495
region_vars: RegionVarBindings,
@@ -260,13 +261,13 @@ pub fn new_infer_ctxt(tcx: ty::ctxt) -> @mut InferCtxt {
260261
tcx: tcx,
261262

262263
ty_var_bindings: new_ValsAndBindings(),
263-
ty_var_counter: 0,
264+
ty_var_counter: Cell::new(0),
264265

265266
int_var_bindings: new_ValsAndBindings(),
266-
int_var_counter: 0,
267+
int_var_counter: Cell::new(0),
267268

268269
float_var_bindings: new_ValsAndBindings(),
269-
float_var_counter: 0,
270+
float_var_counter: Cell::new(0),
270271

271272
region_vars: RegionVarBindings(tcx),
272273
}
@@ -599,8 +600,8 @@ fn next_simple_var<V:Clone,T:Clone>(counter: &mut uint,
599600

600601
impl InferCtxt {
601602
pub fn next_ty_var_id(&mut self) -> TyVid {
602-
let id = self.ty_var_counter;
603-
self.ty_var_counter += 1;
603+
let id = self.ty_var_counter.get();
604+
self.ty_var_counter.set(id + 1);
604605
{
605606
let vals = &mut self.ty_var_bindings.vals;
606607
vals.insert(id, Root(Bounds { lb: None, ub: None }, 0u));
@@ -617,17 +618,23 @@ impl InferCtxt {
617618
}
618619

619620
pub fn next_int_var_id(&mut self) -> IntVid {
620-
IntVid(next_simple_var(&mut self.int_var_counter,
621-
&mut self.int_var_bindings))
621+
let mut int_var_counter = self.int_var_counter.get();
622+
let result = IntVid(next_simple_var(&mut int_var_counter,
623+
&mut self.int_var_bindings));
624+
self.int_var_counter.set(int_var_counter);
625+
result
622626
}
623627

624628
pub fn next_int_var(&mut self) -> ty::t {
625629
ty::mk_int_var(self.tcx, self.next_int_var_id())
626630
}
627631

628632
pub fn next_float_var_id(&mut self) -> FloatVid {
629-
FloatVid(next_simple_var(&mut self.float_var_counter,
630-
&mut self.float_var_bindings))
633+
let mut float_var_counter = self.float_var_counter.get();
634+
let result = FloatVid(next_simple_var(&mut float_var_counter,
635+
&mut self.float_var_bindings));
636+
self.float_var_counter.set(float_var_counter);
637+
result
631638
}
632639

633640
pub fn next_float_var(&mut self) -> ty::t {

0 commit comments

Comments
 (0)