@@ -47,7 +47,8 @@ pub struct Location<'a> {
4747}
4848
4949#[ stable( feature = "panic_hooks" , since = "1.10.0" ) ]
50- impl PartialEq for Location < ' _ > {
50+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
51+ impl const PartialEq for Location < ' _ > {
5152 fn eq ( & self , other : & Self ) -> bool {
5253 // Compare col / line first as they're cheaper to compare and more likely to differ,
5354 // while not impacting the result.
@@ -56,20 +57,26 @@ impl PartialEq for Location<'_> {
5657}
5758
5859#[ stable( feature = "panic_hooks" , since = "1.10.0" ) ]
59- impl Eq for Location < ' _ > { }
60+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
61+ impl const Eq for Location < ' _ > { }
6062
6163#[ stable( feature = "panic_hooks" , since = "1.10.0" ) ]
62- impl Ord for Location < ' _ > {
64+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
65+ impl const Ord for Location < ' _ > {
6366 fn cmp ( & self , other : & Self ) -> Ordering {
64- self . file ( )
65- . cmp ( other. file ( ) )
66- . then_with ( || self . line . cmp ( & other. line ) )
67- . then_with ( || self . col . cmp ( & other. col ) )
67+ match self . file ( ) . cmp ( other. file ( ) ) {
68+ Ordering :: Equal => match self . line . cmp ( & other. line ) {
69+ Ordering :: Equal => self . col . cmp ( & other. col ) ,
70+ ordering => ordering,
71+ } ,
72+ ordering => ordering,
73+ }
6874 }
6975}
7076
7177#[ stable( feature = "panic_hooks" , since = "1.10.0" ) ]
72- impl PartialOrd for Location < ' _ > {
78+ #[ rustc_const_unstable( feature = "const_cmp" , issue = "143800" ) ]
79+ impl const PartialOrd for Location < ' _ > {
7380 fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
7481 Some ( self . cmp ( other) )
7582 }
0 commit comments