- fn is_type(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
- if let Some(lty) = ty {
- if let ast::TyKind::ImplTrait(..) = lty.kind {
- return false;
- }
- }
- true
- }
-
- fn is_opaque(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
- !is_type(ty)
- }
-
- fn both_type(
- a: &Option<rustc_ast::ptr::P<ast::Ty>>,
- b: &Option<rustc_ast::ptr::P<ast::Ty>>,
- ) -> bool {
- is_type(a) && is_type(b)
- }
-
- fn both_opaque(
- a: &Option<rustc_ast::ptr::P<ast::Ty>>,
- b: &Option<rustc_ast::ptr::P<ast::Ty>>,
- ) -> bool {
- is_opaque(a) && is_opaque(b)
- }
-
- // In rustc-ap-v638 the `OpaqueTy` AssocItemKind variant was removed but
- // we still need to differentiate to maintain sorting order.
-
- // type -> opaque -> const -> macro -> method
- use crate::ast::AssocItemKind::*;
- fn need_empty_line(a: &ast::AssocItemKind, b: &ast::AssocItemKind) -> bool {
- match (a, b) {
- (TyAlias(lty), TyAlias(rty))
- if both_type(<y.ty, &rty.ty) || both_opaque(<y.ty, &rty.ty) =>
- {
- false
- }
- (Const(..), Const(..)) => false,
- _ => true,
- }
- }
-