diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-02-20 17:46:01 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-02-20 17:46:01 -0800 |
| commit | bad4463a6b793aa627afe5aeb6a4af54b9562c23 (patch) | |
| tree | f899276d1c379f0c812e07f0bb8cbeaeedbb39ab /src | |
| parent | eed2ca61a9169c3ed97834c3119ce3407e7413e7 (diff) | |
| download | rust-bad4463a6b793aa627afe5aeb6a4af54b9562c23.tar.gz rust-bad4463a6b793aa627afe5aeb6a4af54b9562c23.zip | |
rustc: Use position method in check::method
...because it appears to work now. Removes a FIXME.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/typeck/check/method.rs | 11 | ||||
| -rw-r--r-- | src/test/run-pass/vec-position.rs | 16 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 3524636fe2b..6de8873b6ed 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -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. } diff --git a/src/test/run-pass/vec-position.rs b/src/test/run-pass/vec-position.rs new file mode 100644 index 00000000000..fe186a78ed7 --- /dev/null +++ b/src/test/run-pass/vec-position.rs @@ -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; +} |
