@@ -261,6 +261,12 @@ pub struct RegistrySource<'cfg> {
261
261
/// Otherwise, the resolver would think that those entries no longer
262
262
/// exist, and it would trigger updates to unrelated packages.
263
263
yanked_whitelist : HashSet < PackageId > ,
264
+ /// Yanked versions that have already been selected during queries.
265
+ ///
266
+ /// As of this writing, this is for not emitting the `--precise <yanked>`
267
+ /// warning twice, with the assumption of (`dep.package_name()` + `--precise`
268
+ /// version) being sufficient to uniquely identify the same query result.
269
+ selected_precise_yanked : HashSet < ( InternedString , semver:: Version ) > ,
264
270
}
265
271
266
272
/// The [`config.json`] file stored in the index.
@@ -531,6 +537,7 @@ impl<'cfg> RegistrySource<'cfg> {
531
537
index : index:: RegistryIndex :: new ( source_id, ops. index_path ( ) , config) ,
532
538
yanked_whitelist : yanked_whitelist. clone ( ) ,
533
539
ops,
540
+ selected_precise_yanked : HashSet :: new ( ) ,
534
541
}
535
542
}
536
543
@@ -812,13 +819,13 @@ impl<'cfg> Source for RegistrySource<'cfg> {
812
819
let version = req
813
820
. precise_version ( )
814
821
. expect ( "--precise <yanked-version> in use" ) ;
815
- let source = self . source_id ( ) ;
816
- let mut shell = self . config . shell ( ) ;
817
- shell. warn ( format_args ! (
818
- "yanked package `{name}@{version}` is selected by the `--precise` flag from {source}" ,
819
- ) ) ?;
820
- shell. note ( "it is not recommended to depend on a yanked version" ) ?;
821
- shell . note ( "if possible, try other SemVer-compatbile versions" ) ? ;
822
+ if self . selected_precise_yanked . insert ( ( name , version . clone ( ) ) ) {
823
+ let mut shell = self . config . shell ( ) ;
824
+ shell. warn ( format_args ! (
825
+ "selected package `{name}@{version}` was yanked by the author"
826
+ ) ) ?;
827
+ shell. note ( "if possible, try a compatible non- yanked version" ) ?;
828
+ }
822
829
}
823
830
if called {
824
831
return Poll :: Ready ( Ok ( ( ) ) ) ;
0 commit comments