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

ices/90400-1.rs: fixed with errors #1257

Merged
merged 1 commit into from
May 14, 2022
Merged

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#90400

#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]

trait Bar {
    fn bar(&self);
}

trait Foo {
    type FooFn<B>: FnOnce();
    
    fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B>;
}

struct MyFoo;

impl Foo for MyFoo {
    type FooFn<B> = impl FnOnce();
    
    fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
        move || { bar.bar() }
    }
}

fn main() {
    let boom: <MyFoo as Foo>::FooFn<u32> = unsafe { core::mem::zeroed() };
    boom();
}
=== stdout ===
=== stderr ===
error[E0277]: the trait bound `B: Bar` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/90400-1.rs:20:9
   |
20 |         move || { bar.bar() }
   |         ^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `B`
   |
note: required by a bound in `<MyFoo as Foo>::foo`
  --> /home/runner/work/glacier/glacier/ices/90400-1.rs:19:15
   |
19 |     fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
   |               ^^^ required by this bound in `<MyFoo as Foo>::foo`
help: consider restricting type parameter `B`
   |
17 |     type FooFn<B: Bar> = impl FnOnce();
   |                 +++++

error: aborting due to previous error

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

=== stdout ===
=== stderr ===
error[E0277]: the trait bound `B: Bar` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/90400-1.rs:20:9
   |
20 |         move || { bar.bar() }
   |         ^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `B`
   |
note: required by a bound in `<MyFoo as Foo>::foo`
  --> /home/runner/work/glacier/glacier/ices/90400-1.rs:19:15
   |
19 |     fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
   |               ^^^ required by this bound in `<MyFoo as Foo>::foo`
help: consider restricting type parameter `B`
   |
17 |     type FooFn<B: Bar> = impl FnOnce();
   |                 +++++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
==============
@JohnTitor JohnTitor merged commit c7837a1 into master May 14, 2022
@Alexendoo Alexendoo deleted the autofix/ices/90400-1.rs branch May 14, 2022 14:42
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