Prepare for rust 1.62.1 (#11903)

* Update UI test output for rust 1.62.1

* switch ci to staging image to check that everything works

* fix artifacts node-bench-regression-guard

* Imeplement `scale_info::TypeInfo` manually to silence aggressive rust warning

* Fix more clippy lints

* Make clippy happy by relying on auto-deref were possible

* Add tracking issue to the comments

* pin ci image

Co-authored-by: alvicsam <alvicsam@gmail.com>
This commit is contained in:
Sebastian Kunert
2022-07-26 14:37:05 +02:00
committed by GitHub
parent 151c5d3fd9
commit 9f409dc0b8
45 changed files with 365 additions and 84 deletions
+31 -1
View File
@@ -24,7 +24,7 @@ use crate::{
use core::ops::Sub;
/// Piecewise Linear function in [0, 1] -> [0, 1].
#[derive(PartialEq, Eq, sp_core::RuntimeDebug, scale_info::TypeInfo)]
#[derive(PartialEq, Eq, sp_core::RuntimeDebug)]
pub struct PiecewiseLinear<'a> {
/// Array of points. Must be in order from the lowest abscissas to the highest.
pub points: &'a [(Perbill, Perbill)],
@@ -32,6 +32,36 @@ pub struct PiecewiseLinear<'a> {
pub maximum: Perbill,
}
// This can be replaced with
// #[derive(scale_info::TypeInfo)]
// #[scale_info(skip_type_params(S))]
// again once this issue is fixed in the rust compiler: https://github.com/rust-lang/rust/issues/96956
// Tracking issues: https://github.com/paritytech/substrate/issues/11915
impl scale_info::TypeInfo for PiecewiseLinear<'static> {
type Identity = Self;
fn type_info() -> ::scale_info::Type {
scale_info::Type::builder()
.path(scale_info::Path::new("PiecewiseLinear", "sp_runtime::curve"))
.type_params(crate::Vec::new())
.docs(&["Piecewise Linear function in [0, 1] -> [0, 1]."])
.composite(
scale_info::build::Fields::named()
.field(|f| {
f.ty::<&'static[(Perbill, Perbill)]>()
.name("points")
.type_name("&'static[(Perbill, Perbill)]")
.docs(&["Array of points. Must be in order from the lowest abscissas to the highest."])
})
.field(|f| {
f.ty::<Perbill>()
.name("maximum")
.type_name("Perbill")
.docs(&["The maximum value that can be returned."])
}),
)
}
}
fn abs_sub<N: Ord + Sub<Output = N> + Clone>(a: N, b: N) -> N where {
a.clone().max(b.clone()) - a.min(b)
}