@@ -293,62 +293,6 @@ pub struct CrateData {
293
293
pub is_proc_macro : bool ,
294
294
}
295
295
296
- impl CrateData {
297
- /// Check if [`other`] is almost equal to [`self`] ignoring `CrateOrigin` value.
298
- pub fn eq_ignoring_origin_and_deps ( & self , other : & CrateData , ignore_dev_deps : bool ) -> bool {
299
- // This method has some obscure bits. These are mostly there to be compliant with
300
- // some patches. References to the patches are given.
301
- if self . root_file_id != other. root_file_id {
302
- return false ;
303
- }
304
-
305
- if self . display_name != other. display_name {
306
- return false ;
307
- }
308
-
309
- if self . is_proc_macro != other. is_proc_macro {
310
- return false ;
311
- }
312
-
313
- if self . edition != other. edition {
314
- return false ;
315
- }
316
-
317
- if self . version != other. version {
318
- return false ;
319
- }
320
-
321
- let mut opts = self . cfg_options . difference ( & other. cfg_options ) ;
322
- if let Some ( it) = opts. next ( ) {
323
- // Don't care if rust_analyzer CfgAtom is the only cfg in the difference set of self's and other's cfgs.
324
- // https://github.com/rust-lang/rust-analyzer/blob/0840038f02daec6ba3238f05d8caa037d28701a0/crates/project-model/src/workspace.rs#L894
325
- if it. to_string ( ) != "rust_analyzer" {
326
- return false ;
327
- }
328
-
329
- if opts. next ( ) . is_some ( ) {
330
- return false ;
331
- }
332
- }
333
-
334
- if self . env != other. env {
335
- return false ;
336
- }
337
-
338
- let slf_deps = self . dependencies . iter ( ) ;
339
- let other_deps = other. dependencies . iter ( ) ;
340
-
341
- if ignore_dev_deps {
342
- return slf_deps
343
- . clone ( )
344
- . filter ( |it| it. kind != DependencyKind :: Dev )
345
- . eq ( other_deps. clone ( ) . filter ( |it| it. kind != DependencyKind :: Dev ) ) ;
346
- }
347
-
348
- slf_deps. eq ( other_deps)
349
- }
350
- }
351
-
352
296
#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
353
297
pub enum Edition {
354
298
Edition2015 ,
@@ -389,32 +333,22 @@ pub enum DependencyKind {
389
333
pub struct Dependency {
390
334
pub crate_id : CrateId ,
391
335
pub name : CrateName ,
392
- kind : DependencyKind ,
393
336
prelude : bool ,
394
337
}
395
338
396
339
impl Dependency {
397
- pub fn new ( name : CrateName , crate_id : CrateId , kind : DependencyKind ) -> Self {
398
- Self { name, crate_id, prelude : true , kind }
340
+ pub fn new ( name : CrateName , crate_id : CrateId ) -> Self {
341
+ Self { name, crate_id, prelude : true }
399
342
}
400
343
401
- pub fn with_prelude (
402
- name : CrateName ,
403
- crate_id : CrateId ,
404
- prelude : bool ,
405
- kind : DependencyKind ,
406
- ) -> Self {
407
- Self { name, crate_id, prelude, kind }
344
+ pub fn with_prelude ( name : CrateName , crate_id : CrateId , prelude : bool ) -> Self {
345
+ Self { name, crate_id, prelude }
408
346
}
409
347
410
348
/// Whether this dependency is to be added to the depending crate's extern prelude.
411
349
pub fn is_prelude ( & self ) -> bool {
412
350
self . prelude
413
351
}
414
-
415
- pub fn kind ( & self ) -> DependencyKind {
416
- self . kind
417
- }
418
352
}
419
353
420
354
impl CrateGraph {
@@ -684,11 +618,9 @@ impl CrateGraph {
684
618
match ( cfg_if, std) {
685
619
( Some ( cfg_if) , Some ( std) ) => {
686
620
self . arena [ cfg_if] . dependencies . clear ( ) ;
687
- self . arena [ std] . dependencies . push ( Dependency :: new (
688
- CrateName :: new ( "cfg_if" ) . unwrap ( ) ,
689
- cfg_if,
690
- DependencyKind :: Normal ,
691
- ) ) ;
621
+ self . arena [ std]
622
+ . dependencies
623
+ . push ( Dependency :: new ( CrateName :: new ( "cfg_if" ) . unwrap ( ) , cfg_if) ) ;
692
624
true
693
625
}
694
626
_ => false ,
@@ -836,7 +768,7 @@ impl fmt::Display for CyclicDependenciesError {
836
768
837
769
#[ cfg( test) ]
838
770
mod tests {
839
- use crate :: { CrateOrigin , DependencyKind } ;
771
+ use crate :: CrateOrigin ;
840
772
841
773
use super :: { CrateGraph , CrateName , Dependency , Edition :: Edition2018 , Env , FileId } ;
842
774
@@ -877,22 +809,13 @@ mod tests {
877
809
CrateOrigin :: Local { repo : None , name : None } ,
878
810
) ;
879
811
assert ! ( graph
880
- . add_dep(
881
- crate1,
882
- Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, DependencyKind :: Normal )
883
- )
812
+ . add_dep( crate1, Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, ) )
884
813
. is_ok( ) ) ;
885
814
assert ! ( graph
886
- . add_dep(
887
- crate2,
888
- Dependency :: new( CrateName :: new( "crate3" ) . unwrap( ) , crate3, DependencyKind :: Normal )
889
- )
815
+ . add_dep( crate2, Dependency :: new( CrateName :: new( "crate3" ) . unwrap( ) , crate3, ) )
890
816
. is_ok( ) ) ;
891
817
assert ! ( graph
892
- . add_dep(
893
- crate3,
894
- Dependency :: new( CrateName :: new( "crate1" ) . unwrap( ) , crate1, DependencyKind :: Normal )
895
- )
818
+ . add_dep( crate3, Dependency :: new( CrateName :: new( "crate1" ) . unwrap( ) , crate1, ) )
896
819
. is_err( ) ) ;
897
820
}
898
821
@@ -922,16 +845,10 @@ mod tests {
922
845
CrateOrigin :: Local { repo : None , name : None } ,
923
846
) ;
924
847
assert ! ( graph
925
- . add_dep(
926
- crate1,
927
- Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, DependencyKind :: Normal )
928
- )
848
+ . add_dep( crate1, Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, ) )
929
849
. is_ok( ) ) ;
930
850
assert ! ( graph
931
- . add_dep(
932
- crate2,
933
- Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, DependencyKind :: Normal )
934
- )
851
+ . add_dep( crate2, Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, ) )
935
852
. is_err( ) ) ;
936
853
}
937
854
@@ -972,16 +889,10 @@ mod tests {
972
889
CrateOrigin :: Local { repo : None , name : None } ,
973
890
) ;
974
891
assert ! ( graph
975
- . add_dep(
976
- crate1,
977
- Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, DependencyKind :: Normal )
978
- )
892
+ . add_dep( crate1, Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2, ) )
979
893
. is_ok( ) ) ;
980
894
assert ! ( graph
981
- . add_dep(
982
- crate2,
983
- Dependency :: new( CrateName :: new( "crate3" ) . unwrap( ) , crate3, DependencyKind :: Normal )
984
- )
895
+ . add_dep( crate2, Dependency :: new( CrateName :: new( "crate3" ) . unwrap( ) , crate3, ) )
985
896
. is_ok( ) ) ;
986
897
}
987
898
@@ -1013,20 +924,12 @@ mod tests {
1013
924
assert ! ( graph
1014
925
. add_dep(
1015
926
crate1,
1016
- Dependency :: new(
1017
- CrateName :: normalize_dashes( "crate-name-with-dashes" ) ,
1018
- crate2,
1019
- DependencyKind :: Normal
1020
- )
927
+ Dependency :: new( CrateName :: normalize_dashes( "crate-name-with-dashes" ) , crate2, )
1021
928
)
1022
929
. is_ok( ) ) ;
1023
930
assert_eq ! (
1024
931
graph[ crate1] . dependencies,
1025
- vec![ Dependency :: new(
1026
- CrateName :: new( "crate_name_with_dashes" ) . unwrap( ) ,
1027
- crate2,
1028
- DependencyKind :: Normal
1029
- ) ]
932
+ vec![ Dependency :: new( CrateName :: new( "crate_name_with_dashes" ) . unwrap( ) , crate2, ) ]
1030
933
) ;
1031
934
}
1032
935
}
0 commit comments