gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Parsing error on `box` keyword

Open CohenArthur opened this issue 2 years ago • 3 comments

I tried this code:

fn foo(x: i32) -> Box<i32> {
    box x
}

I expected to see this happen: no parsing error, but an error about that syntax being experimental

Instead, this happened: unexpected token box

This is not an issue for the libcore 1.49 project, but we will need to eventually handle that syntax for liballoc and libstd 1.49. This requires parsing as well as proper handling later in the pipeline.

CohenArthur avatar Feb 14 '23 16:02 CohenArthur

With recent rustc versions this has been replaced with impl Box<T> { fn new(val: T) -> Box<T> { #[rustc_box] Box::new(val) } } which effectively does the same.

bjorn3 avatar Feb 14 '23 16:02 bjorn3

Ah, that's nice thanks @bjorn3! I like that more. But if we want to compile liballoc 1.49 we'll sadly still have to deal with it

CohenArthur avatar Feb 14 '23 16:02 CohenArthur

I'll work on this one.

charmitro avatar Jun 08 '23 09:06 charmitro