]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-13058.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / 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 //~^ HELP as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T)
24 {
25 let cont_iter = cont.iter();
26 //~^ ERROR cannot infer an appropriate lifetime for autoref due to conflicting requirements
27 let result = cont_iter.fold(Some(0), |state, val| {
28 state.map_or(None, |mask| {
29 let bit = 1 << val;
30 if mask & bit == 0 {Some(mask|bit)} else {None}
31 })
32 });
33 result.is_some()
34 }
35
36 fn main() {
37 check((3, 5));
38 //~^ ERROR mismatched types
39 //~| HELP run `rustc --explain E0308` to see a detailed explanation
40 }