From b8ddea7d21a415918ba3d1d40984ef5f1f3658e6 Mon Sep 17 00:00:00 2001 From: tottoto Date: Sat, 17 Feb 2024 05:05:14 +0900 Subject: [PATCH] refactor(header): add comment and lint allowing to panic in const context workaround --- src/header/name.rs | 6 ++++++ src/header/value.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/header/name.rs b/src/header/name.rs index 317bb8cf..e00e229d 100644 --- a/src/header/name.rs +++ b/src/header/name.rs @@ -1269,6 +1269,12 @@ impl HeaderName { i += 1; } } { + // TODO: When msrv is bumped to larger than 1.57, this should be + // replaced with `panic!` macro. + // https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html#panic-in-const-contexts + // + // See the panics section of this method's document for details. + #[allow(clippy::no_effect)] ([] as [u8; 0])[0]; // Invalid header name } diff --git a/src/header/value.rs b/src/header/value.rs index 509c4805..fb2a5c33 100644 --- a/src/header/value.rs +++ b/src/header/value.rs @@ -86,6 +86,12 @@ impl HeaderValue { let mut i = 0; while i < bytes.len() { if !is_visible_ascii(bytes[i]) { + // TODO: When msrv is bumped to larger than 1.57, this should be + // replaced with `panic!` macro. + // https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html#panic-in-const-contexts + // + // See the panics section of this method's document for details. + #[allow(clippy::no_effect)] ([] as [u8; 0])[0]; // Invalid header value } i += 1;