From 2ac64d91ac9df242c780d162863c8c0abce448b1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 18 Sep 2012 14:24:21 -0700 Subject: [PATCH] change relative priority of auto-slice and auto-ptr rationale: if you have an impl for &const ~[T] or &mut ~[T] and one for &[T], the first will be more likely to work and not lead to borrowck errors. I could imagine us wanting to offer multiple impls for methods we select the ptr-to-array when possible and the slice when necessary. Also, taking a ptr seems like fewer adaptations than slicing, and we tend to prefer fewer adaptations. --- src/rustc/middle/typeck/check/method.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 8eb8f06a3ef..8486b9de02b 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -527,12 +527,12 @@ impl LookupContext { * Attempts both auto-slice and auto-ptr, as appropriate. */ - match self.search_for_autosliced_method(self_ty, autoderefs) { + match self.search_for_autoptrd_method(self_ty, autoderefs) { Some(move mme) => { return Some(move mme); } None => {} } - match self.search_for_autoptrd_method(self_ty, autoderefs) { + match self.search_for_autosliced_method(self_ty, autoderefs) { Some(move mme) => { return Some(move mme); } None => {} }