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

refactor: remove const_panic #14

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Changes from all commits
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
19 changes: 2 additions & 17 deletions src/principal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ use std::convert::TryFrom;
use std::fmt::Write;
use thiserror::Error;

// TODO: remove (blocked by rust-lang/rust#85194)
const ASSERT: [(); 1] = [()];
macro_rules! const_panic {
($($arg:tt)*) => {
#[allow(unconditional_panic)]
let _ = $crate::principal::ASSERT[1];
};
}

/// An error happened while encoding, decoding or serializing a principal.
#[derive(Error, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down Expand Up @@ -181,10 +172,7 @@ impl Principal {
if let Ok(v) = Self::try_from_slice(bytes) {
v
} else {
// TODO: replace with panic (blocked by rust-lang/rust#85194)
const_panic!("slice length exceeded capacity");
//panic!("slice length exceeds capacity")
Self::management_canister()
panic!("slice length exceeds capacity")
}
}

Expand Down Expand Up @@ -429,10 +417,7 @@ mod inner {
if let Some(v) = Self::try_from_slice(slice) {
v
} else {
// TODO: replace with panic (blocked by rust-lang/rust#85194)
const_panic!("slice length exceeded capacity");
Self::new()
//panic!("slice length exceeds capacity")
panic!("slice length exceeds capacity")
}
}

Expand Down