@@ -43,17 +43,18 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt<'_>,
43
43
}
44
44
45
45
46
- pub fn ordering_collapsed ( cx : & mut ExtCtxt < ' _ > ,
47
- span : Span ,
48
- self_arg_tags : & [ ast:: Ident ] )
49
- -> P < ast:: Expr > {
46
+ pub fn ordering_collapsed (
47
+ cx : & mut ExtCtxt < ' _ > ,
48
+ span : Span ,
49
+ self_arg_tags : & [ ast:: Ident ] ,
50
+ ) -> P < ast:: Expr > {
50
51
let lft = cx. expr_ident ( span, self_arg_tags[ 0 ] ) ;
51
52
let rgt = cx. expr_addr_of ( span, cx. expr_ident ( span, self_arg_tags[ 1 ] ) ) ;
52
- cx. expr_method_call ( span, lft, cx . ident_of ( " cmp" ) , vec ! [ rgt] )
53
+ cx. expr_method_call ( span, lft, ast :: Ident :: new ( sym :: cmp, span ) , vec ! [ rgt] )
53
54
}
54
55
55
56
pub fn cs_cmp ( cx : & mut ExtCtxt < ' _ > , span : Span , substr : & Substructure < ' _ > ) -> P < Expr > {
56
- let test_id = cx . ident_of ( " cmp" ) . gensym ( ) ;
57
+ let test_id = ast :: Ident :: new ( sym :: cmp, span ) ;
57
58
let equals_path = cx. path_global ( span, cx. std_path ( & [ sym:: cmp, sym:: Ordering , sym:: Equal ] ) ) ;
58
59
59
60
let cmp_path = cx. std_path ( & [ sym:: cmp, sym:: Ord , sym:: cmp] ) ;
@@ -75,34 +76,34 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
75
76
// as the outermost one, and the last as the innermost.
76
77
false ,
77
78
|cx, span, old, self_f, other_fs| {
78
- // match new {
79
- // ::std::cmp::Ordering::Equal => old,
80
- // cmp => cmp
81
- // }
79
+ // match new {
80
+ // ::std::cmp::Ordering::Equal => old,
81
+ // cmp => cmp
82
+ // }
82
83
83
- let new = {
84
- let other_f = match other_fs {
85
- [ o_f] => o_f,
86
- _ => cx. span_bug ( span, "not exactly 2 arguments in `derive(Ord)`" ) ,
87
- } ;
84
+ let new = {
85
+ let other_f = match other_fs {
86
+ [ o_f] => o_f,
87
+ _ => cx. span_bug ( span, "not exactly 2 arguments in `derive(Ord)`" ) ,
88
+ } ;
88
89
89
- let args = vec ! [
90
- cx. expr_addr_of( span, self_f) ,
91
- cx. expr_addr_of( span, other_f. clone( ) ) ,
92
- ] ;
90
+ let args = vec ! [
91
+ cx. expr_addr_of( span, self_f) ,
92
+ cx. expr_addr_of( span, other_f. clone( ) ) ,
93
+ ] ;
93
94
94
- cx. expr_call_global ( span, cmp_path. clone ( ) , args)
95
- } ;
95
+ cx. expr_call_global ( span, cmp_path. clone ( ) , args)
96
+ } ;
96
97
97
- let eq_arm = cx. arm ( span,
98
- vec ! [ cx. pat_path( span, equals_path. clone( ) ) ] ,
99
- old) ;
100
- let neq_arm = cx. arm ( span,
101
- vec ! [ cx. pat_ident( span, test_id) ] ,
102
- cx. expr_ident ( span, test_id) ) ;
98
+ let eq_arm = cx. arm ( span,
99
+ vec ! [ cx. pat_path( span, equals_path. clone( ) ) ] ,
100
+ old) ;
101
+ let neq_arm = cx. arm ( span,
102
+ vec ! [ cx. pat_ident( span, test_id) ] ,
103
+ cx. expr_ident ( span, test_id) ) ;
103
104
104
- cx. expr_match ( span, new, vec ! [ eq_arm, neq_arm] )
105
- } ,
105
+ cx. expr_match ( span, new, vec ! [ eq_arm, neq_arm] )
106
+ } ,
106
107
cx. expr_path ( equals_path. clone ( ) ) ,
107
108
Box :: new ( |cx, span, ( self_args, tag_tuple) , _non_self_args| {
108
109
if self_args. len ( ) != 2 {
0 commit comments