]> git.proxmox.com Git - rustc.git/blob - src/test/ui/never_type/issue-51506.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / never_type / issue-51506.rs
1 #![feature(never_type, specialization)]
2 #![allow(incomplete_features)]
3
4 use std::iter::{self, Empty};
5
6 trait Trait {
7 type Out: Iterator<Item = u32>;
8
9 fn f(&self) -> Option<Self::Out>;
10 }
11
12 impl<T> Trait for T {
13 default type Out = !; //~ ERROR: `!` is not an iterator
14
15 default fn f(&self) -> Option<Self::Out> {
16 None
17 }
18 }
19
20 struct X;
21
22 impl Trait for X {
23 type Out = Empty<u32>;
24
25 fn f(&self) -> Option<Self::Out> {
26 Some(iter::empty())
27 }
28 }
29
30 fn f<T: Trait>(a: T) {
31 if let Some(iter) = a.f() {
32 println!("Some");
33 for x in iter {
34 println!("x = {}", x);
35 }
36 }
37 }
38
39 pub fn main() {
40 f(10);
41 }