Skip to content

Commit 41a4151

Browse files
committed
auto merge of #5065 : catamorphism/rust/issue-3453, r=catamorphism
...because it appears to work now. Removes a FIXME.
2 parents a02da4e + bad4463 commit 41a4151

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,9 @@ pub impl LookupContext {
438438

439439
let trait_methods = ty::trait_methods(tcx, init_trait_id);
440440
let pos = {
441-
// FIXME #3453 can't use trait_methods.position
442-
match vec::position(*trait_methods,
443-
|m| (m.self_ty != ast::sty_static &&
444-
m.ident == self.m_name))
441+
match trait_methods.position(|m| {
442+
m.self_ty != ast::sty_static &&
443+
m.ident == self.m_name })
445444
{
446445
Some(pos) => pos,
447446
None => {
@@ -624,9 +623,7 @@ pub impl LookupContext {
624623
}
625624

626625
let idx = {
627-
// FIXME #3453 can't use impl_info.methods.position
628-
match vec::position(impl_info.methods,
629-
|m| m.ident == self.m_name) {
626+
match impl_info.methods.position(|m| m.ident == self.m_name) {
630627
Some(idx) => idx,
631628
None => { return; } // No method with the right name.
632629
}

src/test/run-pass/vec-position.rs

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

0 commit comments

Comments
 (0)