File tree Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ impl<'cfg> PackageRegistry<'cfg> {
161
161
162
162
// If the previous source was not a precise source, then we can be
163
163
// sure that it's already been updated if we've already loaded it.
164
- Some ( ( previous, _) ) if previous. precise ( ) . is_none ( ) => {
164
+ Some ( ( previous, _) ) if ! previous. has_precise ( ) => {
165
165
debug ! ( "load/precise {}" , namespace) ;
166
166
return Ok ( ( ) ) ;
167
167
}
@@ -471,9 +471,9 @@ impl<'cfg> PackageRegistry<'cfg> {
471
471
//
472
472
// If we have a precise version, then we'll update lazily during the
473
473
// querying phase. Note that precise in this case is only
474
- // `Some( "locked") ` as other `Some` values indicate a `cargo update
474
+ // `"locked"` as other values indicate a `cargo update
475
475
// --precise` request
476
- if source_id. precise ( ) != Some ( "locked" ) {
476
+ if ! source_id. has_locked_precise ( ) {
477
477
self . sources . get_mut ( source_id) . unwrap ( ) . invalidate_cache ( ) ;
478
478
} else {
479
479
debug ! ( "skipping update due to locked registry" ) ;
Original file line number Diff line number Diff line change @@ -332,7 +332,7 @@ impl SourceId {
332
332
pub fn display_registry_name ( self ) -> String {
333
333
if let Some ( key) = self . inner . registry_key . as_ref ( ) . map ( |k| k. key ( ) ) {
334
334
key. into ( )
335
- } else if self . precise ( ) . is_some ( ) {
335
+ } else if self . has_precise ( ) {
336
336
// We remove `precise` here to retrieve an permissive version of
337
337
// `SourceIdInner`, which may contain the registry name.
338
338
self . with_precise ( None ) . display_registry_name ( )
@@ -449,6 +449,16 @@ impl SourceId {
449
449
self . inner . precise . as_deref ( )
450
450
}
451
451
452
+ /// Check if the precise data field has bean set
453
+ pub fn has_precise ( self ) -> bool {
454
+ self . inner . precise . is_some ( )
455
+ }
456
+
457
+ /// Check if the precise data field has bean set to "Locked"
458
+ pub fn has_locked_precise ( self ) -> bool {
459
+ self . inner . precise . as_deref ( ) == Some ( "locked" )
460
+ }
461
+
452
462
/// Check if the precise data field stores information for this `name`
453
463
/// from a call to [SourceId::with_precise_registry_version].
454
464
///
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ a lock file compatible with `{orig}` cannot be generated in this situation
199
199
) ;
200
200
}
201
201
202
- if old_src. requires_precise ( ) && id. precise ( ) . is_none ( ) {
202
+ if old_src. requires_precise ( ) && ! id. has_precise ( ) {
203
203
bail ! (
204
204
"\
205
205
the source {orig} requires a lock file to be present first before it can be
Original file line number Diff line number Diff line change @@ -716,8 +716,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {
716
716
// theory the registry is known to contain this version. If, however, we
717
717
// come back with no summaries, then our registry may need to be
718
718
// updated, so we fall back to performing a lazy update.
719
- if kind == QueryKind :: Exact && dep. source_id ( ) . precise ( ) . is_some ( ) && !self . ops . is_updated ( )
720
- {
719
+ if kind == QueryKind :: Exact && dep. source_id ( ) . has_precise ( ) && !self . ops . is_updated ( ) {
721
720
debug ! ( "attempting query without update" ) ;
722
721
let mut called = false ;
723
722
ready ! ( self . index. query_inner(
You can’t perform that action at this time.
0 commit comments