-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |