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

ices/87142.sh: fixed with no errors #1171

Merged
merged 1 commit into from
Mar 16, 2022
Merged

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#87142

#!/usr/bin/env bash

rustc - --crate-type lib -C debuginfo=2 << 'EOF'
#![feature(type_alias_impl_trait, generator_trait, generators)]
use std::ops::{Generator};

pub trait GeneratorProviderAlt: Sized {
    type Gen: Generator<(), Return=(), Yield=()>;

    fn start(ctx: Context<Self>) -> Self::Gen;
}

pub struct Context<G: 'static + GeneratorProviderAlt> {
    // back-link to our generator state
    // In reality some other pointer type, but Box triggers the bug
    // Also in reality, points to a wrapper struct that only indirectly holds
    //   the generator state.
    link: Box<G::Gen>,
}

impl GeneratorProviderAlt for () {
    type Gen = impl Generator<(), Return=(), Yield=()>;
    fn start(ctx: Context<Self>) -> Self::Gen {
        move || {
            match ctx { _ => () } // make sure to use the context
            yield ();
        }
    }
}
EOF
=== stdout ===
=== stderr ===
warning: field is never read: `link`
  --> <anon>:15:5
   |
15 |     link: Box<G::Gen>,
   |     ^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

==============

=== stdout ===
=== stderr ===
warning: field is never read: `link`
  --> <anon>:15:5
   |
15 |     link: Box<G::Gen>,
   |     ^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

==============
@Alexendoo Alexendoo merged commit 8805b77 into master Mar 16, 2022
@Alexendoo Alexendoo deleted the autofix/ices/87142.sh branch March 16, 2022 13:04
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.

2 participants