use ufcs in derive(Ord) and derive(PartialOrd)
This commit is contained in:
parent
c648bd5558
commit
2c33b070ad
@ -47,9 +47,10 @@ pub fn ordering_collapsed(
|
||||
span: Span,
|
||||
self_arg_tags: &[Ident],
|
||||
) -> P<ast::Expr> {
|
||||
let lft = cx.expr_ident(span, self_arg_tags[0]);
|
||||
let lft = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[0]));
|
||||
let rgt = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[1]));
|
||||
cx.expr_method_call(span, lft, Ident::new(sym::cmp, span), vec![rgt])
|
||||
let fn_cmp_path = cx.std_path(&[sym::cmp, sym::Ord, sym::cmp]);
|
||||
cx.expr_call_global(span, fn_cmp_path, vec![lft, rgt])
|
||||
}
|
||||
|
||||
pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
|
||||
|
@ -107,9 +107,11 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
|
||||
if self_args.len() != 2 {
|
||||
cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
|
||||
} else {
|
||||
let lft = cx.expr_ident(span, tag_tuple[0]);
|
||||
let lft = cx.expr_addr_of(span, cx.expr_ident(span, tag_tuple[0]));
|
||||
let rgt = cx.expr_addr_of(span, cx.expr_ident(span, tag_tuple[1]));
|
||||
cx.expr_method_call(span, lft, Ident::new(sym::partial_cmp, span), vec![rgt])
|
||||
let fn_partial_cmp_path =
|
||||
cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp]);
|
||||
cx.expr_call_global(span, fn_partial_cmp_path, vec![lft, rgt])
|
||||
}
|
||||
}),
|
||||
cx,
|
||||
|
Loading…
Reference in New Issue
Block a user