@@ -293,62 +293,6 @@ pub struct CrateData {
293293 pub is_proc_macro : bool ,
294294}
295295
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-
352296#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
353297pub enum Edition {
354298 Edition2015 ,
@@ -389,32 +333,22 @@ pub enum DependencyKind {
389333pub struct Dependency {
390334 pub crate_id : CrateId ,
391335 pub name : CrateName ,
392- kind : DependencyKind ,
393336 prelude : bool ,
394337}
395338
396339impl 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 }
399342 }
400343
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 }
408346 }
409347
410348 /// Whether this dependency is to be added to the depending crate's extern prelude.
411349 pub fn is_prelude ( & self ) -> bool {
412350 self . prelude
413351 }
414-
415- pub fn kind ( & self ) -> DependencyKind {
416- self . kind
417- }
418352}
419353
420354impl CrateGraph {
@@ -684,11 +618,9 @@ impl CrateGraph {
684618 match ( cfg_if, std) {
685619 ( Some ( cfg_if) , Some ( std) ) => {
686620 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) ) ;
692624 true
693625 }
694626 _ => false ,
@@ -836,7 +768,7 @@ impl fmt::Display for CyclicDependenciesError {
836768
837769#[ cfg( test) ]
838770mod tests {
839- use crate :: { CrateOrigin , DependencyKind } ;
771+ use crate :: CrateOrigin ;
840772
841773 use super :: { CrateGraph , CrateName , Dependency , Edition :: Edition2018 , Env , FileId } ;
842774
@@ -877,22 +809,13 @@ mod tests {
877809 CrateOrigin :: Local { repo : None , name : None } ,
878810 ) ;
879811 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, ) )
884813 . is_ok( ) ) ;
885814 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, ) )
890816 . is_ok( ) ) ;
891817 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, ) )
896819 . is_err( ) ) ;
897820 }
898821
@@ -922,16 +845,10 @@ mod tests {
922845 CrateOrigin :: Local { repo : None , name : None } ,
923846 ) ;
924847 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, ) )
929849 . is_ok( ) ) ;
930850 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, ) )
935852 . is_err( ) ) ;
936853 }
937854
@@ -972,16 +889,10 @@ mod tests {
972889 CrateOrigin :: Local { repo : None , name : None } ,
973890 ) ;
974891 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, ) )
979893 . is_ok( ) ) ;
980894 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, ) )
985896 . is_ok( ) ) ;
986897 }
987898
@@ -1013,20 +924,12 @@ mod tests {
1013924 assert ! ( graph
1014925 . add_dep(
1015926 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, )
1021928 )
1022929 . is_ok( ) ) ;
1023930 assert_eq ! (
1024931 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, ) ]
1030933 ) ;
1031934 }
1032935}
0 commit comments