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

ices/93622.rs: fixed with errors #1688

Merged
merged 1 commit into from
Sep 24, 2023
Merged

ices/93622.rs: fixed with errors #1688

merged 1 commit into from
Sep 24, 2023

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#93622

#![feature(unsized_fn_params)]

pub enum Tree {
    Node(Box<Tree>, Box<Tree>),
    Leaf,
}

pub type Cont<'a> = dyn Fn(u64) -> u64 + 'a;

pub fn height_cps<'a>(x : &'a Tree, k : Cont<'a>) -> u64 {
    match x {
        Tree::Leaf => k(0),
        Tree::Node(l, r) => {
            //                                          v-- causes crash
            height_cps(l, {let k : Box<Cont> = Box::new(move |lh| {
                height_cps(r, {let k : Box<Cont> = Box::new(|lr| { k(1 + lh.max(lr)) }); *k})
            }); *k})
        }
    }
}

fn main () {
    height_cps(&Tree::Leaf, *(Box::new(|i| {i}) as Box<Cont>));
}
=== stdout ===
=== stderr ===
error[E0277]: the size for values of type `(dyn Fn(u64) -> u64 + 'a)` cannot be known at compilation time
  --> /home/runner/work/glacier/glacier/ices/93622.rs:16:68
   |
15 |             height_cps(l, {let k : Box<Cont> = Box::new(move |lh| {
   |                                                              ---- this closure captures all values by move
16 |                 height_cps(r, {let k : Box<Cont> = Box::new(|lr| { k(1 + lh.max(lr)) }); *k})
   |                                                                    ^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `(dyn Fn(u64) -> u64 + 'a)`
   = note: all values captured by value by a closure must have a statically known size

error: aborting due to previous error

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

=== stdout ===
=== stderr ===
error[E0277]: the size for values of type `(dyn Fn(u64) -> u64 + 'a)` cannot be known at compilation time
  --> /home/runner/work/glacier/glacier/ices/93622.rs:16:68
   |
15 |             height_cps(l, {let k : Box<Cont> = Box::new(move |lh| {
   |                                                              ---- this closure captures all values by move
16 |                 height_cps(r, {let k : Box<Cont> = Box::new(|lr| { k(1 + lh.max(lr)) }); *k})
   |                                                                    ^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `(dyn Fn(u64) -> u64 + 'a)`
   = note: all values captured by value by a closure must have a statically known size

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
==============
@JohnTitor JohnTitor merged commit 324d5a5 into master Sep 24, 2023
@JohnTitor JohnTitor deleted the autofix/ices/93622.rs branch September 24, 2023 14:21
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