From ef5a09ebd310b70812d2a3c5567d45f0aa9c5d60 Mon Sep 17 00:00:00 2001 From: KaDiWa Date: Wed, 25 Jan 2023 18:41:38 +0100 Subject: [PATCH] rename IntoOverflowableItem to satisfy clippy --- src/expr.rs | 8 ++++---- src/overflow.rs | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 25226991fbc..ac7b2f5b23b 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -20,7 +20,7 @@ use crate::lists::{ }; use crate::macros::{rewrite_macro, MacroPosition}; use crate::matches::rewrite_match; -use crate::overflow::{self, IntoOverflowableItem, OverflowableItem}; +use crate::overflow::{self, OverflowableItem, ToOverflowableItem}; use crate::pairs::{rewrite_all_pairs, rewrite_pair, PairParts}; use crate::rewrite::{Rewrite, RewriteContext}; use crate::shape::{Indent, Shape}; @@ -420,7 +420,7 @@ pub(crate) fn format_expr( }) } -pub(crate) fn rewrite_array<'a, T: 'a + IntoOverflowableItem<'a>>( +pub(crate) fn rewrite_array<'a, T: 'a + ToOverflowableItem<'a>>( name: &'a str, exprs: impl Iterator, span: Span, @@ -1786,7 +1786,7 @@ pub(crate) fn rewrite_field( } } -fn rewrite_tuple_in_visual_indent_style<'a, T: 'a + IntoOverflowableItem<'a>>( +fn rewrite_tuple_in_visual_indent_style<'a, T: 'a + ToOverflowableItem<'a>>( context: &RewriteContext<'_>, mut items: impl Iterator, span: Span, @@ -1868,7 +1868,7 @@ fn rewrite_let( ) } -pub(crate) fn rewrite_tuple<'a, T: 'a + IntoOverflowableItem<'a>>( +pub(crate) fn rewrite_tuple<'a, T: 'a + ToOverflowableItem<'a>>( context: &'a RewriteContext<'_>, items: impl Iterator, span: Span, diff --git a/src/overflow.rs b/src/overflow.rs index d81bf24dbd1..6fb016c8fb8 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -104,7 +104,7 @@ impl<'a> OverflowableItem<'a> { pub(crate) fn map(&self, f: F) -> T where - F: Fn(&dyn IntoOverflowableItem<'a>) -> T, + F: Fn(&dyn ToOverflowableItem<'a>) -> T, { match self { OverflowableItem::Expr(expr) => f(*expr), @@ -191,21 +191,21 @@ impl<'a> OverflowableItem<'a> { } } -pub(crate) trait IntoOverflowableItem<'a>: Rewrite + Spanned { - fn into_overflowable_item(&'a self) -> OverflowableItem<'a>; +pub(crate) trait ToOverflowableItem<'a>: Rewrite + Spanned { + fn to_overflowable_item(&'a self) -> OverflowableItem<'a>; } -impl<'a, T: 'a + IntoOverflowableItem<'a>> IntoOverflowableItem<'a> for ptr::P { - fn into_overflowable_item(&'a self) -> OverflowableItem<'a> { - (**self).into_overflowable_item() +impl<'a, T: 'a + ToOverflowableItem<'a>> ToOverflowableItem<'a> for ptr::P { + fn to_overflowable_item(&'a self) -> OverflowableItem<'a> { + (**self).to_overflowable_item() } } -macro_rules! impl_into_overflowable_item_for_ast_node { +macro_rules! impl_to_overflowable_item_for_ast_node { ($($ast_node:ident),*) => { $( - impl<'a> IntoOverflowableItem<'a> for ast::$ast_node { - fn into_overflowable_item(&'a self) -> OverflowableItem<'a> { + impl<'a> ToOverflowableItem<'a> for ast::$ast_node { + fn to_overflowable_item(&'a self) -> OverflowableItem<'a> { OverflowableItem::$ast_node(self) } } @@ -213,18 +213,18 @@ macro_rules! impl_into_overflowable_item_for_ast_node { } } -macro_rules! impl_into_overflowable_item_for_rustfmt_types { +macro_rules! impl_to_overflowable_item_for_rustfmt_types { ([$($ty:ident),*], [$($ty_with_lifetime:ident),*]) => { $( - impl<'a> IntoOverflowableItem<'a> for $ty { - fn into_overflowable_item(&'a self) -> OverflowableItem<'a> { + impl<'a> ToOverflowableItem<'a> for $ty { + fn to_overflowable_item(&'a self) -> OverflowableItem<'a> { OverflowableItem::$ty(self) } } )* $( - impl<'a> IntoOverflowableItem<'a> for $ty_with_lifetime<'a> { - fn into_overflowable_item(&'a self) -> OverflowableItem<'a> { + impl<'a> ToOverflowableItem<'a> for $ty_with_lifetime<'a> { + fn to_overflowable_item(&'a self) -> OverflowableItem<'a> { OverflowableItem::$ty_with_lifetime(self) } } @@ -232,19 +232,19 @@ macro_rules! impl_into_overflowable_item_for_rustfmt_types { } } -impl_into_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, FieldDef, Ty, Pat); -impl_into_overflowable_item_for_rustfmt_types!([MacroArg], [SegmentParam, TuplePatField]); +impl_to_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, FieldDef, Ty, Pat); +impl_to_overflowable_item_for_rustfmt_types!([MacroArg], [SegmentParam, TuplePatField]); pub(crate) fn into_overflowable_list<'a, T>( iter: impl Iterator, ) -> impl Iterator> where - T: 'a + IntoOverflowableItem<'a>, + T: 'a + ToOverflowableItem<'a>, { - iter.map(|x| IntoOverflowableItem::into_overflowable_item(x)) + iter.map(|x| ToOverflowableItem::to_overflowable_item(x)) } -pub(crate) fn rewrite_with_parens<'a, T: 'a + IntoOverflowableItem<'a>>( +pub(crate) fn rewrite_with_parens<'a, T: 'a + ToOverflowableItem<'a>>( context: &'a RewriteContext<'_>, ident: &'a str, items: impl Iterator, @@ -268,7 +268,7 @@ pub(crate) fn rewrite_with_parens<'a, T: 'a + IntoOverflowableItem<'a>>( .rewrite(shape) } -pub(crate) fn rewrite_with_angle_brackets<'a, T: 'a + IntoOverflowableItem<'a>>( +pub(crate) fn rewrite_with_angle_brackets<'a, T: 'a + ToOverflowableItem<'a>>( context: &'a RewriteContext<'_>, ident: &'a str, items: impl Iterator, @@ -290,7 +290,7 @@ pub(crate) fn rewrite_with_angle_brackets<'a, T: 'a + IntoOverflowableItem<'a>>( .rewrite(shape) } -pub(crate) fn rewrite_with_square_brackets<'a, T: 'a + IntoOverflowableItem<'a>>( +pub(crate) fn rewrite_with_square_brackets<'a, T: 'a + ToOverflowableItem<'a>>( context: &'a RewriteContext<'_>, name: &'a str, items: impl Iterator, @@ -335,7 +335,7 @@ struct Context<'a> { } impl<'a> Context<'a> { - fn new>( + fn new>( context: &'a RewriteContext<'_>, items: impl Iterator, ident: &'a str,