Skip to content

Commit 2469cba

Browse files
committed
Make auto-slice, auto-ptr not exclusive (fixes #3514)
1 parent 527a6f6 commit 2469cba

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/rustc/middle/typeck/check/method.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ impl LookupContext {
168168
// around newtype enums. They can be further
169169
// deref'd, but they may also have intrinsic
170170
// methods hanging off of them with interior type.
171-
match self.search_for_appr_autorefd_method(self_ty,
172-
autoderefs) {
171+
match self.search_for_any_autorefd_method(self_ty,
172+
autoderefs) {
173173
Some(move mme) => { return Some(mme); }
174174
None => {}
175175
}
@@ -186,7 +186,7 @@ impl LookupContext {
186186
}
187187
}
188188

189-
self.search_for_appr_autorefd_method(self_ty, autoderefs)
189+
self.search_for_any_autorefd_method(self_ty, autoderefs)
190190
}
191191

192192
fn deref(ty: ty::t, enum_dids: &DVec<ast::def_id>) -> Option<ty::t> {
@@ -527,15 +527,13 @@ impl LookupContext {
527527
* Attempts both auto-slice and auto-ptr, as appropriate.
528528
*/
529529

530-
let tcx = self.tcx();
531-
532530
match self.search_for_autosliced_method(self_ty, autoderefs) {
533-
Some(mme) => { return mme; }
531+
Some(move mme) => { return Some(move mme); }
534532
None => {}
535533
}
536534

537535
match self.search_for_autoptrd_method(self_ty, autoderefs) {
538-
Some(mme) => { return mme; }
536+
Some(move mme) => { return Some(move mme); }
539537
None => {}
540538
}
541539

@@ -553,6 +551,7 @@ impl LookupContext {
553551
* Searches for a candidate by converting things like
554552
* `~[]` to `&[]`. */
555553

554+
let tcx = self.tcx();
556555
match ty::get(self_ty).sty {
557556
ty_evec(mt, vstore_box) |
558557
ty_evec(mt, vstore_uniq) |
@@ -593,6 +592,7 @@ impl LookupContext {
593592
* appropriate mutability.
594593
*/
595594

595+
let tcx = self.tcx();
596596
match ty::get(self_ty).sty {
597597
ty_box(*) | ty_uniq(*) | ty_rptr(*) => {
598598
// we should be fully autoderef'd
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trait Pushable<T> {
2+
fn push_val(&mut self, +t: T);
3+
}
4+
5+
impl<T> ~[T]: Pushable<T> {
6+
fn push_val(&mut self, +t: T) {
7+
vec::push(*self, t);
8+
}
9+
}
10+
11+
fn main() {
12+
let mut v = ~[1];
13+
v.push_val(2);
14+
v.push_val(3);
15+
assert v == ~[1, 2, 3];
16+
}

0 commit comments

Comments
 (0)