@@ -48,9 +48,6 @@ pub struct Context {
4848 // at the very end and actually construct the map that we're making.
4949 pub resolve_graph : RcList < GraphNode > ,
5050 pub resolve_replacements : RcList < ( PackageId , PackageId ) > ,
51-
52- // These warnings are printed after resolution.
53- pub warnings : RcList < String > ,
5451}
5552
5653/// When backtracking it can be useful to know how far back to go.
@@ -109,7 +106,6 @@ impl Context {
109106 parents : Graph :: new ( ) ,
110107 resolve_replacements : RcList :: new ( ) ,
111108 activations : im_rc:: HashMap :: new ( ) ,
112- warnings : RcList :: new ( ) ,
113109 }
114110 }
115111
@@ -174,7 +170,7 @@ impl Context {
174170 // First, figure out our set of dependencies based on the requested set
175171 // of features. This also calculates what features we're going to enable
176172 // for our own dependencies.
177- let deps = self . resolve_features ( parent, candidate, method) ?;
173+ let deps = self . resolve_features ( parent, candidate, method, None ) ?;
178174
179175 // Next, transform all dependencies into a list of possible candidates
180176 // which can satisfy that dependency.
@@ -229,11 +225,12 @@ impl Context {
229225 }
230226
231227 /// Returns all dependencies and the features we want from them.
232- fn resolve_features < ' b > (
228+ pub fn resolve_features < ' b > (
233229 & mut self ,
234230 parent : Option < & Summary > ,
235231 s : & ' b Summary ,
236232 method : & ' b Method < ' _ > ,
233+ config : Option < & crate :: util:: config:: Config > ,
237234 ) -> ActivateResult < Vec < ( Dependency , Vec < InternedString > ) > > {
238235 let dev_deps = match * method {
239236 Method :: Everything => true ,
@@ -261,20 +258,23 @@ impl Context {
261258 // name.
262259 let base = reqs. deps . get ( & dep. name_in_toml ( ) ) . unwrap_or ( & default_dep) ;
263260 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+ }
278278 }
279279 let mut base = base. 1 . clone ( ) ;
280280 base. extend ( dep. features ( ) . iter ( ) ) ;
0 commit comments