@@ -5,7 +5,7 @@ use serde::Serialize;
5
5
use std:: borrow:: Cow ;
6
6
use std:: fmt;
7
7
use std:: path:: PathBuf ;
8
- use std:: rc :: Rc ;
8
+ use std:: sync :: Arc ;
9
9
use tracing:: trace;
10
10
11
11
use crate :: core:: compiler:: { CompileKind , CompileTarget } ;
@@ -18,7 +18,7 @@ use crate::util::OptVersionReq;
18
18
/// Cheap to copy.
19
19
#[ derive( PartialEq , Eq , Hash , Clone , Debug ) ]
20
20
pub struct Dependency {
21
- inner : Rc < Inner > ,
21
+ inner : Arc < Inner > ,
22
22
}
23
23
24
24
/// The data underlying a `Dependency`.
@@ -152,7 +152,7 @@ impl Dependency {
152
152
153
153
let mut ret = Dependency :: new_override ( name, source_id) ;
154
154
{
155
- let ptr = Rc :: make_mut ( & mut ret. inner ) ;
155
+ let ptr = Arc :: make_mut ( & mut ret. inner ) ;
156
156
ptr. only_match_name = false ;
157
157
ptr. req = version_req;
158
158
ptr. specified_req = specified_req;
@@ -163,7 +163,7 @@ impl Dependency {
163
163
pub fn new_override ( name : InternedString , source_id : SourceId ) -> Dependency {
164
164
assert ! ( !name. is_empty( ) ) ;
165
165
Dependency {
166
- inner : Rc :: new ( Inner {
166
+ inner : Arc :: new ( Inner {
167
167
name,
168
168
source_id,
169
169
registry_id : None ,
@@ -241,7 +241,7 @@ impl Dependency {
241
241
}
242
242
243
243
pub fn set_registry_id ( & mut self , registry_id : SourceId ) -> & mut Dependency {
244
- Rc :: make_mut ( & mut self . inner ) . registry_id = Some ( registry_id) ;
244
+ Arc :: make_mut ( & mut self . inner ) . registry_id = Some ( registry_id) ;
245
245
self
246
246
}
247
247
@@ -259,7 +259,7 @@ impl Dependency {
259
259
// Setting 'public' only makes sense for normal dependencies
260
260
assert_eq ! ( self . kind( ) , DepKind :: Normal ) ;
261
261
}
262
- Rc :: make_mut ( & mut self . inner ) . public = public;
262
+ Arc :: make_mut ( & mut self . inner ) . public = public;
263
263
self
264
264
}
265
265
@@ -286,7 +286,7 @@ impl Dependency {
286
286
// Setting 'public' only makes sense for normal dependencies
287
287
assert_eq ! ( kind, DepKind :: Normal ) ;
288
288
}
289
- Rc :: make_mut ( & mut self . inner ) . kind = kind;
289
+ Arc :: make_mut ( & mut self . inner ) . kind = kind;
290
290
self
291
291
}
292
292
@@ -295,44 +295,44 @@ impl Dependency {
295
295
& mut self ,
296
296
features : impl IntoIterator < Item = impl Into < InternedString > > ,
297
297
) -> & mut Dependency {
298
- Rc :: make_mut ( & mut self . inner ) . features = features. into_iter ( ) . map ( |s| s. into ( ) ) . collect ( ) ;
298
+ Arc :: make_mut ( & mut self . inner ) . features = features. into_iter ( ) . map ( |s| s. into ( ) ) . collect ( ) ;
299
299
self
300
300
}
301
301
302
302
/// Sets whether the dependency requests default features of the package.
303
303
pub fn set_default_features ( & mut self , default_features : bool ) -> & mut Dependency {
304
- Rc :: make_mut ( & mut self . inner ) . default_features = default_features;
304
+ Arc :: make_mut ( & mut self . inner ) . default_features = default_features;
305
305
self
306
306
}
307
307
308
308
/// Sets whether the dependency is optional.
309
309
pub fn set_optional ( & mut self , optional : bool ) -> & mut Dependency {
310
- Rc :: make_mut ( & mut self . inner ) . optional = optional;
310
+ Arc :: make_mut ( & mut self . inner ) . optional = optional;
311
311
self
312
312
}
313
313
314
314
/// Sets the source ID for this dependency.
315
315
pub fn set_source_id ( & mut self , id : SourceId ) -> & mut Dependency {
316
- Rc :: make_mut ( & mut self . inner ) . source_id = id;
316
+ Arc :: make_mut ( & mut self . inner ) . source_id = id;
317
317
self
318
318
}
319
319
320
320
/// Sets the version requirement for this dependency.
321
321
pub fn set_version_req ( & mut self , req : OptVersionReq ) -> & mut Dependency {
322
- Rc :: make_mut ( & mut self . inner ) . req = req;
322
+ Arc :: make_mut ( & mut self . inner ) . req = req;
323
323
self
324
324
}
325
325
326
326
pub fn set_platform ( & mut self , platform : Option < Platform > ) -> & mut Dependency {
327
- Rc :: make_mut ( & mut self . inner ) . platform = platform;
327
+ Arc :: make_mut ( & mut self . inner ) . platform = platform;
328
328
self
329
329
}
330
330
331
331
pub fn set_explicit_name_in_toml (
332
332
& mut self ,
333
333
name : impl Into < InternedString > ,
334
334
) -> & mut Dependency {
335
- Rc :: make_mut ( & mut self . inner ) . explicit_name_in_toml = Some ( name. into ( ) ) ;
335
+ Arc :: make_mut ( & mut self . inner ) . explicit_name_in_toml = Some ( name. into ( ) ) ;
336
336
self
337
337
}
338
338
@@ -346,7 +346,7 @@ impl Dependency {
346
346
self . source_id( ) ,
347
347
id
348
348
) ;
349
- let me = Rc :: make_mut ( & mut self . inner ) ;
349
+ let me = Arc :: make_mut ( & mut self . inner ) ;
350
350
me. req . lock_to ( id. version ( ) ) ;
351
351
352
352
// Only update the `precise` of this source to preserve other
@@ -361,7 +361,7 @@ impl Dependency {
361
361
/// Mainly used in dependency patching like `[patch]` or `[replace]`, which
362
362
/// doesn't need to lock the entire dependency to a specific [`PackageId`].
363
363
pub fn lock_version ( & mut self , version : & semver:: Version ) -> & mut Dependency {
364
- let me = Rc :: make_mut ( & mut self . inner ) ;
364
+ let me = Arc :: make_mut ( & mut self . inner ) ;
365
365
me. req . lock_to ( version) ;
366
366
self
367
367
}
@@ -430,7 +430,7 @@ impl Dependency {
430
430
}
431
431
432
432
pub ( crate ) fn set_artifact ( & mut self , artifact : Artifact ) {
433
- Rc :: make_mut ( & mut self . inner ) . artifact = Some ( artifact) ;
433
+ Arc :: make_mut ( & mut self . inner ) . artifact = Some ( artifact) ;
434
434
}
435
435
436
436
pub ( crate ) fn artifact ( & self ) -> Option < & Artifact > {
@@ -453,7 +453,7 @@ impl Dependency {
453
453
/// This information represents a requirement in the package this dependency refers to.
454
454
#[ derive( PartialEq , Eq , Hash , Clone , Debug ) ]
455
455
pub struct Artifact {
456
- inner : Rc < Vec < ArtifactKind > > ,
456
+ inner : Arc < Vec < ArtifactKind > > ,
457
457
is_lib : bool ,
458
458
target : Option < ArtifactTarget > ,
459
459
}
@@ -492,7 +492,7 @@ impl Artifact {
492
492
. collect :: < Result < Vec < _ > , _ > > ( ) ?,
493
493
) ?;
494
494
Ok ( Artifact {
495
- inner : Rc :: new ( kinds) ,
495
+ inner : Arc :: new ( kinds) ,
496
496
is_lib,
497
497
target : target. map ( ArtifactTarget :: parse) . transpose ( ) ?,
498
498
} )
0 commit comments