1
Fork 0

Add test for issue-51506

This commit is contained in:
Yuki Okushi 2020-06-23 17:52:26 +09:00
parent bb882d74bd
commit 43ef554b6a
No known key found for this signature in database
GPG key ID: B0986C85C0E2DAA1
2 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,41 @@
#![feature(never_type, specialization)]
#![allow(incomplete_features)]
use std::iter::{self, Empty};
trait Trait {
type Out: Iterator<Item = u32>;
fn f(&self) -> Option<Self::Out>;
}
impl<T> Trait for T {
default type Out = !; //~ ERROR: `!` is not an iterator
default fn f(&self) -> Option<Self::Out> {
None
}
}
struct X;
impl Trait for X {
type Out = Empty<u32>;
fn f(&self) -> Option<Self::Out> {
Some(iter::empty())
}
}
fn f<T: Trait>(a: T) {
if let Some(iter) = a.f() {
println!("Some");
for x in iter {
println!("x = {}", x);
}
}
}
pub fn main() {
f(10);
}

View file

@ -0,0 +1,14 @@
error[E0277]: `!` is not an iterator
--> $DIR/issue-51506.rs:13:5
|
LL | type Out: Iterator<Item = u32>;
| ------------------------------- required by `Trait::Out`
...
LL | default type Out = !;
| ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator
|
= help: the trait `std::iter::Iterator` is not implemented for `!`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.