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

ices/104196.rs: fixed with errors #1643

Merged
merged 1 commit into from
Oct 15, 2023
Merged

ices/104196.rs: fixed with errors #1643

merged 1 commit into from
Oct 15, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 5, 2023

Issue: rust-lang/rust#104196

use core::future::Future;

pub struct Struct<C, Fu, F>
where
    F: Fn(&C) -> Fu,
    Fu: Future,
{
    handler: F,
    context: C,
}

impl<C, Fu, R, F> Struct<C, Fu, F>
where
    F: Fn(&C) -> Fu,
    Fu: Future<Output = R>,
{
    pub const fn new(handler: F, context: C) -> Self {
        Self { handler, context }
    }
}

type TestC = &'static usize;
type TestFu = impl Future;
type TestF = impl Fn(&TestC) -> TestFu;
type TestStruct = Struct<TestC, TestFu, TestF>;

async fn test_handler(context: &TestC) -> () {
    ()
}

fn get_test_struct() -> &'static TestStruct {
    static test_actor: TestStruct = TestStruct::new(test_handler, &0);
    &test_actor
}

fn main() {}
=== stdout ===
=== stderr ===
error[E0658]: `impl Trait` in type aliases is unstable
  --> /home/runner/work/glacier/glacier/ices/104196.rs:23:15
   |
23 | type TestFu = impl Future;
   |               ^^^^^^^^^^^
   |
   = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
   = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

error[E0658]: `impl Trait` in type aliases is unstable
  --> /home/runner/work/glacier/glacier/ices/104196.rs:24:14
   |
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
   = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

error[E0391]: cycle detected when computing type of `TestF::{opaque#0}`
  --> /home/runner/work/glacier/glacier/ices/104196.rs:24:14
   |
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: ...which requires borrow-checking `get_test_struct::test_actor`...
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:5
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires promoting constants in MIR for `get_test_struct::test_actor`...
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:5
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `get_test_struct::test_actor`...
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:5
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: ...which requires computing whether `Struct<&usize, TestFu, TestF>` is freeze...
   = note: ...which requires evaluating trait selection obligation `Struct<&usize, TestFu, TestF>: core::marker::Freeze`...
   = note: ...which again requires computing type of `TestF::{opaque#0}`, completing the cycle
   = note: cycle used when evaluating trait selection obligation `Struct<&'static usize, TestFu, TestF>: core::marker::Sync`
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0700]: hidden type for `TestFu` captures lifetime that does not appear in bounds
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:37
   |
23 | type TestFu = impl Future;
   |               ----------- opaque type defined here
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |                      - hidden type `impl for<'a> Future<Output = ()>` captures the lifetime `'_` as defined here
...
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot check whether the hidden type of `104196[f0d6]::TestF::{opaque#0}` satisfies auto traits
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:24
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |                        ^^^^^^^^^^
   |
note: opaque type is declared here
  --> /home/runner/work/glacier/glacier/ices/104196.rs:24:14
   |
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because it appears within the type `Struct<&usize, TestFu, TestF>`
  --> /home/runner/work/glacier/glacier/ices/104196.rs:3:12
   |
3  | pub struct Struct<C, Fu, F>
   |            ^^^^^^
   = note: shared static variables must have a type that implements `Sync`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0391, E0658, E0700.
For more information about an error, try `rustc --explain E0391`.
==============

=== stdout ===
=== stderr ===
error[E0658]: `impl Trait` in type aliases is unstable
  --> /home/runner/work/glacier/glacier/ices/104196.rs:23:15
   |
23 | type TestFu = impl Future;
   |               ^^^^^^^^^^^
   |
   = note: see issue #63063 <rust-lang/rust#63063> for more information
   = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

error[E0658]: `impl Trait` in type aliases is unstable
  --> /home/runner/work/glacier/glacier/ices/104196.rs:24:14
   |
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #63063 <rust-lang/rust#63063> for more information
   = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

error[E0391]: cycle detected when computing type of `TestF::{opaque#0}`
  --> /home/runner/work/glacier/glacier/ices/104196.rs:24:14
   |
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: ...which requires borrow-checking `get_test_struct::test_actor`...
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:5
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires promoting constants in MIR for `get_test_struct::test_actor`...
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:5
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `get_test_struct::test_actor`...
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:5
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: ...which requires computing whether `Struct<&usize, TestFu, TestF>` is freeze...
   = note: ...which requires evaluating trait selection obligation `Struct<&usize, TestFu, TestF>: core::marker::Freeze`...
   = note: ...which again requires computing type of `TestF::{opaque#0}`, completing the cycle
   = note: cycle used when evaluating trait selection obligation `Struct<&'static usize, TestFu, TestF>: core::marker::Sync`
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0700]: hidden type for `TestFu` captures lifetime that does not appear in bounds
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:37
   |
23 | type TestFu = impl Future;
   |               ----------- opaque type defined here
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |                      - hidden type `impl for<'a> Future<Output = ()>` captures the lifetime `'_` as defined here
...
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot check whether the hidden type of `104196[f0d6]::TestF::{opaque#0}` satisfies auto traits
  --> /home/runner/work/glacier/glacier/ices/104196.rs:32:24
   |
32 |     static test_actor: TestStruct = TestStruct::new(test_handler, &0);
   |                        ^^^^^^^^^^
   |
note: opaque type is declared here
  --> /home/runner/work/glacier/glacier/ices/104196.rs:24:14
   |
24 | type TestF = impl Fn(&TestC) -> TestFu;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because it appears within the type `Struct<&usize, TestFu, TestF>`
  --> /home/runner/work/glacier/glacier/ices/104196.rs:3:12
   |
3  | pub struct Struct<C, Fu, F>
   |            ^^^^^^
   = note: shared static variables must have a type that implements `Sync`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0391, E0658, E0700.
For more information about an error, try `rustc --explain E0391`.
==============
@JohnTitor JohnTitor merged commit af9d970 into master Oct 15, 2023
@JohnTitor JohnTitor deleted the autofix/ices/104196.rs branch October 15, 2023 03:07
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