clippy: fix or silence rust 1.92 signaled warnings#10245
clippy: fix or silence rust 1.92 signaled warnings#10245kskalski merged 1 commit intoanza-xyz:masterfrom
Conversation
| use $crate::with_mock_invoke_context_with_feature_set; | ||
| let feature_set = &solana_svm_feature_set::SVMFeatureSet::default(); | ||
| with_mock_invoke_context_with_feature_set!( | ||
| $crate::with_mock_invoke_context_with_feature_set!( |
There was a problem hiding this comment.
This is required due to
error: unused import: `$crate::with_mock_invoke_context_with_feature_set`
--> program-runtime/src/invoke_context.rs:852:13
|
852 | use $crate::with_mock_invoke_context_with_feature_set;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
1140 | with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
| ------------------------------------------------------------------------------------ in this macro invocation
|
= note: `-D unused-imports` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_imports)]`
= note: this error originates in the macro `with_mock_invoke_context` (in Nightly builds, run with -Z macro-backtrace for more info)
seems like clippy can no longer recognize uses of import in macro that is use as invoke
| // Surface decimal value without triggering clippy::eq_op warning | ||
| assert_eq!( | ||
| u128::MAX, | ||
| u128::from_ne_bytes(u128::MAX.to_ne_bytes()), |
There was a problem hiding this comment.
seems like now clippy treats u128::MAX as identical to 340_282_366_920_938_463_463_374_607_431_768_211_455, which is wrong, but maybe reasonable, so I hacked the value to avoid putting allow on the whole function:
error: identical args used in this `assert_eq!` macro call
--> rust/128bit/src/lib.rs:14:9
|
14 | / u128::MAX,
15 | | 340_282_366_920_938_463_463_374_607_431_768_211_455
| |___________________________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
= note: `#[deny(clippy::eq_op)]` on by default
There was a problem hiding this comment.
I'd recommend
// explanation
#[expect(clippy::eq_op)]
{
offending expression
}There was a problem hiding this comment.
ok, I think a block will be better than this masking, can't do expect, since in current CI won't allow it, but maybe I can turn it from allow to expect as part of toolchain bump
| // Test - float math functions | ||
| let zero = accounts[0].try_borrow_mut_data()?.len() as f64; | ||
| let num = zero + 8.0f64; | ||
| let num = num.powf(0.333f64); |
There was a problem hiding this comment.
for some reason rust thinks now that this num is unused:
warning: unused variable: `zero`
--> rust/sanity/src/lib.rs:88:13
|
88 | let zero = accounts[0].try_borrow_mut_data()?.len() as f64;
| ^^^^ help: if this is intentional, prefix it with an underscore: `_zero`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
warning: unused variable: `val`
--> rust/sanity/src/lib.rs:88:20
|
88 | let zero = accounts[0].try_borrow_mut_data()?.len() as f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_val`
warning: unused variable: `num`
--> rust/sanity/src/lib.rs:89:13
|
89 | let num = zero + 8.0f64;
| ^^^ help: if this is intentional, prefix it with an underscore: `_num`
warning: unused variable: `num`
--> rust/sanity/src/lib.rs:90:13
|
90 | let num = num.powf(0.333f64);
| ^^^ help: if this is intentional, prefix it with an underscore: `_num`
no idea how to fix it other than putting allow on the whole function...
There was a problem hiding this comment.
Probably rust-lang/rust#142390 and rust-lang/rust#151514. Slap an #[expect] on this (in the PR that bumps the toolchain) and move on, I'd say.
There was a problem hiding this comment.
yap, looks like actually it got fixed in 1.93, which now fails the "expect" on my local test ;)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10245 +/- ##
=========================================
- Coverage 82.8% 82.8% -0.1%
=========================================
Files 847 847
Lines 320391 320391
=========================================
- Hits 265584 265578 -6
- Misses 54807 54813 +6 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| solana_program_entrypoint::entrypoint_no_alloc!(process_instruction); | ||
| #[allow(unused_variables)] |
There was a problem hiding this comment.
| #[allow(unused_variables)] | |
| #[expect(unused_variables)] |
There was a problem hiding this comment.
will turn it into expect after toolchain bump, for now I added comment and narrowed to the relevant block
06246eb to
a43f3ab
Compare
Problem
Some new warnings are emitted by clippy using rust 1.92 toolchain. They actually don't look correct, but we need to find a way to silence them for CI to pass.
Summary of Changes
u128::MAXconstant to byte array and back to avoid identical equality assert errorprograms/sbf/rust/sanity/src/lib.rs