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
@@ -613,7 +613,7 @@ fn generate_api_impl_for_runtime_api(impls: &[ItemImpl]) -> Result<TokenStream>
let mut visitor = ApiRuntimeImplToApiRuntimeApiImpl {
runtime_block,
runtime_mod_path: &runtime_mod_path,
runtime_type: &*runtime_type,
runtime_type,
trait_generic_arguments: &trait_generic_arguments,
impl_trait: &impl_trait.ident,
};
@@ -104,10 +104,46 @@ where
/// A bounded slice.
///
/// Similar to a `BoundedVec`, but not owned and cannot be decoded.
#[derive(Encode, scale_info::TypeInfo)]
#[scale_info(skip_type_params(S))]
#[derive(Encode)]
pub struct BoundedSlice<'a, T, S>(pub(super) &'a [T], PhantomData<S>);
// 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<'a, T, S> scale_info::TypeInfo for BoundedSlice<'a, T, S>
where
&'a [T]: scale_info::TypeInfo + 'static,
PhantomData<S>: scale_info::TypeInfo + 'static,
T: scale_info::TypeInfo + 'static,
S: 'static,
{
type Identity = Self;
fn type_info() -> ::scale_info::Type {
scale_info::Type::builder()
.path(scale_info::Path::new("BoundedSlice", "sp_runtime::bounded::bounded_vec"))
.type_params(<[_]>::into_vec(Box::new([
scale_info::TypeParameter::new(
"T",
core::option::Option::Some(::scale_info::meta_type::<T>()),
),
scale_info::TypeParameter::new("S", ::core::option::Option::None),
])))
.docs(&[
"A bounded slice.",
"",
"Similar to a `BoundedVec`, but not owned and cannot be decoded.",
])
.composite(
scale_info::build::Fields::unnamed()
.field(|f| f.ty::<&'static [T]>().type_name("&'static[T]").docs(&[]))
.field(|f| f.ty::<PhantomData<S>>().type_name("PhantomData<S>").docs(&[])),
)
}
}
// `BoundedSlice`s encode to something which will always decode into a `BoundedVec`,
// `WeakBoundedVec`, or a `Vec`.
impl<'a, T: Encode + Decode, S: Get<u32>> EncodeLike<BoundedVec<T, S>> for BoundedSlice<'a, T, S> {}
+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)
}
+1 -1
View File
@@ -55,7 +55,7 @@ pub trait Lazy<T: ?Sized> {
impl<'a> Lazy<[u8]> for &'a [u8] {
fn get(&mut self) -> &[u8] {
&**self
self
}
}
+6 -6
View File
@@ -280,7 +280,7 @@ where
L: TrieConfiguration,
DB: hash_db::HashDBRef<L::Hash, trie_db::DBValue>,
{
TrieDB::<L>::new(&*db, root)?.get(key).map(|x| x.map(|val| val.to_vec()))
TrieDB::<L>::new(db, root)?.get(key).map(|x| x.map(|val| val.to_vec()))
}
/// Read a value from the trie with given Query.
@@ -295,7 +295,7 @@ where
Q: Query<L::Hash, Item = DBValue>,
DB: hash_db::HashDBRef<L::Hash, trie_db::DBValue>,
{
TrieDB::<L>::new(&*db, root)?
TrieDB::<L>::new(db, root)?
.get_with(key, query)
.map(|x| x.map(|val| val.to_vec()))
}
@@ -354,7 +354,7 @@ pub fn record_all_keys<L: TrieConfiguration, DB>(
where
DB: hash_db::HashDBRef<L::Hash, trie_db::DBValue>,
{
let trie = TrieDB::<L>::new(&*db, root)?;
let trie = TrieDB::<L>::new(db, root)?;
let iter = trie.iter()?;
for x in iter {
@@ -379,7 +379,7 @@ pub fn read_child_trie_value<L: TrieConfiguration, DB>(
where
DB: hash_db::HashDBRef<L::Hash, trie_db::DBValue>,
{
let db = KeySpacedDB::new(&*db, keyspace);
let db = KeySpacedDB::new(db, keyspace);
TrieDB::<L>::new(&db, root)?.get(key).map(|x| x.map(|val| val.to_vec()))
}
@@ -400,7 +400,7 @@ where
// root is fetched from DB, not writable by runtime, so it's always valid.
root.as_mut().copy_from_slice(root_slice);
let db = KeySpacedDB::new(&*db, keyspace);
let db = KeySpacedDB::new(db, keyspace);
TrieDB::<L>::new(&db, &root)?
.get_with(key, query)
.map(|x| x.map(|val| val.to_vec()))
@@ -501,7 +501,7 @@ where
T: Default + PartialEq<T> + for<'b> From<&'b [u8]> + Clone + Send + Sync,
{
fn as_hash_db(&self) -> &dyn hash_db::HashDB<H, T> {
&*self
self
}
fn as_hash_db_mut<'b>(&'b mut self) -> &'b mut (dyn hash_db::HashDB<H, T> + 'b) {
@@ -37,7 +37,7 @@ pub fn decl_runtime_version_impl(input: proc_macro::TokenStream) -> proc_macro::
}
fn decl_runtime_version_impl_inner(item: ItemConst) -> Result<TokenStream> {
let runtime_version = ParseRuntimeVersion::parse_expr(&*item.expr)?.build(item.expr.span())?;
let runtime_version = ParseRuntimeVersion::parse_expr(&item.expr)?.build(item.expr.span())?;
let link_section =
generate_emit_link_section_decl(&runtime_version.encode(), "runtime_version");