Skip to content

Commit ca7ab27

Browse files
committed
chore: bump msrv and fix clippy warnings
1 parent 62635ff commit ca7ab27

File tree

19 files changed

+188
-196
lines changed

19 files changed

+188
-196
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Ivan Kalinin <i.kalinin@dexpa.io>"]
55
repository = "https://github.com/broxus/tycho-types"
66
version = "0.2.1"
77
edition = "2024"
8-
rust-version = "1.85"
8+
rust-version = "1.88"
99
include = ["src/**/*.rs", "benches/**/*.rs", "LICENSE-*", "README.md"]
1010
license = "MIT OR Apache-2.0"
1111

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
[crates-io-link]: https://crates.io/crates/tycho-types
55
[docs-badge]: https://docs.rs/tycho-types/badge.svg
66
[docs-url]: https://docs.rs/tycho-types
7-
[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-lightgray.svg
8-
[rust-version-link]: https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/
7+
[rust-version-badge]: https://img.shields.io/badge/rustc-1.88+-lightgray.svg
8+
[rust-version-link]: https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/
99
[workflow-badge]: https://img.shields.io/github/actions/workflow/status/broxus/tycho-types/master.yml?branch=master
1010
[workflow-link]: https://github.com/broxus/tycho-types/actions?query=workflow%3Amaster
1111

abi-proc/src/internals/container.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ pub fn with_bound(fields: &Fields, generics: &syn::Generics, bound: &syn::Path)
4646

4747
impl<'ast> Visit<'ast> for FindTyParams<'ast> {
4848
fn visit_field(&mut self, field: &'ast syn::Field) {
49-
if let syn::Type::Path(ty) = ungroup(&field.ty) {
50-
if let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next() {
51-
if self.all_type_params.contains(&t.ident) {
52-
self.associated_type_usage.push(ty);
53-
}
54-
}
49+
if let syn::Type::Path(ty) = ungroup(&field.ty)
50+
&& let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next()
51+
&& self.all_type_params.contains(&t.ident)
52+
{
53+
self.associated_type_usage.push(ty);
5554
}
55+
5656
self.visit_type(&field.ty);
5757
}
5858

5959
fn visit_macro(&mut self, _mac: &'ast syn::Macro) {}
6060

6161
fn visit_path(&mut self, path: &'ast syn::Path) {
62-
if let Some(seg) = path.segments.last() {
63-
if seg.ident == "PhantomData" {
64-
return;
65-
}
62+
if let Some(seg) = path.segments.last()
63+
&& seg.ident == "PhantomData"
64+
{
65+
return;
6666
}
6767
if path.leading_colon.is_none() && path.segments.len() == 1 {
6868
let id = &path.segments[0].ident;

abi-proc/src/internals/field.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,25 @@ pub struct FieldAttributes {
4141

4242
impl FieldAttributes {
4343
pub fn check(&self) -> Result<(), Error> {
44-
if let Some(path) = &self.mod_handler {
45-
if self.with_handlers.into_abi_handler.is_some()
46-
&& self.with_handlers.from_abi_handler.is_some()
47-
&& self.with_handlers.as_abi_handler.is_some()
48-
&& self.with_handlers.abi_type_handler.is_some()
49-
{
50-
return Err(Error::new_spanned(
51-
path,
52-
"`with` parameter should not be used simultaneously with other handling parameters",
53-
));
54-
}
44+
if let Some(path) = &self.mod_handler
45+
&& self.with_handlers.into_abi_handler.is_some()
46+
&& self.with_handlers.from_abi_handler.is_some()
47+
&& self.with_handlers.as_abi_handler.is_some()
48+
&& self.with_handlers.abi_type_handler.is_some()
49+
{
50+
return Err(Error::new_spanned(
51+
path,
52+
"all `with` module methods are shadowed by explicit attributes",
53+
));
5554
}
5655

57-
if let Some(path) = &self.with_handlers.into_abi_handler {
58-
if self.with_handlers.as_abi_handler.is_none() {
59-
return Err(Error::new_spanned(
60-
path,
61-
"`into_abi_with` also requires `as_abi_with`",
62-
));
63-
}
56+
if let Some(path) = &self.with_handlers.into_abi_handler
57+
&& self.with_handlers.as_abi_handler.is_none()
58+
{
59+
return Err(Error::new_spanned(
60+
path,
61+
"`into_abi_with` also requires `as_abi_with`",
62+
));
6463
}
6564

6665
Ok(())

proc/src/bound.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,22 @@ pub fn with_bound(
3838

3939
impl<'ast> Visit<'ast> for FindTyParams<'ast> {
4040
fn visit_field(&mut self, field: &'ast syn::Field) {
41-
if let syn::Type::Path(ty) = ungroup(&field.ty) {
42-
if let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next() {
43-
if self.all_type_params.contains(&t.ident) {
44-
self.associated_type_usage.push(ty);
45-
}
46-
}
41+
if let syn::Type::Path(ty) = ungroup(&field.ty)
42+
&& let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next()
43+
&& self.all_type_params.contains(&t.ident)
44+
{
45+
self.associated_type_usage.push(ty);
4746
}
4847
self.visit_type(&field.ty);
4948
}
5049

5150
fn visit_macro(&mut self, _mac: &'ast syn::Macro) {}
5251

5352
fn visit_path(&mut self, path: &'ast syn::Path) {
54-
if let Some(seg) = path.segments.last() {
55-
if seg.ident == "PhantomData" {
56-
return;
57-
}
53+
if let Some(seg) = path.segments.last()
54+
&& seg.ident == "PhantomData"
55+
{
56+
return;
5857
}
5958
if path.leading_colon.is_none() && path.segments.len() == 1 {
6059
let id = &path.segments[0].ident;

proc/src/internals/attr.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ impl Container {
2020
continue;
2121
}
2222

23-
if let syn::Meta::List(meta) = &attr.meta {
24-
if meta.tokens.is_empty() {
25-
continue;
26-
}
23+
if let syn::Meta::List(meta) = &attr.meta
24+
&& meta.tokens.is_empty()
25+
{
26+
continue;
2727
}
2828

2929
if let Err(e) = attr.parse_nested_meta(|meta| {
@@ -63,10 +63,10 @@ impl Variant {
6363
continue;
6464
}
6565

66-
if let syn::Meta::List(meta) = &attr.meta {
67-
if meta.tokens.is_empty() {
68-
continue;
69-
}
66+
if let syn::Meta::List(meta) = &attr.meta
67+
&& meta.tokens.is_empty()
68+
{
69+
continue;
7070
}
7171

7272
if let Err(e) = attr.parse_nested_meta(|meta| {
@@ -96,10 +96,10 @@ impl Field {
9696
continue;
9797
}
9898

99-
if let syn::Meta::List(meta) = &attr.meta {
100-
if meta.tokens.is_empty() {
101-
continue;
102-
}
99+
if let syn::Meta::List(meta) = &attr.meta
100+
&& meta.tokens.is_empty()
101+
{
102+
continue;
103103
}
104104

105105
if let Err(e) = attr.parse_nested_meta(|meta| {

src/abi/traits.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,43 +1066,43 @@ impl FromPlainAbi for IntAddr {
10661066

10671067
impl FromAbi for StdAddr {
10681068
fn from_abi(value: AbiValue) -> Result<Self> {
1069-
if let AbiValue::Address(address) = &value {
1070-
if let IntAddr::Std(address) = address.as_ref() {
1071-
return Ok(address.clone());
1072-
}
1069+
if let AbiValue::Address(address) = &value
1070+
&& let IntAddr::Std(address) = address.as_ref()
1071+
{
1072+
return Ok(address.clone());
10731073
}
10741074
Err(expected_type("std address", &value))
10751075
}
10761076
}
10771077

10781078
impl FromPlainAbi for StdAddr {
10791079
fn from_plain_abi(value: PlainAbiValue) -> Result<Self> {
1080-
if let PlainAbiValue::Address(address) = &value {
1081-
if let IntAddr::Std(address) = address.as_ref() {
1082-
return Ok(address.clone());
1083-
}
1080+
if let PlainAbiValue::Address(address) = &value
1081+
&& let IntAddr::Std(address) = address.as_ref()
1082+
{
1083+
return Ok(address.clone());
10841084
}
10851085
Err(expected_plain_type("std address", &value))
10861086
}
10871087
}
10881088

10891089
impl FromAbi for VarAddr {
10901090
fn from_abi(value: AbiValue) -> Result<Self> {
1091-
if let AbiValue::Address(address) = &value {
1092-
if let IntAddr::Var(address) = address.as_ref() {
1093-
return Ok(address.clone());
1094-
}
1091+
if let AbiValue::Address(address) = &value
1092+
&& let IntAddr::Var(address) = address.as_ref()
1093+
{
1094+
return Ok(address.clone());
10951095
}
10961096
Err(expected_type("var address", &value))
10971097
}
10981098
}
10991099

11001100
impl FromPlainAbi for VarAddr {
11011101
fn from_plain_abi(value: PlainAbiValue) -> Result<Self> {
1102-
if let PlainAbiValue::Address(address) = &value {
1103-
if let IntAddr::Var(address) = address.as_ref() {
1104-
return Ok(address.clone());
1105-
}
1102+
if let PlainAbiValue::Address(address) = &value
1103+
&& let IntAddr::Var(address) = address.as_ref()
1104+
{
1105+
return Ok(address.clone());
11061106
}
11071107
Err(expected_plain_type("var address", &value))
11081108
}
@@ -1179,10 +1179,10 @@ impl<T: FromAbi> FromAbi for Option<T> {
11791179

11801180
impl FromAbi for () {
11811181
fn from_abi(value: AbiValue) -> Result<Self> {
1182-
if let AbiValue::Tuple(items) = &value {
1183-
if items.is_empty() {
1184-
return Ok(());
1185-
}
1182+
if let AbiValue::Tuple(items) = &value
1183+
&& items.is_empty()
1184+
{
1185+
return Ok(());
11861186
}
11871187
Err(expected_type("()", &value))
11881188
}

src/boc/de.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ impl<'a> BocHeader<'a> {
129129
if unlikely(absent_count > 0) {
130130
return Err(Error::AbsentCellsNotSupported);
131131
}
132-
if let Some(min_roots) = options.min_roots {
133-
if unlikely(root_count < min_roots) {
134-
return Err(Error::TooFewRootCells);
135-
}
132+
if let Some(min_roots) = options.min_roots
133+
&& unlikely(root_count < min_roots)
134+
{
135+
return Err(Error::TooFewRootCells);
136136
}
137137

138138
{

src/cell/builder.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,18 @@ impl CellBuilder {
503503

504504
let level_mask = 'mask: {
505505
// NOTE: make only a brief check here, as it will raise a proper error in finalier
506-
if is_exotic && self.inner.bit_len >= 8 {
507-
if let Some(ty) = CellType::from_byte_exotic(self.data[0]) {
508-
match ty {
509-
CellType::PrunedBranch => break 'mask LevelMask::new(self.data[1]),
510-
CellType::MerkleProof | CellType::MerkleUpdate => {
511-
break 'mask children_mask.virtualize(1);
512-
}
513-
CellType::LibraryReference => break 'mask LevelMask::EMPTY,
514-
_ => {}
515-
};
516-
}
506+
if is_exotic
507+
&& self.inner.bit_len >= 8
508+
&& let Some(ty) = CellType::from_byte_exotic(self.data[0])
509+
{
510+
match ty {
511+
CellType::PrunedBranch => break 'mask LevelMask::new(self.data[1]),
512+
CellType::MerkleProof | CellType::MerkleUpdate => {
513+
break 'mask children_mask.virtualize(1);
514+
}
515+
CellType::LibraryReference => break 'mask LevelMask::EMPTY,
516+
_ => {}
517+
};
517518
}
518519

519520
children_mask
@@ -1112,20 +1113,16 @@ impl CellDataBuilder {
11121113
*data_ptr |= (value >> (64 - shift)) as u8;
11131114

11141115
// If there are some bits left
1115-
if let Some(bits) = bits.checked_sub(shift) {
1116-
if bits > 0 {
1117-
let byte_len = bits.div_ceil(8) as usize;
1118-
debug_assert!(q + 1 + byte_len <= 128);
1119-
1120-
// Make shifted bytes
1121-
let value: [u8; 8] = (value << shift).to_be_bytes();
1122-
// Write shifted bytes
1123-
std::ptr::copy_nonoverlapping(
1124-
value.as_ptr(),
1125-
data_ptr.add(1),
1126-
byte_len,
1127-
);
1128-
}
1116+
if let Some(bits) = bits.checked_sub(shift)
1117+
&& bits > 0
1118+
{
1119+
let byte_len = bits.div_ceil(8) as usize;
1120+
debug_assert!(q + 1 + byte_len <= 128);
1121+
1122+
// Make shifted bytes
1123+
let value: [u8; 8] = (value << shift).to_be_bytes();
1124+
// Write shifted bytes
1125+
std::ptr::copy_nonoverlapping(value.as_ptr(), data_ptr.add(1), byte_len);
11291126
}
11301127
}
11311128
}

src/cell/slice.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,20 +1742,20 @@ impl<'a> CellSlice<'a> {
17421742

17431743
/// Returns a reference to the Nth child cell (relative to this slice's refs window).
17441744
pub fn get_reference(&self, index: u8) -> Result<&'a DynCell, Error> {
1745-
if self.range.refs_start + index < self.range.refs_end {
1746-
if let Some(cell) = self.cell.reference(self.range.refs_start + index) {
1747-
return Ok(cell);
1748-
}
1745+
if self.range.refs_start + index < self.range.refs_end
1746+
&& let Some(cell) = self.cell.reference(self.range.refs_start + index)
1747+
{
1748+
return Ok(cell);
17491749
}
17501750
Err(Error::CellUnderflow)
17511751
}
17521752

17531753
/// Returns the Nth child cell (relative to this slice's refs window).
17541754
pub fn get_reference_cloned(&self, index: u8) -> Result<Cell, Error> {
1755-
if self.range.refs_start + index < self.range.refs_end {
1756-
if let Some(cell) = self.cell.reference_cloned(self.range.refs_start + index) {
1757-
return Ok(cell);
1758-
}
1755+
if self.range.refs_start + index < self.range.refs_end
1756+
&& let Some(cell) = self.cell.reference_cloned(self.range.refs_start + index)
1757+
{
1758+
return Ok(cell);
17591759
}
17601760
Err(Error::CellUnderflow)
17611761
}

0 commit comments

Comments
 (0)