Skip to content

Commit b27fb10

Browse files
committed
---
yaml --- r: 142911 b: refs/heads/try2 c: 9da42dc h: refs/heads/master i: 142909: 402868e 142907: 87acdc5 142903: 4f97867 142895: 6dae4f3 142879: 0b5ad59 142847: c202baf v: v3
1 parent 9b9f1c9 commit b27fb10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1070
-314
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ad3a69739f508a2d6219479bf98ac9f853ac3574
8+
refs/heads/try2: 9da42dce276b7e9c925c7bba40084ce4ba69597f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/dlist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ impl<T> Deque<T> for DList<T> {
173173
let tail_own = match tail.prev.resolve() {
174174
None => {
175175
self.list_tail = Rawlink::none();
176-
self.list_head.swap_unwrap()
176+
self.list_head.take_unwrap()
177177
},
178178
Some(tail_prev) => {
179179
self.list_tail = tail.prev;
180-
tail_prev.next.swap_unwrap()
180+
tail_prev.next.take_unwrap()
181181
}
182182
};
183183
Some(tail_own.value)
@@ -465,7 +465,7 @@ impl<'self, A> ListInsertion<A> for MutDListIterator<'self, A> {
465465
Some(prev) => prev,
466466
};
467467
let mut ins_node = ~Node{value: elt, next: None, prev: Rawlink::none()};
468-
let node_own = prev_node.next.swap_unwrap();
468+
let node_own = prev_node.next.take_unwrap();
469469
ins_node.next = link_with_prev(node_own, Rawlink::some(ins_node));
470470
prev_node.next = link_with_prev(ins_node, Rawlink::some(prev_node));
471471
self.list.length += 1;

branches/try2/src/libextra/net/ip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub fn get_addr(node: &str, iotask: &iotask)
116116
let (output_po, output_ch) = stream();
117117
let mut output_ch = Some(SharedChan::new(output_ch));
118118
do str::as_buf(node) |node_ptr, len| {
119-
let output_ch = output_ch.swap_unwrap();
119+
let output_ch = output_ch.take_unwrap();
120120
debug!("slice len %?", len);
121121
let handle = create_uv_getaddrinfo_t();
122122
let handle_ptr: *uv_getaddrinfo_t = &handle;

branches/try2/src/libextra/smallintmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ impl<V> SmallIntMap<V> {
161161
/// Visit all key-value pairs in reverse order
162162
pub fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) -> bool {
163163
for uint::range_rev(self.v.len(), 0) |i| {
164-
match self.v[i - 1] {
165-
Some(ref elt) => if !it(i - 1, elt) { return false; },
164+
match self.v[i] {
165+
Some(ref elt) => if !it(i, elt) { return false; },
166166
None => ()
167167
}
168168
}

branches/try2/src/libextra/sync.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'self> Condvar<'self> {
260260
signal_waitqueue(&state.waiters);
261261
}
262262
// Enqueue ourself to be woken up by a signaller.
263-
let SignalEnd = SignalEnd.swap_unwrap();
263+
let SignalEnd = SignalEnd.take_unwrap();
264264
state.blocked[condvar_id].tail.send(SignalEnd);
265265
} else {
266266
out_of_bounds = Some(state.blocked.len());
@@ -281,7 +281,7 @@ impl<'self> Condvar<'self> {
281281
// Unconditionally "block". (Might not actually block if a
282282
// signaller already sent -- I mean 'unconditionally' in contrast
283283
// with acquire().)
284-
let _ = comm::recv_one(WaitEnd.swap_unwrap());
284+
let _ = comm::recv_one(WaitEnd.take_unwrap());
285285
}
286286

287287
// This is needed for a failing condition variable to reacquire the
@@ -353,7 +353,7 @@ impl<'self> Condvar<'self> {
353353
}
354354
}
355355
do check_cvar_bounds(out_of_bounds, condvar_id, "cond.signal_on()") {
356-
let queue = queue.swap_unwrap();
356+
let queue = queue.take_unwrap();
357357
broadcast_waitqueue(&queue)
358358
}
359359
}
@@ -1436,7 +1436,7 @@ mod tests {
14361436
do x.write_downgrade |xwrite| {
14371437
let mut xopt = Some(xwrite);
14381438
do y.write_downgrade |_ywrite| {
1439-
y.downgrade(xopt.swap_unwrap());
1439+
y.downgrade(xopt.take_unwrap());
14401440
error!("oops, y.downgrade(x) should have failed!");
14411441
}
14421442
}

branches/try2/src/libextra/treemap.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ fn mutate_values<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
552552
// Remove left horizontal link by rotating right
553553
fn skew<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
554554
if node.left.map_default(false, |x| x.level == node.level) {
555-
let mut save = node.left.swap_unwrap();
555+
let mut save = node.left.take_unwrap();
556556
swap(&mut node.left, &mut save.right); // save.right now None
557557
swap(node, &mut save);
558558
node.right = Some(save);
@@ -564,7 +564,7 @@ fn skew<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
564564
fn split<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
565565
if node.right.map_default(false,
566566
|x| x.right.map_default(false, |y| y.level == node.level)) {
567-
let mut save = node.right.swap_unwrap();
567+
let mut save = node.right.take_unwrap();
568568
swap(&mut node.right, &mut save.left); // save.left now None
569569
save.level += 1;
570570
swap(node, &mut save);
@@ -643,7 +643,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
643643
Equal => {
644644
if save.left.is_some() {
645645
if save.right.is_some() {
646-
let mut left = save.left.swap_unwrap();
646+
let mut left = save.left.take_unwrap();
647647
if left.right.is_some() {
648648
heir_swap(save, &mut left.right);
649649
} else {
@@ -653,13 +653,13 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
653653
save.left = Some(left);
654654
(remove(&mut save.left, key), true)
655655
} else {
656-
let new = save.left.swap_unwrap();
656+
let new = save.left.take_unwrap();
657657
let ~TreeNode{value, _} = replace(save, new);
658-
*save = save.left.swap_unwrap();
658+
*save = save.left.take_unwrap();
659659
(Some(value), true)
660660
}
661661
} else if save.right.is_some() {
662-
let new = save.right.swap_unwrap();
662+
let new = save.right.take_unwrap();
663663
let ~TreeNode{value, _} = replace(save, new);
664664
(Some(value), true)
665665
} else {

branches/try2/src/librustc/middle/const_eval.rs

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,58 @@ pub fn classify(e: &expr,
165165
pub fn lookup_const(tcx: ty::ctxt, e: &expr) -> Option<@expr> {
166166
match tcx.def_map.find(&e.id) {
167167
Some(&ast::def_static(def_id, false)) => lookup_const_by_id(tcx, def_id),
168+
Some(&ast::def_variant(enum_def, variant_def)) => lookup_variant_by_id(tcx,
169+
enum_def,
170+
variant_def),
168171
_ => None
169172
}
170173
}
171174

175+
pub fn lookup_variant_by_id(tcx: ty::ctxt,
176+
enum_def: ast::def_id,
177+
variant_def: ast::def_id)
178+
-> Option<@expr> {
179+
fn variant_expr(variants: &[ast::variant], id: ast::node_id) -> Option<@expr> {
180+
for variants.iter().advance |variant| {
181+
if variant.node.id == id {
182+
return variant.node.disr_expr;
183+
}
184+
}
185+
None
186+
}
187+
188+
if ast_util::is_local(enum_def) {
189+
match tcx.items.find(&enum_def.node) {
190+
None => None,
191+
Some(&ast_map::node_item(it, _)) => match it.node {
192+
item_enum(ast::enum_def { variants: ref variants }, _) => {
193+
variant_expr(*variants, variant_def.node)
194+
}
195+
_ => None
196+
},
197+
Some(_) => None
198+
}
199+
} else {
200+
let maps = astencode::Maps {
201+
root_map: @mut HashMap::new(),
202+
method_map: @mut HashMap::new(),
203+
vtable_map: @mut HashMap::new(),
204+
write_guard_map: @mut HashSet::new(),
205+
capture_map: @mut HashMap::new()
206+
};
207+
match csearch::maybe_get_item_ast(tcx, enum_def,
208+
|a, b, c, d| astencode::decode_inlined_item(a, b, maps, /*bar*/ copy c, d)) {
209+
csearch::found(ast::ii_item(item)) => match item.node {
210+
item_enum(ast::enum_def { variants: ref variants }, _) => {
211+
variant_expr(*variants, variant_def.node)
212+
}
213+
_ => None
214+
},
215+
_ => None
216+
}
217+
}
218+
}
219+
172220
pub fn lookup_const_by_id(tcx: ty::ctxt,
173221
def_id: ast::def_id)
174222
-> Option<@expr> {
@@ -237,13 +285,13 @@ pub enum const_val {
237285
}
238286

239287
pub fn eval_const_expr(tcx: middle::ty::ctxt, e: &expr) -> const_val {
240-
match eval_const_expr_partial(tcx, e) {
288+
match eval_const_expr_partial(&tcx, e) {
241289
Ok(r) => r,
242290
Err(s) => tcx.sess.span_fatal(e.span, s)
243291
}
244292
}
245293

246-
pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: &expr)
294+
pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &expr)
247295
-> Result<const_val, ~str> {
248296
use middle::ty;
249297
fn fromb(b: bool) -> Result<const_val, ~str> { Ok(const_int(b as i64)) }
@@ -360,7 +408,7 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: &expr)
360408
}
361409
}
362410
expr_cast(base, _) => {
363-
let ety = ty::expr_ty(tcx, e);
411+
let ety = tcx.expr_ty(e);
364412
let base = eval_const_expr_partial(tcx, base);
365413
match /*bad*/copy base {
366414
Err(_) => base,
@@ -390,8 +438,8 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: &expr)
390438
}
391439
}
392440
expr_path(_) => {
393-
match lookup_const(tcx, e) {
394-
Some(actual_e) => eval_const_expr_partial(tcx, actual_e),
441+
match lookup_const(tcx.ty_ctxt(), e) {
442+
Some(actual_e) => eval_const_expr_partial(&tcx.ty_ctxt(), actual_e),
395443
None => Err(~"Non-constant path in constant expr")
396444
}
397445
}

branches/try2/src/librustc/middle/kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
122122
None => cx.tcx.sess.bug("trait ref not in def map!"),
123123
Some(&trait_def) => {
124124
let trait_def_id = ast_util::def_id_of_def(trait_def);
125-
if cx.tcx.lang_items.drop_trait() == trait_def_id {
125+
if cx.tcx.lang_items.drop_trait() == Some(trait_def_id) {
126126
// Yes, it's a destructor.
127127
match self_type.node {
128128
ty_path(_, ref bounds, path_node_id) => {
@@ -309,7 +309,7 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
309309
"explicit copy requires a copyable argument");
310310
}
311311
expr_repeat(element, count_expr, _) => {
312-
let count = ty::eval_repeat_count(cx.tcx, count_expr);
312+
let count = ty::eval_repeat_count(&cx.tcx, count_expr);
313313
if count > 1 {
314314
let element_ty = ty::expr_ty(cx.tcx, element);
315315
check_copy(cx, element_ty, element.span,

0 commit comments

Comments
 (0)