hyperium / http

Rust HTTP types
Apache License 2.0
1.16k stars 292 forks source link

Panics in const fn are now stable #564

Open vabka opened 2 years ago

vabka commented 2 years ago

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?

olix0r commented 2 years ago

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.

vabka commented 2 years ago

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 commented 2 years ago

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

seanmonstar commented 2 years ago

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.