Skip to content

Commit 38c430c

Browse files
committed
---
yaml --- r: 30970 b: refs/heads/incoming c: 9516e7b h: refs/heads/master v: v3
1 parent f838e0e commit 38c430c

File tree

2 files changed

+21
-36
lines changed

2 files changed

+21
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: f33539e446d6f41d4a3296ed50a8f968e7950483
9+
refs/heads/incoming: 9516e7b4b3ef82c2b2183e6d268c695ef5093fa2
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/rustc/middle/typeck/check/vtable.rs

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@ fn lookup_vtables(fcx: @fn_ctxt,
5151
match *bound {
5252
ty::bound_trait(i_ty) => {
5353
let i_ty = ty::subst(tcx, substs, i_ty);
54-
match lookup_vtable(fcx, expr, *ty, i_ty, allow_unsafe,
55-
is_early) {
56-
None => {}
57-
Some(vtable) => {
58-
result.push(vtable);
59-
}
60-
}
54+
result.push(lookup_vtable(fcx, expr, *ty, i_ty,
55+
allow_unsafe, is_early));
6156
}
6257
_ => ()
6358
}
@@ -96,7 +91,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
9691
trait_ty: ty::t,
9792
allow_unsafe: bool,
9893
is_early: bool)
99-
-> Option<vtable_origin>
94+
-> vtable_origin
10095
{
10196

10297
debug!("lookup_vtable(ty=%s, trait_ty=%s)",
@@ -118,7 +113,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
118113
// The type has unconstrained type variables in it, so we can't
119114
// do early resolution on it. Return some completely bogus vtable
120115
// information: we aren't storing it anyways.
121-
return Some(vtable_param(0, 0));
116+
return vtable_param(0, 0);
122117
}
123118
};
124119

@@ -140,7 +135,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
140135
idid);
141136
relate_trait_tys(fcx, expr,
142137
trait_ty, ity);
143-
return Some(vtable_param(n, n_bound));
138+
return vtable_param(n, n_bound);
144139
}
145140
}
146141
_ => tcx.sess.impossible_case(
@@ -175,7 +170,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
175170
}
176171
}
177172
}
178-
return Some(vtable_trait(did, substs.tps));
173+
return vtable_trait(did, substs.tps);
179174
}
180175

181176
_ => {
@@ -308,7 +303,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
308303
None => {
309304
assert is_early;
310305
// Bail out with a bogus answer
311-
return Some(vtable_param(0, 0));
306+
return vtable_param(0, 0);
312307
}
313308
};
314309

@@ -346,20 +341,23 @@ fn lookup_vtable(fcx: @fn_ctxt,
346341

347342
match found.len() {
348343
0 => { /* fallthrough */ }
349-
1 => { return Some(found[0]); }
344+
1 => { return found[0]; }
350345
_ => {
351346
if !is_early {
352347
fcx.ccx.tcx.sess.span_err(
353348
expr.span,
354349
~"multiple applicable methods in scope");
355350
}
356-
return Some(found[0]);
351+
return found[0];
357352
}
358353
}
359354
}
360355
}
361356

362-
return None;
357+
tcx.sess.span_fatal(
358+
expr.span,
359+
fmt!("failed to find an implementation of trait %s for %s",
360+
ty_to_str(tcx, trait_ty), ty_to_str(tcx, ty)));
363361
}
364362

365363
fn fixup_ty(fcx: @fn_ctxt,
@@ -461,26 +459,13 @@ fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
461459
Look up vtables for the type we're casting to,
462460
passing in the source and target type
463461
*/
464-
let ty = fcx.expr_ty(src);
465-
let vtable_opt = lookup_vtable(fcx, ex, ty, target_ty, true,
466-
is_early);
467-
match vtable_opt {
468-
None => {
469-
fcx.tcx().sess.span_err(
470-
ex.span,
471-
fmt!("failed to find an implementation of trait %s \
472-
for %s",
473-
ty_to_str(fcx.tcx(), target_ty),
474-
ty_to_str(fcx.tcx(), ty)));
475-
}
476-
Some(vtable) => {
477-
/*
478-
Map this expression to that vtable (that is: "ex has
479-
vtable <vtable>")
480-
*/
481-
if !is_early { cx.vtable_map.insert(ex.id, @~[vtable]); }
482-
}
483-
}
462+
let vtable = lookup_vtable(fcx, ex, fcx.expr_ty(src),
463+
target_ty, true, is_early);
464+
/*
465+
Map this expression to that vtable (that is: "ex has
466+
vtable <vtable>")
467+
*/
468+
if !is_early { cx.vtable_map.insert(ex.id, @~[vtable]); }
484469
}
485470
_ => ()
486471
}

0 commit comments

Comments
 (0)