20
20
//! b. Compile each dependency in order, passing in the -L's pointing at each
21
21
//! previously compiled dependency.
22
22
23
- use std:: collections:: { HashMap , HashSet } ;
23
+ use std:: collections:: { BTreeSet , HashMap , HashSet } ;
24
+ use std:: iter:: FromIterator ;
24
25
use std:: path:: PathBuf ;
25
26
use std:: sync:: Arc ;
26
27
@@ -108,22 +109,33 @@ impl Packages {
108
109
}
109
110
110
111
pub fn to_package_id_specs ( & self , ws : & Workspace < ' _ > ) -> CargoResult < Vec < PackageIdSpec > > {
111
- let specs = match * self {
112
+ let specs = match self {
112
113
Packages :: All => ws
113
114
. members ( )
114
115
. map ( Package :: package_id)
115
116
. map ( PackageIdSpec :: from_package_id)
116
117
. 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 ( ) => {
124
136
vec ! [ PackageIdSpec :: from_package_id( ws. current( ) ?. package_id( ) ) ]
125
137
}
126
- Packages :: Packages ( ref packages) => packages
138
+ Packages :: Packages ( packages) => packages
127
139
. iter ( )
128
140
. map ( |p| PackageIdSpec :: parse ( p) )
129
141
. collect :: < CargoResult < Vec < _ > > > ( ) ?,
@@ -150,11 +162,11 @@ impl Packages {
150
162
let packages: Vec < _ > = match self {
151
163
Packages :: Default => ws. default_members ( ) . collect ( ) ,
152
164
Packages :: All => ws. members ( ) . collect ( ) ,
153
- Packages :: OptOut ( ref opt_out) => ws
165
+ Packages :: OptOut ( opt_out) => ws
154
166
. members ( )
155
167
. filter ( |pkg| !opt_out. iter ( ) . any ( |name| pkg. name ( ) . as_str ( ) == name) )
156
168
. collect ( ) ,
157
- Packages :: Packages ( ref pkgs ) => pkgs
169
+ Packages :: Packages ( packages ) => packages
158
170
. iter ( )
159
171
. map ( |name| {
160
172
ws. members ( )
0 commit comments