@@ -319,8 +319,32 @@ impl ResolvedFeatures {
319
319
pkg_id : PackageId ,
320
320
features_for : FeaturesFor ,
321
321
) -> Vec < InternedString > {
322
- self . activated_features_int ( pkg_id, features_for)
323
- . expect ( "activated_features for invalid package" )
322
+ let fk = features_for. apply_opts ( & self . opts ) ;
323
+ let key = ( pkg_id, fk) ;
324
+ if let Some ( fs) = self . activated_features . get ( & key) {
325
+ fs. iter ( ) . cloned ( ) . collect ( )
326
+ } else {
327
+ panic ! (
328
+ "did not find features for {key:?} within activated_features:\n {:#?}" ,
329
+ self . activated_features
330
+ )
331
+ }
332
+ }
333
+
334
+ /// Variant of `activated_features` that returns `None` if this is
335
+ /// not a valid pkg_id/is_build combination. Used in places which do
336
+ /// not know which packages are activated (like `cargo clean`).
337
+ pub fn activated_features_unverified (
338
+ & self ,
339
+ pkg_id : PackageId ,
340
+ features_for : FeaturesFor ,
341
+ ) -> Option < Vec < InternedString > > {
342
+ let fk = features_for. apply_opts ( & self . opts ) ;
343
+ if let Some ( fs) = self . activated_features . get ( & ( pkg_id, fk) ) {
344
+ Some ( fs. iter ( ) . cloned ( ) . collect ( ) )
345
+ } else {
346
+ None
347
+ }
324
348
}
325
349
326
350
/// Returns if the given dependency should be included.
@@ -340,30 +364,6 @@ impl ResolvedFeatures {
340
364
. unwrap_or ( false )
341
365
}
342
366
343
- /// Variant of `activated_features` that returns `None` if this is
344
- /// not a valid pkg_id/is_build combination. Used in places which do
345
- /// not know which packages are activated (like `cargo clean`).
346
- pub fn activated_features_unverified (
347
- & self ,
348
- pkg_id : PackageId ,
349
- features_for : FeaturesFor ,
350
- ) -> Option < Vec < InternedString > > {
351
- self . activated_features_int ( pkg_id, features_for) . ok ( )
352
- }
353
-
354
- fn activated_features_int (
355
- & self ,
356
- pkg_id : PackageId ,
357
- features_for : FeaturesFor ,
358
- ) -> CargoResult < Vec < InternedString > > {
359
- let fk = features_for. apply_opts ( & self . opts ) ;
360
- if let Some ( fs) = self . activated_features . get ( & ( pkg_id, fk) ) {
361
- Ok ( fs. iter ( ) . cloned ( ) . collect ( ) )
362
- } else {
363
- bail ! ( "features did not find {:?} {:?}" , pkg_id, fk)
364
- }
365
- }
366
-
367
367
/// Compares the result against the original resolver behavior.
368
368
///
369
369
/// Used by `cargo fix --edition` to display any differences.
0 commit comments