@@ -43,17 +43,18 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt<'_>,
4343}
4444
4545
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 > {
5051 let lft = cx. expr_ident ( span, self_arg_tags[ 0 ] ) ;
5152 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] )
5354}
5455
5556pub 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 ) ;
5758 let equals_path = cx. path_global ( span, cx. std_path ( & [ sym:: cmp, sym:: Ordering , sym:: Equal ] ) ) ;
5859
5960 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<
7576 // as the outermost one, and the last as the innermost.
7677 false ,
7778 |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+ // }
8283
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+ } ;
8889
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+ ] ;
9394
94- cx. expr_call_global ( span, cmp_path. clone ( ) , args)
95- } ;
95+ cx. expr_call_global ( span, cmp_path. clone ( ) , args)
96+ } ;
9697
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) ) ;
103104
104- cx. expr_match ( span, new, vec ! [ eq_arm, neq_arm] )
105- } ,
105+ cx. expr_match ( span, new, vec ! [ eq_arm, neq_arm] )
106+ } ,
106107 cx. expr_path ( equals_path. clone ( ) ) ,
107108 Box :: new ( |cx, span, ( self_args, tag_tuple) , _non_self_args| {
108109 if self_args. len ( ) != 2 {
0 commit comments