From ea7407b73bbd0a977451d84dc25eafb77bb07a1c Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sat, 8 Aug 2026 18:55:09 +0800 Subject: [PATCH] scrap/benchmark: give the Duration divisor an explicit u32 The webrtc feature pulls time 0.3 into scrap's graph (hbb_common -> webrtc -> webrtc-dtls -> der-parser -> asn1-rs), and that crate carries an `impl Div for std::time::Duration`. Orphan rules allow it because the RHS is its own type, and trait impls are visible across the whole dependency graph without a use, so std::time::Duration now has two Div candidates. `yuv_count as _` casts to a plain inference variable, which both candidates fit, so it stops resolving: error[E0282]: type annotations needed --> libs/scrap/examples/benchmark.rs:146:33 Only two of the four sites are reported - rustc emits one E0282 per function body - so all four are annotated. The already-explicit `as u32` at the hwcodec site and `start.elapsed() / cnt` are unaffected, the latter because an integer literal's variable can only unify with an integral type and rules the time impl out on its own. Co-Authored-By: Claude Opus 5 (1M context) --- libs/scrap/examples/benchmark.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/scrap/examples/benchmark.rs b/libs/scrap/examples/benchmark.rs index a867a2d3f..74b3b5b86 100644 --- a/libs/scrap/examples/benchmark.rs +++ b/libs/scrap/examples/benchmark.rs @@ -143,7 +143,7 @@ fn test_vpx( println!( "{:?} encode: {:?}, {} byte", codec_id, - time_sum / yuv_count as _, + time_sum / yuv_count as u32, size / yuv_count ); @@ -156,7 +156,7 @@ fn test_vpx( println!( "{:?} decode: {:?}", codec_id, - start.elapsed() / yuv_count as _ + start.elapsed() / yuv_count as u32 ); } @@ -212,7 +212,7 @@ fn test_av1( assert_eq!(av1s.len(), yuv_count); println!( "AV1 encode: {:?}, {} byte", - time_sum / yuv_count as _, + time_sum / yuv_count as u32, size / yuv_count ); let mut decoder = AomDecoder::new().unwrap(); @@ -221,7 +221,7 @@ fn test_av1( let _ = decoder.decode(&av1); let _ = decoder.flush(); } - println!("AV1 decode: {:?}", start.elapsed() / yuv_count as _); + println!("AV1 decode: {:?}", start.elapsed() / yuv_count as u32); } #[cfg(feature = "hwcodec")]