nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: alexcrichton/proc-macro2
Pull request #46 (2018-01-05 19:18:16)

Ensure that float literal is always formatted as floating point
Previously `Literal::float` could print as something that parsed as an integer.


Patch:
diff --git a/src/stable.rs b/src/stable.rs
index 984a146..b5820b1 100644
--- a/src/stable.rs
+++ b/src/stable.rs
@@ -492,8 +492,15 @@ impl Literal {
         Literal(s.to_string())
     }
 
-    pub fn float(s: f64) -> Literal {
-        Literal(s.to_string())
+    pub fn float(n: f64) -> Literal {
+        if !n.is_finite() {
+            panic!("Invalid float literal {}", n);
+        }
+        let mut s = n.to_string();
+        if !s.contains('.') {
+            s += ".0";
+        }
+        Literal(s)
     }
 
     pub fn integer(s: i64) -> Literal {


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 89f7b10..19f7b27 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -19,6 +19,7 @@ fn symbols() {
 fn literals() {
     assert_eq!(Literal::string("foo").to_string(), "\"foo\"");
     assert_eq!(Literal::string("\"").to_string(), "\"\\\"\"");
+    assert_eq!(Literal::float(10.0).to_string(), "10.0");
 }
 
 #[test]
Repository: alexcrichton/proc-macro2
Pull request #252 (2020-09-25 19:07:29)

Parse integer suffix beginning with a hex digit
Previously e.g. `0o0A` would fail to lex because `A` is not a permissible octal digit. It doesn't need to be a digit though. This is an octal literal `0o0` with suffix `A`.

This matches libproc_macro's behavior which parses it as:

```rust
Literal {
    kind: Integer,
    symbol: "0o0",
    suffix: Some("A"),
    span: #7 bytes(88..92),
}
```

https://github.com/dtolnay/syn/issues/897


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index f4f8a47..36d4f28 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -648,10 +648,25 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
     let mut len = 0;
     let mut empty = true;
     for b in input.bytes() {
-        let digit = match b {
-            b'0'..=b'9' => (b - b'0') as u64,
-            b'a'..=b'f' => 10 + (b - b'a') as u64,
-            b'A'..=b'F' => 10 + (b - b'A') as u64,
+        match b {
+            b'0'..=b'9' => {
+                let digit = (b - b'0') as u64;
+                if digit >= base {
+                    return Err(LexError);
+                }
+            }
+            b'a'..=b'f' => {
+                let digit = 10 + (b - b'a') as u64;
+                if digit >= base {
+                    break;
+                }
+            }
+            b'A'..=b'F' => {
+                let digit = 10 + (b - b'A') as u64;
+                if digit >= base {
+                    break;
+                }
+            }
             b'_' => {
                 if empty && base == 10 {
                     return Err(LexError);
@@ -661,9 +676,6 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
             }
             _ => break,
         };
-        if digit >= base {
-            return Err(LexError);
-        }
         len += 1;
         empty = false;
     }


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 8bd6bf9..895d507 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -115,6 +115,8 @@ fn literal_suffix() {
     assert_eq!(token_count("r#\"\"#r"), 1);
     assert_eq!(token_count("'c'c"), 1);
     assert_eq!(token_count("b'b'b"), 1);
+    assert_eq!(token_count("0E"), 1);
+    assert_eq!(token_count("0o0A"), 1);
 }
 
 #[test]
Repository: alexcrichton/proc-macro2
Pull request #253 (2020-09-25 19:11:13)

Reject duplicate sign in float literal
Previously we'd just pass over as many consecutive `-`/`+` signs as the caller felt like, which is not correct. `0E--0`

https://github.com/dtolnay/syn/issues/897


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index 36d4f28..5200cec 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -591,6 +591,7 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
     }
 
     if has_exp {
+        let mut has_sign = false;
         let mut has_exp_value = false;
         while let Some(&ch) = chars.peek() {
             match ch {
@@ -598,8 +599,12 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
                     if has_exp_value {
                         break;
                     }
+                    if has_sign {
+                        return Err(LexError);
+                    }
                     chars.next();
                     len += 1;
+                    has_sign = true;
                 }
                 '0'..='9' => {
                     chars.next();


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 895d507..4232e45 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -117,6 +117,7 @@ fn literal_suffix() {
     assert_eq!(token_count("b'b'b"), 1);
     assert_eq!(token_count("0E"), 1);
     assert_eq!(token_count("0o0A"), 1);
+    assert_eq!(token_count("0E--0"), 4);
 }
 
 #[test]
Repository: alexcrichton/proc-macro2
Pull request #255 (2020-09-25 19:25:44)

Parse float suffix beginning with `E`
Previously `0.0asdf` would parse as a float literal with suffix `asdf` but `0.0ECMA` would not parse as a float literal with suffix `ECMA`.


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index a4e5262..c8446b0 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -590,6 +590,11 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
     }
 
     if has_exp {
+        let token_before_exp = if has_dot {
+            Ok(input.advance(len - 1))
+        } else {
+            Err(LexError)
+        };
         let mut has_sign = false;
         let mut has_exp_value = false;
         while let Some(&ch) = chars.peek() {
@@ -599,7 +604,7 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
                         break;
                     }
                     if has_sign {
-                        return Err(LexError);
+                        return token_before_exp;
                     }
                     chars.next();
                     len += 1;
@@ -618,7 +623,7 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
             }
         }
         if !has_exp_value {
-            return Err(LexError);
+            return token_before_exp;
         }
     }
 


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 4232e45..db3be12 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -118,6 +118,7 @@ fn literal_suffix() {
     assert_eq!(token_count("0E"), 1);
     assert_eq!(token_count("0o0A"), 1);
     assert_eq!(token_count("0E--0"), 4);
+    assert_eq!(token_count("0.0ECMA"), 1);
 }
 
 #[test]
Repository: alexcrichton/proc-macro2
Pull request #256 (2020-09-26 00:57:54)

Allow only at most 6 digits in unicode escape
Rustc rejects unicode escapes longer than 6 digits, not including `_`.

```console
error: overlong unicode escape (must have at most 6 hex digits)
 --> src/main.rs:2:14
  |
2 |     let _ = "\u{0000000}";
  |              ^^^^^^^^^^^
```


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index adf7119..b4eb281 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -525,12 +525,21 @@ where
 {
     next_ch!(chars @ '{');
     next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
-    loop {
-        let c = next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F' | '_' | '}');
-        if c == '}' {
-            return true;
+    let mut digits = 1;
+    while let Some((_, ch)) = chars.next() {
+        match ch {
+            '}' => return true,
+            '0'..='9' | 'a'..='f' | 'A'..='F' => {
+                digits += 1;
+                if digits > 6 {
+                    return false;
+                }
+            }
+            '_' => {}
+            _ => return false,
         }
     }
+    false
 }
 
 fn float(input: Cursor) -> Result<Cursor, LexError> {


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index db3be12..4cc1f4d 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -191,6 +191,7 @@ fn fail() {
     fail("' static");
     fail("r#1");
     fail("r#_");
+    fail("\"\\u{0000000}\""); // overlong unicode escape (rust allows at most 6 hex digits)
 }
 
 #[cfg(span_locations)]
Repository: alexcrichton/proc-macro2
Pull request #257 (2020-09-26 01:52:40)

Disallow unicode escapes that are out of range, empty, or begin with underscore
- ~~`"\u{999999}"`~~
- ~~`"\u{}"`~~
- ~~`"\u{_0}"`~~


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index b4eb281..a146b24 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -2,6 +2,7 @@ use crate::fallback::{
     is_ident_continue, is_ident_start, Group, LexError, Literal, Span, TokenStream,
 };
 use crate::{Delimiter, Punct, Spacing, TokenTree};
+use std::char;
 use std::str::{Bytes, CharIndices, Chars};
 
 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -524,20 +525,23 @@ where
     I: Iterator<Item = (usize, char)>,
 {
     next_ch!(chars @ '{');
-    next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
-    let mut digits = 1;
+    let mut value = 0;
+    let mut len = 0;
     while let Some((_, ch)) = chars.next() {
-        match ch {
-            '}' => return true,
-            '0'..='9' | 'a'..='f' | 'A'..='F' => {
-                digits += 1;
-                if digits > 6 {
-                    return false;
-                }
-            }
-            '_' => {}
+        let digit = match ch {
+            '0'..='9' => ch as u8 - b'0',
+            'a'..='f' => 10 + ch as u8 - b'a',
+            'A'..='F' => 10 + ch as u8 - b'A',
+            '_' if len > 0 => continue,
+            '}' if len > 0 => return char::from_u32(value).is_some(),
             _ => return false,
+        };
+        if len == 6 {
+            return false;
         }
+        value *= 0x10;
+        value += u32::from(digit);
+        len += 1;
     }
     false
 }


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 4cc1f4d..2564c46 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -192,6 +192,9 @@ fn fail() {
     fail("r#1");
     fail("r#_");
     fail("\"\\u{0000000}\""); // overlong unicode escape (rust allows at most 6 hex digits)
+    fail("\"\\u{999999}\""); // outside of valid range of char
+    fail("\"\\u{_0}\""); // leading underscore
+    fail("\"\\u{}\""); // empty
 }
 
 #[cfg(span_locations)]
Repository: alexcrichton/proc-macro2
Pull request #258 (2020-09-26 02:29:26)

Disallow bare carriage return in raw string literal
This is disallowed by rustc (though notice that the diagnostic is hilariously actually returning the carriage):

```console
error: bare CR not allowed in raw string
 --> src/main.rs:2:15
  |
";|     let s = r"
  |               ^
```


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index a146b24..6c194fb 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -438,7 +438,7 @@ fn raw_string(input: Cursor) -> Result<Cursor, LexError> {
                 let rest = input.advance(i + 1 + n);
                 return Ok(literal_suffix(rest));
             }
-            '\r' => {}
+            '\r' => return Err(LexError),
             _ => {}
         }
     }


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 2564c46..4f46a0c 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -195,6 +195,8 @@ fn fail() {
     fail("\"\\u{999999}\""); // outside of valid range of char
     fail("\"\\u{_0}\""); // leading underscore
     fail("\"\\u{}\""); // empty
+    fail("b\"\r\""); // bare carriage return in byte string
+    fail("r\"\r\""); // bare carriage return in raw string
 }
 
 #[cfg(span_locations)]
Repository: alexcrichton/proc-macro2
Pull request #259 (2020-09-26 02:56:50)

Require newline after backslash carriage return
Carriage return is only accepted if immediately followed by a newline, whether or not the carriage return is preceded by `\`.


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index 6c194fb..ef2fdcf 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -349,7 +349,10 @@ fn cooked_string(input: Cursor) -> Result<Cursor, LexError> {
                         break;
                     }
                 }
-                Some((_, '\n')) | Some((_, '\r')) => {
+                Some((_, ch @ '\n')) | Some((_, ch @ '\r')) => {
+                    if ch == '\r' && chars.next().map_or(true, |(_, ch)| ch != '\n') {
+                        return Err(LexError);
+                    }
                     while let Some(&(_, ch)) = chars.peek() {
                         if ch.is_whitespace() {
                             chars.next();
@@ -399,7 +402,10 @@ fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, LexError> {
                 }
                 Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\'))
                 | Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {}
-                Some((newline, b'\n')) | Some((newline, b'\r')) => {
+                Some((newline, b @ b'\n')) | Some((newline, b @ b'\r')) => {
+                    if b == b'\r' && bytes.next().map_or(true, |(_, b)| b != b'\n') {
+                        return Err(LexError);
+                    }
                     let rest = input.advance(newline + 1);
                     for (offset, ch) in rest.char_indices() {
                         if !ch.is_whitespace() {


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 4f46a0c..37c8ad6 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -197,6 +197,7 @@ fn fail() {
     fail("\"\\u{}\""); // empty
     fail("b\"\r\""); // bare carriage return in byte string
     fail("r\"\r\""); // bare carriage return in raw string
+    fail("\"\\\r  \""); // backslash carriage return
 }
 
 #[cfg(span_locations)]
Repository: alexcrichton/proc-macro2
Pull request #260 (2020-09-26 03:47:01)

Disallow lifetime followed immediately by single quote
This is not lexed as two consecutive lifetime tokens in Rust.

```rust
macro_rules! m {
    ($($tt:tt)*) => {};
}

m!('aa'aa);
```

```console
error: character literal may only contain one codepoint
 --> src/main.rs:5:4
  |
5 | m!('aa'aa);
  |    ^^^^
  |
help: if you meant to write a `str` literal, use double quotes
  |
5 | m!("aa"aa);
  |    ^^^^
```


Patch:
diff --git a/src/parse.rs b/src/parse.rs
index ef2fdcf..bad1fa1 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -716,8 +716,11 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
 fn op(input: Cursor) -> PResult<Punct> {
     match op_char(input) {
         Ok((rest, '\'')) => {
-            ident(rest)?;
-            Ok((rest, Punct::new('\'', Spacing::Joint)))
+            if ident(rest)?.0.starts_with("'") {
+                Err(LexError)
+            } else {
+                Ok((rest, Punct::new('\'', Spacing::Joint)))
+            }
         }
         Ok((rest, ch)) => {
             let kind = match op_char(rest) {


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 37c8ad6..2cf0a4c 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -198,6 +198,7 @@ fn fail() {
     fail("b\"\r\""); // bare carriage return in byte string
     fail("r\"\r\""); // bare carriage return in raw string
     fail("\"\\\r  \""); // backslash carriage return
+    fail("'aa'aa");
 }
 
 #[cfg(span_locations)]
Repository: alexcrichton/toml-rs
Pull request #151 (2017-02-19 15:25:15)

Fixed sorting of table values
Fixes writing array after normal values when writing table, that caused this diff after deserialization and serialization to `toml::Value`.
```diff
 [package]
-authors = ["The Gtk-rs Project Developers"]
 build = "build.rs"
 description = "FFI bindings to libpango-1.0"
 homepage = "http://gtk-rs.org/"
-keywords = ["pango", "ffi", "gtk-rs", "gnome"]
 license = "MIT"
 links = "pango"
 name = "pango-sys"
 repository = "https://github.com/gtk-rs/sys"
 version = "0.3.2"
+authors = ["The Gtk-rs Project Developers"]
+keywords = ["pango", "ffi", "gtk-rs", "gnome"]
```


Patch:
diff --git a/src/value.rs b/src/value.rs
index 4d56023..3a366d8 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -367,12 +367,12 @@ impl ser::Serialize for Value {
                 // array-of-tables) as all keys must be emitted first.
                 for (k, v) in t {
                     if !v.is_table() && !v.is_array() ||
-                       (v.as_array().map(|a| a.len() == 0).unwrap_or(false)) {
+                       (v.as_array().map(|a| !a.iter().any(|v| v.is_table())).unwrap_or(false)) {
                         map.serialize_entry(k, v)?;
                     }
                 }
                 for (k, v) in t {
-                    if v.as_array().map(|a| a.len() > 0).unwrap_or(false) {
+                    if v.as_array().map(|a| a.iter().any(|v| v.is_table())).unwrap_or(false) {
                         map.serialize_entry(k, v)?;
                     }
                 }


Test patch:
diff --git a/tests/display.rs b/tests/display.rs
index c38355a..ca4fdd8 100644
--- a/tests/display.rs
+++ b/tests/display.rs
@@ -94,4 +94,10 @@ fn table() {
                 \n\
                 [[test2]]\n\
                 test = [[2, 3], [\"foo\", \"bar\"]]\n");
+    assert_eq!(Table(map! {
+                    "test" => Array(vec![Integer(2)]),
+                    "test2" => Integer(2)
+               }).to_string(),
+               "test = [2]\n\
+                test2 = 2\n");
 }
Repository: alexcrichton/toml-rs
Pull request #182 (2017-05-30 22:35:34)

Fix some fuzzing bugs


Patch:
diff --git a/src/datetime.rs b/src/datetime.rs
index 7917cad..f39d9fa 100644
--- a/src/datetime.rs
+++ b/src/datetime.rs
@@ -55,7 +55,7 @@ struct Time {
     hour: u8,
     minute: u8,
     second: u8,
-    secfract: Option<f64>,
+    secfract: f64,
 }
 
 #[derive(PartialEq, Clone)]
@@ -97,8 +97,8 @@ impl fmt::Display for Date {
 impl fmt::Display for Time {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{:02}:{:02}:{:02}", self.hour, self.minute, self.second)?;
-        if let Some(i) = self.secfract {
-            let s = format!("{}", i);
+        if self.secfract != 0.0 {
+            let s = format!("{}", self.secfract);
             write!(f, "{}", s.trim_left_matches("0"))?;
         }
         Ok(())
@@ -219,11 +219,11 @@ impl FromStr for Datetime {
                 }
                 chars = whole[end..].chars();
                 match format!("0.{}", &whole[..end]).parse() {
-                    Ok(f) => Some(f),
+                    Ok(f) => f,
                     Err(_) => return Err(DatetimeParseError { _private: () }),
                 }
             } else {
-                None
+                0.0
             };
 
             let time = Time {
diff --git a/src/ser.rs b/src/ser.rs
index 9af304f..de5d41c 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -290,7 +290,7 @@ impl<'a> Serializer<'a> {
                 '\u{22}' => drop(write!(self.dst, "\\\"")),
                 '\u{5c}' => drop(write!(self.dst, "\\\\")),
                 c if c < '\u{1f}' => {
-                    drop(write!(self.dst, "\\u{:04}", ch as u32))
+                    drop(write!(self.dst, "\\u{:04X}", ch as u32))
                 }
                 ch => drop(write!(self.dst, "{}", ch)),
             }


Test patch:
diff --git a/tests/valid/unicode-escape.json b/tests/valid/unicode-escape.json
index 8c09dc0..32948c6 100644
--- a/tests/valid/unicode-escape.json
+++ b/tests/valid/unicode-escape.json
@@ -1,4 +1,5 @@
 {
+    "answer1": {"type": "string", "value": "\u000B"},
     "answer4": {"type": "string", "value": "\u03B4α"},
     "answer8": {"type": "string", "value": "\u03B4β"}
 }
diff --git a/tests/valid/unicode-escape.toml b/tests/valid/unicode-escape.toml
index 20198f4..c0d5a25 100644
--- a/tests/valid/unicode-escape.toml
+++ b/tests/valid/unicode-escape.toml
@@ -1,2 +1,3 @@
+answer1 = "\u000B"
 answer4 = "\u03B4α"
 answer8 = "\U000003B4β"
Repository: algesten/ureq
Pull request #176 (2020-10-04 08:55:33)

Replace lazy_static! with once_cell Lazy
Modern rust code bases prefer once_cell::sync::Lazy over the older
macro based lazy_static.

Notice we still have `lazy_static` in the tree, but only for tests. If we run `cargo tree` without test deps, we are now lazy_static free:

```bash
cargo tree -e normal,build
```


algesten: @jsha just a small code hygien PR.
jsha: Nice cleanup! 🧹 

Patch:
diff --git a/Cargo.toml b/Cargo.toml
index e562bc3..d71fb83 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,7 @@ socks-proxy = ["socks"]
 base64 = "0.13"
 chunked_transfer = "1.2.0"
 cookie = { version = "0.14", features = ["percent-encode"], optional = true}
-lazy_static = "1"
+once_cell = "1"
 qstring = "0.7"
 url = "2"
 socks = { version = "0.3.2", optional = true }
diff --git a/src/stream.rs b/src/stream.rs
index 0697f93..84ac940 100644
--- a/src/stream.rs
+++ b/src/stream.rs
@@ -327,16 +327,14 @@ fn configure_certs(config: &mut rustls::ClientConfig) {
 
 #[cfg(all(feature = "tls", not(feature = "native-tls")))]
 pub(crate) fn connect_https(unit: &Unit, hostname: &str) -> Result<Stream, Error> {
-    use lazy_static::lazy_static;
+    use once_cell::sync::Lazy;
     use std::sync::Arc;
 
-    lazy_static! {
-        static ref TLS_CONF: Arc<rustls::ClientConfig> = {
-            let mut config = rustls::ClientConfig::new();
-            configure_certs(&mut config);
-            Arc::new(config)
-        };
-    }
+    static TLS_CONF: Lazy<Arc<rustls::ClientConfig>> = Lazy::new(|| {
+        let mut config = rustls::ClientConfig::new();
+        configure_certs(&mut config);
+        Arc::new(config)
+    });
 
     let port = unit.url.port().unwrap_or(443);
 


Test patch:
diff --git a/src/test/mod.rs b/src/test/mod.rs
index 801b7c9..d6f9306 100644
--- a/src/test/mod.rs
+++ b/src/test/mod.rs
@@ -1,7 +1,7 @@
 use crate::error::Error;
 use crate::stream::Stream;
 use crate::unit::Unit;
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
 use std::collections::HashMap;
 use std::io::{Cursor, Write};
 use std::sync::{Arc, Mutex};
@@ -19,10 +19,8 @@ mod timeout;
 
 type RequestHandler = dyn Fn(&Unit) -> Result<Stream, Error> + Send + 'static;
 
-lazy_static! {
-    pub(crate) static ref TEST_HANDLERS: Arc<Mutex<HashMap<String, Box<RequestHandler>>>> =
-        Arc::new(Mutex::new(HashMap::new()));
-}
+pub(crate) static TEST_HANDLERS: Lazy<Arc<Mutex<HashMap<String, Box<RequestHandler>>>>> =
+    Lazy::new(|| Arc::new(Mutex::new(HashMap::new())));
 
 pub(crate) fn set_handler<H>(path: &str, handler: H)
 where