Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

fix deprecated usage of panic #8134

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ where
) {
extrinsics.into_iter().for_each(|e| if let Err(e) = Self::apply_extrinsic(e) {
let err: &'static str = e.into();
panic!(err)
panic!("{}", err)
Copy link
Contributor

@ascjones ascjones Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the error implement Display itself?

Edit: It does but only in std

#[cfg(feature = "std")]
impl std::fmt::Display for TransactionValidityError {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah only on "std", I guess we can implement display on on not(std) as well

});

// post-extrinsics book-keeping
Expand Down
4 changes: 2 additions & 2 deletions frame/staking/reward-curve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ fn generate_piecewise_linear(points: Vec<(u32, u32)>) -> TokenStream2 {
.unwrap_or(1_000_000_000);

for (x, y) in points {
let error = || panic!(format!(
let error = || panic!(
"Generated reward curve approximation doesn't fit into [0, 1] -> [0, 1] \
because of point:
x = {:07} per million
y = {:07} per million",
x, y
));
);

let x_perbill = x.checked_mul(1_000).unwrap_or_else(error);
let y_perbill = y.checked_mul(1_000).unwrap_or_else(error);
Expand Down