fix rpass/cfail tests

This commit is contained in:
Jorge Aparicio 2015-01-02 10:25:54 -05:00
parent 3bf24d6b63
commit 4f4ae538ae
12 changed files with 39 additions and 18 deletions

View file

@ -9,6 +9,7 @@
// except according to those terms.
#![crate_type = "lib"]
#![feature(associated_types)]
pub struct TreeBuilder<H>;
@ -20,7 +21,9 @@ impl<H> TreeBuilder<H> {
}
}
impl<H> Iterator<H> for TreeBuilder<H> {
impl<H> Iterator for TreeBuilder<H> {
type Item = H;
fn next(&mut self) -> Option<H> {
None
}

View file

@ -26,7 +26,7 @@ impl<T> Foo {
// issue 8134
pub struct Parser<T>;
impl<T: std::iter::Iterator<char>> Parser<T> {
impl<T: std::iter::Iterator<Item=char>> Parser<T> {
fn in_doctype(&mut self) {
static DOCTYPEPattern: [char; 6] = ['O', 'C', 'T', 'Y', 'P', 'E'];
}

View file

@ -10,7 +10,7 @@
use std::iter::{Range,range};
trait Itble<'r, T, I: Iterator<T>> { fn iter(&'r self) -> I; }
trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
impl<'r> Itble<'r, uint, Range<uint>> for (uint, uint) {
fn iter(&'r self) -> Range<uint> {
@ -19,8 +19,8 @@ impl<'r> Itble<'r, uint, Range<uint>> for (uint, uint) {
}
}
fn check<'r, I: Iterator<uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool
//~^ HELP as shown: fn check<'r, I: Iterator<uint>, T: Itble<'r, uint, I>>(cont: &'r T) -> bool
fn check<'r, I: Iterator<Item=uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool
//~^ HELP as shown: fn check<'r, I: Iterator<Item = uint>, T: Itble<'r, uint, I>>(cont: &'r T)
{
let cont_iter = cont.iter();
//~^ ERROR cannot infer an appropriate lifetime for autoref due to conflicting requirements

View file

@ -13,11 +13,11 @@ trait Node {
}
trait Graph<N: Node> {
fn nodes<'a, I: Iterator<&'a N>>(&'a self) -> I;
fn nodes<'a, I: Iterator<Item=&'a N>>(&'a self) -> I;
}
impl<N: Node> Graph<N> for Vec<N> {
fn nodes<'a, I: Iterator<&'a N>>(&self) -> I {
fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I {
self.iter() //~ ERROR mismatched types
}
}

View file

@ -12,7 +12,7 @@
use std::iter::{Range,range};
trait Itble<'r, T, I: Iterator<T>> { fn iter(&'r self) -> I; }
trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
impl<'r> Itble<'r, uint, Range<uint>> for (uint, uint) {
fn iter(&'r self) -> Range<uint> {
@ -21,8 +21,8 @@ impl<'r> Itble<'r, uint, Range<uint>> for (uint, uint) {
}
}
fn check<'r, I: Iterator<uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool {
//~^ HELP: consider using an explicit lifetime parameter as shown: fn check<'r, I: Iterator<uint>, T: Itble<'r, uint, I>>(cont: &'r T) -> bool
fn check<'r, I: Iterator<Item=uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool {
//~^ HELP: consider using an explicit lifetime parameter as shown: fn check<'r, I: Iterator<Item = uint>, T: Itble<'r, uint, I>>(cont: &'r T)
let cont_iter = cont.iter(); //~ ERROR: cannot infer
let result = cont_iter.fold(Some(0u16), |state, val| {
state.map_or(None, |mask| {

View file

@ -8,13 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(associated_types)]
struct StateMachineIter<'a> {
statefn: &'a StateMachineFunc<'a>
}
type StateMachineFunc<'a> = fn(&mut StateMachineIter<'a>) -> Option<&'static str>;
impl<'a> Iterator<&'static str> for StateMachineIter<'a> {
impl<'a> Iterator for StateMachineIter<'a> {
type Item = &'static str;
fn next(&mut self) -> Option<&'static str> {
return (*self.statefn)(self);
}

View file

@ -8,13 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(associated_types)]
use std::slice;
pub struct PhfMapEntries<'a, T: 'a> {
iter: slice::Iter<'a, (&'static str, T)>,
}
impl<'a, T> Iterator<(&'static str, &'a T)> for PhfMapEntries<'a, T> {
impl<'a, T> Iterator for PhfMapEntries<'a, T> {
type Item = (&'static str, &'a T);
fn next(&mut self) -> Option<(&'static str, &'a T)> {
self.iter.by_ref().map(|&(key, ref value)| (key, value)).next()
}

View file

@ -12,7 +12,7 @@
// lifetime parameters defined on the method bound correctly.
pub trait Foo {
fn bar<'a, I: Iterator<&'a ()>>(&self, it: I) -> uint {
fn bar<'a, I: Iterator<Item=&'a ()>>(&self, it: I) -> uint {
let mut xs = it.filter(|_| true);
xs.count()
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(associated_types)]
trait Matcher {
fn next_match(&mut self) -> Option<(uint, uint)>;
}
@ -40,7 +42,9 @@ struct MatchIndices<M> {
matcher: M
}
impl<M: Matcher> Iterator<(uint, uint)> for MatchIndices<M> {
impl<M: Matcher> Iterator for MatchIndices<M> {
type Item = (uint, uint);
fn next(&mut self) -> Option<(uint, uint)> {
self.matcher.next_match()
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(associated_types)]
trait MatrixRow {}
struct Mat;
@ -18,7 +20,9 @@ struct Rows<M: MatrixRow> {
mat: M,
}
impl<'a> Iterator<()> for Rows<&'a Mat> {
impl<'a> Iterator for Rows<&'a Mat> {
type Item = ();
fn next(&mut self) -> Option<()> {
unimplemented!()
}

View file

@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unsafe_destructor)]
#![feature(associated_types, unsafe_destructor)]
pub struct Foo<T>;
impl<T> Iterator<T> for Foo<T> {
impl<T> Iterator for Foo<T> {
type Item = T;
fn next(&mut self) -> Option<T> {
None
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo<'a, I>(mut it: I) where I: Iterator<&'a int> {}
fn foo<'a, I>(mut it: I) where I: Iterator<Item=&'a int> {}
fn main() {
foo([1i, 2].iter());