@@ -173,7 +173,12 @@ pub(crate) async fn extract(ctx: &DiscoverCtx<'_>, out: &mut Discovery) {
173173 // hosted rewriter pins a crate in (each that declares it).
174174 let mut manifests: Vec < ( String , DocumentMut ) > = Vec :: new ( ) ;
175175 if let Some ( doc) = root {
176- let root_pins = manifest_has_socket_pin ( & doc) ;
176+ // Any Socket pin the root or the config carries, a `[patch]`
177+ // entry included: members may hold the declarations it governs.
178+ let root_pins = doc. to_string ( ) . contains ( PIN_NAME_PREFIX )
179+ || config
180+ . as_ref ( )
181+ . is_some_and ( |c| c. 1 . to_string ( ) . contains ( PIN_NAME_PREFIX ) ) ;
177182 manifests. push ( ( CARGO_TOML . to_string ( ) , doc) ) ;
178183 manifests. extend ( read_members ( ctx, & lock, root_pins, out) . await ) ;
179184 }
@@ -354,30 +359,26 @@ async fn read_toml(ctx: &DiscoverCtx<'_>, file: &str, out: &mut Discovery) -> Op
354359/// not a declaration — or a build `target/`). Unparseable ones are skipped
355360/// (diagnosed).
356361///
357- /// Members only ever decide about Socket wiring, so the walk is skipped
358- /// when there is none they could decide about: a parsed lock with no
359- /// Socket-sourced package, or an unparseable one (no ref either way). With
360- /// no lock, a member matters only when some manifest carries a
361- /// `socket- patch-` pin ( a lockless pin, [`UnlockedPin`]); the walk has the
362- /// texts, so the parse is skipped otherwise .
362+ /// Members only ever decide about Socket wiring, so they are parsed only
363+ /// when there is some they could decide about: a lock with a
364+ /// Socket-sourced package, or a `socket-patch-` name in a member's own
365+ /// text, the root's or the config's (a pin to diagnose or recognize, a
366+ /// `[ patch]` entry members declare, a lockless pin, [`UnlockedPin`]),
367+ /// whatever the lock says (stale, unparseable or absent) .
363368async fn read_members (
364369 ctx : & DiscoverCtx < ' _ > ,
365370 lock : & Lock ,
366371 root_pins : bool ,
367372 out : & mut Discovery ,
368373) -> Vec < ( String , DocumentMut ) > {
369- let lockless = match lock {
370- Lock :: Parsed ( _) if has_socket_sourced ( ctx, lock) => false ,
371- Lock :: Parsed ( _) | Lock :: Unparseable => return Vec :: new ( ) ,
372- Lock :: Absent => true ,
373- } ;
374+ let socket_sourced = matches ! ( lock, Lock :: Parsed ( _) ) && has_socket_sourced ( ctx, lock) ;
374375 let texts: Vec < ( String , String ) > =
375376 crate :: utils:: cargo_workspace:: member_manifest_texts_in ( & ctx. view )
376377 . await
377378 . into_iter ( )
378379 . filter ( |( rel, _) | crate :: patch:: redirect:: is_cargo_member_manifest_key ( rel) )
379380 . collect ( ) ;
380- if lockless && !root_pins && !texts. iter ( ) . any ( |( _, t) | t. contains ( PIN_NAME_PREFIX ) ) {
381+ if !socket_sourced && !root_pins && !texts. iter ( ) . any ( |( _, t) | t. contains ( PIN_NAME_PREFIX ) ) {
381382 return Vec :: new ( ) ;
382383 }
383384 let mut members = Vec :: new ( ) ;
@@ -390,16 +391,6 @@ async fn read_members(
390391 members
391392}
392393
393- /// Whether some dependency declaration of `doc` names a `socket-patch-`
394- /// registry.
395- fn manifest_has_socket_pin ( doc : & DocumentMut ) -> bool {
396- dependency_entries ( doc) . iter ( ) . any ( |d| {
397- d. registry
398- . as_deref ( )
399- . is_some_and ( |r| r. trim ( ) . starts_with ( PIN_NAME_PREFIX ) )
400- } )
401- }
402-
403394/// Whether the lock resolves some package from a Socket patch server.
404395fn has_socket_sourced ( ctx : & DiscoverCtx < ' _ > , lock : & Lock ) -> bool {
405396 lock. packages ( ) . iter ( ) . any ( |p| {
@@ -2536,6 +2527,24 @@ mod tests {
25362527 let p = Project :: new ( ) ;
25372528 workspace_with_member ( & p, & pinned ( "serde" , "1" , UUID_A ) ) ;
25382529 assert ! ( member_read( & p. discover( ) . await ) ) ;
2530+ // Review on #2012 (round 2): a stale crates.io lock beside a member
2531+ // pin still reads the member, so the pin is diagnosed (a stale lock
2532+ // or a server outside the allowlist) and its uuid recognized.
2533+ let p = Project :: new ( ) ;
2534+ workspace_with_member ( & p, & pinned ( "serde" , "1" , UUID_A ) ) ;
2535+ p. write (
2536+ "Cargo.lock" ,
2537+ lock ( & [ ( "serde" , "1.0.1" , Some ( CRATES_IO ) , Some ( CKSUM ) ) ] ) ,
2538+ ) ;
2539+ let out = p. discover ( ) . await ;
2540+ assert ! ( member_read( & out) ) ;
2541+ assert ! (
2542+ out. diagnostics
2543+ . iter( )
2544+ . any( |d| d. code == DIAG_REF_UNATTRIBUTABLE ) ,
2545+ "{:?}" ,
2546+ out. diagnostics
2547+ ) ;
25392548 }
25402549
25412550 /// A rotated grant token in the definition is the same patch.
0 commit comments