@@ -14,7 +14,7 @@ use crate::core::resolver::HasDevUnits;
14
14
use crate :: core:: { Feature , PackageIdSpecQuery , Shell , Verbosity , Workspace } ;
15
15
use crate :: core:: { Package , PackageId , PackageSet , Resolve , SourceId } ;
16
16
use crate :: ops:: lockfile:: LOCKFILE_NAME ;
17
- use crate :: ops:: registry:: RegistryOrIndex ;
17
+ use crate :: ops:: registry:: { infer_registry , RegistryOrIndex } ;
18
18
use crate :: sources:: registry:: index:: { IndexPackage , RegistryDependency } ;
19
19
use crate :: sources:: { PathSource , SourceConfigMap , CRATES_IO_REGISTRY } ;
20
20
use crate :: util:: cache_lock:: CacheLockMode ;
@@ -174,45 +174,6 @@ fn create_package(
174
174
return Ok ( dst) ;
175
175
}
176
176
177
- /// If this set of packages has an unambiguous publish registry, find it.
178
- pub ( crate ) fn infer_registry ( pkgs : & [ & Package ] ) -> CargoResult < Option < RegistryOrIndex > > {
179
- if pkgs[ 1 ..] . iter ( ) . all ( |p| p. publish ( ) == pkgs[ 0 ] . publish ( ) ) {
180
- // If all packages have the same publish settings, we take that as the default.
181
- match pkgs[ 0 ] . publish ( ) . as_deref ( ) {
182
- Some ( [ unique_pkg_reg] ) => {
183
- Ok ( Some ( RegistryOrIndex :: Registry ( unique_pkg_reg. to_owned ( ) ) ) )
184
- }
185
- None | Some ( [ ] ) => Ok ( None ) ,
186
- Some ( regs) => {
187
- let mut regs: Vec < _ > = regs. iter ( ) . map ( |s| format ! ( "\" {}\" " , s) ) . collect ( ) ;
188
- regs. sort ( ) ;
189
- regs. dedup ( ) ;
190
- // unwrap: the match block ensures that there's more than one reg.
191
- let ( last_reg, regs) = regs. split_last ( ) . unwrap ( ) ;
192
- bail ! (
193
- "--registry is required to disambiguate between {} or {} registries" ,
194
- regs. join( ", " ) ,
195
- last_reg
196
- )
197
- }
198
- }
199
- } else {
200
- let common_regs = pkgs
201
- . iter ( )
202
- // `None` means "all registries", so drop them instead of including them
203
- // in the intersection.
204
- . filter_map ( |p| p. publish ( ) . as_deref ( ) )
205
- . map ( |p| p. iter ( ) . collect :: < HashSet < _ > > ( ) )
206
- . reduce ( |xs, ys| xs. intersection ( & ys) . cloned ( ) . collect ( ) )
207
- . unwrap_or_default ( ) ;
208
- if common_regs. is_empty ( ) {
209
- bail ! ( "conflicts between `package.publish` fields in the selected packages" ) ;
210
- } else {
211
- bail ! ( "--registry is required because not all `package.publish` settings agree" , ) ;
212
- }
213
- }
214
- }
215
-
216
177
/// Packages an entire workspace.
217
178
///
218
179
/// Returns the generated package files. If `opts.list` is true, skips
0 commit comments