Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/51506.rs: fixed with errors #406

Merged
merged 1 commit into from
Jun 22, 2020
Merged

ices/51506.rs: fixed with errors #406

merged 1 commit into from
Jun 22, 2020

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#51506

#![feature(never_type)]
#![feature(specialization)]

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 = !;

    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);
}
=== stdout ===
=== stderr ===
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /home/runner/work/glacier/glacier/ices/51506.rs:2:12
  |
2 | #![feature(specialization)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information

error[E0277]: `!` is not an iterator
  --> /home/runner/work/glacier/glacier/ices/51506.rs:13:5
   |
7  |     type Out: Iterator<Item = u32>;
   |     ------------------------------- required by `Trait::Out`
...
13 |     default type Out = !;
   |     ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator
   |
   = help: the trait `std::iter::Iterator` is not implemented for `!`

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
==============

=== stdout ===
=== stderr ===
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /home/runner/work/glacier/glacier/ices/51506.rs:2:12
  |
2 | #![feature(specialization)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #31844 <rust-lang/rust#31844> for more information

error[E0277]: `!` is not an iterator
  --> /home/runner/work/glacier/glacier/ices/51506.rs:13:5
   |
7  |     type Out: Iterator<Item = u32>;
   |     ------------------------------- required by `Trait::Out`
...
13 |     default type Out = !;
   |     ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator
   |
   = help: the trait `std::iter::Iterator` is not implemented for `!`

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
==============
@JohnTitor JohnTitor merged commit 4338359 into master Jun 22, 2020
@JohnTitor JohnTitor deleted the autofix/ices/51506.rs branch June 22, 2020 12:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants