Add test for issue-51506
This commit is contained in:
parent
bb882d74bd
commit
43ef554b6a
2 changed files with 55 additions and 0 deletions
41
src/test/ui/never_type/issue-51506.rs
Normal file
41
src/test/ui/never_type/issue-51506.rs
Normal 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);
|
||||
}
|
14
src/test/ui/never_type/issue-51506.stderr
Normal file
14
src/test/ui/never_type/issue-51506.stderr
Normal 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`.
|
Loading…
Add table
Add a link
Reference in a new issue