← Back to Pull requests

deps: drop cfg-if in favor of cfg_select #1818

Open
Xynnn007 opened this pull request with 118 lines diff across 9 files
View on GitHub
Xynnn007 Xynnn007 commented on Oct 19, 2026 02:46 UTC
Author

cfg_select! is stable on the pinned 1.95 toolchain, so the direct cfg-if dependency is no longer needed.

Close #1815

Diff: 118 lines (+39 / -79) across 9 files Reviewer: mythi Review duration: 2691m
All Vouch review confidence checks passed
Residual risk 0.08 = Change Risk (0.43) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 118 lines diff across 9 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.80 · 5 substantive comment(s)
0.80
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
82%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.286
Real PR Conversation Timeline
8 items
mythi mythi commented on code on Oct 19, 2026 07:03 UTC
Code Review
image-rs/src/resource/kbs/mod.rs:1
@@ -55,18 +55,18 @@ impl SecureChannel {
     /// Create a new [`SecureChannel`] that talks to a `GetResource` service
     /// (typically Confidential Data Hub) over ttrpc or gRPC.
     pub fn new(work_dir: &Path) -> Result<Self> {
-        let client: Box<dyn Client> = {
-            cfg_if::cfg_if! {
-                if #[cfg(feature = "keywrap-ttrpc")] {
-                    info!("secure channel uses ttrpc");
-                    Box::<ttrpc::Ttrpc>::default()
-                } else if #[cfg(feature = "keywrap-grpc")] {
-                    info!("secure channel uses gRPC");
-                    Box::<grpc::Grpc>::default()
-                } else  {
-                    compile_error!("At least one feature of `keywrap-grpc` and `keywrap-ttrpc` must be enabled.");
-                }
+        cfg_select! {
+            feature = "keywrap-ttrpc" => {
+                info!("secure channel uses ttrpc");
+                let client: Box<dyn Client> = Box::<ttrpc::Ttrpc>::default();
             }
+            feature = "keywrap-grpc" => {
+                info!("secure channel uses gRPC");
+                let client: Box<dyn Client> = Box::<grpc::Grpc>::default();
+            }
+            _ => compile_error!(
+                "At least one feature of `keywrap-grpc` and `keywrap-ttrpc` must be enabled."
+            ),

the documentation says the default arm is handled automatically so maybe just:

let client: Box<dyn Client> = cfg_select! {
    feature = "keywrap-ttrpc" => {
        info!("secure channel uses ttrpc");
        Box::<ttrpc::Ttrpc>::default()
    },
    feature = "keywrap-grpc" => {
        info!("secure channel uses gRPC");
        Box::<grpc::Grpc>::default()
    },
};

mod.rs has some cfg rules for this also...

mythi mythi commented on Oct 19, 2026 07:03 UTC
Reviewer

nice improvement, thanks

Xynnn007 Xynnn007 commented on code on Oct 19, 2026 07:40 UTC
Code Review
image-rs/src/resource/kbs/mod.rs:1
@@ -55,18 +55,18 @@ impl SecureChannel {
     /// Create a new [`SecureChannel`] that talks to a `GetResource` service
     /// (typically Confidential Data Hub) over ttrpc or gRPC.
     pub fn new(work_dir: &Path) -> Result<Self> {
-        let client: Box<dyn Client> = {
-            cfg_if::cfg_if! {
-                if #[cfg(feature = "keywrap-ttrpc")] {
-                    info!("secure channel uses ttrpc");
-                    Box::<ttrpc::Ttrpc>::default()
-                } else if #[cfg(feature = "keywrap-grpc")] {
-                    info!("secure channel uses gRPC");
-                    Box::<grpc::Grpc>::default()
-                } else  {
-                    compile_error!("At least one feature of `keywrap-grpc` and `keywrap-ttrpc` must be enabled.");
-                }
+        cfg_select! {
+            feature = "keywrap-ttrpc" => {
+                info!("secure channel uses ttrpc");
+                let client: Box<dyn Client> = Box::<ttrpc::Ttrpc>::default();
             }
+            feature = "keywrap-grpc" => {
+                info!("secure channel uses gRPC");
+                let client: Box<dyn Client> = Box::<grpc::Grpc>::default();
+            }
+            _ => compile_error!(
+                "At least one feature of `keywrap-grpc` and `keywrap-ttrpc` must be enabled."
+            ),

Hi @mythi could you give a link to the doc you mentioend?

mythi mythi commented on code on Oct 19, 2026 08:21 UTC
Code Review
image-rs/src/resource/kbs/mod.rs:1
@@ -55,18 +55,18 @@ impl SecureChannel {
     /// Create a new [`SecureChannel`] that talks to a `GetResource` service
     /// (typically Confidential Data Hub) over ttrpc or gRPC.
     pub fn new(work_dir: &Path) -> Result<Self> {
-        let client: Box<dyn Client> = {
-            cfg_if::cfg_if! {
-                if #[cfg(feature = "keywrap-ttrpc")] {
-                    info!("secure channel uses ttrpc");
-                    Box::<ttrpc::Ttrpc>::default()
-                } else if #[cfg(feature = "keywrap-grpc")] {
-                    info!("secure channel uses gRPC");
-                    Box::<grpc::Grpc>::default()
-                } else  {
-                    compile_error!("At least one feature of `keywrap-grpc` and `keywrap-ttrpc` must be enabled.");
-                }
+        cfg_select! {
+            feature = "keywrap-ttrpc" => {
+                info!("secure channel uses ttrpc");
+                let client: Box<dyn Client> = Box::<ttrpc::Ttrpc>::default();
             }
+            feature = "keywrap-grpc" => {
+                info!("secure channel uses gRPC");
+                let client: Box<dyn Client> = Box::<grpc::Grpc>::default();
+            }
+            _ => compile_error!(
+                "At least one feature of `keywrap-grpc` and `keywrap-ttrpc` must be enabled."
+            ),
Xynnn007 Xynnn007 commented on Oct 19, 2026 08:28 UTC
Author

@mythi fixed. PTAL

mythi mythi approved these changes on Oct 19, 2026 08:56 UTC
Approved Reviewer

LGTM

fitzthum fitzthum commented on Oct 19, 2026 14:44 UTC
Contributor

Waiting for MSRV discussion on Thursday

Reviewers
Assignees
Xynnn007 Xynnn007
Labels
risk: low confidence: 82.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 43.3% (MEDIUM) · Higher = larger blast radius
43.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 82.1% · Lower = rushed or shallow review
82.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 7.8% · Safe to merge
7.8%