Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump MSRV to 1.71.1 #1119

Merged
merged 35 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dfaa738
bump msrv to 1.71.1
rnbguy Mar 9, 2024
513594c
add ci check
rnbguy Mar 9, 2024
bbe76bf
rm windows
rnbguy Mar 9, 2024
e022acf
refactor msrv check
rnbguy Mar 9, 2024
28947f6
use cargo-msrv
rnbguy Mar 9, 2024
44c64d0
add names to steps
rnbguy Mar 9, 2024
cd44a48
apply clippy suggestions
rnbguy Mar 9, 2024
b640135
rm redundant import
rnbguy Mar 9, 2024
568a5a2
clippy::use_self
rnbguy Mar 10, 2024
f5c12ff
clippy::cast_lossless
rnbguy Mar 10, 2024
0544df3
clippy::match_same_arms
rnbguy Mar 10, 2024
0a1a708
apply clippy suggestions
rnbguy Mar 10, 2024
aff9942
reuse old var
rnbguy Mar 10, 2024
fcda368
refactor old code
rnbguy Mar 10, 2024
38b5371
badge for license, version, downloads
rnbguy Mar 10, 2024
665fc15
rm broken tokei loc badge
rnbguy Mar 10, 2024
e065529
add changelog
rnbguy Mar 11, 2024
2084711
clippy::derive_partial_eq_without_eq
rnbguy Mar 11, 2024
ac7c4ab
clippy::string_lit_as_bytes
rnbguy Mar 11, 2024
cb32ce8
clippy::empty_line_after_doc_comments
rnbguy Mar 11, 2024
604c69e
clippy::cloned_instead_of_copied
rnbguy Mar 11, 2024
8587c28
clippy::unreadable_literal
rnbguy Mar 11, 2024
8ba7ad1
clippy::single_match_else
rnbguy Mar 11, 2024
e1c14a1
expect over unwrap
rnbguy Mar 11, 2024
91d2c68
use let-else
rnbguy Mar 11, 2024
5b221d4
use ok_or_else
rnbguy Mar 11, 2024
0f8001d
propagate None
rnbguy Mar 11, 2024
6acf412
clippy::match_same_arms
rnbguy Mar 11, 2024
b50d08b
return precise error
rnbguy Mar 11, 2024
4b0f27f
rm downcast in favor of let-else
rnbguy Mar 11, 2024
1e90a9b
chore: add unclog for 1101 + move 1118 under breaking-changes
Farhad-Shabani Mar 11, 2024
c7beb71
add msrv in clippy config
rnbguy Mar 12, 2024
332c5de
update changelog
rnbguy Mar 12, 2024
d435bda
use into over from
rnbguy Mar 12, 2024
6161f2c
clippy::redundant_closure_for_method_calls
rnbguy Mar 12, 2024
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
Prev Previous commit
Next Next commit
clippy::use_self
  • Loading branch information
rnbguy committed Mar 10, 2024
commit 568a5a25664b74cca4697933559f4c2668cf0c4f
4 changes: 2 additions & 2 deletions ibc-derive/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) struct ClientCtx {

impl ClientCtx {
fn new(ident: Ident, generics: Vec<GenericArgument>, predicates: Vec<WherePredicate>) -> Self {
ClientCtx {
Self {
ident,
generics,
predicates,
Expand Down Expand Up @@ -104,7 +104,7 @@ impl Opts {
let client_execution_context = client_execution_context
.ok_or_else(|| Error::new_spanned(ast, MISSING_EXECUTION_ATTR))?;

Ok(Opts {
Ok(Self {
client_validation_context,
client_execution_context,
})
Expand Down
41 changes: 20 additions & 21 deletions ibc-primitives/src/types/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ impl borsh::BorshDeserialize for Timestamp {
reader: &mut R,
) -> borsh::maybestd::io::Result<Self> {
let timestamp = u64::deserialize_reader(reader)?;
Ok(Timestamp::from_nanoseconds(timestamp)
.map_err(|_| borsh::maybestd::io::ErrorKind::Other)?)
Ok(Self::from_nanoseconds(timestamp).map_err(|_| borsh::maybestd::io::ErrorKind::Other)?)
}
}

Expand All @@ -66,7 +65,7 @@ impl parity_scale_codec::Decode for Timestamp {
input: &mut I,
) -> Result<Self, parity_scale_codec::Error> {
let timestamp = u64::decode(input)?;
Timestamp::from_nanoseconds(timestamp)
Self::from_nanoseconds(timestamp)
.map_err(|_| parity_scale_codec::Error::from("from nanoseconds error"))
}
}
Expand Down Expand Up @@ -108,9 +107,9 @@ impl Timestamp {
/// is not set. In this case, our domain type takes the
/// value of None.
///
pub fn from_nanoseconds(nanoseconds: u64) -> Result<Timestamp, ParseTimestampError> {
pub fn from_nanoseconds(nanoseconds: u64) -> Result<Self, ParseTimestampError> {
if nanoseconds == 0 {
Ok(Timestamp { time: None })
Ok(Self { time: None })
} else {
// As the `u64` representation can only represent times up to
// about year 2554, there is no risk of overflowing `Time`
Expand All @@ -123,26 +122,26 @@ impl Timestamp {
.map_err(|e: tendermint::error::Error| {
ParseTimestampError::DataOutOfRange(e.to_string())
})?;
Ok(Timestamp { time: Some(ts) })
Ok(Self { time: Some(ts) })
}
}

/// Returns a `Timestamp` representation of the current time.
#[cfg(feature = "std")]
pub fn now() -> Timestamp {
pub fn now() -> Self {
Time::now().into()
}

/// Returns a `Timestamp` representation of a timestamp not being set.
pub fn none() -> Self {
Timestamp { time: None }
Self { time: None }
}

/// Computes the duration difference of another `Timestamp` from the current one.
/// Returns the difference in time as an [`core::time::Duration`].
/// Returns `None` if the other `Timestamp` is more advanced
/// than the current or if either of the `Timestamp`s is not set.
pub fn duration_since(&self, other: &Timestamp) -> Option<Duration> {
pub fn duration_since(&self, other: &Self) -> Option<Duration> {
match (self.time, other.time) {
(Some(time1), Some(time2)) => time1.duration_since(time2).ok(),
_ => None,
Expand Down Expand Up @@ -197,7 +196,7 @@ impl Timestamp {

/// Checks whether the timestamp has expired when compared to the
/// `other` timestamp. Returns an [`Expiry`] result.
pub fn check_expiry(&self, other: &Timestamp) -> Expiry {
pub fn check_expiry(&self, other: &Self) -> Expiry {
match (self.time, other.time) {
(Some(time1), Some(time2)) => {
if time1 > time2 {
Expand Down Expand Up @@ -237,29 +236,29 @@ pub enum TimestampOverflowError {
impl std::error::Error for TimestampOverflowError {}

impl Add<Duration> for Timestamp {
type Output = Result<Timestamp, TimestampOverflowError>;
type Output = Result<Self, TimestampOverflowError>;

fn add(self, duration: Duration) -> Result<Timestamp, TimestampOverflowError> {
fn add(self, duration: Duration) -> Result<Self, TimestampOverflowError> {
match self.time {
Some(time) => {
let time =
(time + duration).map_err(|_| TimestampOverflowError::TimestampOverflow)?;
Ok(Timestamp { time: Some(time) })
Ok(Self { time: Some(time) })
}
None => Ok(self),
}
}
}

impl Sub<Duration> for Timestamp {
type Output = Result<Timestamp, TimestampOverflowError>;
type Output = Result<Self, TimestampOverflowError>;

fn sub(self, duration: Duration) -> Result<Timestamp, TimestampOverflowError> {
fn sub(self, duration: Duration) -> Result<Self, TimestampOverflowError> {
match self.time {
Some(time) => {
let time =
(time - duration).map_err(|_| TimestampOverflowError::TimestampOverflow)?;
Ok(Timestamp { time: Some(time) })
Ok(Self { time: Some(time) })
}
None => Ok(self),
}
Expand All @@ -278,8 +277,8 @@ pub enum ParseTimestampError {
impl std::error::Error for ParseTimestampError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match &self {
ParseTimestampError::ParseInt(e) => Some(e),
ParseTimestampError::DataOutOfRange(_) => None,
Self::ParseInt(e) => Some(e),
Self::DataOutOfRange(_) => None,
}
}
}
Expand All @@ -290,13 +289,13 @@ impl FromStr for Timestamp {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let nanoseconds = u64::from_str(s).map_err(ParseTimestampError::ParseInt)?;

Timestamp::from_nanoseconds(nanoseconds)
Self::from_nanoseconds(nanoseconds)
}
}

impl From<Time> for Timestamp {
fn from(tendermint_time: Time) -> Timestamp {
Timestamp {
fn from(tendermint_time: Time) -> Self {
Self {
time: Some(tendermint_time),
}
}
Expand Down