Fix Rust beta compiler errors 1.78.0-beta.1 (#5439)

* remove redundant imports

* fix test

* contains key

* fmt

* Merge branch 'unstable' into fix-beta-compiler
This commit is contained in:
Eitan Seri-Levi
2024-03-20 07:17:02 +02:00
committed by GitHub
parent 4449627c7c
commit 01ec42e75a
148 changed files with 104 additions and 301 deletions

View File

@@ -6,6 +6,7 @@ use serde::Serialize;
use ssz::Encode;
use ssz_derive::{Decode, Encode};
use ssz_types::{typenum::U256, VariableList};
use std::fmt::Display;
use std::marker::PhantomData;
use std::ops::Deref;
use std::sync::Arc;
@@ -44,11 +45,13 @@ impl Deref for ErrorType {
}
}
impl ToString for ErrorType {
fn to_string(&self) -> String {
impl Display for ErrorType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
#[allow(clippy::invalid_regex)]
let re = Regex::new("\\p{C}").expect("Regex is valid");
String::from_utf8_lossy(&re.replace_all(self.0.deref(), &b""[..])).to_string()
let error_type_str =
String::from_utf8_lossy(&re.replace_all(self.0.deref(), &b""[..])).to_string();
write!(f, "{}", error_type_str)
}
}
@@ -580,7 +583,7 @@ impl<T: EthSpec> std::fmt::Display for RPCCodedResponse<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RPCCodedResponse::Success(res) => write!(f, "{}", res),
RPCCodedResponse::Error(code, err) => write!(f, "{}: {}", code, err.to_string()),
RPCCodedResponse::Error(code, err) => write!(f, "{}: {}", code, err),
RPCCodedResponse::StreamTermination(_) => write!(f, "Stream Termination"),
}
}