@@ -47,7 +47,8 @@ pub struct Location<'a> {
47
47
}
48
48
49
49
#[ 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 < ' _ > {
51
52
fn eq ( & self , other : & Self ) -> bool {
52
53
// Compare col / line first as they're cheaper to compare and more likely to differ,
53
54
// while not impacting the result.
@@ -56,20 +57,26 @@ impl PartialEq for Location<'_> {
56
57
}
57
58
58
59
#[ 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 < ' _ > { }
60
62
61
63
#[ 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 < ' _ > {
63
66
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
+ }
68
74
}
69
75
}
70
76
71
77
#[ 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 < ' _ > {
73
80
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
74
81
Some ( self . cmp ( other) )
75
82
}
0 commit comments