|
1 | 1 | import check::{fn_ctxt, impl_self_ty, methods};
|
2 | 2 | import infer::{resolve_type, resolve_all, force_all, fixup_err_to_str};
|
| 3 | +import ast_util::new_def_hash; |
3 | 4 |
|
4 | 5 | fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool {
|
5 | 6 | vec::any(tps, |bs| {
|
@@ -49,6 +50,8 @@ fn relate_trait_tys(fcx: @fn_ctxt, sp: span,
|
49 | 50 | /*
|
50 | 51 | Look up the vtable to use when treating an item of type <t>
|
51 | 52 | as if it has type <trait_ty>
|
| 53 | +
|
| 54 | +XXX: This doesn't use the coherence tables yet. |
52 | 55 | */
|
53 | 56 | fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
|
54 | 57 | ty: ty::t, trait_ty: ty::t, allow_unsafe: bool)
|
@@ -114,10 +117,19 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
|
114 | 117 | _ {
|
115 | 118 | let mut found = ~[];
|
116 | 119 |
|
| 120 | + let mut impls_seen = new_def_hash(); |
| 121 | + |
117 | 122 | for list::each(isc) |impls| {
|
118 | 123 | /* For each impl in scope... */
|
119 | 124 | for vec::each(*impls) |im| {
|
120 | 125 | // im = one specific impl
|
| 126 | + |
| 127 | + // First, ensure that we haven't processed this impl yet. |
| 128 | + if impls_seen.contains_key(im.did) { |
| 129 | + again; |
| 130 | + } |
| 131 | + impls_seen.insert(im.did, ()); |
| 132 | + |
121 | 133 | // find the trait that im implements (if any)
|
122 | 134 | for vec::each(ty::impl_traits(tcx, im.did)) |of_ty| {
|
123 | 135 | // it must have the same id as the expected one
|
|
0 commit comments