auto merge of #5065 : catamorphism/rust/issue-3453, r=catamorphism

...because it appears to work now. Removes a FIXME.
This commit is contained in:
bors 2013-02-20 22:36:31 -08:00
commit 41a4151173
2 changed files with 20 additions and 7 deletions

View File

@ -438,10 +438,9 @@ pub impl LookupContext {
let trait_methods = ty::trait_methods(tcx, init_trait_id);
let pos = {
// FIXME #3453 can't use trait_methods.position
match vec::position(*trait_methods,
|m| (m.self_ty != ast::sty_static &&
m.ident == self.m_name))
match trait_methods.position(|m| {
m.self_ty != ast::sty_static &&
m.ident == self.m_name })
{
Some(pos) => pos,
None => {
@ -624,9 +623,7 @@ pub impl LookupContext {
}
let idx = {
// FIXME #3453 can't use impl_info.methods.position
match vec::position(impl_info.methods,
|m| m.ident == self.m_name) {
match impl_info.methods.position(|m| m.ident == self.m_name) {
Some(idx) => idx,
None => { return; } // No method with the right name.
}

View File

@ -0,0 +1,16 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn main() {
let mut v = ~[1, 2, 3];
assert v.position(|x| *x == 1) == Some(0);
assert v.position(|x| *x == 3) == Some(2);
assert v.position(|x| *x == 17) == None;
}