mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 11:59:35 +00:00
Fix invalid printer IR error (#5422)
This commit is contained in:
parent
ca5e10b5ea
commit
38189ed913
4 changed files with 70 additions and 18 deletions
|
@ -242,23 +242,25 @@ impl<'fmt, 'ast, 'buf> JoinCommaSeparatedBuilder<'fmt, 'ast, 'buf> {
|
|||
}
|
||||
|
||||
pub(crate) fn finish(&mut self) -> FormatResult<()> {
|
||||
if let Some(last_end) = self.last_end.take() {
|
||||
if_group_breaks(&text(",")).fmt(self.fmt)?;
|
||||
self.result.and_then(|_| {
|
||||
if let Some(last_end) = self.last_end.take() {
|
||||
if_group_breaks(&text(",")).fmt(self.fmt)?;
|
||||
|
||||
if self.fmt.options().magic_trailing_comma().is_respect()
|
||||
&& matches!(
|
||||
first_non_trivia_token(last_end, self.fmt.context().contents()),
|
||||
Some(Token {
|
||||
kind: TokenKind::Comma,
|
||||
..
|
||||
})
|
||||
)
|
||||
{
|
||||
expand_parent().fmt(self.fmt)?;
|
||||
if self.fmt.options().magic_trailing_comma().is_respect()
|
||||
&& matches!(
|
||||
first_non_trivia_token(last_end, self.fmt.context().contents()),
|
||||
Some(Token {
|
||||
kind: TokenKind::Comma,
|
||||
..
|
||||
})
|
||||
)
|
||||
{
|
||||
expand_parent().fmt(self.fmt)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue