]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-13058.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / issues / issue-13058.rs
1 // Copyright 2014 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 use std::ops::Range;
12
13 trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
14
15 impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
16     fn iter(&'r self) -> Range<usize> {
17         let &(min, max) = self;
18         min..max
19     }
20 }
21
22 fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
23 {
24     let cont_iter = cont.iter();
25 //~^ ERROR 24:26: 24:30: explicit lifetime required in the type of `cont` [E0621]
26     let result = cont_iter.fold(Some(0), |state, val| {
27         state.map_or(None, |mask| {
28             let bit = 1 << val;
29             if mask & bit == 0 {Some(mask|bit)} else {None}
30         })
31     });
32     result.is_some()
33 }
34
35 fn main() {
36     check((3, 5));
37 //~^ ERROR mismatched types
38 }