@@ -8,7 +8,7 @@ use crate::util::{closest_msg, config, CargoResult, Config};
8
8
use anyhow:: { bail, Context as _} ;
9
9
use std:: collections:: { BTreeMap , HashMap , HashSet } ;
10
10
use std:: hash:: Hash ;
11
- use std:: { cmp , env, fmt, hash } ;
11
+ use std:: { env, fmt} ;
12
12
13
13
/// Collection of all profiles.
14
14
#[ derive( Clone , Debug ) ]
@@ -539,10 +539,16 @@ pub enum ProfileRoot {
539
539
540
540
/// Profile settings used to determine which compiler flags to use for a
541
541
/// target.
542
- #[ derive( Clone , Eq , PartialOrd , Ord , serde:: Serialize ) ]
542
+ #[ derive( Clone , Eq , PartialOrd , Ord , serde:: Serialize , derivative:: Derivative ) ]
543
+ /// Don't compare/hash fields which wont affect compilation.
544
+ /// This is necessary for `Unit` deduplication for things like "test" and
545
+ /// "dev" which are essentially the same.
546
+ #[ derivative( Hash , PartialEq ) ]
543
547
pub struct Profile {
548
+ #[ derivative( Hash = "ignore" , PartialEq = "ignore" ) ]
544
549
pub name : InternedString ,
545
550
pub opt_level : InternedString ,
551
+ #[ derivative( Hash = "ignore" , PartialEq = "ignore" ) ]
546
552
#[ serde( skip) ] // named profiles are unstable
547
553
pub root : ProfileRoot ,
548
554
pub lto : Lto ,
@@ -620,21 +626,6 @@ impl fmt::Display for Profile {
620
626
}
621
627
}
622
628
623
- impl hash:: Hash for Profile {
624
- fn hash < H > ( & self , state : & mut H )
625
- where
626
- H : hash:: Hasher ,
627
- {
628
- self . comparable ( ) . hash ( state) ;
629
- }
630
- }
631
-
632
- impl cmp:: PartialEq for Profile {
633
- fn eq ( & self , other : & Self ) -> bool {
634
- self . comparable ( ) == other. comparable ( )
635
- }
636
- }
637
-
638
629
impl Profile {
639
630
fn default_dev ( ) -> Profile {
640
631
Profile {
@@ -656,27 +647,6 @@ impl Profile {
656
647
..Profile :: default ( )
657
648
}
658
649
}
659
-
660
- /// Don't compare/hash fields which wont affect compilation.
661
- /// This is necessary for `Unit` deduplication for things like "test" and
662
- /// "dev" which are essentially the same.
663
- fn comparable ( & self ) -> impl Hash + Eq + ' _ {
664
- (
665
- self . opt_level ,
666
- self . lto ,
667
- self . codegen_backend ,
668
- self . codegen_units ,
669
- self . debuginfo ,
670
- self . split_debuginfo ,
671
- self . debug_assertions ,
672
- self . overflow_checks ,
673
- self . rpath ,
674
- self . incremental ,
675
- self . panic ,
676
- //"This trait is implemented for tuples up to twelve items long." - https://doc.rust-lang.org/std/cmp/trait.Eq.html#impl-Eq-203
677
- ( self . strip , & self . rustflags ) ,
678
- )
679
- }
680
650
}
681
651
682
652
/// The link-time-optimization setting.
0 commit comments