stop to strip 'impl' from impl trait type alias (#3816)
This commit is contained in:
parent
e28ae8b4a3
commit
7926851bb0
15
src/items.rs
15
src/items.rs
@ -1118,6 +1118,18 @@ pub(crate) fn format_trait(
|
||||
}
|
||||
}
|
||||
|
||||
struct OpaqueTypeBounds<'a> {
|
||||
generic_bounds: &'a ast::GenericBounds,
|
||||
}
|
||||
|
||||
impl<'a> Rewrite for OpaqueTypeBounds<'a> {
|
||||
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
|
||||
self.generic_bounds
|
||||
.rewrite(context, shape)
|
||||
.map(|s| format!("impl {}", s))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct TraitAliasBounds<'a> {
|
||||
generic_bounds: &'a ast::GenericBounds,
|
||||
generics: &'a ast::Generics,
|
||||
@ -1524,13 +1536,14 @@ pub(crate) fn rewrite_opaque_type(
|
||||
generics: &ast::Generics,
|
||||
vis: &ast::Visibility,
|
||||
) -> Option<String> {
|
||||
let opaque_type_bounds = OpaqueTypeBounds { generic_bounds };
|
||||
rewrite_type_item(
|
||||
context,
|
||||
indent,
|
||||
"type",
|
||||
" =",
|
||||
ident,
|
||||
generic_bounds,
|
||||
&opaque_type_bounds,
|
||||
generics,
|
||||
vis,
|
||||
)
|
||||
|
@ -13,3 +13,11 @@ pub type Adderrr<T> = impl Fn( T ) -> T;
|
||||
impl Foo for Bar {
|
||||
type E = impl Trait;
|
||||
}
|
||||
|
||||
pub type Adder_without_impl<F, T>
|
||||
where
|
||||
T: Clone,
|
||||
F: Copy
|
||||
= Fn(T) -> T;
|
||||
|
||||
pub type Adderrr_without_impl<T> = Fn( T ) -> T;
|
||||
|
@ -6,10 +6,18 @@ pub type Adder<F, T>
|
||||
where
|
||||
T: Clone,
|
||||
F: Copy,
|
||||
= Fn(T) -> T;
|
||||
= impl Fn(T) -> T;
|
||||
|
||||
pub type Adderrr<T> = Fn(T) -> T;
|
||||
pub type Adderrr<T> = impl Fn(T) -> T;
|
||||
|
||||
impl Foo for Bar {
|
||||
type E = impl Trait;
|
||||
}
|
||||
|
||||
pub type Adder_without_impl<F, T>
|
||||
where
|
||||
T: Clone,
|
||||
F: Copy,
|
||||
= Fn(T) -> T;
|
||||
|
||||
pub type Adderrr_without_impl<T> = Fn(T) -> T;
|
||||
|
4
tests/target/issue-3815.rs
Normal file
4
tests/target/issue-3815.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub type Type = impl Deref<Target = i8>;
|
||||
|
||||
pub type Type =
|
||||
impl VeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeryLongType<Target = i8>;
|
Loading…
x
Reference in New Issue
Block a user