@@ -9,7 +9,7 @@ use std::sync::Arc;
99use tracing:: trace;
1010
1111use crate :: core:: compiler:: { CompileKind , CompileTarget } ;
12- use crate :: core:: { PackageId , SourceId , Summary } ;
12+ use crate :: core:: { CliUnstable , Feature , Features , PackageId , SourceId , Summary } ;
1313use crate :: util:: errors:: CargoResult ;
1414use crate :: util:: interning:: InternedString ;
1515use crate :: util:: OptVersionReq ;
@@ -72,6 +72,12 @@ pub struct SerializedDependency {
7272 /// The file system path for a local path dependency.
7373 #[ serde( skip_serializing_if = "Option::is_none" ) ]
7474 path : Option < PathBuf > ,
75+
76+ /// `public` flag is unset if `-Zpublic-dependency` is not enabled
77+ ///
78+ /// Once that feature is stabilized, `public` will not need to be `Option`
79+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
80+ public : Option < bool > ,
7581}
7682
7783#[ derive( PartialEq , Eq , Hash , Ord , PartialOrd , Clone , Debug , Copy ) ]
@@ -158,7 +164,11 @@ impl Dependency {
158164 }
159165 }
160166
161- pub fn serialized ( & self ) -> SerializedDependency {
167+ pub fn serialized (
168+ & self ,
169+ unstable_flags : & CliUnstable ,
170+ features : & Features ,
171+ ) -> SerializedDependency {
162172 SerializedDependency {
163173 name : self . package_name ( ) ,
164174 source : self . source_id ( ) ,
@@ -172,6 +182,13 @@ impl Dependency {
172182 registry : self . registry_id ( ) . as_ref ( ) . map ( |sid| sid. url ( ) . to_string ( ) ) ,
173183 path : self . source_id ( ) . local_path ( ) ,
174184 artifact : self . inner . artifact . clone ( ) ,
185+ public : if unstable_flags. public_dependency
186+ || features. is_enabled ( Feature :: public_dependency ( ) )
187+ {
188+ Some ( self . inner . public )
189+ } else {
190+ None
191+ } ,
175192 }
176193 }
177194
0 commit comments