2020//! b. Compile each dependency in order, passing in the -L's pointing at each
2121//! previously compiled dependency.
2222
23- use std:: collections:: { HashMap , HashSet } ;
23+ use std:: collections:: { BTreeSet , HashMap , HashSet } ;
24+ use std:: iter:: FromIterator ;
2425use std:: path:: PathBuf ;
2526use std:: sync:: Arc ;
2627
@@ -108,22 +109,33 @@ impl Packages {
108109 }
109110
110111 pub fn to_package_id_specs ( & self , ws : & Workspace < ' _ > ) -> CargoResult < Vec < PackageIdSpec > > {
111- let specs = match * self {
112+ let specs = match self {
112113 Packages :: All => ws
113114 . members ( )
114115 . map ( Package :: package_id)
115116 . map ( PackageIdSpec :: from_package_id)
116117 . collect ( ) ,
117- Packages :: OptOut ( ref opt_out) => ws
118- . members ( )
119- . map ( Package :: package_id)
120- . map ( PackageIdSpec :: from_package_id)
121- . filter ( |p| opt_out. iter ( ) . position ( |x| * x == p. name ( ) ) . is_none ( ) )
122- . collect ( ) ,
123- Packages :: Packages ( ref packages) if packages. is_empty ( ) => {
118+ Packages :: OptOut ( opt_out) => {
119+ let mut opt_out = BTreeSet :: from_iter ( opt_out. iter ( ) . cloned ( ) ) ;
120+ let packages = ws
121+ . members ( )
122+ . filter ( |pkg| !opt_out. remove ( pkg. name ( ) . as_str ( ) ) )
123+ . map ( Package :: package_id)
124+ . map ( PackageIdSpec :: from_package_id)
125+ . collect ( ) ;
126+ if !opt_out. is_empty ( ) {
127+ ws. config ( ) . shell ( ) . warn ( format ! (
128+ "excluded package(s) {} not found in workspace `{}`" ,
129+ opt_out. iter( ) . map( |x| x. as_ref( ) ) . collect:: <Vec <_>>( ) . join( ", " ) ,
130+ ws. root( ) . display( ) ,
131+ ) ) ?;
132+ }
133+ packages
134+ } ,
135+ Packages :: Packages ( packages) if packages. is_empty ( ) => {
124136 vec ! [ PackageIdSpec :: from_package_id( ws. current( ) ?. package_id( ) ) ]
125137 }
126- Packages :: Packages ( ref packages) => packages
138+ Packages :: Packages ( packages) => packages
127139 . iter ( )
128140 . map ( |p| PackageIdSpec :: parse ( p) )
129141 . collect :: < CargoResult < Vec < _ > > > ( ) ?,
@@ -150,11 +162,11 @@ impl Packages {
150162 let packages: Vec < _ > = match self {
151163 Packages :: Default => ws. default_members ( ) . collect ( ) ,
152164 Packages :: All => ws. members ( ) . collect ( ) ,
153- Packages :: OptOut ( ref opt_out) => ws
165+ Packages :: OptOut ( opt_out) => ws
154166 . members ( )
155167 . filter ( |pkg| !opt_out. iter ( ) . any ( |name| pkg. name ( ) . as_str ( ) == name) )
156168 . collect ( ) ,
157- Packages :: Packages ( ref pkgs ) => pkgs
169+ Packages :: Packages ( packages ) => packages
158170 . iter ( )
159171 . map ( |name| {
160172 ws. members ( )
0 commit comments