@@ -48,9 +48,6 @@ pub struct Context {
48
48
// at the very end and actually construct the map that we're making.
49
49
pub resolve_graph : RcList < GraphNode > ,
50
50
pub resolve_replacements : RcList < ( PackageId , PackageId ) > ,
51
-
52
- // These warnings are printed after resolution.
53
- pub warnings : RcList < String > ,
54
51
}
55
52
56
53
/// When backtracking it can be useful to know how far back to go.
@@ -109,7 +106,6 @@ impl Context {
109
106
parents : Graph :: new ( ) ,
110
107
resolve_replacements : RcList :: new ( ) ,
111
108
activations : im_rc:: HashMap :: new ( ) ,
112
- warnings : RcList :: new ( ) ,
113
109
}
114
110
}
115
111
@@ -174,7 +170,7 @@ impl Context {
174
170
// First, figure out our set of dependencies based on the requested set
175
171
// of features. This also calculates what features we're going to enable
176
172
// for our own dependencies.
177
- let deps = self . resolve_features ( parent, candidate, method) ?;
173
+ let deps = self . resolve_features ( parent, candidate, method, None ) ?;
178
174
179
175
// Next, transform all dependencies into a list of possible candidates
180
176
// which can satisfy that dependency.
@@ -229,11 +225,12 @@ impl Context {
229
225
}
230
226
231
227
/// Returns all dependencies and the features we want from them.
232
- fn resolve_features < ' b > (
228
+ pub fn resolve_features < ' b > (
233
229
& mut self ,
234
230
parent : Option < & Summary > ,
235
231
s : & ' b Summary ,
236
232
method : & ' b Method < ' _ > ,
233
+ config : Option < & crate :: util:: config:: Config > ,
237
234
) -> ActivateResult < Vec < ( Dependency , Vec < InternedString > ) > > {
238
235
let dev_deps = match * method {
239
236
Method :: Everything => true ,
@@ -261,20 +258,23 @@ impl Context {
261
258
// name.
262
259
let base = reqs. deps . get ( & dep. name_in_toml ( ) ) . unwrap_or ( & default_dep) ;
263
260
used_features. insert ( dep. name_in_toml ( ) ) ;
264
- let always_required = !dep. is_optional ( )
265
- && !s
266
- . dependencies ( )
267
- . iter ( )
268
- . any ( |d| d. is_optional ( ) && d. name_in_toml ( ) == dep. name_in_toml ( ) ) ;
269
- if always_required && base. 0 {
270
- self . warnings . push ( format ! (
271
- "Package `{}` does not have feature `{}`. It has a required dependency \
272
- with that name, but only optional dependencies can be used as features. \
273
- This is currently a warning to ease the transition, but it will become an \
274
- error in the future.",
275
- s. package_id( ) ,
276
- dep. name_in_toml( )
277
- ) ) ;
261
+ if let Some ( config) = config {
262
+ let mut shell = config. shell ( ) ;
263
+ let always_required = !dep. is_optional ( )
264
+ && !s
265
+ . dependencies ( )
266
+ . iter ( )
267
+ . any ( |d| d. is_optional ( ) && d. name_in_toml ( ) == dep. name_in_toml ( ) ) ;
268
+ if always_required && base. 0 {
269
+ shell. warn ( & format ! (
270
+ "Package `{}` does not have feature `{}`. It has a required dependency \
271
+ with that name, but only optional dependencies can be used as features. \
272
+ This is currently a warning to ease the transition, but it will become an \
273
+ error in the future.",
274
+ s. package_id( ) ,
275
+ dep. name_in_toml( )
276
+ ) ) ?
277
+ }
278
278
}
279
279
let mut base = base. 1 . clone ( ) ;
280
280
base. extend ( dep. features ( ) . iter ( ) ) ;
0 commit comments