http icon indicating copy to clipboard operation
http copied to clipboard

Panics in const fn are now stable

Open vabka opened this issue 3 years ago • 4 comments

So we can replace https://github.com/hyperium/http/blob/master/src/header/name.rs#L1258

([] as [u8; 0])[0]; // Invalid header name

with adequate

panic!("Invalid header name");

Or im missing something and it will not going work?

vabka avatar Jul 30 '22 20:07 vabka

If I understand correctly, this would require changing the minimum supported Rust version.

From the Readme:

This project follows the Tokio MSRV and is currently set to 1.49.

olix0r avatar Jul 30 '22 21:07 olix0r

Tokio will keep a rolling MSRV (minimum supported rust version) policy of at least 6 months. When increasing the MSRV, the new Rust version must have been released at least six months ago. The current MSRV is 1.49.0.

Theoretically, tokio may switch to a newer 1.57 (released 7 month ago) version, which can compile const fn with panic.

vabka avatar Jul 30 '22 23:07 vabka

Asked a question in tokio repo: https://github.com/tokio-rs/tokio/discussions/4876, is it possible to bump MSRV

vabka avatar Jul 30 '22 23:07 vabka

We change it separately from Tokio.

My preference (without stating this is a requirement) is that we only increase the required version when it would give a significant improvement to users. Such as making it a const fn in the first place.

A better error message would be nice, but we could improve it with conditional compilation, and this not require everyone upgrade.

seanmonstar avatar Jul 31 '22 14:07 seanmonstar