Implement RTN support in rustfmt

This commit is contained in:
Michael Goulet 2024-06-28 14:18:36 -04:00
parent 51df533d06
commit 88f98c2929
2 changed files with 29 additions and 15 deletions

View File

@ -484,21 +484,25 @@ fn rewrite_generic_args(
span: Span,
) -> Option<String> {
match gen_args {
ast::GenericArgs::AngleBracketed(ref data) if !data.args.is_empty() => {
let args = data
.args
.iter()
.map(|x| match x {
ast::AngleBracketedArg::Arg(generic_arg) => {
SegmentParam::from_generic_arg(generic_arg)
}
ast::AngleBracketedArg::Constraint(constraint) => {
SegmentParam::Binding(constraint)
}
})
.collect::<Vec<_>>();
ast::GenericArgs::AngleBracketed(ref data) => {
if data.args.is_empty() {
Some("".to_owned())
} else {
let args = data
.args
.iter()
.map(|x| match x {
ast::AngleBracketedArg::Arg(generic_arg) => {
SegmentParam::from_generic_arg(generic_arg)
}
ast::AngleBracketedArg::Constraint(constraint) => {
SegmentParam::Binding(constraint)
}
})
.collect::<Vec<_>>();
overflow::rewrite_with_angle_brackets(context, "", args.iter(), shape, span)
overflow::rewrite_with_angle_brackets(context, "", args.iter(), shape, span)
}
}
ast::GenericArgs::Parenthesized(ref data) => format_function_type(
data.inputs.iter().map(|x| &**x),
@ -508,7 +512,7 @@ fn rewrite_generic_args(
context,
shape,
),
_ => Some("".to_owned()),
ast::GenericArgs::ParenthesizedElided(..) => Some("(..)".to_owned()),
}
}

View File

@ -0,0 +1,10 @@
fn rtn()
where
T: Trait<method(..): Send + 'static>,
T::method(..): Send + 'static,
{
}
fn test() {
let x: T::method(..);
}